Re: [FFmpeg-devel] [PATCH] doc/encoders: document libjxl encoder options

2022-04-27 Thread Gyan Doshi




On 2022-04-27 02:38 am, Leo Izen wrote:

Add more detailed documenation for the libjxl encoder
wrapper than is present currently inside libavcodec.
---
  doc/encoders.texi | 34 ++
  1 file changed, 34 insertions(+)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index aac9f25e55..99399d4674 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1809,6 +1809,40 @@ by ":". See the SVT-AV1 encoder user guide for a list of 
accepted parameters.
  
  @end table
  
+@section libjxl

+
+libjxl JPEG XL encoder wrapper.
+
+Requires the presence of the libjxl headers and library during
+configuration. You need to explicitly configure the build with
+@code{--enable-libjxl}.
+
+@subsection Options
+
+The libjxl wrapper supports the following options:
+
+@table @option
+
+@item distance
+Set the target Butteraugli distance. This is a quality setting: lower
+distance yields higher quality, with distance=1.0 roughly comparable to
+libjpeg Quality 90 for photographic content. Setting distance=0.0 yields
+true lossless encoding. Valid values range between 0.0 and 15.0, and sane
+values rarely exceed 5.0. Setting distance=0.1 is usually attains
+transparency for most input. The default is 1.0.
+
+@item effort
+Set the encoding effort used. Higher effort values produce more consistent
+quality and usually produces a better quality/bpp curve, at the cost of
+more CPU time required. Valid values range from 1 to 9, and the default is 7.
+
+@item modular
+Force the encoder to use Modular mode. The default is to let the encoder pick
+between VarDCT and Modular encoding modes based on encoding settings and the
+type of input content.


What happens in these two modes? Why would the user want to force 
modular? Is there a way and reason to force VarDCT?


Regards,
Gyan
___
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".


[FFmpeg-devel] [PATCH] libavcodec/mpeg12dec: extract embedded CC of particular type only

2022-04-27 Thread Ivan Baykalov
Some streams contain closed caption data embedded using several wrapping
types. For example stream can contain CC wrapped as ATSC A53 packets +
the same data wrapped as SCTE-20 packets. Prior to the patch CC data was
extracted from both types of packets, so it gave duplicated character
pairs on the output.

Now we calculate some statistics which CC types appear more often in the
stream and extract the data from a single type only. If at some point
the other CC type becomes more active, we switch to this new type.

Fixes ticket #9724.
---
 libavcodec/mpeg12dec.c | 44 ++
 1 file changed, 44 insertions(+)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index e9bde48f7a..f7e54ef0a9 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -58,6 +58,14 @@
 
 #define A53_MAX_CC_COUNT 2000
 
+typedef enum CcType {
+CC_TYPE_UNKNOWN = -1,
+CC_TYPE_A53 = 0,
+CC_TYPE_SCTE20,
+CC_TYPE_DVD,
+CC_TYPE_COUNT
+} CcType;
+
 typedef struct Mpeg1Context {
 MpegEncContext mpeg_enc_ctx;
 int mpeg_enc_ctx_allocated; /* true if decoding context allocated */
@@ -81,6 +89,7 @@ typedef struct Mpeg1Context {
 int first_slice;
 int extradata_decoded;
 int64_t timecode_frame_start;  /*< GOP timecode frame start number, in non 
drop frame format */
+int cc_packet_count[CC_TYPE_COUNT];
 } Mpeg1Context;
 
 #define MB_TYPE_ZERO_MV   0x2000
@@ -2198,6 +2207,32 @@ static int vcr2_init_sequence(AVCodecContext *avctx)
 return 0;
 }
 
