Re: [FFmpeg-devel] [PATCH] avformat/mov: Add support for still image AVIF parsing

2022-04-19 Thread Gyan Doshi




On 2022-04-20 02:49 am, Paul B Mahol wrote:

On Tue, Apr 19, 2022 at 10:57 PM Vignesh Venkatasubramanian <
vigneshv-at-google@ffmpeg.org> wrote:


Add support for parsing AVIF still images. This patches supports
AVIF still images that have exactly 1 item (i.e.) no alpha channel.
Essentially, we will have to parse the "iloc" box and populate
the mov index.

With this patch, we can decode still AVIF images like so:
ffmpeg -i image.avif image.png

Partially fixes trac ticket #7621


LGTM


Will push tomorrow if no one else has.

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] avutil/hwcontext_d3d11va: enable D3D11_RESOURCE_MISC_SHARED for texture

2022-04-19 Thread Tong Wu
Add D3D11_RESOURCE_MISC_SHARED flag for texture to make it shareable.
This can fix the green frames issue when mapping from d3d11va to opencl.
Sample command line: ffmpeg.exe -hwaccel d3d11va -hwaccel_output_format
d3d11 -i input.264 -vf
"hwmap=derive_device=opencl,format=opencl,hwdownload,format=nv12" -c:v
libx264 output.mp4

Signed-off-by: Tong Wu 
---
 libavutil/hwcontext_d3d11va.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
index 8ab96bad25..c7227a13b4 100644
--- a/libavutil/hwcontext_d3d11va.c
+++ b/libavutil/hwcontext_d3d11va.c
@@ -199,7 +199,7 @@ static AVBufferRef *d3d11va_alloc_single(AVHWFramesContext 
*ctx)
 .ArraySize  = 1,
 .Usage  = D3D11_USAGE_DEFAULT,
 .BindFlags  = hwctx->BindFlags,
-.MiscFlags  = hwctx->MiscFlags,
+.MiscFlags  = hwctx->MiscFlags | D3D11_RESOURCE_MISC_SHARED,
 };
 
 hr = ID3D11Device_CreateTexture2D(device_hwctx->device, , NULL, 
);
@@ -263,7 +263,7 @@ static int d3d11va_frames_init(AVHWFramesContext *ctx)
 .ArraySize  = ctx->initial_pool_size,
 .Usage  = D3D11_USAGE_DEFAULT,
 .BindFlags  = hwctx->BindFlags,
-.MiscFlags  = hwctx->MiscFlags,
+.MiscFlags  = hwctx->MiscFlags | D3D11_RESOURCE_MISC_SHARED,
 };
 
 if (hwctx->texture) {
-- 
2.35.3.windows.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] avformat/mov: Add support for still image AVIF parsing

2022-04-19 Thread Paul B Mahol
On Tue, Apr 19, 2022 at 10:57 PM Vignesh Venkatasubramanian <
vigneshv-at-google@ffmpeg.org> wrote:

> Add support for parsing AVIF still images. This patches supports
> AVIF still images that have exactly 1 item (i.e.) no alpha channel.
> Essentially, we will have to parse the "iloc" box and populate
> the mov index.
>
> With this patch, we can decode still AVIF images like so:
> ffmpeg -i image.avif image.png
>
> Partially fixes trac ticket #7621
>

LGTM


>
> Signed-off-by: Vignesh Venkatasubramanian 
> ---
>  libavformat/isom.h |   1 +
>  libavformat/mov.c  | 137 +
>  2 files changed, 138 insertions(+)
>
> diff --git a/libavformat/isom.h b/libavformat/isom.h
> index 5caf42b15d..02d681e3ae 100644
> --- a/libavformat/isom.h
> +++ b/libavformat/isom.h
> @@ -315,6 +315,7 @@ typedef struct MOVContext {
>  int have_read_mfra_size;
>  uint32_t mfra_size;
>  uint32_t max_stts_delta;
> +int is_still_picture_avif;
>  } MOVContext;
>
>  int ff_mp4_read_descr_len(AVIOContext *pb);
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 6c847de164..e925690584 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -1136,6 +1136,7 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext
> *pb, MOVAtom atom)
>  c->isom = 1;
>  av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand:
> %.4s\n",(char *));
>  av_dict_set(>fc->metadata, "major_brand", type, 0);
> +c->is_still_picture_avif = !strncmp(type, "avif", 4);
>  minor_ver = avio_rb32(pb); /* minor version */
>  av_dict_set_int(>fc->metadata, "minor_version", minor_ver, 0);
>
> @@ -7430,6 +7431,141 @@ static int mov_read_SAND(MOVContext *c,
> AVIOContext *pb, MOVAtom atom)
>  return 0;
>  }
>
> +static int rb_size(AVIOContext *pb, uint64_t* value, int size)
> +{
> +if (size == 0)
> +*value = 0;
> +else if (size == 1)
> +*value = avio_r8(pb);
> +else if (size == 2)
> +*value = avio_rb16(pb);
> +else if (size == 4)
> +*value = avio_rb32(pb);
> +else if (size == 8)
> +*value = avio_rb64(pb);
> +else
> +return -1;
> +return size;
> +}
> +
> +static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
> +{
> +int version, offset_size, length_size, base_offset_size, index_size;
> +int item_count, extent_count;
> +uint64_t base_offset, extent_offset, extent_length;
> +uint8_t value;
> +AVStream *st;
> +MOVStreamContext *sc;
> +
> +if (!c->is_still_picture_avif) {
> +// * For non-avif, we simply ignore the iloc box.
> +// * For animated avif, we don't care about the iloc box as all
> the
> +//   necessary information can be found in the moov box.
> +return 0;
> +}
> +
> +if (c->fc->nb_streams) {
> +av_log(c->fc, AV_LOG_INFO, "Duplicate iloc box found\n");
> +return 0;
> +}
> +
> +st = avformat_new_stream(c->fc, NULL);
> +if (!st)
> +return AVERROR(ENOMEM);
> +st->id = c->fc->nb_streams;
> +sc = av_mallocz(sizeof(MOVStreamContext));
> +if (!sc)
> +return AVERROR(ENOMEM);
> +
> +st->priv_data = sc;
> +st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
> +st->codecpar->codec_id = AV_CODEC_ID_AV1;
> +sc->ffindex = st->index;
> +c->trak_index = st->index;
> +st->avg_frame_rate.num = st->avg_frame_rate.den = 1;
> +st->time_base.num = st->time_base.den = 1;
> +st->nb_frames = 1;
> +sc->time_scale = 1;
> +sc = st->priv_data;
> +sc->pb = c->fc->pb;
> +sc->pb_is_copied = 1;
> +
> +version = avio_r8(pb);
> +avio_rb24(pb);  // flags.
> +
> +value = avio_r8(pb);
> +offset_size = (value >> 4) & 0xF;
> +length_size = value & 0xF;
> +value = avio_r8(pb);
> +base_offset_size = (value >> 4) & 0xF;
> +index_size = !version ? 0 : (value & 0xF);
> +if (index_size)
> +return AVERROR_PATCHWELCOME;
> +item_count = (version < 2) ? avio_rb16(pb) : avio_rb32(pb);
> +if (item_count > 1) {
> +// For still AVIF images, we only support one item. Second item
> will
> +// generally be found for AVIF images with alpha channel. We don't
> +// support them as of now.
> +return AVERROR_PATCHWELCOME;
> +}
> +
> +// Populate the necessary fields used by mov_build_index.
> +sc->stsc_count = item_count;
> +sc->stsc_data = av_malloc_array(item_count, sizeof(*sc->stsc_data));
> +if (!sc->stsc_data)
> +return AVERROR(ENOMEM);
> +sc->stsc_data[0].first = 1;
> +sc->stsc_data[0].count = 1;
> +sc->stsc_data[0].id = 1;
> +sc->chunk_count = item_count;
> +sc->chunk_offsets =
> +av_malloc_array(item_count, sizeof(*sc->chunk_offsets));
> +if (!sc->chunk_offsets)
> +return AVERROR(ENOMEM);
> +sc->sample_count = item_count;
> +sc->sample_sizes =
> +av_malloc_array(item_count, sizeof(*sc->sample_sizes));

Re: [FFmpeg-devel] [PATCH 2/2] swscale/aarch64: add vscale specializations

2022-04-19 Thread Martin Storsjö

On Fri, 15 Apr 2022, Swinney, Jonathan wrote:


This commit adds new code paths for vscale when filterSize is 2, 4, or 8. By
using specialized code with unrolling to match the filterSize we can improve
performance.

| (seconds)   | c6g   |   |   |
| | - | - | - |
| filterSize  | 2 | 4 | 8 |
| original| 0.581 | 0.974 | 1.744 |
| optimized   | 0.399 | 0.569 | 1.052 |
| improvement | 31.1% | 41.6% | 39.7% |

Signed-off-by: Jonathan Swinney 
---
libswscale/aarch64/output.S  | 147 +--
libswscale/aarch64/swscale.c |  12 +++
2 files changed, 153 insertions(+), 6 deletions(-)

diff --git a/libswscale/aarch64/output.S b/libswscale/aarch64/output.S
index af71de6050..9c99c3bea9 100644
--- a/libswscale/aarch64/output.S
+++ b/libswscale/aarch64/output.S
@@ -21,12 +21,27 @@
#include "libavutil/aarch64/asm.S"

function ff_yuv2planeX_8_neon, export=1
+// x0 - const int16_t *filter,
+// x1 - int filterSize,
+// x2 - const int16_t **src,
+// x3 - uint8_t *dest,
+// x4 - int dstW,
+// x5 - const uint8_t *dither,
+// x6 - int offset
+
ld1 {v0.8B}, [x5]   // load 8x8-bit 
dither
cbz w6, 1f  // check if 
offsetting present
ext v0.8B, v0.8B, v0.8B, #3 // honor offsetting 
which can be 0 or 3 only
1:  uxtlv0.8H, v0.8B// extend dither to 
16-bit
ushll   v1.4S, v0.4H, #12   // extend dither to 
32-bit with left shift by 12 (part 1)
ushll2  v2.4S, v0.8H, #12   // extend dither to 
32-bit with left shift by 12 (part 2)
+cmp w1, #8  // if filterSize 
== 8, branch to specialized version
+b.eq5f
+cmp w1, #4  // if filterSize 
== 4, branch to specialized version
+b.eq7f
+cmp w1, #2  // if filterSize 
== 2, branch to specialized version
+b.eq9f
+
mov x7, #0  // i = 0
2:  mov v3.16B, v1.16B  // initialize 
accumulator part 1 with dithering value
mov v4.16B, v2.16B  // initialize 
accumulator part 2 with dithering value
@@ -34,16 +49,15 @@ function ff_yuv2planeX_8_neon, export=1
mov x9, x2  // srcp= src
mov x10, x0 // filterp = filter
3:  ldp x11, x12, [x9], #16 // get 2 pointers: 
src[j] and src[j+1]
+ld2r{v16.8H, v17.8H}, [x10], #4 // read 2x16-bit 
coeff X and Y at filter[j] and filter[j+1]
add x11, x11, x7, lsl #1// [j  ][i]
add x12, x12, x7, lsl #1// [j+1][i]
ld1 {v5.8H}, [x11]  // read 8x16-bit @ 
src[j  ][i + {0..7}]: A,B,C,D,E,F,G,H
ld1 {v6.8H}, [x12]  // read 8x16-bit @ 
src[j+1][i + {0..7}]: I,J,K,L,M,N,O,P
-ld1r{v7.8H}, [x10], #2  // read 1x16-bit 
coeff X at filter[j  ] and duplicate across lanes
-ld1r{v16.8H}, [x10], #2 // read 1x16-bit 
coeff Y at filter[j+1] and duplicate across lanes
-smlal   v3.4S, v5.4H, v7.4H // val0 += 
{A,B,C,D} * X
-smlal2  v4.4S, v5.8H, v7.8H // val1 += 
{E,F,G,H} * X
-smlal   v3.4S, v6.4H, v16.4H// val0 += 
{I,J,K,L} * Y
-smlal2  v4.4S, v6.8H, v16.8H// val1 += 
{M,N,O,P} * Y
+smlal   v3.4S, v5.4H, v16.4H// val0 += 
{A,B,C,D} * X
+smlal2  v4.4S, v5.8H, v16.8H// val1 += 
{E,F,G,H} * X
+smlal   v3.4S, v6.4H, v17.4H// val0 += 
{I,J,K,L} * Y
+smlal2  v4.4S, v6.8H, v17.8H// val1 += 
{M,N,O,P} * Y
subsw8, w8, #2  // tmpfilterSize -= 
2
b.gt3b  // loop until 
filterSize consumed

@@ -55,4 +69,125 @@ function ff_yuv2planeX_8_neon, export=1
add x7, x7, #8  // i += 8
b.gt2b  // loop until width 
consumed
ret
+
+5:  // fs=8
+ldp x5, x6, [x2]// load 2 
pointers: src[j  ] and src[j+1]
+ldp x7, x9, [x2, #16]   // load 2 
pointers: src[j+2] and src[j+3]
+ldp x10, x11, [x2, #32] // load 2 
pointers: src[j+4] and src[j+5]
+ldp  

[FFmpeg-devel] [PATCH] avformat/mov: Add support for still image AVIF parsing

2022-04-19 Thread Vignesh Venkatasubramanian
Add support for parsing AVIF still images. This patches supports
AVIF still images that have exactly 1 item (i.e.) no alpha channel.
Essentially, we will have to parse the "iloc" box and populate
the mov index.

With this patch, we can decode still AVIF images like so:
ffmpeg -i image.avif image.png

Partially fixes trac ticket #7621

Signed-off-by: Vignesh Venkatasubramanian 
---
 libavformat/isom.h |   1 +
 libavformat/mov.c  | 137 +
 2 files changed, 138 insertions(+)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index 5caf42b15d..02d681e3ae 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -315,6 +315,7 @@ typedef struct MOVContext {
 int have_read_mfra_size;
 uint32_t mfra_size;
 uint32_t max_stts_delta;
+int is_still_picture_avif;
 } MOVContext;
 
 int ff_mp4_read_descr_len(AVIOContext *pb);
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 6c847de164..e925690584 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1136,6 +1136,7 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 c->isom = 1;
 av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: %.4s\n",(char 
*));
 av_dict_set(>fc->metadata, "major_brand", type, 0);
+c->is_still_picture_avif = !strncmp(type, "avif", 4);
 minor_ver = avio_rb32(pb); /* minor version */
 av_dict_set_int(>fc->metadata, "minor_version", minor_ver, 0);
 
@@ -7430,6 +7431,141 @@ static int mov_read_SAND(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 return 0;
 }
 
+static int rb_size(AVIOContext *pb, uint64_t* value, int size)
+{
+if (size == 0)
+*value = 0;
+else if (size == 1)
+*value = avio_r8(pb);
+else if (size == 2)
+*value = avio_rb16(pb);
+else if (size == 4)
+*value = avio_rb32(pb);
+else if (size == 8)
+*value = avio_rb64(pb);
+else
+return -1;
+return size;
+}
+
+static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+{
+int version, offset_size, length_size, base_offset_size, index_size;
+int item_count, extent_count;
+uint64_t base_offset, extent_offset, extent_length;
+uint8_t value;
+AVStream *st;
+MOVStreamContext *sc;
+
+if (!c->is_still_picture_avif) {
+// * For non-avif, we simply ignore the iloc box.
+// * For animated avif, we don't care about the iloc box as all the
+//   necessary information can be found in the moov box.
+return 0;
+}
+
+if (c->fc->nb_streams) {
+av_log(c->fc, AV_LOG_INFO, "Duplicate iloc box found\n");
+return 0;
+}
+
+st = avformat_new_stream(c->fc, NULL);
+if (!st)
+return AVERROR(ENOMEM);
+st->id = c->fc->nb_streams;
+sc = av_mallocz(sizeof(MOVStreamContext));
+if (!sc)
+return AVERROR(ENOMEM);
+
+st->priv_data = sc;
+st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+st->codecpar->codec_id = AV_CODEC_ID_AV1;
+sc->ffindex = st->index;
+c->trak_index = st->index;
+st->avg_frame_rate.num = st->avg_frame_rate.den = 1;
+st->time_base.num = st->time_base.den = 1;
+st->nb_frames = 1;
+sc->time_scale = 1;
+sc = st->priv_data;
+sc->pb = c->fc->pb;
+sc->pb_is_copied = 1;
+
+version = avio_r8(pb);
+avio_rb24(pb);  // flags.
+
+value = avio_r8(pb);
+offset_size = (value >> 4) & 0xF;
+length_size = value & 0xF;
+value = avio_r8(pb);
+base_offset_size = (value >> 4) & 0xF;
+index_size = !version ? 0 : (value & 0xF);
+if (index_size)
+return AVERROR_PATCHWELCOME;
+item_count = (version < 2) ? avio_rb16(pb) : avio_rb32(pb);
+if (item_count > 1) {
+// For still AVIF images, we only support one item. Second item will
+// generally be found for AVIF images with alpha channel. We don't
+// support them as of now.
+return AVERROR_PATCHWELCOME;
+}
+
+// Populate the necessary fields used by mov_build_index.
+sc->stsc_count = item_count;
+sc->stsc_data = av_malloc_array(item_count, sizeof(*sc->stsc_data));
+if (!sc->stsc_data)
+return AVERROR(ENOMEM);
+sc->stsc_data[0].first = 1;
+sc->stsc_data[0].count = 1;
+sc->stsc_data[0].id = 1;
+sc->chunk_count = item_count;
+sc->chunk_offsets =
+av_malloc_array(item_count, sizeof(*sc->chunk_offsets));
+if (!sc->chunk_offsets)
+return AVERROR(ENOMEM);
+sc->sample_count = item_count;
+sc->sample_sizes =
+av_malloc_array(item_count, sizeof(*sc->sample_sizes));
+if (!sc->sample_sizes)
+return AVERROR(ENOMEM);
+sc->stts_count = item_count;
+sc->stts_data = av_malloc_array(item_count, sizeof(*sc->stts_data));
+if (!sc->stts_data)
+return AVERROR(ENOMEM);
+sc->stts_data[0].count = 1;
+// Not used for still images. But needed by mov_build_index.
+sc->stts_data[0].duration = 0;
+
+for (int i = 0; 

Re: [FFmpeg-devel] [PATCH] avformat/mov: Add support for still image AVIF parsing

2022-04-19 Thread Vignesh Venkatasubramanian
On Tue, Apr 19, 2022 at 1:18 PM Paul B Mahol  wrote:
>
>
>
> On Mon, Mar 28, 2022 at 9:12 PM Vignesh Venkatasubramanian 
>  wrote:
>>
>> Add support for parsing AVIF still images. This patches supports
>> AVIF still images that have exactly 1 item (i.e.) no alpha channel.
>> Essentially, we will have to parse the "iloc" box and populate
>> the mov index.
>>
>> With this patch, we can decode still AVIF images like so:
>> ffmpeg -i image.avif image.png
>>
>> Partially fixes trac ticket #7621
>>
>> Signed-off-by: Vignesh Venkatasubramanian 
>> ---
>>  libavformat/isom.h |   1 +
>>  libavformat/mov.c  | 148 +
>>  2 files changed, 149 insertions(+)
>>
>> diff --git a/libavformat/isom.h b/libavformat/isom.h
>> index 5caf42b15d..02d681e3ae 100644
>> --- a/libavformat/isom.h
>> +++ b/libavformat/isom.h
>> @@ -315,6 +315,7 @@ typedef struct MOVContext {
>>  int have_read_mfra_size;
>>  uint32_t mfra_size;
>>  uint32_t max_stts_delta;
>> +int is_still_picture_avif;
>>  } MOVContext;
>>
>>  int ff_mp4_read_descr_len(AVIOContext *pb);
>> diff --git a/libavformat/mov.c b/libavformat/mov.c
>> index 6c847de164..fb6d071b95 100644
>> --- a/libavformat/mov.c
>> +++ b/libavformat/mov.c
>> @@ -1136,6 +1136,7 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext 
>> *pb, MOVAtom atom)
>>  c->isom = 1;
>>  av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: %.4s\n",(char 
>> *));
>>  av_dict_set(>fc->metadata, "major_brand", type, 0);
>> +c->is_still_picture_avif = !strncmp(type, "avif", 4);
>>  minor_ver = avio_rb32(pb); /* minor version */
>>  av_dict_set_int(>fc->metadata, "minor_version", minor_ver, 0);
>>
>> @@ -7430,6 +7431,152 @@ static int mov_read_SAND(MOVContext *c, AVIOContext 
>> *pb, MOVAtom atom)
>>  return 0;
>>  }
>>
>> +static int rb_size(AVIOContext *pb, uint64_t* value, int size)
>> +{
>> +if (size == 0) {
>> +*value = 0;
>> +} else if (size == 1) {
>> +*value = avio_r8(pb);
>> +} else if (size == 2) {
>> +*value = avio_rb16(pb);
>> +} else if (size == 4) {
>> +*value = avio_rb32(pb);
>> +} else if (size == 8) {
>> +*value = avio_rb64(pb);
>> +} else {
>> +return -1;
>> +}
>> +return size;
>> +}
>> +
>> +static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
>> +{
>> +int version, offset_size, length_size, base_offset_size, index_size;
>> +int item_count, extent_count;
>> +uint64_t base_offset, extent_offset, extent_length;
>> +uint8_t value;
>> +AVStream *st;
>> +MOVStreamContext *sc;
>> +
>> +if (!c->is_still_picture_avif) {
>> +// * For non-avif, we simply ignore the iloc box.
>> +// * For animated avif, we don't care about the iloc box as all the
>> +//   necessary information can be found in the moov box.
>> +return 0;
>> +}
>> +
>> +if (c->fc->nb_streams) {
>> +av_log(c->fc, AV_LOG_INFO, "Duplicate iloc box found\n");
>> +return 0;
>> +}
>> +
>> +st = avformat_new_stream(c->fc, NULL);
>> +if (!st) {
>> +return AVERROR(ENOMEM);
>> +}
>
>
> Here  and everywhere else, remove excessive {/}, they are not needed for one 
> liners.
>

Done.

>> +st->id = c->fc->nb_streams;
>> +sc = av_mallocz(sizeof(MOVStreamContext));
>> +if (!sc) {
>> +return AVERROR(ENOMEM);
>> +}
>> +
>> +st->priv_data = sc;
>> +st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
>> +st->codecpar->codec_id = AV_CODEC_ID_AV1;
>> +sc->ffindex = st->index;
>> +c->trak_index = st->index;
>> +st->avg_frame_rate.num = st->avg_frame_rate.den = 1;
>> +st->time_base.num = st->time_base.den = 1;
>> +st->nb_frames = 1;
>> +sc->time_scale = 1;
>> +sc = st->priv_data;
>> +sc->pb = c->fc->pb;
>> +sc->pb_is_copied = 1;
>> +
>> +version = avio_r8(pb);
>> +avio_rb24(pb);  // flags.
>> +
>> +value = avio_r8(pb);
>> +offset_size = (value >> 4) & 0xF;
>> +length_size = value & 0xF;
>> +value = avio_r8(pb);
>> +base_offset_size = (value >> 4) & 0xF;
>> +index_size = !version ? 0 : (value & 0xF);
>> +if (index_size) {
>> +return AVERROR_PATCHWELCOME;
>> +}
>> +item_count = (version < 2) ? avio_rb16(pb) : avio_rb32(pb);
>> +if (item_count > 1) {
>> +// For still AVIF images, we only support one item. Second item will
>> +// generally be found for AVIF images with alpha channel. We don't
>> +// support them as of now.
>> +return AVERROR_PATCHWELCOME;
>> +}
>> +
>> +// Populate the necessary fields used by mov_build_index.
>> +sc->stsc_count = item_count;
>> +sc->stsc_data = av_malloc_array(item_count, sizeof(*sc->stsc_data));
>> +if (!sc->stsc_data) {
>> +return AVERROR(ENOMEM);
>> +}
>> +sc->stsc_data[0].first = 1;
>> +sc->stsc_data[0].count = 1;
>> +sc->stsc_data[0].id 

Re: [FFmpeg-devel] [PATCH] avcodec/jpeg2000:fast-fail if HTJ2K codeblocks are present

2022-04-19 Thread Pierre-Anthony Lemieux
FYI. This is the qualification task for the GSOC project at [1].

[1] 
https://trac.ffmpeg.org/wiki/SponsoringPrograms/GSoC/2022#AddsupportforPart15totheJPEG2000decoder

On Tue, Apr 19, 2022 at 1:17 AM caleb  wrote:
>
> ---
> This patch adds support for detecting Part 15 codeblocks to JPEG2000 
> specified in (Rec. ITU-T T.814 | ISO/IEC 15444-15).
>
> The decoder on detecting Part 15 codeblocks now fails gracefully with a 
> AVERROR_PATCHWELCOME return code
>
>  libavcodec/jpeg2000.h| 2 ++
>  libavcodec/jpeg2000dec.c | 9 +
>  2 files changed, 11 insertions(+)
>
> diff --git a/libavcodec/jpeg2000.h b/libavcodec/jpeg2000.h
> index d06313425e..e5ecb4cbf9 100644
> --- a/libavcodec/jpeg2000.h
> +++ b/libavcodec/jpeg2000.h
> @@ -110,6 +110,8 @@ enum Jpeg2000Quantsty { // quantization style
>  #define JPEG2000_CSTY_PREC  0x01 // Precincts defined in coding style
>  #define JPEG2000_CSTY_SOP   0x02 // SOP marker present
>  #define JPEG2000_CSTY_EPH   0x04 // EPH marker present
> +#define JPEG2000_CTSY_HTJ2K_F   0x40 // Only HT code-blocks (Rec. ITU-T 
> T.814 | ISO/IEC 15444-15) are present
> +#define JPEG2000_CTSY_HTJ2K_M   0xC0 // HT code blocks (Rec. ITU-T T.814 | 
> ISO/IEC 15444-15) can be present
>
>  // Progression orders
>  #define JPEG2000_PGOD_LRCP  0x00  // Layer-resolution 
> level-component-position progression
> diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> index 92966b11f5..ef4a653afe 100644
> --- a/libavcodec/jpeg2000dec.c
> +++ b/libavcodec/jpeg2000dec.c
> @@ -521,6 +521,15 @@ static int get_cox(Jpeg2000DecoderContext *s, 
> Jpeg2000CodingStyle *c)
>
>  c->cblk_style = bytestream2_get_byteu(>g);
>  if (c->cblk_style != 0) { // cblk style
> +if (c->cblk_style & JPEG2000_CTSY_HTJ2K_M || c->cblk_style & 
> JPEG2000_CTSY_HTJ2K_F) {
> +/*
> + * HT code-blocks (Rec. ITU-T T.814 | ISO/IEC 15444-15) 
> bit-stream
> + * Not yet supported in ffmpeg, cannot continue.
> + */
> +av_log(s->avctx, AV_LOG_FATAL, "Support for High throughput JPEG 
> 2000 is not yet available\n");
> +return AVERROR_PATCHWELCOME;
> +}
> +
>  av_log(s->avctx, AV_LOG_WARNING, "extra cblk styles %X\n", 
> c->cblk_style);
>  if (c->cblk_style & JPEG2000_CBLK_BYPASS)
>  av_log(s->avctx, AV_LOG_WARNING, "Selective arithmetic coding 
> bypass\n");
> --
> 2.34.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 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 1/1] librtmp: use AVBPrint instead of char *

2022-04-19 Thread Martin Storsjö

On Tue, 19 Apr 2022, Marton Balint wrote:




On Sat, 16 Apr 2022, Martin Storsjö wrote:


On Fri, 15 Apr 2022, Tristan Matthews wrote:

 This avoids having to do one pass to calculate the full length to 

allocate

 followed by a second pass to actually append values.
 ---
 libavformat/librtmp.c | 124 +++---
 1 file changed, 33 insertions(+), 91 deletions(-)

 diff --git a/libavformat/librtmp.c b/libavformat/librtmp.c
 index 43013e46e0..b7e9fc81cf 100644
 --- a/libavformat/librtmp.c
 +++ b/libavformat/librtmp.c
 @@ -25,6 +25,7 @@
  */

 #include "libavutil/avstring.h"
 +#include "libavutil/bprint.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/opt.h"
 #include "avformat.h"
 @@ -38,6 +39,7 @@

 typedef struct LibRTMPContext {
 const AVClass *class;
 +AVBPrint filename;
 RTMP rtmp;
 char *app;
 char *conn;
 @@ -50,7 +52,6 @@ typedef struct LibRTMPContext {
 char *pageurl;
 char *client_buffer_time;
 int live;
 -char *temp_filename;
 int buffer_size;
 } LibRTMPContext;


This looks ok to me.

(I guess it also could be considered viable to not store the AVBprint in 
the 
context but detach an allocated string instead; that would decrease the 
persistent allocation size a little, at the cost of some more copying, but 
the difference is probably negligible, so this probably is sensible as is.)


Agreed.



Let's still wait for Marton's review too.


LGTM as well. Thanks.


Pushed now then.

// 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] avformat/mov: Add support for still image AVIF parsing

2022-04-19 Thread Paul B Mahol
On Mon, Mar 28, 2022 at 9:12 PM Vignesh Venkatasubramanian <
vigneshv-at-google@ffmpeg.org> wrote:

> Add support for parsing AVIF still images. This patches supports
> AVIF still images that have exactly 1 item (i.e.) no alpha channel.
> Essentially, we will have to parse the "iloc" box and populate
> the mov index.
>
> With this patch, we can decode still AVIF images like so:
> ffmpeg -i image.avif image.png
>
> Partially fixes trac ticket #7621
>
> Signed-off-by: Vignesh Venkatasubramanian 
> ---
>  libavformat/isom.h |   1 +
>  libavformat/mov.c  | 148 +
>  2 files changed, 149 insertions(+)
>
> diff --git a/libavformat/isom.h b/libavformat/isom.h
> index 5caf42b15d..02d681e3ae 100644
> --- a/libavformat/isom.h
> +++ b/libavformat/isom.h
> @@ -315,6 +315,7 @@ typedef struct MOVContext {
>  int have_read_mfra_size;
>  uint32_t mfra_size;
>  uint32_t max_stts_delta;
> +int is_still_picture_avif;
>  } MOVContext;
>
>  int ff_mp4_read_descr_len(AVIOContext *pb);
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 6c847de164..fb6d071b95 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -1136,6 +1136,7 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext
> *pb, MOVAtom atom)
>  c->isom = 1;
>  av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand:
> %.4s\n",(char *));
>  av_dict_set(>fc->metadata, "major_brand", type, 0);
> +c->is_still_picture_avif = !strncmp(type, "avif", 4);
>  minor_ver = avio_rb32(pb); /* minor version */
>  av_dict_set_int(>fc->metadata, "minor_version", minor_ver, 0);
>
> @@ -7430,6 +7431,152 @@ static int mov_read_SAND(MOVContext *c,
> AVIOContext *pb, MOVAtom atom)
>  return 0;
>  }
>
> +static int rb_size(AVIOContext *pb, uint64_t* value, int size)
> +{
> +if (size == 0) {
> +*value = 0;
> +} else if (size == 1) {
> +*value = avio_r8(pb);
> +} else if (size == 2) {
> +*value = avio_rb16(pb);
> +} else if (size == 4) {
> +*value = avio_rb32(pb);
> +} else if (size == 8) {
> +*value = avio_rb64(pb);
> +} else {
> +return -1;
> +}
> +return size;
> +}
> +
> +static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
> +{
> +int version, offset_size, length_size, base_offset_size, index_size;
> +int item_count, extent_count;
> +uint64_t base_offset, extent_offset, extent_length;
> +uint8_t value;
> +AVStream *st;
> +MOVStreamContext *sc;
> +
> +if (!c->is_still_picture_avif) {
> +// * For non-avif, we simply ignore the iloc box.
> +// * For animated avif, we don't care about the iloc box as all
> the
> +//   necessary information can be found in the moov box.
> +return 0;
> +}
> +
> +if (c->fc->nb_streams) {
> +av_log(c->fc, AV_LOG_INFO, "Duplicate iloc box found\n");
> +return 0;
> +}
> +
> +st = avformat_new_stream(c->fc, NULL);
> +if (!st) {
> +return AVERROR(ENOMEM);
> +}
>

Here  and everywhere else, remove excessive {/}, they are not needed for
one liners.

+st->id = c->fc->nb_streams;
> +sc = av_mallocz(sizeof(MOVStreamContext));
> +if (!sc) {
> +return AVERROR(ENOMEM);
> +}
> +
> +st->priv_data = sc;
> +st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
> +st->codecpar->codec_id = AV_CODEC_ID_AV1;
> +sc->ffindex = st->index;
> +c->trak_index = st->index;
> +st->avg_frame_rate.num = st->avg_frame_rate.den = 1;
> +st->time_base.num = st->time_base.den = 1;
> +st->nb_frames = 1;
> +sc->time_scale = 1;
> +sc = st->priv_data;
> +sc->pb = c->fc->pb;
> +sc->pb_is_copied = 1;
> +
> +version = avio_r8(pb);
> +avio_rb24(pb);  // flags.
> +
> +value = avio_r8(pb);
> +offset_size = (value >> 4) & 0xF;
> +length_size = value & 0xF;
> +value = avio_r8(pb);
> +base_offset_size = (value >> 4) & 0xF;
> +index_size = !version ? 0 : (value & 0xF);
> +if (index_size) {
> +return AVERROR_PATCHWELCOME;
> +}
> +item_count = (version < 2) ? avio_rb16(pb) : avio_rb32(pb);
> +if (item_count > 1) {
> +// For still AVIF images, we only support one item. Second item
> will
> +// generally be found for AVIF images with alpha channel. We don't
> +// support them as of now.
> +return AVERROR_PATCHWELCOME;
> +}
> +
> +// Populate the necessary fields used by mov_build_index.
> +sc->stsc_count = item_count;
> +sc->stsc_data = av_malloc_array(item_count, sizeof(*sc->stsc_data));
> +if (!sc->stsc_data) {
> +return AVERROR(ENOMEM);
> +}
> +sc->stsc_data[0].first = 1;
> +sc->stsc_data[0].count = 1;
> +sc->stsc_data[0].id = 1;
> +sc->chunk_count = item_count;
> +sc->chunk_offsets =
> +av_malloc_array(item_count, sizeof(*sc->chunk_offsets));
> +if (!sc->chunk_offsets) {
> +

Re: [FFmpeg-devel] [PATCH v2] avformat/mpegts: set data broadcast streams as such

2022-04-19 Thread Marton Balint



On Tue, 19 Apr 2022, Jan Ekström wrote:


On Tue, Apr 19, 2022 at 1:13 PM Jan Ekström  wrote:


On Tue, Apr 19, 2022 at 3:00 AM Marton Balint  wrote:
>
>
>
> On Thu, 14 Apr 2022, Jan Ekström wrote:
>
> > On Mon, Apr 11, 2022 at 1:50 PM Jan Ekström  wrote:
> >>
> >> From: Jan Ekström 
> >>
> >> Additionally, they should not be probed, as this is essentially
> >> various types of binary data.
> >>
> >> Signed-off-by: Jan Ekström 
> >> ---
> >
> > Ping.
> >
> > Basically this checks if we have an unknown stream with a private
> > stream type still at the end of the per-stream loop in PMT parsing,
> > and then cancels the stop of parsing that usually occurs as a PMT is
> > hit. Instead the logic will continue parsing further. When an SDT is
> > then found and a PMT for that program has already been received, it
> > will then stop header reading at that point.
>
> But why does it matter when the initial parsing is stopped? I mean it
> stops at the first PMT right now, nobody expects it to find all the
> programs and all the streams or all the stream codecs/parameters.
>
> I am saying, that ideally, the ts->stop_parse magic should not be needed
> to be changed to fix your issue and when an SDT is detected with the
> broadcast descriptor that should stop any existing data stream parsing. Do
> you know why it does not work like that?
>

If the codec is unknown after header parsing, the general parsing
logic is utilized to probe which codec is possibly in that unknown
stream, and thus more data is read from that stream, which can cause
further delays.

If the codec is known as data, it leads to no such result.

Basically, the idea is to figure out whether a stream is a data stream
or not during header parsing, if possible.



Just double-checked and the difference is whether
max_stream_analyze_duration gets utilized in
libavformat/demux.c::avformat_find_stream_info .

If a stream is marked as unknown, it will get checked for longer. If
it is marked as a known "codec" it gets through quicker.


The part of the patch which parses the SDT and sets the codec is fine. 
But the fact that you have to set the codec during mpegts_read_header 
to make it stop parsing definitely looks like some bug in some code 
somewhere. It should be enough to set the codec sometime later in 
mpegts_read_packet() (which is called during avformat_find_stream_info())


Or to make it even more strange: comment out handle_packets() in 
mpegts_read_header. And it will work just fine. So if nothing is parsed 
in mpegts_read_header then it works. If something is parsed, then it does 
not. Kind of unexpected...


Regards,
Marton



There is a longer sample from an example stream under:
https://megumin.fushizen.eu/samples/2022-02-04-radio_with_data_stream/
with the files
13699753.{ts,aux}

You can then
`multicat -U ./13699753.ts "239.255.1.1:6001@127.0.0.1/ifaddr=127.0.0.1"`
and that should bind & connect and start pushing out UDP multicast via
localhost, using the aux file as timing.

Then you can with f.ex. ffprobe do
`/usr/bin/time -v ffprobe -v verbose -localaddr 127.0.0.1
udp://239.255.1.1:6001`
and compare the probe times with and without SDT being parsed during
the header read :) .

Jan
___
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 v2] avcodec/libaomenc: Add unmet target level warning

2022-04-19 Thread Bohan Li
When target levels are set, this patch checks whether they are
satisfied by libaom. If not, a warning is shown. Otherwise the output
levels are also logged.

This patch applies basically the same approach used for libvpx.

Signed-off-by: Bohan Li 
---
 libavcodec/libaomenc.c | 64 ++
 1 file changed, 64 insertions(+)

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 054903e6e2..77be56fa51 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -198,6 +198,12 @@ static const char *const ctlidstr[] = {
 [AV1E_SET_ENABLE_SMOOTH_INTERINTRA] = "AV1E_SET_ENABLE_SMOOTH_INTERINTRA",
 [AV1E_SET_ENABLE_REF_FRAME_MVS] = "AV1E_SET_ENABLE_REF_FRAME_MVS",
 #endif
+#ifdef AOM_CTRL_AV1E_GET_SEQ_LEVEL_IDX
+[AV1E_GET_SEQ_LEVEL_IDX]= "AV1E_GET_SEQ_LEVEL_IDX",
+#endif
+#ifdef AOM_CTRL_AV1E_GET_TARGET_SEQ_LEVEL_IDX
+[AV1E_GET_TARGET_SEQ_LEVEL_IDX] = "AV1E_GET_TARGET_SEQ_LEVEL_IDX",
+#endif
 };
 
 static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc)