+static int cc_type_is_selected(Mpeg1Context *s1, CcType type)
+{
+int max = 0;
+int max_index = -1;
+int sum = 0;
+av_assert0(type >= 0 && type < CC_TYPE_COUNT);
+s1->cc_packet_count[type]++;
+
+for (int i = 0; i < CC_TYPE_COUNT; i++) {
+if (s1->cc_packet_count[i] > max) {
+max = s1->cc_packet_count[i];
+max_index = i;
+}
+sum += s1->cc_packet_count[i];
+}
+
+if (sum < 2 || sum > 20) {
+// reset statistics, but give some advantage to the current selection
+// to avoid frequent switching between the types
+memset(s1->cc_packet_count, 0, sizeof(s1->cc_packet_count));
+s1->cc_packet_count[max_index] = 2;
+}
+
+return type == max_index;
+}
+
 static int mpeg_decode_a53_cc(AVCodecContext *avctx,
   const uint8_t *p, int buf_size)
 {
@@ -2217,6 +2252,9 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
 if (new_size > 3*A53_MAX_CC_COUNT)
 return AVERROR(EINVAL);
 
+if (!cc_type_is_selected(s1, CC_TYPE_A53))
+return 0;
+
 ret = av_buffer_realloc(&s1->a53_buf_ref, new_size);
 if (ret >= 0)
 memcpy(s1->a53_buf_ref->data + old_size, p + 7, cc_count * 
UINT64_C(3));
@@ -2240,6 +2278,9 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
 if (new_size > 3*A53_MAX_CC_COUNT)
 return AVERROR(EINVAL);
 
+if (!cc_type_is_selected(s1, CC_TYPE_SCTE20))
+return 0;
+
 ret = av_buffer_realloc(&s1->a53_buf_ref, new_size);
 if (ret >= 0) {
 uint8_t field, cc1, cc2;
@@ -2310,6 +2351,9 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
 if (new_size > 3*A53_MAX_CC_COUNT)
 return AVERROR(EINVAL);
 
+if (!cc_type_is_selected(s1, CC_TYPE_DVD))
+return 0;
+
 ret = av_buffer_realloc(&s1->a53_buf_ref, new_size);
 if (ret >= 0) {
 uint8_t field1 = !!(p[4] & 0x80);
-- 
2.35.1

___
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] [PATCH] avcodec/openh264: return (DE|EN)CODER_NOT_FOUND if version check fails

2022-04-27 Thread Martin Storsjö

On Wed, 20 Apr 2022, Martin Storsjö wrote:


On Fri, 18 Feb 2022, Andreas Schneider wrote:


Signed-off-by: Andreas Schneider 
---
libavcodec/libopenh264dec.c | 2 +-
libavcodec/libopenh264enc.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/libopenh264dec.c b/libavcodec/libopenh264dec.c
index 7f5e85402a..97d3630df6 100644
--- a/libavcodec/libopenh264dec.c
+++ b/libavcodec/libopenh264dec.c
@@ -56,7 +56,7 @@ static av_cold int svc_decode_init(AVCodecContext *avctx)
WelsTraceCallback callback_function;

if ((err = ff_libopenh264_check_version(avctx)) < 0)
-return err;
+return AVERROR_DECODER_NOT_FOUND;

if (WelsCreateDecoder(&s->decoder)) {
av_log(avctx, AV_LOG_ERROR, "Unable to create decoder\n");
diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 7c0501a2eb..7649e7b025 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -137,7 +137,7 @@ static av_cold int svc_encode_init(AVCodecContext 
*avctx)

AVCPBProperties *props;

if ((err = ff_libopenh264_check_version(avctx)) < 0)
-return err;
+return AVERROR_ENCODER_NOT_FOUND;

if (WelsCreateSVCEncoder(&s->encoder)) {
av_log(avctx, AV_LOG_ERROR, "Unable to create encoder\n");
--
2.35.1


This looks reasonable to me, so I could push this in a little while if 
there's no more comments on it.


But the patch lacks an explanation of _why_ this is done, in addition to 
_what_ it does. I presume that's because the current error code makes some 
decoder/encoder selection logic error out entirely, instead of continuing 
trying some other codec - is that right? That would really be valuable to 
include in the commit message.


Actually, I don't see anything in the code where returning 
AVERROR_DECODER_NOT_FOUND would behave differently than returning 
AVERROR(EINVAL) (as I would say it does right now).


So what's the motive for this patch, what does it change in practice?

I guess it changes what error message is printed (which certainly makes 
sense to change), but it would be very relevant to know whether this is a 
cosmetic change or if it changes something functionally that I haven't 
found.


// Martin
___
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] [PATCH] libavcodec/qsvdec.c: extract frame packing arrangement data

2022-04-27 Thread Xiang, Haihao
On Tue, 2022-04-26 at 18:00 +0800, Wenbin Chen wrote:
> Use h264_sei to parse SEI data got from MediaSDK. Extract frame
> packing arrangement information from SEI data and config AVStereo3D
> side data for decoded frame.
> 
> Signed-off-by: Wenbin Chen 
> Signed-off-by: Tong Wu 
> ---
>  libavcodec/qsv_internal.h |   2 +
>  libavcodec/qsvdec.c   | 160 ++
>  2 files changed, 162 insertions(+)
> 
> diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
> index e2aecdcbd6..a804c392c1 100644
> --- a/libavcodec/qsv_internal.h
> +++ b/libavcodec/qsv_internal.h
> @@ -54,6 +54,8 @@
>  
>  #define QSV_MAX_FRAME_EXT_PARAMS 4
>  
> +#define QSV_PAYLOAD_SIZE 1024
> +
>  #define QSV_VERSION_ATLEAST(MAJOR, MINOR)   \
>  (MFX_VERSION_MAJOR > (MAJOR) || \
>   MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR))
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> index 5fc5bed4c8..26fa178b4d 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -41,13 +41,16 @@
>  #include "libavutil/time.h"
>  #include "libavutil/imgutils.h"
>  #include "libavutil/film_grain_params.h"
> +#include "libavutil/stereo3d.h"
>  
>  #include "avcodec.h"
>  #include "codec_internal.h"
>  #include "internal.h"
>  #include "decode.h"
>  #include "hwconfig.h"
> +#include "get_bits.h"
>  #include "qsv.h"
> +#include "h264_sei.h"
>  #include "qsv_internal.h"
>  
>  static const AVRational mfx_tb = { 1, 9 };
> @@ -101,6 +104,10 @@ typedef struct QSVContext {
>  
>  mfxExtBuffer **ext_buffers;
>  int nb_ext_buffers;
> +
> +mfxPayload payload;
> +H264SEIContext sei;
> +H264ParamSets ps;
>  } QSVContext;
>  
>  static const AVCodecHWConfigInternal *const qsv_hw_configs[] = {
> @@ -600,6 +607,150 @@ static int qsv_export_film_grain(AVCodecContext *avctx,
> mfxExtAV1FilmGrainParam
>  }
>  #endif
>  
> +static int h264_decode_fpa(H264SEIFramePacking *fpa, AVFrame *frame)
> +{
> +if (!fpa || !frame)
> +return AVERROR(EINVAL);
> +
> +if (!fpa->arrangement_cancel_flag &&
> +fpa->arrangement_type <= 6 &&
> +fpa->content_interpretation_type > 0 &&
> +fpa->content_interpretation_type < 3) {
> +AVStereo3D *stereo = av_stereo3d_create_side_data(frame);
> +if (stereo) {
> +switch (fpa->arrangement_type) {
> +case 0:
> +stereo->type = AV_STEREO3D_CHECKERBOARD;
> +break;
> +case 1:
> +stereo->type = AV_STEREO3D_COLUMNS;
> +break;
> +case 2:
> +stereo->type = AV_STEREO3D_LINES;
> +break;
> +case 3:
> +if (fpa->quincunx_sampling_flag)
> +stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
> +else
> +stereo->type = AV_STEREO3D_SIDEBYSIDE;
> +break;
> +case 4:
> +stereo->type = AV_STEREO3D_TOPBOTTOM;
> +break;
> +case 5:
> +stereo->type = AV_STEREO3D_FRAMESEQUENCE;
> +if (fpa->current_frame_is_frame0_flag)
> +stereo->view = AV_STEREO3D_VIEW_LEFT;
> +else
> +stereo->view = AV_STEREO3D_VIEW_RIGHT;
> +break;
> +case 6:
> +stereo->type = AV_STEREO3D_2D;
> +break;
> +}
> +
> +if (fpa->content_interpretation_type == 2)
> +stereo->flags = AV_STEREO3D_FLAG_INVERT;
> +}
> +}
> +return 0;
> +}
> +
> +static int h264_parse_side_data(AVCodecContext *avctx, QSVContext *q, AVFrame
> *frame)
> +{
> +GetBitContext gb_payload;
> +uint8_t *sei_buffer;
> +int sei_buffer_index;
> +int ret;
> +
> +if (q->payload.Type != SEI_TYPE_FRAME_PACKING_ARRANGEMENT)
> +return 0;
> +
> +sei_buffer = (uint8_t *)av_mallocz(q->payload.NumBit / 8);
> +if (!sei_buffer) {
> +av_freep(&sei_buffer);
> +return AVERROR(ENOMEM);
> +}
> +/* remove emulation prevention bytes */
> +sei_buffer_index = 0;
> +for (int i = 0; i < q->payload.NumBit / 8; i++) {
> +if (q->payload.Data[i] == 3)
> +i++;
> +sei_buffer[sei_buffer_index] = q->payload.Data[i];
> +sei_buffer_index += 1;
> +}
> +
> +ret = init_get_bits8(&gb_payload, sei_buffer, sei_buffer_index+1);
> +if (ret < 0) {
> +av_freep(&sei_buffer);
> +return ret;
> +}
> +
> +ret = ff_h264_sei_decode(&q->sei, &gb_payload, &q->ps, avctx);
> +if (ret < 0) {
> +av_freep(&sei_buffer);
> +return ret;
> +}
> +
> +switch (q->payload.Type) {
> +case SEI_TYPE_FRAME_PACKING_ARRANGEMENT:
> +ret = h264_decode_fpa(&q->sei.frame_packing, frame);
> +break;
> +default:
> +break;
> +}
> +
> +av_freep(&sei_buffer);

[FFmpeg-devel] [PATCH] libavformat/isom: Add more language mappings

2022-04-27 Thread Ivan Baykalov
mov_mdhd_language_map table doesn't contain ISO 639 codes for some of
the languages. I added a few which have no contradictory mappings

Fixes ticket #9743
---
 libavformat/isom.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavformat/isom.c b/libavformat/isom.c
index e6569dfb68..2bc240ed5c 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -119,9 +119,9 @@ static const char mov_mdhd_language_map[][4] = {
 "hun",/*  26 Hungarian */
 "est",/*  27 Estonian */
 "lav",/*  28 Latvian */
-   "",/*  29 Sami */
+"smi",/*  29 Sami */
 "fo ",/*  30 Faroese */
-   "",/*  31 Farsi */
+"per",/*  31 Farsi */
 "rus",/*  32 Russian */
 "chi",/*  33 Simplified Chinese */
"",/*  34 Flemish */
@@ -166,7 +166,7 @@ static const char mov_mdhd_language_map[][4] = {
 "kan",/*  73 Kannada */
 "tam",/*  74 Tamil */
 "tel",/*  75 Telugu */
-   "",/*  76 Sinhala */
+"sin",/*  76 Sinhala */
 "bur",/*  77 Burmese */
 "khm",/*  78 Khmer */
 "lao",/*  79 Lao */
@@ -180,9 +180,9 @@ static const char mov_mdhd_language_map[][4] = {
 "orm",/*  87 Oromo */
 "som",/*  88 Somali */
 "swa",/*  89 Swahili */
-   "",/*  90 Kinyarwanda */
+"kin",/*  90 Kinyarwanda */
 "run",/*  91 Rundi */
-   "",/*  92 Nyanja */
+"nya",/*  92 Nyanja */
 "mlg",/*  93 Malagasy */
 "epo",/*  94 Esperanto */
"",/*  95  */
-- 
2.35.1

___
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] [PATCH] doc/encoders: document libjxl encoder options

2022-04-27 Thread Leo Izen

On 4/27/22 04:39, Gyan Doshi wrote:



On 2022-04-27 02:38 am, Leo Izen wrote:


+
+@item modular
+Force the encoder to use Modular mode. The default is to let the 
encoder pick
+between VarDCT and Modular encoding modes based on encoding settings 
and the

+type of input content.


What happens in these two modes? Why would the user want to force 
modular? Is there a way and reason to force VarDCT?



VarDCT uses a fourier-DCT-based transform in essence. Modular uses a 
variety of transforms that can be combined like Lego bricks into 
patches, including a modified Haar transform.


In general, VarDCT will be superior to Modular for lossy encoding, but 
VarDCT doesn't support lossless, so Modular is required for lossless 
encoding. Currently, the library always chooses VarDCT for lossy and 
Modular for lossless, although this could potentially be subject to change.


A user will have very little reason to force modular unless they're 
testing the two modes against each other. The library API does not 
provide a way to force VarDCT. Or rather, it does, but if you force 
VarDCT and tell it to encode losslessly it will silently use modular 
rather than fail.


You generally won't have a reason to force VarDCT anyway, since it's 
chosen by default if you pick lossy, so this isn't an issue.


Leo Izen (thebombzen)


___
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".


[FFmpeg-devel] Guidance needed for a semi-breaking change

2022-04-27 Thread MCC CS
Hi,

It's my first time writing an (original) patch for ffmpeg, so I would like your 
help.

I’m planning to propose a diff to an encoder param for aac_at, which is, as 
currently listed by "ffmpeg -h encoder=aac_at”:

  -aac_at_qualityE...A.. quality vs speed control (from 0 
to 2) (default 0)

Currently, 0 uses HIGH, and 1, 2 use MID, LOW quality encodings.

I’d like to change this param so that all 5 levels listed by Apple (MAX, HIGH, 
MID, LOW, MIN) can be used.

Do I change it to:

  -aac_at_qualityE...A.. quality vs speed control (from 0 
to 4) (default 0)

and migrate everyone to a higher-quality encoding preset

or
  -aac_at_qualityE...A.. quality vs speed control (from -1 
to 3) (default -1)

so that previous levels are kept as they are, adding only MAX and MIN, which 
were previously out of range.

I’d like to know: Which of these aligns better with FFMPEG’s policies?

Many thanks
___
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] Guidance needed for a semi-breaking change

2022-04-27 Thread Timo Rothenpieler
You need to keep API and ABI compatibility, cause otherwise it's a 
breaking change which can only happen at a major bump.
Any and all existing applications and commandline need to keep working 
as they do right now.


What you could do is convert the option into a OPT_TYPE_CONST one, and 
offer the new values as actual textual option, and set up the numerical 
values so that they align with what's currently offered.

___
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] [PATCH] libavformat/rtsp: pkt_size option is not honored in rtsp

2022-04-27 Thread zhilizhao(赵志立)



> On Apr 6, 2022, at 8:52 PM, Yubo Xie  wrote:
> 
> Signed-off-by: xyb 
> ---
> libavformat/rtsp.c| 4 ++--
> libavformat/rtsp.h| 1 -
> libavformat/rtspenc.c | 2 +-
> 3 files changed, 3 insertions(+), 4 deletions(-)
> 

Applied, thanks!
___
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] Guidance needed for a semi-breaking change

2022-04-27 Thread MCC CS
I wasn't considering a breaking change, those using
-aac_at_quality 0 or -aac_at_quality 2 would continue to use those.
However, would moving -aac_at_quality 0 from HIGH (currently highest
used by FFMPEG) to MAX be welcome? I'd assume that those using
-aac_at_quality 0 do so to use the highest quality option available.

If not, extending the range (0,2) to (-1,3) without moving any
previous options would work. From what I understand negative
numbers are OK in ffmpeg since `-q:a -1` produces higher quality
than `-q:a 0` for me.

How about this?

Thanks again

Sent: Wednesday, April 27, 2022 at 1:49 PM
From: "Timo Rothenpieler" 
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] Guidance needed for a semi-breaking change
You need to keep API and ABI compatibility, cause otherwise it's a
breaking change which can only happen at a major bump.
Any and all existing applications and commandline need to keep working
as they do right now.

What you could do is convert the option into a OPT_TYPE_CONST one, and
offer the new values as actual textual option, and set up the numerical
values so that they align with what's currently offered.
___
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".
___
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] Guidance needed for a semi-breaking change

2022-04-27 Thread Timo Rothenpieler
Any existing commandline should produce the exact same output after the 
change.

Not sure if the encoder is bitexact, but if it is, the output should match.
___
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] Guidance needed for a semi-breaking change

2022-04-27 Thread Nicolas George
Timo Rothenpieler (12022-04-27):
> Any existing commandline should produce the exact same output after the
> change.

I do not agree.

Small changes in default behavior are acceptable, since the user did not
specify what they want.

(I would argue that changes that fix a bug and changes that are
unambiguously and exclusively an improvement are acceptable.)

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
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] [PATCH] doc/encoders: document libjxl encoder options

2022-04-27 Thread Gyan Doshi




On 2022-04-27 05:58 pm, Leo Izen wrote:

On 4/27/22 04:39, Gyan Doshi wrote:



On 2022-04-27 02:38 am, Leo Izen wrote:


+
+@item modular
+Force the encoder to use Modular mode. The default is to let the 
encoder pick
+between VarDCT and Modular encoding modes based on encoding 
settings and the

+type of input content.


What happens in these two modes? Why would the user want to force 
modular? Is there a way and reason to force VarDCT?



VarDCT uses a fourier-DCT-based transform in essence. Modular uses a 
variety of transforms that can be combined like Lego bricks into 
patches, including a modified Haar transform.


In general, VarDCT will be superior to Modular for lossy encoding, but 
VarDCT doesn't support lossless, so Modular is required for lossless 
encoding. Currently, the library always chooses VarDCT for lossy and 
Modular for lossless, although this could potentially be subject to 
change.