@@ -323,10 +329,68 @@ static av_cold int codecctl_int(AVCodecContext *avctx,
 return 0;
 }
 
+#if defined(AOM_CTRL_AV1E_GET_SEQ_LEVEL_IDX) && \
+defined(AOM_CTRL_AV1E_GET_TARGET_SEQ_LEVEL_IDX)
+static av_cold int codecctl_intp(AVCodecContext *avctx,
+#ifdef UENUM1BYTE
+ aome_enc_control_id id,
+#else
+ enum aome_enc_control_id id,
+#endif
+ int* ptr)
+{
+AOMContext *ctx = avctx->priv_data;
+char buf[80];
+int width = -30;
+int res;
+
+snprintf(buf, sizeof(buf), "%s:", ctlidstr[id]);
+av_log(avctx, AV_LOG_DEBUG, "  %*s%d\n", width, buf, *ptr);
+
+res = aom_codec_control(>encoder, id, ptr);
+if (res != AOM_CODEC_OK) {
+snprintf(buf, sizeof(buf), "Failed to set %s codec control",
+ ctlidstr[id]);
+log_encoder_error(avctx, buf);
+return AVERROR(EINVAL);
+}
+
+return 0;
+}
+#endif
+
 static av_cold int aom_free(AVCodecContext *avctx)
 {
 AOMContext *ctx = avctx->priv_data;
 
+#if defined(AOM_CTRL_AV1E_GET_SEQ_LEVEL_IDX) && \
+defined(AOM_CTRL_AV1E_GET_TARGET_SEQ_LEVEL_IDX)
+if (!(avctx->flags & AV_CODEC_FLAG_PASS1)) {
+int levels[32] = { 0 };
+int target_levels[32] = { 0 };
+
+if (!codecctl_intp(avctx, AV1E_GET_SEQ_LEVEL_IDX, levels) &&
+!codecctl_intp(avctx, AV1E_GET_TARGET_SEQ_LEVEL_IDX,
+   target_levels)) {
+for (int i = 0; i < 32; i++) {
+if (levels[i] > target_levels[i]) {
+// Warn when the target level was not met
+av_log(avctx, AV_LOG_WARNING,
+   "Could not encode to target level %d.%d for "
+   "operating point %d. The output level is %d.%d.\n",
+   2 + (target_levels[i] >> 2), target_levels[i] & 3,
+   i, 2 + (levels[i] >> 2), levels[i] & 3);
+} else if (target_levels[i] < 31) {
+// Log the encoded level if a target level was given
+av_log(avctx, AV_LOG_INFO,
+   "Output level for operating point %d is %d.%d.\n",
+   i, 2 + (levels[i] >> 2), levels[i] & 3);
+}
+}
+}
+}
+#endif
+
 aom_codec_destroy(>encoder);
 av_freep(>twopass_stats.buf);
 av_freep(>stats_out);
-- 
2.36.0.rc0.470.gd361397f0d-goog

___
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] avcodec/libaomenc: Add unmet target level warning