A user will have very little reason to force modular unless they're 
testing the two modes against each other. The library API does not 
provide a way to force VarDCT. Or rather, it does, but if you force 
VarDCT and tell it to encode losslessly it will silently use modular 
rather than fail.


You generally won't have a reason to force VarDCT anyway, since it's 
chosen by default if you pick lossy, so this isn't an issue.


Ok, maybe qualify the option description to state lossless is always 
modular and lossy is VarDCT unless forced otherwise.


LGTM with those changes.

Regards,
Gyan
___
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".


[FFmpeg-devel] [PATCH v3 1/2] doc/examples/transcode_aac: Don't ignore last encoded frame

2022-04-27 Thread Andreas Unterweger
The last encoded frame is now fetched on EOF. It was previously left in 
the encoder and caused a "1 frame left in queue" warning.


Signed-off-by: Andreas Unterweger 
---
 doc/examples/transcode_aac.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/doc/examples/transcode_aac.c b/doc/examples/transcode_aac.c
index 9102e55f16..c9b93f6439 100644
--- a/doc/examples/transcode_aac.c
+++ b/doc/examples/transcode_aac.c
@@ -377,6 +377,8 @@ static int decode_audio_frame(AVFrame *frame,
 if (error < 0)
 return error;
 +*data_present = 0;
+*finished = 0;
 /* Read one audio frame from the input file into a temporary 
packet. */

 if ((error = av_read_frame(input_format_context, input_packet)) < 0) {
 /* If we are at the end of the file, flush the decoder below. */
@@ -555,7 +557,7 @@ static int read_decode_convert_and_store(AVAudioFifo 
*fifo,

 AVFrame *input_frame = NULL;
 /* Temporary storage for the converted input samples. */
 uint8_t **converted_input_samples = NULL;
-int data_present = 0;
+int data_present;
 int ret = AVERROR_EXIT;
  /* Initialize temporary storage for one input frame. */
@@ -675,18 +677,17 @@ static int encode_audio_frame(AVFrame *frame,
 frame->pts = pts;
 pts += frame->nb_samples;
 }
-
++*data_present = 0;
 /* Send the audio frame stored in the temporary packet to the encoder.
  * The output audio stream encoder is used to do this. */
 error = avcodec_send_frame(output_codec_context, frame);
-/* The encoder signals that it has nothing more to encode. */
-if (error == AVERROR_EOF) {
-error = 0;
-goto cleanup;
-} else if (error < 0) {
-fprintf(stderr, "Could not send packet for encoding (error 
'%s')\n",

-av_err2str(error));
-goto cleanup;
+/* Check for errors, but proceed with fetching encoded samples if the
+ *  encoder signals that it has nothing more to encode. */
+if (error < 0 && error != AVERROR_EOF) {
+  fprintf(stderr, "Could not send packet for encoding (error '%s')\n",
+  av_err2str(error));
+  goto cleanup;
 }
  /* Receive one encoded frame from the encoder. */
@@ -857,7 +858,6 @@ int main(int argc, char **argv)
 int data_written;
 /* Flush the encoder as it may have delayed frames. */
 do {
-data_written = 0;
 if (encode_audio_frame(NULL, output_format_context,
output_codec_context, 
&data_written))

 goto cleanup;
--
2.30.2

___
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".


[FFmpeg-devel] [PATCH v3 2/2] doc/examples/transcode_aac: Set decoder packet timebase

2022-04-27 Thread Andreas Unterweger
Previously, the default timebase caused two warnings during decoding 
about not being able to update timestamps for skipped and discarded 
samples, respectively.


Signed-off-by: Andreas Unterweger 
---
 doc/examples/transcode_aac.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/doc/examples/transcode_aac.c b/doc/examples/transcode_aac.c
index c9b93f6439..6197369756 100644
--- a/doc/examples/transcode_aac.c
+++ b/doc/examples/transcode_aac.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2018 Andreas Unterweger
+ * Copyright (c) 2013-2022 Andreas Unterweger
  *
  * This file is part of FFmpeg.
  *
@@ -120,6 +120,10 @@ static int open_input_file(const char *filename,
 avformat_close_input(input_format_context);
 return error;
 }
++/* Set the packet timebase for the decoder. The input file's 
sample

+ * rate is used as the denominator for simplicity. */
+avctx->pkt_timebase = (AVRational) { 1, avctx->sample_rate };
  /* Save the decoder context for easier access later. */
 *input_codec_context = avctx;
--
2.30.2

___
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] [PATCH v3 2/2] doc/examples/transcode_aac: Set decoder packet timebase

2022-04-27 Thread Andreas Unterweger

Am 27.04.2022 um 15:35 schrieb Andreas Unterweger:
Previously, the default timebase caused two warnings during decoding 
about not being able to update timestamps for skipped and discarded 
samples, respectively.


Signed-off-by: Andreas Unterweger 
---
  doc/examples/transcode_aac.c | 6 +-
  1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/doc/examples/transcode_aac.c b/doc/examples/transcode_aac.c
index c9b93f6439..6197369756 100644
--- a/doc/examples/transcode_aac.c
+++ b/doc/examples/transcode_aac.c
@@ -1,5 +1,5 @@
  /*
- * Copyright (c) 2013-2018 Andreas Unterweger
+ * Copyright (c) 2013-2022 Andreas Unterweger
   *
   * This file is part of FFmpeg.
   *
@@ -120,6 +120,10 @@ static int open_input_file(const char *filename,
  avformat_close_input(input_format_context);
  return error;
  }
+    +    /* Set the packet timebase for the decoder. The input file's 
sample

+ * rate is used as the denominator for simplicity. */
+    avctx->pkt_timebase = (AVRational) { 1, avctx->sample_rate };
   /* Save the decoder context for easier access later. */
  *input_codec_context = avctx;


I rebased the patch another one time onto the current master. Please apply.

Best,
Andreas
___
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".


[FFmpeg-devel] [PATCH v4 1/2] doc/examples/transcode_aac: Don't ignore last encoded

2022-04-27 Thread Andreas Unterweger
The last encoded frame is now fetched on EOF. It was previously left
in the encoder and caused a "1 frame left in queue" warning.

Signed-off-by: Andreas Unterweger 
---
 doc/examples/transcode_aac.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/doc/examples/transcode_aac.c b/doc/examples/transcode_aac.c
index 9102e55f16..c9b93f6439 100644
--- a/doc/examples/transcode_aac.c
+++ b/doc/examples/transcode_aac.c
@@ -377,6 +377,8 @@ static int decode_audio_frame(AVFrame *frame,
 if (error < 0)
 return error;

+*data_present = 0;
+*finished = 0;
 /* Read one audio frame from the input file into a temporary packet. */
 if ((error = av_read_frame(input_format_context, input_packet)) < 0) {
 /* If we are at the end of the file, flush the decoder below. */
@@ -555,7 +557,7 @@ static int read_decode_convert_and_store(AVAudioFifo *fifo,
 AVFrame *input_frame = NULL;
 /* Temporary storage for the converted input samples. */
 uint8_t **converted_input_samples = NULL;
-int data_present = 0;
+int data_present;
 int ret = AVERROR_EXIT;

 /* Initialize temporary storage for one input frame. */
@@ -675,18 +677,17 @@ static int encode_audio_frame(AVFrame *frame,
 frame->pts = pts;
 pts += frame->nb_samples;
 }
-
+
+*data_present = 0;
 /* Send the audio frame stored in the temporary packet to the encoder.
  * The output audio stream encoder is used to do this. */
 error = avcodec_send_frame(output_codec_context, frame);
-/* The encoder signals that it has nothing more to encode. */
-if (error == AVERROR_EOF) {
-error = 0;
-goto cleanup;
-} else if (error < 0) {
-fprintf(stderr, "Could not send packet for encoding (error '%s')\n",
-av_err2str(error));
-goto cleanup;
+/* Check for errors, but proceed with fetching encoded samples if the
+ *  encoder signals that it has nothing more to encode. */
+if (error < 0 && error != AVERROR_EOF) {
+  fprintf(stderr, "Could not send packet for encoding (error '%s')\n",
+  av_err2str(error));
+  goto cleanup;
 }

 /* Receive one encoded frame from the encoder. */
@@ -857,7 +858,6 @@ int main(int argc, char **argv)
 int data_written;
 /* Flush the encoder as it may have delayed frames. */
 do {
-data_written = 0;
 if (encode_audio_frame(NULL, output_format_context,
output_codec_context, &data_written))
 goto cleanup;
-- 
2.30.2
___
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] Guidance needed for a semi-breaking change

2022-04-27 Thread MCC CS
The default for AAC_AT is to produce highest quality audio, which I'll keep 
undoubtedly
in the same direction. However, the question is this:

Should the one who explicitly set `-aac_at_quality 0` (highest quality 
available) be moved from HIGH to MAX,
HOWEVER causing the side effect of moving everyone up in the quality-speed 
tradeoff by one,

(or we can eliminate HIGH and just replace it with MAX which has no tradeoffs 
AFAIK)

OR add `-1`, so that only those who entered no `aac_at_quality` be moved to -1,
and keeping explicit people having set `-aac_at_quality 0` at HIGH for them,
although they might have meant MAX when they started using it?
(i.e. no regression nor improvement for them)

---
Sent: Wednesday, April 27, 2022 at 2:18 PM
From: "Nicolas George" 
To: "FFmpeg development discussions and patches" 
Subject: Re: [FFmpeg-devel] Guidance needed for a semi-breaking change
Timo Rothenpieler (12022-04-27):
> Any existing commandline should produce the exact same output after the
> change.

I do not agree.

Small changes in default behavior are acceptable, since the user did not
specify what they want.

(I would argue that changes that fix a bug and changes that are
unambiguously and exclusively an improvement are acceptable.)

Regards,

--
Nicolas George
___
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".
___
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".


[FFmpeg-devel] [PATCH v4 2/2] doc/examples/transcode_aac: Set decoder packet timebase

2022-04-27 Thread Andreas Unterweger
Previously, the default timebase caused two warnings during decoding
about not being able to update timestamps for skipped and discarded
samples, respectively.

Signed-off-by: Andreas Unterweger 
---
 doc/examples/transcode_aac.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/doc/examples/transcode_aac.c b/doc/examples/transcode_aac.c
index c9b93f6439..6197369756 100644
--- a/doc/examples/transcode_aac.c
+++ b/doc/examples/transcode_aac.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2018 Andreas Unterweger
+ * Copyright (c) 2013-2022 Andreas Unterweger
  *
  * This file is part of FFmpeg.
  *
@@ -120,6 +120,10 @@ static int open_input_file(const char *filename,
 avformat_close_input(input_format_context);
 return error;
 }
+
+/* Set the packet timebase for the decoder. The input file's sample
+ * rate is used as the denominator for simplicity. */
+avctx->pkt_timebase = (AVRational) { 1, avctx->sample_rate };

 /* Save the decoder context for easier access later. */
 *input_codec_context = avctx;
-- 
2.30.2
___
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] [PATCH v4 2/2] doc/examples/transcode_aac: Set decoder packet timebase

2022-04-27 Thread Andreas Unterweger
On Wed, 27 Apr 2022 at 16:07, Andreas Unterweger  wrote:
>
> Previously, the default timebase caused two warnings during decoding
> about not being able to update timestamps for skipped and discarded
> samples, respectively.
>
> Signed-off-by: Andreas Unterweger 
> ---
>  doc/examples/transcode_aac.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/doc/examples/transcode_aac.c b/doc/examples/transcode_aac.c
> index c9b93f6439..6197369756 100644
> --- a/doc/examples/transcode_aac.c
> +++ b/doc/examples/transcode_aac.c
> @@ -1,5 +1,5 @@
>  /*
> - * Copyright (c) 2013-2018 Andreas Unterweger
> + * Copyright (c) 2013-2022 Andreas Unterweger
>   *
>   * This file is part of FFmpeg.
>   *
> @@ -120,6 +120,10 @@ static int open_input_file(const char *filename,
>  avformat_close_input(input_format_context);
>  return error;
>  }
> +
> +/* Set the packet timebase for the decoder. The input file's sample
> + * rate is used as the denominator for simplicity. */
> +avctx->pkt_timebase = (AVRational) { 1, avctx->sample_rate };
>
>  /* Save the decoder context for easier access later. */
>  *input_codec_context = avctx;
> --
> 2.30.2

It seems that recent versions of Thunderbird broke eml import when
lines contain single characters (such as + in a diff). Here is the
same patch again sent with a different e-mail client.

Please apply. Thanks.
Best,
Andreas
___
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".


[FFmpeg-devel] [PATCH v2] doc/encoders: document libjxl encoder options

2022-04-27 Thread Leo Izen
Add more detailed documenation for the libjxl encoder
wrapper than is present currently inside libavcodec.
---
 doc/encoders.texi | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index aac9f25e55..51f0dc3fcb 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1809,6 +1809,41 @@ by ":". See the SVT-AV1 encoder user guide for a list of 
accepted parameters.
 
 @end table
 
+@section libjxl
+
+libjxl JPEG XL encoder wrapper.
+
+Requires the presence of the libjxl headers and library during
+configuration. You need to explicitly configure the build with
+@code{--enable-libjxl}.
+
+@subsection Options
+
+The libjxl wrapper supports the following options:
+
+@table @option
+
+@item distance
+Set the target Butteraugli distance. This is a quality setting: lower
+distance yields higher quality, with distance=1.0 roughly comparable to
+libjpeg Quality 90 for photographic content. Setting distance=0.0 yields
+true lossless encoding. Valid values range between 0.0 and 15.0, and sane
+values rarely exceed 5.0. Setting distance=0.1 is usually attains
+transparency for most input. The default is 1.0.
+
+@item effort
+Set the encoding effort used. Higher effort values produce more consistent
+quality and usually produces a better quality/bpp curve, at the cost of
+more CPU time required. Valid values range from 1 to 9, and the default is 7.
+
+@item modular
+Force the encoder to use Modular mode instead of choosing automatically. The
+default is to use VarDCT for lossy encoding and Modular for lossless. VarDCT
+is generally superior to Modular for lossy encoding but does not support
+lossless encoding.
+
+@end table
+
 @section libkvazaar
 
 Kvazaar H.265/HEVC encoder.
-- 
2.36.0

___
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] Guidance needed for a semi-breaking change

2022-04-27 Thread Timo Rothenpieler

On 27.04.2022 16:07, MCC CS wrote:

The default for AAC_AT is to produce highest quality audio, which I'll keep 
undoubtedly
in the same direction. However, the question is this:

Should the one who explicitly set `-aac_at_quality 0` (highest quality 
available) be moved from HIGH to MAX,
HOWEVER causing the side effect of moving everyone up in the quality-speed 
tradeoff by one,

(or we can eliminate HIGH and just replace it with MAX which has no tradeoffs 
AFAIK)

OR add `-1`, so that only those who entered no `aac_at_quality` be moved to -1,
and keeping explicit people having set `-aac_at_quality 0` at HIGH for them,
although they might have meant MAX when they started using it?
(i.e. no regression nor improvement for them)


The strictly correct approach here would be to add version guards, and 
switch to the new behaviour next major bump.
I do agree though that that seems a bit over the top for this, and 
specially if there is a higher quality than what ffmpeg currently 
offers, I could definitely see keeping 0 as "highest possible quality".

___
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] Guidance needed for a semi-breaking change

2022-04-27 Thread MCC CS
Would you then approve changing current 0 from HIGH to MAX? Alternatively
-1 can be added until a major bump, while keeping 0 as default.
Either would be nondestructive.

And do you have an example/doc text about adding version guards to an arg?
I hope there's a general preprocessor variable for FFMPEGv6

Sent: Wednesday, April 27, 2022 at 4:18 PM
From: "Timo Rothenpieler" 
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] Guidance needed for a semi-breaking change
On 27.04.2022 16:07, MCC CS wrote:
> The default for AAC_AT is to produce highest quality audio, which I'll keep 
> undoubtedly
> in the same direction. However, the question is this:
>
> Should the one who explicitly set `-aac_at_quality 0` (highest quality 
> available) be moved from HIGH to MAX,
> HOWEVER causing the side effect of moving everyone up in the quality-speed 
> tradeoff by one,
>
> (or we can eliminate HIGH and just replace it with MAX which has no tradeoffs 
> AFAIK)
>
> OR add `-1`, so that only those who entered no `aac_at_quality` be moved to 
> -1,
> and keeping explicit people having set `-aac_at_quality 0` at HIGH for them,
> although they might have meant MAX when they started using it?
> (i.e. no regression nor improvement for them)

The strictly correct approach here would be to add version guards, and
switch to the new behaviour next major bump.
I do agree though that that seems a bit over the top for this, and
specially if there is a higher quality than what ffmpeg currently
offers, I could definitely see keeping 0 as "highest possible quality".
___
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".
___
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".


[FFmpeg-devel] [PATCH 1/2] avcodec/Makefile: Add libjxl.h to SKIPHEADERS if necessary

2022-04-27 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index d6ad23474d..cfaa6f196a 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1229,6 +1229,7 @@ SKIPHEADERS-$(CONFIG_AMF)  += amfenc.h
 SKIPHEADERS-$(CONFIG_D3D11VA)  += d3d11va.h dxva2_internal.h
 SKIPHEADERS-$(CONFIG_DXVA2)+= dxva2.h dxva2_internal.h
 SKIPHEADERS-$(CONFIG_JNI)  += ffjni.h
+SKIPHEADERS-$(CONFIG_LIBJXL)   += libjxl.h
 SKIPHEADERS-$(CONFIG_LIBVPX)   += libvpx.h
 SKIPHEADERS-$(CONFIG_LIBWEBP_ENCODER)  += libwebpenc_common.h
 SKIPHEADERS-$(CONFIG_MEDIACODEC)   += mediacodecdec_common.h 
mediacodec_surface.h mediacodec_wrapper.h mediacodec_sw_buffer.h
-- 
2.32.0

___
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".


[FFmpeg-devel] [PATCH 2/2] avfilter/Makefile: Add fflcms2.h to SKIPHEADERS- if necessary

2022-04-27 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 1db097b464..e06acdf881 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -596,6 +596,7 @@ SHLIBOBJS+= log2_tab.o
 # Windows resource file
 SLIBOBJS-$(HAVE_GNU_WINDRES) += avfilterres.o
 
+SKIPHEADERS-$(CONFIG_LCMS2)  += fflcms2.h
 SKIPHEADERS-$(CONFIG_LIBVIDSTAB) += vidstabutils.h
 
 SKIPHEADERS-$(CONFIG_QSVVPP) += qsvvpp.h
-- 
2.32.0

___
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] [PATCH] libavcodec/qsvdec.c: extract frame packing arrangement data

2022-04-27 Thread Andreas Rheinhardt
Wenbin Chen:
> Use h264_sei to parse SEI data got from MediaSDK. Extract frame
> packing arrangement information from SEI data and config AVStereo3D
> side data for decoded frame.
> 
> Signed-off-by: Wenbin Chen 
> Signed-off-by: Tong Wu 
> ---
>  libavcodec/qsv_internal.h |   2 +
>  libavcodec/qsvdec.c   | 160 ++
>  2 files changed, 162 insertions(+)
> 
> diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
> index e2aecdcbd6..a804c392c1 100644
> --- a/libavcodec/qsv_internal.h
> +++ b/libavcodec/qsv_internal.h
> @@ -54,6 +54,8 @@
>  
>  #define QSV_MAX_FRAME_EXT_PARAMS 4
>  
> +#define QSV_PAYLOAD_SIZE 1024
> +
>  #define QSV_VERSION_ATLEAST(MAJOR, MINOR)   \
>  (MFX_VERSION_MAJOR > (MAJOR) || \
>   MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR))
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> index 5fc5bed4c8..26fa178b4d 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -41,13 +41,16 @@
>  #include "libavutil/time.h"
>  #include "libavutil/imgutils.h"
>  #include "libavutil/film_grain_params.h"
> +#include "libavutil/stereo3d.h"
>  
>  #include "avcodec.h"
>  #include "codec_internal.h"
>  #include "internal.h"
>  #include "decode.h"
>  #include "hwconfig.h"
> +#include "get_bits.h"
>  #include "qsv.h"
> +#include "h264_sei.h"
>  #include "qsv_internal.h"
>  
>  static const AVRational mfx_tb = { 1, 9 };
> @@ -101,6 +104,10 @@ typedef struct QSVContext {
>  
>  mfxExtBuffer **ext_buffers;
>  int nb_ext_buffers;
> +
> +mfxPayload payload;
> +H264SEIContext sei;
> +H264ParamSets ps;
>  } QSVContext;
>  
>  static const AVCodecHWConfigInternal *const qsv_hw_configs[] = {
> @@ -600,6 +607,150 @@ static int qsv_export_film_grain(AVCodecContext *avctx, 
> mfxExtAV1FilmGrainParam
>  }
>  #endif
>  
> +static int h264_decode_fpa(H264SEIFramePacking *fpa, AVFrame *frame)
> +{
> +if (!fpa || !frame)
> +return AVERROR(EINVAL);
> +
> +if (!fpa->arrangement_cancel_flag &&
> +fpa->arrangement_type <= 6 &&
> +fpa->content_interpretation_type > 0 &&
> +fpa->content_interpretation_type < 3) {
> +AVStereo3D *stereo = av_stereo3d_create_side_data(frame);
> +if (stereo) {
> +switch (fpa->arrangement_type) {
> +case 0:
> +stereo->type = AV_STEREO3D_CHECKERBOARD;
> +break;
> +case 1:
> +stereo->type = AV_STEREO3D_COLUMNS;
> +break;
> +case 2:
> +stereo->type = AV_STEREO3D_LINES;
> +break;
> +case 3:
> +if (fpa->quincunx_sampling_flag)
> +stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
> +else
> +stereo->type = AV_STEREO3D_SIDEBYSIDE;
> +break;
> +case 4:
> +stereo->type = AV_STEREO3D_TOPBOTTOM;
> +break;
> +case 5:
> +stereo->type = AV_STEREO3D_FRAMESEQUENCE;
> +if (fpa->current_frame_is_frame0_flag)
> +stereo->view = AV_STEREO3D_VIEW_LEFT;
> +else
> +stereo->view = AV_STEREO3D_VIEW_RIGHT;
> +break;
> +case 6:
> +stereo->type = AV_STEREO3D_2D;
> +break;
> +}
> +
> +if (fpa->content_interpretation_type == 2)
> +stereo->flags = AV_STEREO3D_FLAG_INVERT;
> +}
> +}
> +return 0;
> +}
> +
> +static int h264_parse_side_data(AVCodecContext *avctx, QSVContext *q, 
> AVFrame *frame)
> +{
> +GetBitContext gb_payload;
> +uint8_t *sei_buffer;
> +int sei_buffer_index;
> +int ret;
> +
> +if (q->payload.Type != SEI_TYPE_FRAME_PACKING_ARRANGEMENT)
> +return 0;
> +
> +sei_buffer = (uint8_t *)av_mallocz(q->payload.NumBit / 8);
> +if (!sei_buffer) {
> +av_freep(&sei_buffer);
> +return AVERROR(ENOMEM);
> +}
> +/* remove emulation prevention bytes */
> +sei_buffer_index = 0;
> +for (int i = 0; i < q->payload.NumBit / 8; i++) {
> +if (q->payload.Data[i] == 3)
> +i++;
> +sei_buffer[sei_buffer_index] = q->payload.Data[i];
> +sei_buffer_index += 1;

Not every 0x03 is an emulation prevention byte.

> +}
> +
> +ret = init_get_bits8(&gb_payload, sei_buffer, sei_buffer_index+1);

Buffers used with the get-bits API need to be padded. Best to use
av_fast_padded_malloc and ff_h2645_extract_rbsp.

> +if (ret < 0) {
> +av_freep(&sei_buffer);
> +return ret;
> +}
> +
> +ret = ff_h264_sei_decode(&q->sei, &gb_payload, &q->ps, avctx);
> +if (ret < 0) {
> +av_freep(&sei_buffer);
> +return ret;
> +}
> +
> +switch (q->payload.Type) {
> +case SEI_TYPE_FRAME_PACKING_ARRANGEMENT:
> +ret = h264_decode_fp

Re: [FFmpeg-devel] [PATCH] libavcodec/qsvdec.c: extract frame packing arrangement data

2022-04-27 Thread Chen, Wenbin
> On Tue, 2022-04-26 at 18:00 +0800, Wenbin Chen wrote:
> > Use h264_sei to parse SEI data got from MediaSDK. Extract frame
> > packing arrangement information from SEI data and config AVStereo3D
> > side data for decoded frame.
> >
> > Signed-off-by: Wenbin Chen 
> > Signed-off-by: Tong Wu 
> > ---
> >  libavcodec/qsv_internal.h |   2 +
> >  libavcodec/qsvdec.c   | 160
> ++
> >  2 files changed, 162 insertions(+)
> >
> > diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
> > index e2aecdcbd6..a804c392c1 100644
> > --- a/libavcodec/qsv_internal.h
> > +++ b/libavcodec/qsv_internal.h
> > @@ -54,6 +54,8 @@
> >
> >  #define QSV_MAX_FRAME_EXT_PARAMS 4
> >
> > +#define QSV_PAYLOAD_SIZE 1024
> > +
> >  #define QSV_VERSION_ATLEAST(MAJOR, MINOR)   \
> >  (MFX_VERSION_MAJOR > (MAJOR) || \
> >   MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >=
> (MINOR))
> > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> > index 5fc5bed4c8..26fa178b4d 100644
> > --- a/libavcodec/qsvdec.c
> > +++ b/libavcodec/qsvdec.c
> > @@ -41,13 +41,16 @@
> >  #include "libavutil/time.h"
> >  #include "libavutil/imgutils.h"
> >  #include "libavutil/film_grain_params.h"
> > +#include "libavutil/stereo3d.h"
> >
> >  #include "avcodec.h"
> >  #include "codec_internal.h"
> >  #include "internal.h"
> >  #include "decode.h"
> >  #include "hwconfig.h"
> > +#include "get_bits.h"
> >  #include "qsv.h"
> > +#include "h264_sei.h"
> >  #include "qsv_internal.h"
> >
> >  static const AVRational mfx_tb = { 1, 9 };
> > @@ -101,6 +104,10 @@ typedef struct QSVContext {
> >
> >  mfxExtBuffer **ext_buffers;
> >  int nb_ext_buffers;
> > +
> > +mfxPayload payload;
> > +H264SEIContext sei;
> > +H264ParamSets ps;
> >  } QSVContext;
> >
> >  static const AVCodecHWConfigInternal *const qsv_hw_configs[] = {
> > @@ -600,6 +607,150 @@ static int qsv_export_film_grain(AVCodecContext
> *avctx,
> > mfxExtAV1FilmGrainParam
> >  }
> >  #endif
> >
> > +static int h264_decode_fpa(H264SEIFramePacking *fpa, AVFrame *frame)
> > +{
> > +if (!fpa || !frame)
> > +return AVERROR(EINVAL);
> > +
> > +if (!fpa->arrangement_cancel_flag &&
> > +fpa->arrangement_type <= 6 &&
> > +fpa->content_interpretation_type > 0 &&
> > +fpa->content_interpretation_type < 3) {
> > +AVStereo3D *stereo = av_stereo3d_create_side_data(frame);
> > +if (stereo) {
> > +switch (fpa->arrangement_type) {
> > +case 0:
> > +stereo->type = AV_STEREO3D_CHECKERBOARD;
> > +break;
> > +case 1:
> > +stereo->type = AV_STEREO3D_COLUMNS;
> > +break;
> > +case 2:
> > +stereo->type = AV_STEREO3D_LINES;
> > +break;
> > +case 3:
> > +if (fpa->quincunx_sampling_flag)
> > +stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
> > +else
> > +stereo->type = AV_STEREO3D_SIDEBYSIDE;
> > +break;
> > +case 4:
> > +stereo->type = AV_STEREO3D_TOPBOTTOM;
> > +break;
> > +case 5:
> > +stereo->type = AV_STEREO3D_FRAMESEQUENCE;
> > +if (fpa->current_frame_is_frame0_flag)
> > +stereo->view = AV_STEREO3D_VIEW_LEFT;
> > +else
> > +stereo->view = AV_STEREO3D_VIEW_RIGHT;
> > +break;
> > +case 6:
> > +stereo->type = AV_STEREO3D_2D;
> > +break;
> > +}
> > +
> > +if (fpa->content_interpretation_type == 2)
> > +stereo->flags = AV_STEREO3D_FLAG_INVERT;
> > +}
> > +}
> > +return 0;
> > +}
> > +
> > +static int h264_parse_side_data(AVCodecContext *avctx, QSVContext *q,
> AVFrame
> > *frame)
> > +{
> > +GetBitContext gb_payload;
> > +uint8_t *sei_buffer;
> > +int sei_buffer_index;
> > +int ret;
> > +
> > +if (q->payload.Type != SEI_TYPE_FRAME_PACKING_ARRANGEMENT)
> > +return 0;
> > +
> > +sei_buffer = (uint8_t *)av_mallocz(q->payload.NumBit / 8);
> > +if (!sei_buffer) {
> > +av_freep(&sei_buffer);
> > +return AVERROR(ENOMEM);
> > +}
> > +/* remove emulation prevention bytes */
> > +sei_buffer_index = 0;
> > +for (int i = 0; i < q->payload.NumBit / 8; i++) {
> > +if (q->payload.Data[i] == 3)
> > +i++;
> > +sei_buffer[sei_buffer_index] = q->payload.Data[i];
> > +sei_buffer_index += 1;
> > +}
> > +
> > +ret = init_get_bits8(&gb_payload, sei_buffer, sei_buffer_index+1);
> > +if (ret < 0) {
> > +av_freep(&sei_buffer);
> > +return ret;
> > +}
> > +
> > +ret = ff_h264_sei_decode(&q->sei, &gb_payload, &q->ps, avctx);
> > +if (ret < 0) {
> > +av_freep(&sei_buff

[FFmpeg-devel] [PATCH] avformat/jpegxl_probe: Fix potential incorrect and UB shift

2022-04-27 Thread Andreas Rheinhardt
Fixes Coverity issue #1504273.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/jpegxl_probe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/jpegxl_probe.c b/libavformat/jpegxl_probe.c
index 924b529ad5..9cd00da194 100644
--- a/libavformat/jpegxl_probe.c
+++ b/libavformat/jpegxl_probe.c
@@ -96,10 +96,10 @@ static uint64_t jpegxl_u64(GetBitContext *gb)
 ret = jxl_bits(12);
 while (jxl_bits(1)) {
 if (shift < 60) {
-ret |= jxl_bits(8) << shift;
+ret |= (uint64_t)jxl_bits(8) << shift;
 shift += 8;
 } else {
-ret |= jxl_bits(4) << shift;
+ret |= (uint64_t)jxl_bits(4) << shift;
 break;
 }
 }
-- 
2.32.0

___
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] [PATCH v4 2/2] doc/examples/transcode_aac: Set decoder packet timebase

2022-04-27 Thread Andreas Rheinhardt
Andreas Unterweger:
> Previously, the default timebase caused two warnings during decoding
> about not being able to update timestamps for skipped and discarded
> samples, respectively.
> 
> Signed-off-by: Andreas Unterweger 
> ---
>  doc/examples/transcode_aac.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/examples/transcode_aac.c b/doc/examples/transcode_aac.c
> index c9b93f6439..6197369756 100644
> --- a/doc/examples/transcode_aac.c
> +++ b/doc/examples/transcode_aac.c
> @@ -1,5 +1,5 @@
>  /*
> - * Copyright (c) 2013-2018 Andreas Unterweger
> + * Copyright (c) 2013-2022 Andreas Unterweger
>   *
>   * This file is part of FFmpeg.
>   *
> @@ -120,6 +120,10 @@ static int open_input_file(const char *filename,
>  avformat_close_input(input_format_context);
>  return error;
>  }
> +
> +/* Set the packet timebase for the decoder. The input file's sample
> + * rate is used as the denominator for simplicity. */
> +avctx->pkt_timebase = (AVRational) { 1, avctx->sample_rate };
> 
>  /* Save the decoder context for easier access later. */
>  *input_codec_context = avctx;

The timebase of the packets sent to the decoder is given by
AVStream.time_base; this need not be the natural time base (i.e. the
inverse of the sample rate).

- Andreas
___
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".