2022-04-19 Thread Bohan Li
When target levels are set, this patch checks whether they are
satisfied by libaom. If not, a warning is shown. Otherwise the output
levels are also logged.

This patch applies basically the same approach used for libvpx.

Signed-off-by: Bohan Li 
---
 libavcodec/libaomenc.c | 64 ++
 1 file changed, 64 insertions(+)

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 054903e6e2..402bcb5198 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -198,6 +198,12 @@ static const char *const ctlidstr[] = {
 [AV1E_SET_ENABLE_SMOOTH_INTERINTRA] = "AV1E_SET_ENABLE_SMOOTH_INTERINTRA",
 [AV1E_SET_ENABLE_REF_FRAME_MVS] = "AV1E_SET_ENABLE_REF_FRAME_MVS",
 #endif
+#ifdef AOM_CTRL_AV1E_GET_SEQ_LEVEL_IDX
+[AV1E_GET_SEQ_LEVEL_IDX]= "AV1E_GET_SEQ_LEVEL_IDX",
+#endif
+#ifdef AOM_CTRL_AV1E_GET_TARGET_SEQ_LEVEL_IDX
+[AV1E_GET_TARGET_SEQ_LEVEL_IDX] = "AV1E_GET_TARGET_SEQ_LEVEL_IDX",
+#endif
 };
 
 static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc)
@@ -323,10 +329,68 @@ static av_cold int codecctl_int(AVCodecContext *avctx,
 return 0;
 }
 
+#if defined(AOM_CTRL_AV1E_GET_SEQ_LEVEL_IDX) && \
+defined(AOM_CTRL_AV1E_GET_TARGET_SEQ_LEVEL_IDX)
+static av_cold int codecctl_intp(AVCodecContext *avctx,
+#ifdef UENUM1BYTE
+ aome_enc_control_id id,
+#else
+ enum aome_enc_control_id id,
+#endif
+ int* ptr)
+{
+AOMContext *ctx = avctx->priv_data;
+char buf[80];
+int width = -30;
+int res;
+
+snprintf(buf, sizeof(buf), "%s:", ctlidstr[id]);
+av_log(avctx, AV_LOG_DEBUG, "  %*s%d\n", width, buf, *ptr);
+
+res = aom_codec_control(>encoder, id, ptr);
+if (res != AOM_CODEC_OK) {
+snprintf(buf, sizeof(buf), "Failed to set %s codec control",
+ ctlidstr[id]);
+log_encoder_error(avctx, buf);
+return AVERROR(EINVAL);
+}
+
+return 0;
+}
+#endif
+
 static av_cold int aom_free(AVCodecContext *avctx)
 {
 AOMContext *ctx = avctx->priv_data;
 
+#if defined(AOM_CTRL_AV1E_GET_SEQ_LEVEL_IDX) && \
+defined(AOM_CTRL_AV1E_GET_TARGET_SEQ_LEVEL_IDX)
+if (!(avctx->flags & AV_CODEC_FLAG_PASS1)) {
+int levels[32] = { 0 };
+int target_levels[32] = { 0 };
+
+if (!codecctl_intp(avctx, AV1E_GET_SEQ_LEVEL_IDX, levels) &&
+!codecctl_intp(avctx, AV1E_GET_TARGET_SEQ_LEVEL_IDX,
+   target_levels)) {
+for (int i = 0; i < 32; i++) {
+if (levels[i] > target_levels[i]) {
+// Warn when the target level was not met
+av_log(avctx, AV_LOG_WARNING,
+   "Could not encode to target level %d.%d for "
+   "operating point %d. The output level is %d.%d.",
+   2 + (target_levels[i] >> 2), target_levels[i] & 3,
+   i, 2 + (levels[i] >> 2), levels[i] & 3);
+} else if (target_levels[i] < 31) {
+// Log the encoded level if a target level was given
+av_log(avctx, AV_LOG_INFO,
+   "Output level for operating point %d is %d.%d.",
+   i, 2 + (levels[i] >> 2), levels[i] & 3);
+}
+}
+}
+}
+#endif
+
 aom_codec_destroy(>encoder);
 av_freep(>twopass_stats.buf);
 av_freep(>stats_out);
-- 
2.36.0.rc0.470.gd361397f0d-goog

___
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 1/2] avfilter: add colormap video filter

2022-04-19 Thread Paul B Mahol
Gonna apply soon.
___
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 v2] avformat/mpegts: set data broadcast streams as such

2022-04-19 Thread Jan Ekström
On Tue, Apr 19, 2022 at 1:13 PM Jan Ekström  wrote:
>
> On Tue, Apr 19, 2022 at 3:00 AM Marton Balint  wrote:
> >
> >
> >
> > On Thu, 14 Apr 2022, Jan Ekström wrote:
> >
> > > On Mon, Apr 11, 2022 at 1:50 PM Jan Ekström  wrote:
> > >>
> > >> From: Jan Ekström 
> > >>
> > >> Additionally, they should not be probed, as this is essentially
> > >> various types of binary data.
> > >>
> > >> Signed-off-by: Jan Ekström 
> > >> ---
> > >
> > > Ping.
> > >
> > > Basically this checks if we have an unknown stream with a private
> > > stream type still at the end of the per-stream loop in PMT parsing,
> > > and then cancels the stop of parsing that usually occurs as a PMT is
> > > hit. Instead the logic will continue parsing further. When an SDT is
> > > then found and a PMT for that program has already been received, it
> > > will then stop header reading at that point.
> >
> > But why does it matter when the initial parsing is stopped? I mean it
> > stops at the first PMT right now, nobody expects it to find all the
> > programs and all the streams or all the stream codecs/parameters.
> >
> > I am saying, that ideally, the ts->stop_parse magic should not be needed
> > to be changed to fix your issue and when an SDT is detected with the
> > broadcast descriptor that should stop any existing data stream parsing. Do
> > you know why it does not work like that?
> >
>
> If the codec is unknown after header parsing, the general parsing
> logic is utilized to probe which codec is possibly in that unknown
> stream, and thus more data is read from that stream, which can cause
> further delays.
>
> If the codec is known as data, it leads to no such result.
>
> Basically, the idea is to figure out whether a stream is a data stream
> or not during header parsing, if possible.
>

Just double-checked and the difference is whether
max_stream_analyze_duration gets utilized in
libavformat/demux.c::avformat_find_stream_info .

If a stream is marked as unknown, it will get checked for longer. If
it is marked as a known "codec" it gets through quicker.

You can check an example locally with multicat:

There is a longer sample from an example stream under:
https://megumin.fushizen.eu/samples/2022-02-04-radio_with_data_stream/
with the files
13699753.{ts,aux}

You can then
`multicat -U ./13699753.ts "239.255.1.1:6001@127.0.0.1/ifaddr=127.0.0.1"`
and that should bind & connect and start pushing out UDP multicast via
localhost, using the aux file as timing.

Then you can with f.ex. ffprobe do
`/usr/bin/time -v ffprobe -v verbose -localaddr 127.0.0.1
udp://239.255.1.1:6001`
and compare the probe times with and without SDT being parsed during
the header read :) .

Jan
___
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-19 Thread Tristan Matthews
On Wed, Apr 6, 2022 at 10:04 AM Zhao Zhili  wrote:

>
> > 在 2022年4月6日,下午9:49,Yubo Xie  写道:
> >
> > Yes, I've removed it already.
>
> Sorry I missed that. LGTM.
>

Nice catch, I guess this bug only impacted using TCP as the
media-transport? I'm guessing I only tested UDP at the time.

Best,
Tristan
___
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 v2 1/5] lavfi: generalize colorspace coefficent helpers

2022-04-19 Thread Niklas Haas
Merging this series at the end of the week if I don't get any additional
feedback.
___
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 5/5] lavfi: add vf_iccdetect for parsing ICC profiles

2022-04-19 Thread Niklas Haas
From: Niklas Haas 

This filter is designed to parse embedded ICC profiles and attempt
extracting colorspace tags from them, updating the AVFrame metadata
accordingly.

This is intentionally made a separate filter, rather than being part of
libavcodec itself, so that it's an opt-in behavior for the time being.
This also gives the user more flexibility to e.g. first attach an ICC
profile and then also set the colorspace tags from it.

This makes #9673 possible, though not automatic.

Signed-off-by: Niklas Haas 
---
 configure  |   1 +
 doc/filters.texi   |  14 
 libavfilter/Makefile   |   1 +
 libavfilter/allfilters.c   |   1 +
 libavfilter/vf_iccdetect.c | 142 +
 5 files changed, 159 insertions(+)
 create mode 100644 libavfilter/vf_iccdetect.c

diff --git a/configure b/configure
index 44f8ff738e..612c894f1b 100755
--- a/configure
+++ b/configure
@@ -3661,6 +3661,7 @@ gblur_vulkan_filter_deps="vulkan spirv_compiler"
 hflip_vulkan_filter_deps="vulkan spirv_compiler"
 histeq_filter_deps="gpl"
 hqdn3d_filter_deps="gpl"
+iccdetect_filter_deps="lcms2"
 iccgen_filter_deps="lcms2"
 interlace_filter_deps="gpl"
 kerndeint_filter_deps="gpl"
diff --git a/doc/filters.texi b/doc/filters.texi
index f29845890e..85b1586486 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -14342,6 +14342,20 @@ By default value is 0.
 
 The @code{hysteresis} filter also supports the @ref{framesync} options.
 
+@section iccdetect
+
+Detect the colorspace  from an embedded ICC profile (if present), and update
+the frame's tags accordingly.
+
+This filter accepts the following options:
+
+@table @option
+@item force
+If true, the frame's existing colorspace tags will always be overridden by
+values detected from an ICC profile. Otherwise, they will only be assigned if
+they contain @code{unknown}. Enabled by default.
+@end table
+
 @section iccgen
 
 Generate ICC profiles and attach them to frames.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 1f2b03fa9c..2c131e6af5 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -321,6 +321,7 @@ OBJS-$(CONFIG_HWMAP_FILTER)  += vf_hwmap.o
 OBJS-$(CONFIG_HWUPLOAD_CUDA_FILTER)  += vf_hwupload_cuda.o
 OBJS-$(CONFIG_HWUPLOAD_FILTER)   += vf_hwupload.o
 OBJS-$(CONFIG_HYSTERESIS_FILTER) += vf_hysteresis.o framesync.o
+OBJS-$(CONFIG_ICCDETECT_FILTER)  += vf_iccdetect.o fflcms2.o 
colorspace.o
 OBJS-$(CONFIG_ICCGEN_FILTER) += vf_iccgen.o fflcms2.o 
colorspace.o
 OBJS-$(CONFIG_IDENTITY_FILTER)   += vf_identity.o
 OBJS-$(CONFIG_IDET_FILTER)   += vf_idet.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 212615019d..ebe12520b5 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -304,6 +304,7 @@ extern const AVFilter ff_vf_hwmap;
 extern const AVFilter ff_vf_hwupload;
 extern const AVFilter ff_vf_hwupload_cuda;
 extern const AVFilter ff_vf_hysteresis;
+extern const AVFilter ff_vf_iccdetect;
 extern const AVFilter ff_vf_iccgen;
 extern const AVFilter ff_vf_identity;
 extern const AVFilter ff_vf_idet;
diff --git a/libavfilter/vf_iccdetect.c b/libavfilter/vf_iccdetect.c
new file mode 100644
index 00..fb7871f035
--- /dev/null
+++ b/libavfilter/vf_iccdetect.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2022 Niklas Haas
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * filter for generating ICC profiles
+ */
+
+#include 
+
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+
+#include "avfilter.h"
+#include "fflcms2.h"
+#include "internal.h"
+
+typedef struct IccDetectContext {
+const AVClass *class;
+FFIccContext icc;
+int force;
+/* (cached) detected ICC profile values */
+AVBufferRef *profile;
+enum AVColorPrimaries profile_prim;
+enum AVColorTransferCharacteristic profile_trc;
+} IccDetectContext;
+
+#define OFFSET(x) offsetof(IccDetectContext, x)
+#define VF AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
+
+static const AVOption iccdetect_options[] = {
+{ "force", "overwrite existing tags", OFFSET(force), AV_OPT_TYPE_BOOL, 
{.i64=1}, 0, 1, VF },
+{ NULL }
+};
+

[FFmpeg-devel] [PATCH v2 4/5] lavfi: add vf_iccgen for generating ICC profiles

2022-04-19 Thread Niklas Haas
From: Niklas Haas 

This filter is designed to specifically cover the task of generating ICC
profiles (and attaching them to output frames) on demand. Other tasks,
such as ICC profile loading/stripping, or ICC profile application, are
better left to separate filters (or included into e.g. vf_setparams).

Signed-off-by: Niklas Haas 
---
 configure|   1 +
 doc/filters.texi |  21 +
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/vf_iccgen.c  | 181 +++
 5 files changed, 205 insertions(+)
 create mode 100644 libavfilter/vf_iccgen.c

diff --git a/configure b/configure
index c894efa600..44f8ff738e 100755
--- a/configure
+++ b/configure
@@ -3661,6 +3661,7 @@ gblur_vulkan_filter_deps="vulkan spirv_compiler"
 hflip_vulkan_filter_deps="vulkan spirv_compiler"
 histeq_filter_deps="gpl"
 hqdn3d_filter_deps="gpl"
+iccgen_filter_deps="lcms2"
 interlace_filter_deps="gpl"
 kerndeint_filter_deps="gpl"
 ladspa_filter_deps="ladspa libdl"
diff --git a/doc/filters.texi b/doc/filters.texi
index a161754233..f29845890e 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -14342,6 +14342,27 @@ By default value is 0.
 
 The @code{hysteresis} filter also supports the @ref{framesync} options.
 
+@section iccgen
+
+Generate ICC profiles and attach them to frames.
+
+This filter accepts the following options:
+
+@table @option
+@item color_primaries
+@item color_trc
+Configure the colorspace that the ICC profile will be generated for. The
+default value of @code{auto} infers the value from the input frame's metadata,
+defaulting to BT.709/sRGB as appropriate.
+
+See the @ref{setparams} filter for a list of possible values, but note that
+@code{unknown} are not valid values for this filter.
+
+@item force
+If true, an ICC profile will be generated even if it would overwrite an
+already existing ICC profile. Disabled by default.
+@end table
+
 @section identity
 
 Obtain the identity score between two input videos.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index b870ae2697..1f2b03fa9c 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -321,6 +321,7 @@ OBJS-$(CONFIG_HWMAP_FILTER)  += vf_hwmap.o
 OBJS-$(CONFIG_HWUPLOAD_CUDA_FILTER)  += vf_hwupload_cuda.o
 OBJS-$(CONFIG_HWUPLOAD_FILTER)   += vf_hwupload.o
 OBJS-$(CONFIG_HYSTERESIS_FILTER) += vf_hysteresis.o framesync.o
+OBJS-$(CONFIG_ICCGEN_FILTER) += vf_iccgen.o fflcms2.o 
colorspace.o
 OBJS-$(CONFIG_IDENTITY_FILTER)   += vf_identity.o
 OBJS-$(CONFIG_IDET_FILTER)   += vf_idet.o
 OBJS-$(CONFIG_IL_FILTER) += vf_il.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 366c5f4e7f..212615019d 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -304,6 +304,7 @@ extern const AVFilter ff_vf_hwmap;
 extern const AVFilter ff_vf_hwupload;
 extern const AVFilter ff_vf_hwupload_cuda;
 extern const AVFilter ff_vf_hysteresis;
+extern const AVFilter ff_vf_iccgen;
 extern const AVFilter ff_vf_identity;
 extern const AVFilter ff_vf_idet;
 extern const AVFilter ff_vf_il;
diff --git a/libavfilter/vf_iccgen.c b/libavfilter/vf_iccgen.c
new file mode 100644
index 00..67d02f5bc2
--- /dev/null
+++ b/libavfilter/vf_iccgen.c
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2022 Niklas Haas
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * filter for generating ICC profiles
+ */
+
+#include 
+
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+
+#include "avfilter.h"
+#include "fflcms2.h"
+#include "internal.h"
+
+typedef struct IccGenContext {
+const AVClass *class;
+FFIccContext icc;
+/* options */
+int color_prim;
+int color_trc;
+int force;
+/* (cached) generated ICC profile */
+cmsHPROFILE profile;
+int profile_prim;
+int profile_trc;
+} IccGenContext;
+
+#define OFFSET(x) offsetof(IccGenContext, x)
+#define VF AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
+
+static const AVOption iccgen_options[] = {
+{"color_primaries", "select color primaries", OFFSET(color_prim), 
AV_OPT_TYPE_INT, {.i64=0}, 0, AVCOL_PRI_NB-1, VF, "color_primaries"},
+

[FFmpeg-devel] [PATCH v2 3/5] lavfi: add ICC profile support via lcms2

2022-04-19 Thread Niklas Haas
From: Niklas Haas 

This introduces an optional dependency on lcms2 into FFmpeg. lcms2 is a
widely used library for ICC profile handling, which apart from being
used in almost all major image processing programs and video players,
has also been deployed in browsers. As such, it's both widely available
and well-tested.

Add a few helpers to cover our major use cases. This commit merely
introduces the helpers (and configure check), even though nothing uses
them yet.

It's worth pointing out that the reason the cmsToneCurves for each
AVCOL_TRC are cached inside the context, is because constructing a
cmsToneCurve requires evaluating the curve at 4096 (by default) grid
points and constructing a LUT. So, we ideally only want to do this once
per curve. This matters for e.g. ff_icc_profile_detect_transfer, which
essentially compares a profile against all of these generated LUTs.
Re-generating the LUTs for every iteration would be unnecessarily
wasteful.

The same consideration does not apply to e.g. cmsCreate*Profile, which
is a very lightweight operation just involving struct allocation and
setting a few pointers.

The cutoff value of 0.01 was determined by experimentation. The lowest
"false positive" delta I saw in practice was 0.13, and the largest
"false negative" delta was 0.0008. So a value of 0.01 sits comfortaby
almost exactly in the middle.

Signed-off-by: Niklas Haas 
---
 configure |   3 +
 libavfilter/fflcms2.c | 310 ++
 libavfilter/fflcms2.h |  87 
 3 files changed, 400 insertions(+)
 create mode 100644 libavfilter/fflcms2.c
 create mode 100644 libavfilter/fflcms2.h

diff --git a/configure b/configure
index 358a614854..c894efa600 100755
--- a/configure
+++ b/configure
@@ -215,6 +215,7 @@ External library support:
   --disable-iconv  disable iconv [autodetect]
   --enable-jni enable JNI support [no]
   --enable-ladspa  enable LADSPA audio filtering [no]
+  --enable-lcms2   enable ICC profile support via LittleCMS 2 [no]
   --enable-libaom  enable AV1 video encoding/decoding via libaom [no]
   --enable-libaribb24  enable ARIB text and caption decoding via 
libaribb24 [no]
   --enable-libass  enable libass subtitles rendering,
@@ -1813,6 +1814,7 @@ EXTERNAL_LIBRARY_LIST="
 gnutls
 jni
 ladspa
+lcms2
 libaom
 libass
 libbluray
@@ -6506,6 +6508,7 @@ enabled gmp   && require gmp gmp.h mpz_export 
-lgmp
 enabled gnutls&& require_pkg_config gnutls gnutls gnutls/gnutls.h 
gnutls_global_init
 enabled jni   && { [ $target_os = "android" ] && check_headers 
jni.h && enabled pthreads || die "ERROR: jni not found"; }
 enabled ladspa&& require_headers "ladspa.h dlfcn.h"
+enabled lcms2 && require_pkg_config lcms2 "lcms2 >= 2.13" lcms2.h 
cmsCreateContext
 enabled libaom&& require_pkg_config libaom "aom >= 1.0.0" 
aom/aom_codec.h aom_codec_version
 enabled libaribb24&& { check_pkg_config libaribb24 "aribb24 > 1.0.3" 
"aribb24/aribb24.h" arib_instance_new ||
{ enabled gpl && require_pkg_config libaribb24 
aribb24 "aribb24/aribb24.h" arib_instance_new; } ||
diff --git a/libavfilter/fflcms2.c b/libavfilter/fflcms2.c
new file mode 100644
index 00..efc7cb5189
--- /dev/null
+++ b/libavfilter/fflcms2.c
@@ -0,0 +1,310 @@
+/*
+ * Copyright (c) 2022 Niklas Haas
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/color_utils.h"
+
+#include "fflcms2.h"
+
+static void log_cb(cmsContext ctx, cmsUInt32Number error, const char *str)
+{
+FFIccContext *s = cmsGetContextUserData(ctx);
+av_log(s->avctx, AV_LOG_ERROR, "lcms2: [%"PRIu32"] %s\n", error, str);
+}
+
+int ff_icc_context_init(FFIccContext *s, void *avctx)
+{
+memset(s, 0, sizeof(*s));
+s->avctx = avctx;
+s->ctx = cmsCreateContext(NULL, s);
+if (!s->ctx)
+return AVERROR(ENOMEM);
+
+cmsSetLogErrorHandlerTHR(s->ctx, log_cb);
+return 0;
+}
+
+void ff_icc_context_uninit(FFIccContext *s)
+{
+for (int i = 0; i < FF_ARRAY_ELEMS(s->curves); i++)
+cmsFreeToneCurve(s->curves[i]);
+cmsDeleteContext(s->ctx);
+memset(s, 0, sizeof(*s));

[FFmpeg-devel] [PATCH v2 2/5] lavfi: add ff_detect_color_primaries helper

2022-04-19 Thread Niklas Haas
From: Niklas Haas 

Related to #9673, this helper exists to facilitate "guessing" the right
primary tags from a given set of raw primary coefficients.

The cutoff value of 0.001 was chosen by experimentation. The smallest
"false positive" delta observed in practice was 0.023329, while the
largest "false negative" delta was 0.00016. So, a value of 0.001 sits
comfortably in the middle.

Signed-off-by: Niklas Haas 
---
 libavfilter/colorspace.c | 25 +
 libavfilter/colorspace.h |  3 +++
 2 files changed, 28 insertions(+)

diff --git a/libavfilter/colorspace.c b/libavfilter/colorspace.c
index 25e99f4759..8d7b882375 100644
--- a/libavfilter/colorspace.c
+++ b/libavfilter/colorspace.c
@@ -170,6 +170,31 @@ const struct ColorPrimaries *ff_get_color_primaries(enum 
AVColorPrimaries prm)
 return p;
 }
 
+enum AVColorPrimaries ff_detect_color_primaries(const struct ColorPrimaries 
*prm)
+{
+double delta;
+
+for (enum AVColorPrimaries p = 0; p < AVCOL_PRI_NB; p++) {
+const struct ColorPrimaries *ref = _primaries[p];
+if (!ref->prim.xr)
+continue;
+
+delta = fabs(prm->prim.xr - ref->prim.xr) +
+fabs(prm->prim.yr - ref->prim.yr) +
+fabs(prm->prim.yg - ref->prim.yg) +
+fabs(prm->prim.yg - ref->prim.yg) +
+fabs(prm->prim.yb - ref->prim.yb) +
+fabs(prm->prim.yb - ref->prim.yb) +
+fabs(prm->wp.xw - ref->wp.xw) +
+fabs(prm->wp.yw - ref->wp.yw);
+
+if (delta < 0.001)
+return p;
+}
+
+return AVCOL_PRI_UNSPECIFIED;
+}
+
 void ff_fill_rgb2yuv_table(const struct LumaCoefficients *coeffs,
double rgb2yuv[3][3])
 {
diff --git a/libavfilter/colorspace.h b/libavfilter/colorspace.h
index fc415fed05..6959133a49 100644
--- a/libavfilter/colorspace.h
+++ b/libavfilter/colorspace.h
@@ -49,6 +49,9 @@ void ff_fill_rgb2xyz_table(const struct PrimaryCoefficients 
*coeffs,
const struct WhitepointCoefficients *wp,
double rgb2xyz[3][3]);
 
+/* Returns AVCOL_PRI_UNSPECIFIED if no clear match can be identified */
+enum AVColorPrimaries ff_detect_color_primaries(const struct ColorPrimaries 
*prm);
+
 const struct ColorPrimaries *ff_get_color_primaries(enum AVColorPrimaries prm);
 const struct LumaCoefficients *ff_get_luma_coefficients(enum AVColorSpace csp);
 void ff_fill_rgb2yuv_table(const struct LumaCoefficients *coeffs,
-- 
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".


[FFmpeg-devel] [PATCH v2 1/5] lavfi: generalize colorspace coefficent helpers

2022-04-19 Thread Niklas Haas
From: Niklas Haas 

These are needed beyond just vf_colorspace, so give them a new home in
colorspace.h.

In addition to moving code around, also merge the white point and
primary coefficients into a single struct to slightly increase the
convenience and shrink the size of the new API by avoiding the need
to introduce an extra function just to look up the white point as well.
The only place the distinction matters is in a single enum comparison,
which can just as well be a single memcpy - the difference is
negligible.

Signed-off-by: Niklas Haas 
---
Changes to v1 of this series:
- minor cleanup here and there
---
 libavfilter/colorspace.c| 32 +
 libavfilter/colorspace.h|  6 
 libavfilter/vf_colorspace.c | 70 ++---
 3 files changed, 49 insertions(+), 59 deletions(-)

diff --git a/libavfilter/colorspace.c b/libavfilter/colorspace.c
index 19616e4f12..25e99f4759 100644
--- a/libavfilter/colorspace.c
+++ b/libavfilter/colorspace.c
@@ -138,6 +138,38 @@ const struct LumaCoefficients 
*ff_get_luma_coefficients(enum AVColorSpace csp)
 return coeffs;
 }
 
+#define WP_D65 { 0.3127, 0.3290 }
+#define WP_C   { 0.3100, 0.3160 }
+#define WP_DCI { 0.3140, 0.3510 }
+#define WP_E   { 1/3.0f, 1/3.0f }
+
+static const struct ColorPrimaries color_primaries[AVCOL_PRI_NB] = {
+[AVCOL_PRI_BT709] = { WP_D65, { 0.640, 0.330, 0.300, 0.600, 0.150, 
0.060 } },
+[AVCOL_PRI_BT470M]= { WP_C,   { 0.670, 0.330, 0.210, 0.710, 0.140, 
0.080 } },
+[AVCOL_PRI_BT470BG]   = { WP_D65, { 0.640, 0.330, 0.290, 0.600, 0.150, 
0.060 } },
+[AVCOL_PRI_SMPTE170M] = { WP_D65, { 0.630, 0.340, 0.310, 0.595, 0.155, 
0.070 } },
+[AVCOL_PRI_SMPTE240M] = { WP_D65, { 0.630, 0.340, 0.310, 0.595, 0.155, 
0.070 } },
+[AVCOL_PRI_SMPTE428]  = { WP_E,   { 0.735, 0.265, 0.274, 0.718, 0.167, 
0.009 } },
+[AVCOL_PRI_SMPTE431]  = { WP_DCI, { 0.680, 0.320, 0.265, 0.690, 0.150, 
0.060 } },
+[AVCOL_PRI_SMPTE432]  = { WP_D65, { 0.680, 0.320, 0.265, 0.690, 0.150, 
0.060 } },
+[AVCOL_PRI_FILM]  = { WP_C,   { 0.681, 0.319, 0.243, 0.692, 0.145, 
0.049 } },
+[AVCOL_PRI_BT2020]= { WP_D65, { 0.708, 0.292, 0.170, 0.797, 0.131, 
0.046 } },
+[AVCOL_PRI_JEDEC_P22] = { WP_D65, { 0.630, 0.340, 0.295, 0.605, 0.155, 
0.077 } },
+};
+
+const struct ColorPrimaries *ff_get_color_primaries(enum AVColorPrimaries prm)
+{
+const struct ColorPrimaries *p;
+
+if (prm >= AVCOL_PRI_NB)
+return NULL;
+p = _primaries[prm];
+if (!p->prim.xr)
+return NULL;
+
+return p;
+}
+
 void ff_fill_rgb2yuv_table(const struct LumaCoefficients *coeffs,
double rgb2yuv[3][3])
 {
diff --git a/libavfilter/colorspace.h b/libavfilter/colorspace.h
index a4c5078d5f..fc415fed05 100644
--- a/libavfilter/colorspace.h
+++ b/libavfilter/colorspace.h
@@ -37,6 +37,11 @@ struct WhitepointCoefficients {
 double xw, yw;
 };
 
+struct ColorPrimaries {
+struct WhitepointCoefficients wp;
+struct PrimaryCoefficients prim;
+};
+
 void ff_matrix_invert_3x3(const double in[3][3], double out[3][3]);
 void ff_matrix_mul_3x3(double dst[3][3],
const double src1[3][3], const double src2[3][3]);
@@ -44,6 +49,7 @@ void ff_fill_rgb2xyz_table(const struct PrimaryCoefficients 
*coeffs,
const struct WhitepointCoefficients *wp,
double rgb2xyz[3][3]);
 
+const struct ColorPrimaries *ff_get_color_primaries(enum AVColorPrimaries prm);
 const struct LumaCoefficients *ff_get_luma_coefficients(enum AVColorSpace csp);
 void ff_fill_rgb2yuv_table(const struct LumaCoefficients *coeffs,
double rgb2yuv[3][3]);
diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
index 0bd8e2b0cf..3c8b3b20eb 100644
--- a/libavfilter/vf_colorspace.c
+++ b/libavfilter/vf_colorspace.c
@@ -55,14 +55,6 @@ enum Colorspace {
 CS_NB,
 };
 
-enum Whitepoint {
-WP_D65,
-WP_C,
-WP_DCI,
-WP_E,
-WP_NB,
-};
-
 enum WhitepointAdaptation {
 WP_ADAPT_BRADFORD,
 WP_ADAPT_VON_KRIES,
@@ -110,11 +102,6 @@ static const enum AVColorSpace default_csp[CS_NB + 1] = {
 [CS_NB]  = AVCOL_SPC_UNSPECIFIED,
 };
 
-struct ColorPrimaries {
-enum Whitepoint wp;
-struct PrimaryCoefficients coeff;
-};
-
 struct TransferCharacteristics {
 double alpha, beta, gamma, delta;
 };
@@ -201,40 +188,6 @@ static const struct TransferCharacteristics *
 return coeffs;
 }
 
-static const struct WhitepointCoefficients whitepoint_coefficients[WP_NB] = {
-[WP_D65] = { 0.3127, 0.3290 },
-[WP_C]   = { 0.3100, 0.3160 },
-[WP_DCI] = { 0.3140, 0.3510 },
-[WP_E]   = { 1/3.0f, 1/3.0f },
-};
-
-static const struct ColorPrimaries color_primaries[AVCOL_PRI_NB] = {
-[AVCOL_PRI_BT709] = { WP_D65, { 0.640, 0.330, 0.300, 0.600, 0.150, 
0.060 } },
-[AVCOL_PRI_BT470M]= { WP_C,   { 0.670, 0.330, 0.210, 0.710, 0.140, 
0.080 } },
-

Re: [FFmpeg-devel] [PATCH 2/2] avdevice/dshow: silence warnings about unused variable

2022-04-19 Thread James Almer

On 4/19/2022 3:05 AM, Roger Pack wrote:

On Wed, Apr 13, 2022 at 10:15 AM James Almer  wrote:


Use av_unused instead of wrapping the declaration under the DSHOWDEBUG check
in case future changes make use of it.

Signed-off-by: James Almer 
---
  libavdevice/dshow.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
index ac8b64366f..6277a27453 100644
--- a/libavdevice/dshow.c
+++ b/libavdevice/dshow.c
@@ -976,7 +976,7 @@ dshow_cycle_formats(AVFormatContext *avctx, enum 
dshowDeviceType devtype,
  }
  } else {
  WAVEFORMATEX *fx;
-AUDIO_STREAM_CONFIG_CAPS *acaps = caps;
+AUDIO_STREAM_CONFIG_CAPS av_unused *acaps = caps;
  #if DSHOWDEBUG
  ff_print_AUDIO_STREAM_CONFIG_CAPS(acaps);
  #endif


Or maybe put it within the #if ? Just an idea.


I mentioned as much in the commit message, but figured it would be nicer 
to not do it in case it's needed later. But ok, will go that route instead.



___
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] [FFmpeg-cvslog] doc: install css files along html docs

2022-04-19 Thread Timo Rothenpieler
This broke all fate instances that have htmlpages enabled, as this broke 
"make install" whenever building out of the source tree - the html files 
are generated and exist in the build tree, but the css files don't.


Should be fixed now
___
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 v2] avformat/mpegts: set data broadcast streams as such

2022-04-19 Thread Jan Ekström
On Tue, Apr 19, 2022 at 3:00 AM Marton Balint  wrote:
>
>
>
> On Thu, 14 Apr 2022, Jan Ekström wrote:
>
> > On Mon, Apr 11, 2022 at 1:50 PM Jan Ekström  wrote:
> >>
> >> From: Jan Ekström 
> >>
> >> Additionally, they should not be probed, as this is essentially
> >> various types of binary data.
> >>
> >> Signed-off-by: Jan Ekström 
> >> ---
> >
> > Ping.
> >
> > Basically this checks if we have an unknown stream with a private
> > stream type still at the end of the per-stream loop in PMT parsing,
> > and then cancels the stop of parsing that usually occurs as a PMT is
> > hit. Instead the logic will continue parsing further. When an SDT is
> > then found and a PMT for that program has already been received, it
> > will then stop header reading at that point.
>
> But why does it matter when the initial parsing is stopped? I mean it
> stops at the first PMT right now, nobody expects it to find all the
> programs and all the streams or all the stream codecs/parameters.
>
> I am saying, that ideally, the ts->stop_parse magic should not be needed
> to be changed to fix your issue and when an SDT is detected with the
> broadcast descriptor that should stop any existing data stream parsing. Do
> you know why it does not work like that?
>

If the codec is unknown after header parsing, the general parsing
logic is utilized to probe which codec is possibly in that unknown
stream, and thus more data is read from that stream, which can cause
further delays.

If the codec is known as data, it leads to no such result.

Basically, the idea is to figure out whether a stream is a data stream
or not during header parsing, if possible.

Jan
___
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] [FFmpeg-cvslog] doc: install css files along html docs

2022-04-19 Thread Martin Storsjö

On Mon, 18 Apr 2022, Timo Rothenpieler wrote:


ffmpeg | branch: master | Timo Rothenpieler  | Thu Apr  
7 20:11:24 2022 +0200| [d5687236aba6fd31dd4369c290df9a5b1192e43e] | committer: Timo 
Rothenpieler

doc: install css files along html docs


http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d5687236aba6fd31dd4369c290df9a5b1192e43e

---

doc/Makefile | 3 +++
1 file changed, 3 insertions(+)

diff --git a/doc/Makefile b/doc/Makefile
index 58ca3fabd8..0f09783699 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -27,6 +27,9 @@ HTMLPAGES   = $(AVPROGS-yes:%=doc/%.html) 
$(AVPROGS-yes:%=doc/%-all.html) $(COMP
  doc/mailing-list-faq.html \
  doc/nut.html  \
  doc/platform.html \
+  doc/bootstrap.min.css \
+  doc/style.min.css \
+  doc/default.css   \

TXTPAGES= doc/fate.txt  \


This broke all fate instances that have htmlpages enabled, as this broke 
"make install" whenever building out of the source tree - the html files 
are generated and exist in the build tree, but the css files don't.


(Adding .css to the list of extensions that are set up with vpath in the 
main Makefile might help a bit, but the install command would need to be 
updated to take that into account too.)


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


[FFmpeg-devel] [PATCH] avcodec/jpeg2000:fast-fail if HTJ2K codeblocks are present

2022-04-19 Thread caleb
---
This patch adds support for detecting Part 15 codeblocks to JPEG2000 specified 
in (Rec. ITU-T T.814 | ISO/IEC 15444-15).

The decoder on detecting Part 15 codeblocks now fails gracefully with a 
AVERROR_PATCHWELCOME return code

 libavcodec/jpeg2000.h| 2 ++
 libavcodec/jpeg2000dec.c | 9 +
 2 files changed, 11 insertions(+)

diff --git a/libavcodec/jpeg2000.h b/libavcodec/jpeg2000.h
index d06313425e..e5ecb4cbf9 100644
--- a/libavcodec/jpeg2000.h
+++ b/libavcodec/jpeg2000.h
@@ -110,6 +110,8 @@ enum Jpeg2000Quantsty { // quantization style
 #define JPEG2000_CSTY_PREC  0x01 // Precincts defined in coding style
 #define JPEG2000_CSTY_SOP   0x02 // SOP marker present
 #define JPEG2000_CSTY_EPH   0x04 // EPH marker present
+#define JPEG2000_CTSY_HTJ2K_F   0x40 // Only HT code-blocks (Rec. ITU-T T.814 
| ISO/IEC 15444-15) are present
+#define JPEG2000_CTSY_HTJ2K_M   0xC0 // HT code blocks (Rec. ITU-T T.814 | 
ISO/IEC 15444-15) can be present
 
 // Progression orders
 #define JPEG2000_PGOD_LRCP  0x00  // Layer-resolution 
level-component-position progression
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 92966b11f5..ef4a653afe 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -521,6 +521,15 @@ static int get_cox(Jpeg2000DecoderContext *s, 
Jpeg2000CodingStyle *c)
 
 c->cblk_style = bytestream2_get_byteu(>g);
 if (c->cblk_style != 0) { // cblk style
+if (c->cblk_style & JPEG2000_CTSY_HTJ2K_M || c->cblk_style & 
JPEG2000_CTSY_HTJ2K_F) {
+/*
+ * HT code-blocks (Rec. ITU-T T.814 | ISO/IEC 15444-15) bit-stream
+ * Not yet supported in ffmpeg, cannot continue.
+ */
+av_log(s->avctx, AV_LOG_FATAL, "Support for High throughput JPEG 
2000 is not yet available\n");
+return AVERROR_PATCHWELCOME;
+}
+
 av_log(s->avctx, AV_LOG_WARNING, "extra cblk styles %X\n", 
c->cblk_style);
 if (c->cblk_style & JPEG2000_CBLK_BYPASS)
 av_log(s->avctx, AV_LOG_WARNING, "Selective arithmetic coding 
bypass\n");
-- 
2.34.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] avdevice/dshow: reuse unused variables.

2022-04-19 Thread Diederick Niehorster
Fix for f125c504d8fece6420bb97767f9e72414c26312a, requested_sample_rate
and such should be used.

Signed-off-by: Diederick Niehorster 
---
 libavdevice/dshow.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
index 1e69620880..5946a72cc2 100644
--- a/libavdevice/dshow.c
+++ b/libavdevice/dshow.c
@@ -1003,9 +1003,9 @@ dshow_cycle_formats(AVFormatContext *avctx, enum 
dshowDeviceType devtype,
 continue;
 }
 if (
-(ctx->sample_rate && ctx->sample_rate != fx->nSamplesPerSec) ||
-(ctx->sample_size && ctx->sample_size != fx->wBitsPerSample) ||
-(ctx->channels&& ctx->channels!= fx->nChannels )
+(requested_sample_rate && requested_sample_rate != 
fx->nSamplesPerSec) ||
+(requested_sample_size && requested_sample_size != 
fx->wBitsPerSample) ||
+(requested_channels&& requested_channels!= 
fx->nChannels )
 ) {
 goto next;
 }
-- 
2.28.0.windows.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 4/4] avfilter/vf_frei0r: Copy to frame allocated according to frei0r requirements

2022-04-19 Thread Paul B Mahol
patch set probably ok
___
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 1/2] avdevice/dshow: remove unused variables

2022-04-19 Thread Diederick C. Niehorster
On Tue, Apr 19, 2022 at 8:10 AM Roger Pack  wrote:
>
> LGTM.

Not LGTM, see below

> On Wed, Apr 13, 2022 at 10:15 AM James Almer  wrote:
> >
> > Remnant from f125c504d8fece6420bb97767f9e72414c26312a
> >
> > Signed-off-by: James Almer 
> > ---
> >  libavdevice/dshow.c | 8 
> >  1 file changed, 8 deletions(-)
> >
> > diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
> > index 1e69620880..ac8b64366f 100644
> > --- a/libavdevice/dshow.c
> > +++ b/libavdevice/dshow.c
> > @@ -814,10 +814,6 @@ dshow_cycle_formats(AVFormatContext *avctx, enum 
> > dshowDeviceType devtype,
> >  / 
> > ctx->requested_framerate.num : 0;
> >  int requested_width   = ctx->requested_width;
> >  int requested_height  = ctx->requested_height;
> > -// audio
> > -int requested_sample_rate = ctx->sample_rate;
> > -int requested_sample_size = ctx->sample_size;
> > -int requested_channels= ctx->channels;
> >
> >  if (IPin_QueryInterface(pin, _IAMStreamConfig, (void **) ) 
> > != S_OK)
> >  return;
> > @@ -854,10 +850,6 @@ dshow_cycle_formats(AVFormatContext *avctx, enum 
> > dshowDeviceType devtype,
> >  requested_framerate  = fmt_info->framerate;
> >  requested_width  = fmt_info->width;
> >  requested_height = fmt_info->height;
> > -} else {
> > -requested_sample_rate = fmt_info->sample_rate;
> > -requested_sample_size = fmt_info->sample_size;
> > -requested_channels= fmt_info->channels;
> >  }
> >  av_free(fmt_info);  // free but don't set to NULL to 
> > enable below check
> >  }

These should be used further down when checking audio formats. I'll
send a patch.

Cheers,
Dee
___
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 1/2] avdevice/dshow: remove unused variables

2022-04-19 Thread Roger Pack
LGTM.

On Wed, Apr 13, 2022 at 10:15 AM James Almer  wrote:
>
> Remnant from f125c504d8fece6420bb97767f9e72414c26312a
>
> Signed-off-by: James Almer 
> ---
>  libavdevice/dshow.c | 8 
>  1 file changed, 8 deletions(-)
>
> diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
> index 1e69620880..ac8b64366f 100644
> --- a/libavdevice/dshow.c
> +++ b/libavdevice/dshow.c
> @@ -814,10 +814,6 @@ dshow_cycle_formats(AVFormatContext *avctx, enum 
> dshowDeviceType devtype,
>  / 
> ctx->requested_framerate.num : 0;
>  int requested_width   = ctx->requested_width;
>  int requested_height  = ctx->requested_height;
> -// audio
> -int requested_sample_rate = ctx->sample_rate;
> -int requested_sample_size = ctx->sample_size;
> -int requested_channels= ctx->channels;
>
>  if (IPin_QueryInterface(pin, _IAMStreamConfig, (void **) ) != 
> S_OK)
>  return;
> @@ -854,10 +850,6 @@ dshow_cycle_formats(AVFormatContext *avctx, enum 
> dshowDeviceType devtype,
>  requested_framerate  = fmt_info->framerate;
>  requested_width  = fmt_info->width;
>  requested_height = fmt_info->height;
> -} else {
> -requested_sample_rate = fmt_info->sample_rate;
> -requested_sample_size = fmt_info->sample_size;
> -requested_channels= fmt_info->channels;
>  }
>  av_free(fmt_info);  // free but don't set to NULL to enable 
> below check
>  }
> --
> 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".
___
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 2/2] avdevice/dshow: silence warnings about unused variable

2022-04-19 Thread Roger Pack
On Wed, Apr 13, 2022 at 10:15 AM James Almer  wrote:
>
> Use av_unused instead of wrapping the declaration under the DSHOWDEBUG check
> in case future changes make use of it.
>
> Signed-off-by: James Almer 
> ---
>  libavdevice/dshow.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
> index ac8b64366f..6277a27453 100644
> --- a/libavdevice/dshow.c
> +++ b/libavdevice/dshow.c
> @@ -976,7 +976,7 @@ dshow_cycle_formats(AVFormatContext *avctx, enum 
> dshowDeviceType devtype,
>  }
>  } else {
>  WAVEFORMATEX *fx;
> -AUDIO_STREAM_CONFIG_CAPS *acaps = caps;
> +AUDIO_STREAM_CONFIG_CAPS av_unused *acaps = caps;
>  #if DSHOWDEBUG
>  ff_print_AUDIO_STREAM_CONFIG_CAPS(acaps);
>  #endif

Or maybe put it within the #if ? Just an idea.
___
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".