Re: [FFmpeg-devel] [PATCH] libavformat/mpegts.c: fix hardcoded 5-bytes skip for metadata streams.

2023-06-20 Thread James Almer

On 6/20/2023 8:58 PM, Romain Beauxis wrote:

Le mar. 20 juin 2023 à 02:10, Paul B Mahol  a écrit :




On Tue, Jun 20, 2023 at 7:19 AM  wrote:


From: Romain Beauxis 

Before the introduction of AV_CODEC_ID_TIMED_ID3 for timed_id3 metadata

streams

in mpegts (commit 4a4437c0fbc8f7afe0c533070395a42e56b4ee75),

AV_CODEC_ID_SMPTE_KLV

was the only existing codec for metadata.

It seems that this codec has a 5-bytes metadata header[1] that, for some

reason,

was always skipped when decoding data packets.

However, when working with a AV_CODEC_ID_TIMED_ID3 streams, this results

in the

5 first bytes of the payload being cut-off, which includes essential

informations

such as the ID3 tag version.

This patch fixes the issue by keeping the 5-bytes skip only for

AV_CODEC_ID_SMPTE_KLV

streams.

To test:
1. download this file:

https://www.dropbox.com/s/jy8sih3pe8qskxb/bla.ts?dl=1


This file was download from:

http://playertest.longtailvideo.com/adaptive/wowzaid3/playlist.m3u8


2. run this command:
   ffprobe -show_streams -select_streams 0 -show_packets

-show_private_data \

   -show_data /path/to/bla.ts

Before:
[PACKET]
codec_type=data
stream_index=0
pts=494646418
pts_time=5496.071311
dts=494646418
dts_time=5496.071311
duration=N/A
duration_time=N/A
size=21
pos=482784
flags=K__
data=
:   1054 4954 3200  0600 0003  .TIT2...
0010: 7465 7374 00 test.

After:
[PACKET]
codec_type=data
stream_index=0
pts=494646418
pts_time=5496.071311
dts=494646418
dts_time=5496.071311
duration=N/A
duration_time=N/A
size=26
pos=482784
flags=K__
data=
: 4944 3304   0010 5449 5432   ID3...TIT2..
0010: 0006  0374 6573 7400 .test.

---
  libavformat/mpegts.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index fb8b0bf8fd..0b3edda817 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -1305,7 +1305,7 @@ skip:
  p += sl_header_bytes;
  buf_size -= sl_header_bytes;
  }
-if (pes->stream_type == 0x15 && buf_size >= 5) {
+if (pes->st->codecpar->codec_id ==

AV_CODEC_ID_SMPTE_KLV && buf_size >= 5) {

  /* skip metadata access unit header */
  pes->pes_header_size += 5;
  p += 5;
--
2.39.2 (Apple Git-143)



LGTM


Great, thanks!

Anything I can do to help move this to the finish line?

Thanks,
-- Romain


Pushed, 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] [PATCH] libavformat/mpegts.c: fix hardcoded 5-bytes skip for metadata streams.

2023-06-20 Thread Romain Beauxis
Le mar. 20 juin 2023 à 02:10, Paul B Mahol  a écrit :
>
>
>
> On Tue, Jun 20, 2023 at 7:19 AM  wrote:
>>
>> From: Romain Beauxis 
>>
>> Before the introduction of AV_CODEC_ID_TIMED_ID3 for timed_id3 metadata
streams
>> in mpegts (commit 4a4437c0fbc8f7afe0c533070395a42e56b4ee75),
AV_CODEC_ID_SMPTE_KLV
>> was the only existing codec for metadata.
>>
>> It seems that this codec has a 5-bytes metadata header[1] that, for some
reason,
>> was always skipped when decoding data packets.
>>
>> However, when working with a AV_CODEC_ID_TIMED_ID3 streams, this results
in the
>> 5 first bytes of the payload being cut-off, which includes essential
informations
>> such as the ID3 tag version.
>>
>> This patch fixes the issue by keeping the 5-bytes skip only for
AV_CODEC_ID_SMPTE_KLV
>> streams.
>>
>> To test:
>> 1. download this file:
https://www.dropbox.com/s/jy8sih3pe8qskxb/bla.ts?dl=1
>>
>> This file was download from:
http://playertest.longtailvideo.com/adaptive/wowzaid3/playlist.m3u8
>>
>> 2. run this command:
>>   ffprobe -show_streams -select_streams 0 -show_packets
-show_private_data \
>>   -show_data /path/to/bla.ts
>>
>> Before:
>> [PACKET]
>> codec_type=data
>> stream_index=0
>> pts=494646418
>> pts_time=5496.071311
>> dts=494646418
>> dts_time=5496.071311
>> duration=N/A
>> duration_time=N/A
>> size=21
>> pos=482784
>> flags=K__
>> data=
>> :   1054 4954 3200  0600 0003  .TIT2...
>> 0010: 7465 7374 00 test.
>>
>> After:
>> [PACKET]
>> codec_type=data
>> stream_index=0
>> pts=494646418
>> pts_time=5496.071311
>> dts=494646418
>> dts_time=5496.071311
>> duration=N/A
>> duration_time=N/A
>> size=26
>> pos=482784
>> flags=K__
>> data=
>> : 4944 3304   0010 5449 5432   ID3...TIT2..
>> 0010: 0006  0374 6573 7400 .test.
>>
>> ---
>>  libavformat/mpegts.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
>> index fb8b0bf8fd..0b3edda817 100644
>> --- a/libavformat/mpegts.c
>> +++ b/libavformat/mpegts.c
>> @@ -1305,7 +1305,7 @@ skip:
>>  p += sl_header_bytes;
>>  buf_size -= sl_header_bytes;
>>  }
>> -if (pes->stream_type == 0x15 && buf_size >= 5) {
>> +if (pes->st->codecpar->codec_id ==
AV_CODEC_ID_SMPTE_KLV && buf_size >= 5) {
>>  /* skip metadata access unit header */
>>  pes->pes_header_size += 5;
>>  p += 5;
>> --
>> 2.39.2 (Apple Git-143)
>
>
> LGTM

Great, thanks!

Anything I can do to help move this to the finish line?

Thanks,
-- Romain

>>
>>
>> ___
>> 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] vulkan/av1: fix tile upload offsets.

2023-06-20 Thread airlied
From: Dave Airlie 

This fixes decoding av1-1-b8-22-svc-L2T1.ivf
while not breaking other videos.
---
 libavcodec/vulkan_av1.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c
index 91e44ba803..005998b1bd 100644
--- a/libavcodec/vulkan_av1.c
+++ b/libavcodec/vulkan_av1.c
@@ -513,13 +513,15 @@ static int vk_av1_decode_slice(AVCodecContext *avctx,
 .tg_end   = s->tg_end,
 };
 
-err = ff_vk_decode_add_slice(avctx, vp, data, size, 0,
+err = ff_vk_decode_add_slice(avctx, vp,
+ data + s->tile_group_info[i].tile_offset,
+ s->tile_group_info[i].tile_size, 0,
  >tile_list.nb_tiles,
  >tile_offsets);
 if (err < 0)
 return err;
 
-//ap->tiles[ap->tile_list.nb_tiles - 1].offset = 
ap->tile_offsets[ap->tile_list.nb_tiles - 1];
+ap->tiles[ap->tile_list.nb_tiles - 1].offset = 
ap->tile_offsets[ap->tile_list.nb_tiles - 1];
 }
 
 return 0;
-- 
2.41.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] av1dec: handle dimension changes via get_format

2023-06-20 Thread airlied
From: Dave Airlie 

av1-1-b8-03-sizeup.ivf on vulkan causes gpu hangs as none of the
images get resized when dimensions change, this detects the dim
change and calls the get_format to reinit the context.
---
 libavcodec/av1dec.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index e7f98a6c81..1cec328563 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -721,6 +721,7 @@ static av_cold int av1_decode_free(AVCodecContext *avctx)
 }
 
 static int set_context_with_sequence(AVCodecContext *avctx,
+ int *dim_change,
  const AV1RawSequenceHeader *seq)
 {
 int width = seq->max_frame_width_minus_1 + 1;
@@ -753,6 +754,8 @@ static int set_context_with_sequence(AVCodecContext *avctx,
 int ret = ff_set_dimensions(avctx, width, height);
 if (ret < 0)
 return ret;
+if (dim_change)
+*dim_change = 1;
 }
 avctx->sample_aspect_ratio = (AVRational) { 1, 1 };
 
@@ -859,7 +862,7 @@ static av_cold int av1_decode_init(AVCodecContext *avctx)
 goto end;
 }
 
-ret = set_context_with_sequence(avctx, seq);
+ret = set_context_with_sequence(avctx, NULL, seq);
 if (ret < 0) {
 av_log(avctx, AV_LOG_WARNING, "Failed to set decoder context.\n");
 goto end;
@@ -1202,7 +1205,7 @@ static int av1_receive_frame_internal(AVCodecContext 
*avctx, AVFrame *frame)
 CodedBitstreamUnit *unit = >current_obu.units[i];
 AV1RawOBU *obu = unit->content;
 const AV1RawOBUHeader *header;
-
+int dim_change = 0;
 if (!obu)
 continue;
 
@@ -1220,7 +1223,8 @@ static int av1_receive_frame_internal(AVCodecContext 
*avctx, AVFrame *frame)
 
 s->raw_seq = >obu.sequence_header;
 
-ret = set_context_with_sequence(avctx, s->raw_seq);
+dim_change = 0;
+ret = set_context_with_sequence(avctx, _change, s->raw_seq);
 if (ret < 0) {
 av_log(avctx, AV_LOG_ERROR, "Failed to set context.\n");
 s->raw_seq = NULL;
@@ -1229,7 +1233,7 @@ static int av1_receive_frame_internal(AVCodecContext 
*avctx, AVFrame *frame)
 
 s->operating_point_idc = 
s->raw_seq->operating_point_idc[s->operating_point];
 
-if (s->pix_fmt == AV_PIX_FMT_NONE) {
+if (s->pix_fmt == AV_PIX_FMT_NONE || dim_change) {
 ret = get_pixel_format(avctx);
 if (ret < 0) {
 av_log(avctx, AV_LOG_ERROR,
-- 
2.41.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 1/2] lavfi: remove scale_vulkan filter

2023-06-20 Thread Lynne
Jun 20, 2023, 23:58 by ffm...@haasn.xyz:

> On Tue, 20 Jun 2023 19:32:28 +0200 Lynne  wrote:
>
>> libplacebo is better in every way for anything involving scaling or format 
>> conversions
>>
>
> Hi,
>
> vf_libplacebo always goes through internal RGB conversion, even for no-op.
> scale_vulkan (ditto overlay_vulkan) can be more efficient for simple YCbCr
> frames.
>
> I would rather replace scale_vulkan's implementation by pl_scale_* calls if 
> you
> want to go this route.
>

I suppose I'll fix them up a little and leave them in, with
a note in the docs.
overlay_vulkan does work, but scale_vulkan is currently
broken for yuv420p (444 works oddly).
___
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] lavfi: remove scale_vulkan filter

2023-06-20 Thread Niklas Haas
On Tue, 20 Jun 2023 19:32:28 +0200 Lynne  wrote:
> libplacebo is better in every way for anything involving scaling or format 
> conversions

Hi,

vf_libplacebo always goes through internal RGB conversion, even for no-op.
scale_vulkan (ditto overlay_vulkan) can be more efficient for simple YCbCr
frames.

I would rather replace scale_vulkan's implementation by pl_scale_* calls if you
want to go this route.
___
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] avformat/id3v2: check the return value of avio_close_dyn_buf()

2023-06-20 Thread James Almer
Fixes ticket #10424.

Signed-off-by: James Almer 
---
 libavformat/id3v2.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index cb31864045..38c86a8e79 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -246,7 +246,7 @@ static int decode_str(AVFormatContext *s, AVIOContext *pb, 
int encoding,
 int ret;
 uint8_t tmp;
 uint32_t ch = 1;
-int left = *maxread;
+int left = *maxread, dynsize;
 unsigned int (*get)(AVIOContext*) = avio_rb16;
 AVIOContext *dynbuf;
 
@@ -308,7 +308,9 @@ static int decode_str(AVFormatContext *s, AVIOContext *pb, 
int encoding,
 if (ch)
 avio_w8(dynbuf, 0);
 
-avio_close_dyn_buf(dynbuf, dst);
+dynsize = avio_close_dyn_buf(dynbuf, dst);
+if (dynsize <= 0)
+return AVERROR(ENOMEM);
 *maxread = left;
 
 return 0;
-- 
2.41.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] tests/fate/ffmpeg: silence the audio for fate-ffmpeg-streamloop-transcode-av

2023-06-20 Thread James Almer

On 6/20/2023 4:41 PM, Anton Khirnov wrote:

Quoting James Almer (2023-06-20 21:39:22)

On 6/20/2023 3:53 PM, Anton Khirnov wrote:

Fixed-point AAC decoder currently does not produce the same output on
all platforms. Until that is fixed, silence the audio stream using the
volume filter.

Also, actually use the aac_fixed decoder as was the original intent.
---
   tests/fate/ffmpeg.mak |   7 +-
   tests/ref/fate/ffmpeg-streamloop-transcode-av | 144 +-
   2 files changed, 77 insertions(+), 74 deletions(-)

diff --git a/tests/fate/ffmpeg.mak b/tests/fate/ffmpeg.mak
index 87cd0b46d0..763ed381ee 100644
--- a/tests/fate/ffmpeg.mak
+++ b/tests/fate/ffmpeg.mak
@@ -132,9 +132,12 @@ fate-ffmpeg-fix_sub_duration_heartbeat: CMD = fmtstdout 
srt -fix_sub_duration \
 -c:s srt \
 -f null -
   
-FATE_SAMPLES_FFMPEG-$(call FRAMECRC, MATROSKA, H264 AAC_FIXED, PCM_S32LE_ENCODER) += fate-ffmpeg-streamloop-transcode-av

+# FIXME: the integer AAC decoder does not produce the same output on all 
platforms
+# so until that is fixed we use the volume filter to silence the data
+FATE_SAMPLES_FFMPEG-$(call FRAMECRC, MATROSKA, H264 AAC_FIXED, 
PCM_S32LE_ENCODER VOLUME_FILTER) += fate-ffmpeg-streamloop-transcode-av
   fate-ffmpeg-streamloop-transcode-av: CMD = \
-   framecrc -auto_conversion_filters -stream_loop 3 -i 
$(TARGET_SAMPLES)/mkv/1242-small.mkv -c:a pcm_s32le
+framecrc -auto_conversion_filters -stream_loop 3 -c:a aac_fixed -i 
$(TARGET_SAMPLES)/mkv/1242-small.mkv \
+-af volume=0 -c:a pcm_s32le


Maybe do volume=0:precision=fixed so you can remove the
-auto_conversion_filters part.


It's mainly there to interleave s32p to s32 for encoding


Yeah, just checked and it fails without -auto_conversion_filters even if 
you force fixed point in the filter.
Still, even if it's a temporal change, it's best to add precision=fixed 
since it will prevent conversion to float and back to fixed from auto 
inserting two aresample instances in the filterchain.


With precision=fixed


[AVFilterGraph @ 01f29a306e20] Setting 'volume' to value '0'
[AVFilterGraph @ 01f29a306e20] Setting 'precision' to value 'fixed'
[graph_0_in_0_0 @ 01f29a30eea0] Setting 'time_base' to value '1/48000'
[graph_0_in_0_0 @ 01f29a30eea0] Setting 'sample_rate' to value '48000'
[graph_0_in_0_0 @ 01f29a30eea0] Setting 'sample_fmt' to value 's32p'
[graph_0_in_0_0 @ 01f29a30eea0] Setting 'channel_layout' to value 'stereo'
[graph_0_in_0_0 @ 01f29a30eea0] tb:1/48000 samplefmt:s32p samplerate:48000 
chlayout:stereo
[format_out_0_0 @ 01f29a0defa0] Setting 'sample_fmts' to value 's32'
[format_out_0_0 @ 01f29a0defa0] auto-inserting filter 'auto_aresample_0' 
between the filter 'Parsed_volume_0' and the filter 'format_out_0_0'
[AVFilterGraph @ 01f29a306e20] query_formats: 4 queried, 4 merged, 6 
already done, 0 delayed
[graph_0_in_0_0 @ 01f29a30eea0] tb:0.21 sample_rate:48000.00 
nb_channels:2.00
[Parsed_volume_0 @ 01f29a026f60] n:nan t:nan pts:nan precision:fixed 
volume_i:0/255 volume:0.00 volume_dB:-inf
[auto_aresample_0 @ 01f29a0df8a0] [SWR @ 01f29a1cbf60] Using s32p 
internally between filters
[auto_aresample_0 @ 01f29a0df8a0] ch:2 chl:stereo fmt:s32p r:48000Hz -> 
ch:2 chl:stereo fmt:s32 r:48000Hz


Without it


[AVFilterGraph @ 01ccb6036aa0] Setting 'volume' to value '0'
[graph_0_in_0_0 @ 01ccb603b6c0] Setting 'time_base' to value '1/48000'
[graph_0_in_0_0 @ 01ccb603b6c0] Setting 'sample_rate' to value '48000'
[graph_0_in_0_0 @ 01ccb603b6c0] Setting 'sample_fmt' to value 's32p'
[graph_0_in_0_0 @ 01ccb603b6c0] Setting 'channel_layout' to value 'stereo'
[graph_0_in_0_0 @ 01ccb603b6c0] tb:1/48000 samplefmt:s32p samplerate:48000 
chlayout:stereo
[format_out_0_0 @ 01ccb5e0eec0] Setting 'sample_fmts' to value 's32'
[Parsed_volume_0 @ 01ccb5d56f80] auto-inserting filter 'auto_aresample_0' 
between the filter 'graph_0_in_0_0' and the filter 'Parsed_volume_0'
[format_out_0_0 @ 01ccb5e0eec0] auto-inserting filter 'auto_aresample_1' 
between the filter 'Parsed_volume_0' and the filter 'format_out_0_0'
[AVFilterGraph @ 01ccb6036aa0] query_formats: 4 queried, 2 merged, 9 
already done, 0 delayed
[auto_aresample_0 @ 01ccb5d59be0] picking fltp out of 2 ref:s32p
[auto_aresample_0 @ 01ccb5d59be0] [SWR @ 01ccb5efbf80] Using fltp 
internally between filters
[auto_aresample_0 @ 01ccb5d59be0] ch:2 chl:stereo fmt:s32p r:48000Hz -> 
ch:2 chl:stereo fmt:fltp r:48000Hz
[auto_aresample_0 @ 01ccb5d59be0] tb:0.21 sample_rate:48000.00 
nb_channels:2.00
[Parsed_volume_0 @ 01ccb5d56f80] n:nan t:nan pts:nan precision:float 
volume:0.00 volume_dB:-inf
[auto_aresample_1 @ 01ccb5d5ae80] [SWR @ 01ccb5f10fc0] Using fltp 
internally between filters
[auto_aresample_1 @ 01ccb5d5ae80] ch:2 chl:stereo fmt:fltp r:48000Hz -> 
ch:2 chl:stereo fmt:s32 r:48000Hz


Re: [FFmpeg-devel] [PATCH] tests/fate/ffmpeg: silence the audio for fate-ffmpeg-streamloop-transcode-av

2023-06-20 Thread Anton Khirnov
Quoting James Almer (2023-06-20 21:39:22)
> On 6/20/2023 3:53 PM, Anton Khirnov wrote:
> > Fixed-point AAC decoder currently does not produce the same output on
> > all platforms. Until that is fixed, silence the audio stream using the
> > volume filter.
> > 
> > Also, actually use the aac_fixed decoder as was the original intent.
> > ---
> >   tests/fate/ffmpeg.mak |   7 +-
> >   tests/ref/fate/ffmpeg-streamloop-transcode-av | 144 +-
> >   2 files changed, 77 insertions(+), 74 deletions(-)
> > 
> > diff --git a/tests/fate/ffmpeg.mak b/tests/fate/ffmpeg.mak
> > index 87cd0b46d0..763ed381ee 100644
> > --- a/tests/fate/ffmpeg.mak
> > +++ b/tests/fate/ffmpeg.mak
> > @@ -132,9 +132,12 @@ fate-ffmpeg-fix_sub_duration_heartbeat: CMD = 
> > fmtstdout srt -fix_sub_duration \
> > -c:s srt \
> > -f null -
> >   
> > -FATE_SAMPLES_FFMPEG-$(call FRAMECRC, MATROSKA, H264 AAC_FIXED, 
> > PCM_S32LE_ENCODER) += fate-ffmpeg-streamloop-transcode-av
> > +# FIXME: the integer AAC decoder does not produce the same output on all 
> > platforms
> > +# so until that is fixed we use the volume filter to silence the data
> > +FATE_SAMPLES_FFMPEG-$(call FRAMECRC, MATROSKA, H264 AAC_FIXED, 
> > PCM_S32LE_ENCODER VOLUME_FILTER) += fate-ffmpeg-streamloop-transcode-av
> >   fate-ffmpeg-streamloop-transcode-av: CMD = \
> > -   framecrc -auto_conversion_filters -stream_loop 3 -i 
> > $(TARGET_SAMPLES)/mkv/1242-small.mkv -c:a pcm_s32le
> > +framecrc -auto_conversion_filters -stream_loop 3 -c:a aac_fixed -i 
> > $(TARGET_SAMPLES)/mkv/1242-small.mkv \
> > +-af volume=0 -c:a pcm_s32le
> 
> Maybe do volume=0:precision=fixed so you can remove the 
> -auto_conversion_filters part.

It's mainly there to interleave s32p to s32 for encoding

-- 
Anton Khirnov
___
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] tests/fate/ffmpeg: silence the audio for fate-ffmpeg-streamloop-transcode-av

2023-06-20 Thread James Almer

On 6/20/2023 3:53 PM, Anton Khirnov wrote:

Fixed-point AAC decoder currently does not produce the same output on
all platforms. Until that is fixed, silence the audio stream using the
volume filter.

Also, actually use the aac_fixed decoder as was the original intent.
---
  tests/fate/ffmpeg.mak |   7 +-
  tests/ref/fate/ffmpeg-streamloop-transcode-av | 144 +-
  2 files changed, 77 insertions(+), 74 deletions(-)

diff --git a/tests/fate/ffmpeg.mak b/tests/fate/ffmpeg.mak
index 87cd0b46d0..763ed381ee 100644
--- a/tests/fate/ffmpeg.mak
+++ b/tests/fate/ffmpeg.mak
@@ -132,9 +132,12 @@ fate-ffmpeg-fix_sub_duration_heartbeat: CMD = fmtstdout 
srt -fix_sub_duration \
-c:s srt \
-f null -
  
-FATE_SAMPLES_FFMPEG-$(call FRAMECRC, MATROSKA, H264 AAC_FIXED, PCM_S32LE_ENCODER) += fate-ffmpeg-streamloop-transcode-av

+# FIXME: the integer AAC decoder does not produce the same output on all 
platforms
+# so until that is fixed we use the volume filter to silence the data
+FATE_SAMPLES_FFMPEG-$(call FRAMECRC, MATROSKA, H264 AAC_FIXED, 
PCM_S32LE_ENCODER VOLUME_FILTER) += fate-ffmpeg-streamloop-transcode-av
  fate-ffmpeg-streamloop-transcode-av: CMD = \
-   framecrc -auto_conversion_filters -stream_loop 3 -i 
$(TARGET_SAMPLES)/mkv/1242-small.mkv -c:a pcm_s32le
+framecrc -auto_conversion_filters -stream_loop 3 -c:a aac_fixed -i 
$(TARGET_SAMPLES)/mkv/1242-small.mkv \
+-af volume=0 -c:a pcm_s32le


Maybe do volume=0:precision=fixed so you can remove the 
-auto_conversion_filters part.


  
  FATE_STREAMCOPY-$(call REMUX, MP4 MOV, EAC3_DEMUXER) += fate-copy-trac3074

  fate-copy-trac3074: CMD = transcode eac3 
$(TARGET_SAMPLES)/eac3/csi_miami_stereo_128_spx.eac3\
diff --git a/tests/ref/fate/ffmpeg-streamloop-transcode-av 
b/tests/ref/fate/ffmpeg-streamloop-transcode-av
index 50a626b281..6934e39d41 100644
--- a/tests/ref/fate/ffmpeg-streamloop-transcode-av
+++ b/tests/ref/fate/ffmpeg-streamloop-transcode-av
@@ -18,31 +18,31 @@
  1,   4072,   4072, 1024, 8192, 0x
  1,   5096,   5096, 1024, 8192, 0x
  0,  3,  3,1,  1378560, 0xca1deba8
-1,   6120,   6120, 1024, 8192, 0x687330d2
-1,   7128,   7128, 1024, 8192, 0x9131462c
+1,   6120,   6120, 1024, 8192, 0x
+1,   7128,   7128, 1024, 8192, 0x
  0,  4,  4,1,  1378560, 0xd4eed467
-1,   8208,   8208, 1024, 8192, 0x48c01c32
-1,   9232,   9232, 1024, 8192, 0x0ccd8d5f
+1,   8208,   8208, 1024, 8192, 0x
+1,   9232,   9232, 1024, 8192, 0x
  0,  5,  5,1,  1378560, 0xd6e1d5b7
-1,  10248,  10248, 1024, 8192, 0xd50cbe9f
-1,  11256,  11256, 1024, 8192, 0xbe069303
+1,  10248,  10248, 1024, 8192, 0x
+1,  11256,  11256, 1024, 8192, 0x
  0,  6,  6,1,  1378560, 0x0b574d39
-1,  12280,  12280, 1024, 8192, 0x85fccf5b
-1,  13304,  13304, 1024, 8192, 0x4180de71
+1,  12280,  12280, 1024, 8192, 0x
+1,  13304,  13304, 1024, 8192, 0x
  0,  7,  7,1,  1378560, 0x1bdd4d61
-1,  14328,  14328, 1024, 8192, 0x0e9b6ac3
-1,  15336,  15336, 1024, 8192, 0x5c33f724
+1,  14328,  14328, 1024, 8192, 0x
+1,  15336,  15336, 1024, 8192, 0x
  0,  8,  8,1,  1378560, 0x3b28f549
-1,  16360,  16360, 1024, 8192, 0x668aaaec
-1,  17384,  17384, 1024, 8192, 0xd137d412
+1,  16360,  16360, 1024, 8192, 0x
+1,  17384,  17384, 1024, 8192, 0x
  0,  9,  9,1,  1378560, 0x45b2f57b
-1,  18408,  18408, 1024, 8192, 0x08e1fbf6
-1,  19416,  19416, 1024, 8192, 0xbf3fb4f6
+1,  18408,  18408, 1024, 8192, 0x
+1,  19416,  19416, 1024, 8192, 0x
  0, 10, 10,1,  1378560, 0x8955570e
-1,  20440,  20440, 1024, 8192, 0x69cd08a4
-1,  21464,  21464, 1024, 8192, 0xe0fe6297
-1,  22488,  22488, 1024, 8192, 0x172867ad
-1,  23496,  23496, 1024, 8192, 0xcbcc1461
+1,  20440,  20440, 1024, 8192, 0x
+1,  21464,  21464, 1024, 8192, 0x
+1,  22488,  22488, 1024, 8192, 0x
+1,  23496,  23496, 1024, 8192, 0x
  0, 12, 12,1,  1378560, 0x9c598000
  1,  25488,  25488, 1024, 8192, 0x
  0, 13, 13,1,  1378560, 0xbaf121ba
@@ -52,32 +52,32 @@
  1,  28552,  28552, 1024, 8192, 0x
  1,  

Re: [FFmpeg-devel] [PATCH] tests/fate/ffmpeg: silence the audio for fate-ffmpeg-streamloop-transcode-av

2023-06-20 Thread James Almer

On 6/20/2023 3:53 PM, Anton Khirnov wrote:

Fixed-point AAC decoder currently does not produce the same output on
all platforms. Until that is fixed, silence the audio stream using the
volume filter.

Also, actually use the aac_fixed decoder as was the original intent.
---
  tests/fate/ffmpeg.mak |   7 +-
  tests/ref/fate/ffmpeg-streamloop-transcode-av | 144 +-
  2 files changed, 77 insertions(+), 74 deletions(-)


LGTM.
___
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] tests/fate/ffmpeg: silence the audio for fate-ffmpeg-streamloop-transcode-av

2023-06-20 Thread Anton Khirnov
Fixed-point AAC decoder currently does not produce the same output on
all platforms. Until that is fixed, silence the audio stream using the
volume filter.

Also, actually use the aac_fixed decoder as was the original intent.
---
 tests/fate/ffmpeg.mak |   7 +-
 tests/ref/fate/ffmpeg-streamloop-transcode-av | 144 +-
 2 files changed, 77 insertions(+), 74 deletions(-)

diff --git a/tests/fate/ffmpeg.mak b/tests/fate/ffmpeg.mak
index 87cd0b46d0..763ed381ee 100644
--- a/tests/fate/ffmpeg.mak
+++ b/tests/fate/ffmpeg.mak
@@ -132,9 +132,12 @@ fate-ffmpeg-fix_sub_duration_heartbeat: CMD = fmtstdout 
srt -fix_sub_duration \
   -c:s srt \
   -f null -
 
-FATE_SAMPLES_FFMPEG-$(call FRAMECRC, MATROSKA, H264 AAC_FIXED, 
PCM_S32LE_ENCODER) += fate-ffmpeg-streamloop-transcode-av
+# FIXME: the integer AAC decoder does not produce the same output on all 
platforms
+# so until that is fixed we use the volume filter to silence the data
+FATE_SAMPLES_FFMPEG-$(call FRAMECRC, MATROSKA, H264 AAC_FIXED, 
PCM_S32LE_ENCODER VOLUME_FILTER) += fate-ffmpeg-streamloop-transcode-av
 fate-ffmpeg-streamloop-transcode-av: CMD = \
-   framecrc -auto_conversion_filters -stream_loop 3 -i 
$(TARGET_SAMPLES)/mkv/1242-small.mkv -c:a pcm_s32le
+framecrc -auto_conversion_filters -stream_loop 3 -c:a aac_fixed -i 
$(TARGET_SAMPLES)/mkv/1242-small.mkv \
+-af volume=0 -c:a pcm_s32le
 
 FATE_STREAMCOPY-$(call REMUX, MP4 MOV, EAC3_DEMUXER) += fate-copy-trac3074
 fate-copy-trac3074: CMD = transcode eac3 
$(TARGET_SAMPLES)/eac3/csi_miami_stereo_128_spx.eac3\
diff --git a/tests/ref/fate/ffmpeg-streamloop-transcode-av 
b/tests/ref/fate/ffmpeg-streamloop-transcode-av
index 50a626b281..6934e39d41 100644
--- a/tests/ref/fate/ffmpeg-streamloop-transcode-av
+++ b/tests/ref/fate/ffmpeg-streamloop-transcode-av
@@ -18,31 +18,31 @@
 1,   4072,   4072, 1024, 8192, 0x
 1,   5096,   5096, 1024, 8192, 0x
 0,  3,  3,1,  1378560, 0xca1deba8
-1,   6120,   6120, 1024, 8192, 0x687330d2
-1,   7128,   7128, 1024, 8192, 0x9131462c
+1,   6120,   6120, 1024, 8192, 0x
+1,   7128,   7128, 1024, 8192, 0x
 0,  4,  4,1,  1378560, 0xd4eed467
-1,   8208,   8208, 1024, 8192, 0x48c01c32
-1,   9232,   9232, 1024, 8192, 0x0ccd8d5f
+1,   8208,   8208, 1024, 8192, 0x
+1,   9232,   9232, 1024, 8192, 0x
 0,  5,  5,1,  1378560, 0xd6e1d5b7
-1,  10248,  10248, 1024, 8192, 0xd50cbe9f
-1,  11256,  11256, 1024, 8192, 0xbe069303
+1,  10248,  10248, 1024, 8192, 0x
+1,  11256,  11256, 1024, 8192, 0x
 0,  6,  6,1,  1378560, 0x0b574d39
-1,  12280,  12280, 1024, 8192, 0x85fccf5b
-1,  13304,  13304, 1024, 8192, 0x4180de71
+1,  12280,  12280, 1024, 8192, 0x
+1,  13304,  13304, 1024, 8192, 0x
 0,  7,  7,1,  1378560, 0x1bdd4d61
-1,  14328,  14328, 1024, 8192, 0x0e9b6ac3
-1,  15336,  15336, 1024, 8192, 0x5c33f724
+1,  14328,  14328, 1024, 8192, 0x
+1,  15336,  15336, 1024, 8192, 0x
 0,  8,  8,1,  1378560, 0x3b28f549
-1,  16360,  16360, 1024, 8192, 0x668aaaec
-1,  17384,  17384, 1024, 8192, 0xd137d412
+1,  16360,  16360, 1024, 8192, 0x
+1,  17384,  17384, 1024, 8192, 0x
 0,  9,  9,1,  1378560, 0x45b2f57b
-1,  18408,  18408, 1024, 8192, 0x08e1fbf6
-1,  19416,  19416, 1024, 8192, 0xbf3fb4f6
+1,  18408,  18408, 1024, 8192, 0x
+1,  19416,  19416, 1024, 8192, 0x
 0, 10, 10,1,  1378560, 0x8955570e
-1,  20440,  20440, 1024, 8192, 0x69cd08a4
-1,  21464,  21464, 1024, 8192, 0xe0fe6297
-1,  22488,  22488, 1024, 8192, 0x172867ad
-1,  23496,  23496, 1024, 8192, 0xcbcc1461
+1,  20440,  20440, 1024, 8192, 0x
+1,  21464,  21464, 1024, 8192, 0x
+1,  22488,  22488, 1024, 8192, 0x
+1,  23496,  23496, 1024, 8192, 0x
 0, 12, 12,1,  1378560, 0x9c598000
 1,  25488,  25488, 1024, 8192, 0x
 0, 13, 13,1,  1378560, 0xbaf121ba
@@ -52,32 +52,32 @@
 1,  28552,  28552, 1024, 8192, 0x
 1,  29576,  29576, 1024, 8192, 0x
 0, 15, 15,1,  1378560, 0x6579d31a
-1,  30600,  30600, 1024, 8192, 

Re: [FFmpeg-devel] [PATCH 8/9] lavc/decode: move submitting input packets to bitstream filters

2023-06-20 Thread James Almer

On 6/20/2023 11:16 AM, Anton Khirnov wrote:

Do it from ff_decode_get_packet() rather than from
avcodec_send_packet(). This way all nontrivial stages of the decoding
pipeline (i.e. other than just placing a packet at its entrance) are
pull-based rather than a mix of push an pull.
---
  libavcodec/decode.c | 36 ++--
  1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index c61ce74fb8..8d892432be 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -193,14 +193,11 @@ fail:
  return ret;
  }
  
-int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)

+static int decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
  {
  AVCodecInternal *avci = avctx->internal;
  int ret;
  
-if (avci->draining)

-return AVERROR_EOF;
-
  ret = av_bsf_receive_packet(avci->bsf, pkt);
  if (ret == AVERROR_EOF)
  avci->draining = 1;
@@ -223,6 +220,31 @@ finish:
  return ret;
  }
  
+int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)

+{
+AVCodecInternal *avci = avctx->internal;
+
+if (avci->draining)
+return AVERROR_EOF;
+
+while (1) {
+int ret = decode_get_packet(avctx, pkt);
+if (ret == AVERROR(EAGAIN) &&
+(avci->buffer_pkt->data || avci->buffer_pkt->side_data_elems ||


nit: Since i removed the IS_EMPTY() macro recently from this file, you 
could move the one in bsf.c into packet_internal.h, rename it to 
something like AVPACKET_IS_EMPTY(), and use it here.




+ avci->d->draining_started)) {
+ret = av_bsf_send_packet(avci->bsf, avci->buffer_pkt);
+if (ret < 0) {
+av_packet_unref(avci->buffer_pkt);
+return ret;
+}
+
+continue;
+}
+
+return ret;
+}
+}
+
  /**
   * Attempt to guess proper monotonic timestamps for decoded video frames
   * which might have incorrect times. Input timestamps may wrap around, in
@@ -643,12 +665,6 @@ int attribute_align_arg avcodec_send_packet(AVCodecContext 
*avctx, const AVPacke
  } else
  avci->d->draining_started = 1;
  
-ret = av_bsf_send_packet(avci->bsf, avci->buffer_pkt);

-if (ret < 0) {
-av_packet_unref(avci->buffer_pkt);
-return ret;
-}
-
  if (!avci->buffer_frame->buf[0]) {
  ret = decode_receive_frame_internal(avctx, avci->buffer_frame);
  if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF)

___
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] overlay_vulkan: remove in favor of libplacebo

2023-06-20 Thread Nicolas George
Lynne (12023-06-20):
> Patch attached.
> 

> >From 453c513bb4960dee72228a8713375fce75a40482 Mon Sep 17 00:00:00 2001
> From: Lynne 
> Date: Tue, 20 Jun 2023 18:59:03 +0200
> Subject: [PATCH 2/2] lavfi: remove overlay_vulkan in favor of libplacebo

Similar questions than for the other patch:

Is libplacebo considered a system library?

Is overlaying not considered an integral part of FFmpeg's task?

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 1/2] lavfi: remove scale_vulkan filter

2023-06-20 Thread Nicolas George
Lynne (12023-06-20):
> libplacebo is better in every way for anything involving scaling or format 
> conversions

Is libplacebo considered a system library?

Are scaling and format conversions not considered essential parts of
FFmpeg's task?

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


[FFmpeg-devel] [PATCH 2/2] overlay_vulkan: remove in favor of libplacebo

2023-06-20 Thread Lynne
Patch attached.

>From 453c513bb4960dee72228a8713375fce75a40482 Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Tue, 20 Jun 2023 18:59:03 +0200
Subject: [PATCH 2/2] lavfi: remove overlay_vulkan in favor of libplacebo

---
 configure   |   1 -
 doc/filters.texi|  20 --
 libavfilter/Makefile|   1 -
 libavfilter/allfilters.c|   1 -
 libavfilter/vf_overlay_vulkan.c | 346 
 5 files changed, 369 deletions(-)
 delete mode 100644 libavfilter/vf_overlay_vulkan.c

diff --git a/configure b/configure
index 81ec58bacd..df3ae8cb77 100755
--- a/configure
+++ b/configure
@@ -3772,7 +3772,6 @@ overlay_opencl_filter_deps="opencl"
 overlay_qsv_filter_deps="libmfx"
 overlay_qsv_filter_select="qsvvpp"
 overlay_vaapi_filter_deps="vaapi VAProcPipelineCaps_blend_flags"
-overlay_vulkan_filter_deps="vulkan spirv_compiler"
 owdenoise_filter_deps="gpl"
 pad_opencl_filter_deps="opencl"
 pan_filter_deps="swresample"
diff --git a/doc/filters.texi b/doc/filters.texi
index f596773af6..bf70fadacb 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -27613,26 +27613,6 @@ Must be odd number in range [0, 99].
 
 @end table
 
-@section overlay_vulkan
-
-Overlay one video on top of another.
-
-It takes two inputs and has one output. The first input is the "main" video on which the second input is overlaid.
-This filter requires all inputs to use the same pixel format. So, format conversion may be needed.
-
-The filter accepts the following options:
-
-@table @option
-@item x
-Set the x coordinate of the overlaid video on the main video.
-Default value is @code{0}.
-
-@item y
-Set the y coordinate of the overlaid video on the main video.
-Default value is @code{0}.
-
-@end table
-
 @section transpose_vulkan
 
 Transpose rows with columns in the input video and optionally flip it.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 62e98bbb09..27c02570b2 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -409,7 +409,6 @@ OBJS-$(CONFIG_OVERLAY_OPENCL_FILTER) += vf_overlay_opencl.o opencl.o \
 opencl/overlay.o framesync.o
 OBJS-$(CONFIG_OVERLAY_QSV_FILTER)+= vf_overlay_qsv.o framesync.o
 OBJS-$(CONFIG_OVERLAY_VAAPI_FILTER)  += vf_overlay_vaapi.o framesync.o vaapi_vpp.o
-OBJS-$(CONFIG_OVERLAY_VULKAN_FILTER) += vf_overlay_vulkan.o vulkan.o vulkan_filter.o
 OBJS-$(CONFIG_OWDENOISE_FILTER)  += vf_owdenoise.o
 OBJS-$(CONFIG_PAD_FILTER)+= vf_pad.o
 OBJS-$(CONFIG_PAD_OPENCL_FILTER) += vf_pad_opencl.o opencl.o opencl/pad.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index eeb014248b..3b379a0d38 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -382,7 +382,6 @@ extern const AVFilter ff_vf_overlay;
 extern const AVFilter ff_vf_overlay_opencl;
 extern const AVFilter ff_vf_overlay_qsv;
 extern const AVFilter ff_vf_overlay_vaapi;
-extern const AVFilter ff_vf_overlay_vulkan;
 extern const AVFilter ff_vf_overlay_cuda;
 extern const AVFilter ff_vf_owdenoise;
 extern const AVFilter ff_vf_pad;
diff --git a/libavfilter/vf_overlay_vulkan.c b/libavfilter/vf_overlay_vulkan.c
deleted file mode 100644
index ef8e9fd59b..00
--- a/libavfilter/vf_overlay_vulkan.c
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * Copyright (c) Lynne
- *
- * 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/random_seed.h"
-#include "libavutil/opt.h"
-#include "vulkan_filter.h"
-#include "vulkan_spirv.h"
-#include "internal.h"
-#include "framesync.h"
-
-typedef struct OverlayVulkanContext {
-FFVulkanContext vkctx;
-FFFrameSync fs;
-
-int initialized;
-FFVulkanPipeline pl;
-FFVkExecPool e;
-FFVkQueueFamilyCtx qf;
-FFVkSPIRVShader shd;
-VkSampler sampler;
-
-/* Push constants / options */
-struct {
-int32_t o_offset[2*3];
-int32_t o_size[2*3];
-} opts;
-
-int overlay_x;
-int overlay_y;
-int overlay_w;
-int overlay_h;
-} OverlayVulkanContext;
-
-static const char overlay_noalpha[] = {
-C(0, void overlay_noalpha(int i, ivec2 pos))
-C(0, {   

[FFmpeg-devel] [PATCH 1/2] lavfi: remove scale_vulkan filter

2023-06-20 Thread Lynne
libplacebo is better in every way for anything involving scaling or format 
conversions

Patch attached.

>From 146e753f3e618cb986c2649f0776f66e99098dea Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Tue, 20 Jun 2023 18:56:26 +0200
Subject: [PATCH 1/2] lavfi: remove scale_vulkan filter

libplacebo is better in every way for anything involving scaling or format conversions
---
 configure |   1 -
 libavfilter/Makefile  |   1 -
 libavfilter/allfilters.c  |   1 -
 libavfilter/vf_scale_vulkan.c | 419 --
 4 files changed, 422 deletions(-)
 delete mode 100644 libavfilter/vf_scale_vulkan.c

diff --git a/configure b/configure
index ed9efad985..81ec58bacd 100755
--- a/configure
+++ b/configure
@@ -3831,7 +3831,6 @@ zmq_filter_deps="libzmq"
 zoompan_filter_deps="swscale"
 zscale_filter_deps="libzimg const_nan"
 scale_vaapi_filter_deps="vaapi"
-scale_vulkan_filter_deps="vulkan spirv_compiler"
 vpp_qsv_filter_deps="libmfx"
 vpp_qsv_filter_select="qsvvpp"
 xfade_opencl_filter_deps="opencl"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 9b7813575a..62e98bbb09 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -457,7 +457,6 @@ OBJS-$(CONFIG_SCALE_CUDA_FILTER) += vf_scale_cuda.o scale_eval.o \
 OBJS-$(CONFIG_SCALE_NPP_FILTER)  += vf_scale_npp.o scale_eval.o
 OBJS-$(CONFIG_SCALE_QSV_FILTER)  += vf_vpp_qsv.o
 OBJS-$(CONFIG_SCALE_VAAPI_FILTER)+= vf_scale_vaapi.o scale_eval.o vaapi_vpp.o
-OBJS-$(CONFIG_SCALE_VULKAN_FILTER)   += vf_scale_vulkan.o vulkan.o vulkan_filter.o
 OBJS-$(CONFIG_SCALE2REF_FILTER)  += vf_scale.o scale_eval.o
 OBJS-$(CONFIG_SCALE2REF_NPP_FILTER)  += vf_scale_npp.o scale_eval.o
 OBJS-$(CONFIG_SCDET_FILTER)  += vf_scdet.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 9a7fadc58d..eeb014248b 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -427,7 +427,6 @@ extern const AVFilter ff_vf_scale_cuda;
 extern const AVFilter ff_vf_scale_npp;
 extern const AVFilter ff_vf_scale_qsv;
 extern const AVFilter ff_vf_scale_vaapi;
-extern const AVFilter ff_vf_scale_vulkan;
 extern const AVFilter ff_vf_scale2ref;
 extern const AVFilter ff_vf_scale2ref_npp;
 extern const AVFilter ff_vf_scdet;
diff --git a/libavfilter/vf_scale_vulkan.c b/libavfilter/vf_scale_vulkan.c
deleted file mode 100644
index 3029cf2b42..00
--- a/libavfilter/vf_scale_vulkan.c
+++ /dev/null
@@ -1,419 +0,0 @@
-/*
- * Copyright (c) Lynne
- *
- * 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/random_seed.h"
-#include "libavutil/opt.h"
-#include "vulkan_filter.h"
-#include "vulkan_spirv.h"
-#include "scale_eval.h"
-#include "internal.h"
-#include "colorspace.h"
-
-enum ScalerFunc {
-F_BILINEAR = 0,
-F_NEAREST,
-
-F_NB,
-};
-
-typedef struct ScaleVulkanContext {
-FFVulkanContext vkctx;
-
-int initialized;
-FFVulkanPipeline pl;
-FFVkExecPool e;
-FFVkQueueFamilyCtx qf;
-FFVkSPIRVShader shd;
-VkSampler sampler;
-
-/* Push constants / options */
-struct {
-float yuv_matrix[4][4];
-} opts;
-
-char *out_format_string;
-char *w_expr;
-char *h_expr;
-
-enum ScalerFunc scaler;
-enum AVColorRange out_range;
-} ScaleVulkanContext;
-
-static const char scale_bilinear[] = {
-C(0, vec4 scale_bilinear(int idx, ivec2 pos, vec2 crop_range, vec2 crop_off))
-C(0, {  )
-C(1, vec2 npos = (vec2(pos) + 0.5f) / imageSize(output_img[idx]);   )
-C(1, npos *= crop_range;/* Reduce the range */  )
-C(1, npos += crop_off;  /* Offset the start */  )
-C(1, return texture(input_img[idx], npos);  )
-C(0, }  )
-};
-
-static const char rgb2yuv[] = {
-C(0, vec4 rgb2yuv(vec4 src, int fullrange)  )
-C(0, {  )
-C(1, src *= yuv_matrix; )
-   

Re: [FFmpeg-devel] [PATCH] avformat/avcodec: Add DTS-UHD demuxer and parser, movenc support.

2023-06-20 Thread Roy Funderburk

On 6/18/23 5:18 AM, Paul B Mahol wrote:
> Well, just keep that part as is currently, until someone else cleans it up.
> 
> Can probing in new demuxer be smarter than just decreasing score of another
> demuxer?


A new patch is attached where the dtshddec.c probe function change is updated 
to no longer just decrease the score.

Regards,
-Roy
--- Begin Message ---
Parsing of DTS-UHD input files per ETSI TS 102 114 is added
as parser for codec id AV_CODEC_ID_DTSUHD.

Signed-off-by: Roy Funderburk 
---
 libavcodec/Makefile|1 +
 libavcodec/codec_desc.c|7 +
 libavcodec/codec_id.h  |1 +
 libavcodec/dtsuhd_common.c | 1079 
 libavcodec/dtsuhd_common.h |   87 +++
 libavcodec/dtsuhd_parser.c |  141 +
 libavcodec/parsers.c   |1 +
 libavcodec/version.h   |2 +-
 8 files changed, 1318 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/dtsuhd_common.c
 create mode 100644 libavcodec/dtsuhd_common.h
 create mode 100644 libavcodec/dtsuhd_parser.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 2efab60d7d..0b49984902 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1164,6 +1164,7 @@ OBJS-$(CONFIG_DIRAC_PARSER)+= dirac_parser.o
 OBJS-$(CONFIG_DNXHD_PARSER)+= dnxhd_parser.o dnxhddata.o
 OBJS-$(CONFIG_DOLBY_E_PARSER)  += dolby_e_parser.o dolby_e_parse.o
 OBJS-$(CONFIG_DPX_PARSER)  += dpx_parser.o
+OBJS-$(CONFIG_DTSUHD_PARSER)   += dtsuhd_parser.o dtsuhd_common.o
 OBJS-$(CONFIG_DVAUDIO_PARSER)  += dvaudio_parser.o
 OBJS-$(CONFIG_DVBSUB_PARSER)   += dvbsub_parser.o
 OBJS-$(CONFIG_DVD_NAV_PARSER)  += dvd_nav_parser.o
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 3e31a1eed6..63dc939905 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -3406,6 +3406,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("RKA (RK Audio)"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY | 
AV_CODEC_PROP_LOSSLESS,
 },
+{
+.id= AV_CODEC_ID_DTSUHD,
+.type  = AVMEDIA_TYPE_AUDIO,
+.name  = "dtsuhd",
+.long_name = NULL_IF_CONFIG_SMALL("DTSUHD (DTS-UHD Audio Format)"),
+.props = AV_CODEC_PROP_LOSSY,
+},
 
 /* subtitle codecs */
 {
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index d23549d7e0..a5d580169b 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -542,6 +542,7 @@ enum AVCodecID {
 AV_CODEC_ID_FTR,
 AV_CODEC_ID_WAVARC,
 AV_CODEC_ID_RKA,
+AV_CODEC_ID_DTSUHD,
 
 /* subtitle codecs */
 AV_CODEC_ID_FIRST_SUBTITLE = 0x17000,  ///< A dummy ID pointing at 
the start of subtitle codecs.
diff --git a/libavcodec/dtsuhd_common.c b/libavcodec/dtsuhd_common.c
new file mode 100644
index 00..4d91172b33
--- /dev/null
+++ b/libavcodec/dtsuhd_common.c
@@ -0,0 +1,1079 @@
+/*
+ * DTS-UHD common audio frame parsing code
+ * Copyright (c) 2023 Xperi Corporation / DTS, Inc.
+ *
+ * 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
+ * Parse DTS-UHD audio frame headers, report frame sizes and configuration.
+ * Specification: ETSI TS 103 491 V1.2.1
+ */
+
+#include 
+
+#include "dtsuhd_common.h"
+#include "get_bits.h"
+#include "put_bits.h"
+#include "libavutil/channel_layout.h"
+#include "libavutil/crc.h"
+
+#define DTSUHD_ALLOC_INCREMENT 16
+#define DTSUHD_CHUNK_HEADER16
+#define DTSUHD_CRC_SEED0x
+#define DTSUHD_UDTS_BUFFER 32 // work buffer to construct 'udts' box
+
+enum RepType {
+REP_TYPE_CH_MASK_BASED,
+REP_TYPE_MTRX2D_CH_MASK_BASED,
+REP_TYPE_MTRX3D_CH_MASK_BASED,
+REP_TYPE_BINAURAL,
+REP_TYPE_AMBISONIC,
+REP_TYPE_AUDIO_TRACKS,
+REP_TYPE_3D_OBJECT_SINGLE_SRC_PER_WF,
+REP_TYPE_3D_MONO_OBJECT_SINGLE_SRC_PER_WF,
+};
+
+typedef struct MDObject {
+int started;  /* Object seen since last reset. */
+int pres_index;
+int rep_type;
+int ch_activity_mask;
+} MDObject;
+
+typedef struct MD01 {
+GetBitContext gb;
+MDObject object[257]; /* object id max value is 256 */
+int chunk_id;
+int object_list[256]; int 

Re: [FFmpeg-devel] [PATCH 3/6] avformat/jpegxl_anim_dec: add FF_JPEGXL_CONTAINER_SIGNATURE_LE

2023-06-20 Thread Leo Izen

On 6/19/23 13:01, Michael Niedermayer wrote:

On Sun, Jun 18, 2023 at 06:57:58PM -0400, Leo Izen wrote:

On 6/18/23 17:50, Michael Niedermayer wrote:

Fixes: out of array read
Fixes: 
59828/clusterfuzz-testcase-minimized-ffmpeg_dem_JPEGXL_ANIM_fuzzer-5029813220671488

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
   libavformat/jpegxl_anim_dec.c | 13 +++--
   1 file changed, 7 insertions(+), 6 deletions(-)



What's with the commit message? Seems unrelated to the change.


Must be some copy and paste mistake


Pushed with a different commit message as 6a9d13acc26b.

- Leo Izen

___
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] libavfilter/vf_drawtext: add letter_spacing as an evaluated parameter

2023-06-20 Thread Paul B Mahol
On Tue, Jun 20, 2023 at 4:27 PM Francesco Carusi 
wrote:

> You can find an overview of the changes here:
>
> https://github.com/yethie/FFmpeg/blob/master/drawtext/CHANGES.md
>
> and the new code here:
>
> https://github.com/yethie/FFmpeg/blob/master/libavfilter/vf_drawtext.c


This have been already merged, with some minor changes.


>
>
>
> On 19/06/2023 19:56, Mark Ren wrote:
> > Ah alright I see. When might that push come through and is there
> somewhere
> > I can look at the kind of changes in the meantime?
> >
> > On Mon, Jun 19, 2023 at 12:39 PM Paul B Mahol  wrote:
> >
> >>
> >> On Mon, Jun 19, 2023 at 6:34 PM Mark Ren  wrote:
> >>
> >>> When enabled it will add pixels (or subtract if given a negative value)
> >>> between each letters,
> >>> set use_kerning to false,
> >>> and add the pixels to text_w.
> >>>
> >> Conflicts with big drawtext filter set that will be pushed soon.
> >>
> >>
> >>> Signed-off-by: Mark Ren 
> >>> ---
> >>>   libavfilter/vf_drawtext.c | 24 
> >>>   1 file changed, 20 insertions(+), 4 deletions(-)
> >>>
> >>> diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
> >>> index 71ab851462..ec8313820d 100644
> >>> --- a/libavfilter/vf_drawtext.c
> >>> +++ b/libavfilter/vf_drawtext.c
> >>> @@ -183,6 +183,7 @@ typedef struct DrawTextContext {
> >>>   unsigned int fontsize;  ///< font size to use
> >>>   unsigned int default_fontsize;  ///< default font size to use
> >>>
> >>> +int letter_spacing; ///< letter spacing in pixels
> >>>   int line_spacing;   ///< lines spacing in pixels
> >>>   short int draw_box; ///< draw box around text - true
> or
> >>> false
> >>>   int boxborderw; ///< box border width
> >>> @@ -208,6 +209,8 @@ typedef struct DrawTextContext {
> >>>   char   *a_expr;
> >>>   AVExpr *a_pexpr;
> >>>   int alpha;
> >>> +char* letter_spacing_expr;  ///< expression for letter spacing
> >>> +AVExpr* letter_spacing_pexpr;   ///< parsed expression for letter
> >>> spacing
> >>>   AVLFG  prng;///< random
> >>>   char   *tc_opt_string;  ///< specified timecode option
> string
> >>>   AVRational  tc_rate;///< frame rate for timecode
> >>> @@ -237,6 +240,7 @@ static const AVOption drawtext_options[]= {
> >>>   {"shadowcolor", "set shadow color", OFFSET(shadowcolor.rgba),
> >>>   AV_OPT_TYPE_COLOR,  {.str="black"}, 0, 0, FLAGS},
> >>>   {"box", "set box",  OFFSET(draw_box),
> >>>   AV_OPT_TYPE_BOOL,   {.i64=0}, 0,1   , FLAGS},
> >>>   {"boxborderw",  "set box border width", OFFSET(boxborderw),
> >>>   AV_OPT_TYPE_INT,{.i64=0}, INT_MIN,  INT_MAX , FLAGS},
> >>> +{"letter_spacing", "set letter spacing in pixels",
> >>> OFFSET(letter_spacing_expr), AV_OPT_TYPE_STRING, {.str="0"}, 0, 0,
> FLAGS},
> >>>   {"line_spacing",  "set line spacing in pixels",
> >>> OFFSET(line_spacing),   AV_OPT_TYPE_INT,{.i64=0}, INT_MIN,
> >>> INT_MAX,FLAGS},
> >>>   {"fontsize","set font size",OFFSET(fontsize_expr),
> >>> AV_OPT_TYPE_STRING, {.str=NULL},  0, 0 , FLAGS},
> >>>   {"x",   "set x expression", OFFSET(x_expr),
> >>>   AV_OPT_TYPE_STRING, {.str="0"},   0, 0, FLAGS},
> >>> @@ -812,7 +816,7 @@ static av_cold int init(AVFilterContext *ctx)
> >>>  FT_STROKER_LINEJOIN_ROUND, 0);
> >>>   }
> >>>
> >>> -s->use_kerning = FT_HAS_KERNING(s->face);
> >>> +s->use_kerning = FT_HAS_KERNING(s->face) && !s->letter_spacing;
> >>>
> >>>   /* load the fallback glyph with code 0 */
> >>>   load_glyph(ctx, NULL, 0);
> >>> @@ -857,8 +861,9 @@ static av_cold void uninit(AVFilterContext *ctx)
> >>>   av_expr_free(s->y_pexpr);
> >>>   av_expr_free(s->a_pexpr);
> >>>   av_expr_free(s->fontsize_pexpr);
> >>> +av_expr_free(s->letter_spacing_pexpr);
> >>>
> >>> -s->x_pexpr = s->y_pexpr = s->a_pexpr = s->fontsize_pexpr = NULL;
> >>> +s->x_pexpr = s->y_pexpr = s->a_pexpr = s->fontsize_pexpr =
> >>> s->letter_spacing_pexpr = NULL;
> >>>
> >>>   av_freep(>positions);
> >>>   s->nb_positions = 0;
> >>> @@ -903,13 +908,16 @@ static int config_input(AVFilterLink *inlink)
> >>>   av_expr_free(s->x_pexpr);
> >>>   av_expr_free(s->y_pexpr);
> >>>   av_expr_free(s->a_pexpr);
> >>> -s->x_pexpr = s->y_pexpr = s->a_pexpr = NULL;
> >>> +av_expr_free(s->letter_spacing_pexpr);
> >>> +s->x_pexpr = s->y_pexpr = s->a_pexpr = s->letter_spacing_pexpr =
> >>> NULL;
> >>>
> >>>   if ((ret = av_expr_parse(>x_pexpr, expr = s->x_expr,
> var_names,
> >>>NULL, NULL, fun2_names, fun2, 0, ctx))
> < 0
> >>> ||
> >>>   (ret = av_expr_parse(>y_pexpr, expr = s->y_expr,
> var_names,
> >>>NULL, NULL, fun2_names, fun2, 0, ctx))
> < 0
> >>> ||
> >>>   (ret = 

[FFmpeg-devel] [PATCH] lavfi/vf_libplacebo: simplify SAR normalization

2023-06-20 Thread Niklas Haas
From: Niklas Haas 

The old logic was trying to be excessively clever in "deducing" that the
user wanted to stretch/scale the image when ow/oh differed from iw/ih
aspect ratio. But this is almost surely unintended except in
pathological cases, and in those cases users should simply disable
normalize_sar and do all the stretching/scaling logic themselves. This
is especially important in multi-input mode, where the canvas may be
vastly different from the input dimensions of any stream. Also, passing
through input 0 SAR in multi-input mode is arbitrary and nearly useless,
so again force output SAR to 1:1 here.
---
 libavfilter/vf_libplacebo.c | 19 ++-
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index 0f7c6481925..e58183a5caa 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -160,7 +160,6 @@ typedef struct LibplaceboContext {
 // Parsed expressions for input/output crop
 AVExpr *crop_x_pexpr, *crop_y_pexpr, *crop_w_pexpr, *crop_h_pexpr;
 AVExpr *pos_x_pexpr, *pos_y_pexpr, *pos_w_pexpr, *pos_h_pexpr;
-AVRational target_sar;
 float pad_crop_ratio;
 float corner_rounding;
 int force_original_aspect_ratio;
@@ -795,9 +794,9 @@ static void update_crops(AVFilterContext *ctx, 
LibplaceboInput *in,
 target->crop.y0 = av_expr_eval(s->pos_y_pexpr, s->var_values, 
NULL);
 target->crop.x1 = target->crop.x0 + s->var_values[VAR_POS_W];
 target->crop.y1 = target->crop.y0 + s->var_values[VAR_POS_H];
-
-if (s->target_sar.num) {
-float aspect = pl_rect2df_aspect(>crop) * 
av_q2d(s->target_sar);
+if (s->normalize_sar) {
+float aspect = pl_rect2df_aspect(>crop);
+aspect *= av_q2d(in->link->sample_aspect_ratio);
 pl_rect2df_aspect_set(>crop, aspect, 
s->pad_crop_ratio);
 }
 }
@@ -1188,7 +1187,6 @@ static int libplacebo_config_output(AVFilterLink *outlink)
 const AVPixFmtDescriptor *out_desc = av_pix_fmt_desc_get(outlink->format);
 AVHWFramesContext *hwfc;
 AVVulkanFramesContext *vkfc;
-AVRational scale_sar;
 
 /* Frame dimensions */
 RET(ff_scale_eval_dimensions(s, s->w_expr, s->h_expr, inlink, outlink,
@@ -1198,20 +1196,15 @@ static int libplacebo_config_output(AVFilterLink 
*outlink)
s->force_original_aspect_ratio,
s->force_divisible_by);
 
-scale_sar = (AVRational){outlink->h * inlink->w, outlink->w * inlink->h};
-if (inlink->sample_aspect_ratio.num)
-scale_sar = av_mul_q(scale_sar, inlink->sample_aspect_ratio);
-
-if (s->normalize_sar) {
-/* Apply all SAR during scaling, so we don't need to set the out SAR */
+if (s->normalize_sar || s->nb_inputs > 1) {
+/* SAR is normalized, or we have multiple inputs, set out to 1:1 */
 outlink->sample_aspect_ratio = (AVRational){ 1, 1 };
-s->target_sar = scale_sar;
 } else {
 /* This is consistent with other scale_* filters, which only
  * set the outlink SAR to be equal to the scale SAR iff the input SAR
  * was set to something nonzero */
 if (inlink->sample_aspect_ratio.num)
-outlink->sample_aspect_ratio = scale_sar;
+outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
 }
 
 /* Frame rate */
-- 
2.41.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] lavfi/vf_libplacebo: generalize to multiple inputs

2023-06-20 Thread Niklas Haas
On Tue, 20 Jun 2023 16:50:08 +0200 Marvin Scholz  wrote:
> On 18 Jun 2023, at 13:16, Niklas Haas wrote:
> 
> > Changes since v1:
> > - added explicit `if (s->inputs)` check to input_uninit() loop
> > - added extra `!s->status` check to handle case of negative PTS on
> >   status change (since `s->status_pts >= 0` would fail here)
> >
> >
> 
> Tested and LGTM from my side

Thanks, merged as 7be4434c...f998a618b.
___
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] flvdec: Check the avio_seek return value after reading a metadata packet

2023-06-20 Thread Armstrong Huang
In most cases, flv_read_metabody reads pass the beginning of the meta_pos.
If the beginning of the meta_pos had been flushed from the IO buffer,
we would not be able to seek to the right position (for a nonseekable stream).

Is better to check the seek result and skip the current flv body if necessary,
than to silently try to read from a
desynchronized stream that will only be interpreted as garbage.

Signed-off-by: Armstrong Huang 
---
 libavformat/flvdec.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index d83edff727..21ff73a1aa 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -1096,7 +1096,18 @@ retry:
 } else if (type == TYPE_UNKNOWN) {
 stream_type = FLV_STREAM_TYPE_DATA;
 }
-avio_seek(s->pb, meta_pos, SEEK_SET);
+if (avio_seek(s->pb, meta_pos, SEEK_SET) != meta_pos) {
+/**
+ * This can happen after flv_read_metabody
+ * above, on a non-seekable input, and the
+ * preceding data has been flushed out from
+ * the IO buffer.
+ */
+av_log(s, AV_LOG_ERROR,
+   "Unable to seek back to the meta_pos: %ld\n",
+   meta_pos);
+goto skip;
+}
 }
 } else {
 av_log(s, AV_LOG_DEBUG,
-- 
2.20.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] DRAFT: riscv: add Linux riscv_hwprobe()

2023-06-20 Thread Rémi Denis-Courmont
---
 configure |  2 ++
 libavutil/riscv/cpu.c | 54 ---
 2 files changed, 43 insertions(+), 13 deletions(-)

diff --git a/configure b/configure
index ed9efad985..8cad88cdd2 100755
--- a/configure
+++ b/configure
@@ -5412,6 +5412,8 @@ elif enabled ppc; then
 
 elif enabled riscv; then
 
+check_headers sys/hwprobe.h
+
 if test_cpp_condition stddef.h "__riscv_zbb"; then
 enable fast_clz
 fi
diff --git a/libavutil/riscv/cpu.c b/libavutil/riscv/cpu.c
index a9263dbb78..36432f9777 100644
--- a/libavutil/riscv/cpu.c
+++ b/libavutil/riscv/cpu.c
@@ -20,6 +20,7 @@
 
 #include "libavutil/cpu.h"
 #include "libavutil/cpu_internal.h"
+#include "libavutil/macros.h"
 #include "libavutil/log.h"
 #include "config.h"
 
@@ -27,26 +28,53 @@
 #include 
 #define HWCAP_RV(letter) (1ul << ((letter) - 'A'))
 #endif
+#ifdef HAVE_SYS_HWPROBE_H
+#include 
+#endif
 
 int ff_get_cpu_flags_riscv(void)
 {
 int ret = 0;
+#if defined (HAVE_SYS_HWPROBE_H)
+struct riscv_hwprobe pairs[] = {
+{ RISCV_HWPROBE_KEY_BASE_BEHAVIOR, 0 },
+{ RISCV_HWPROBE_KEY_IMA_EXT_0, 0 },
+};
+
+if (riscv_hwprobe(pairs, FF_ARRAY_ELEMS(pairs), 0, NULL, 0) == 0) {
+if (pairs[0].value & RISCV_HWPROBE_BASE_BEHAVIOR_IMA) {
+ret |= AV_CPU_FLAG_RVI;
+if (pairs[1].value & RISCV_HWPROBE_IMA_FD)
+ret |= AV_FLAG_RVF | AV_FLAG_RVD;
+# ifdef RISCV_HWPROBE_IMA_V
+if (pairs[1].value & RISCV_HWPROBE_IMA_V)
+ret |= AV_CPU_FLAG_RVV_I32 | AV_CPU_FLAG_RVV_I64
+ | AV_CPU_FLAG_RVV_F32 | AV_CPU_FLAG_RVV_F64;
+# endif
+# ifdef RISCV_HWPROBE_EXT_ZBB
+if (pairs[1].value & RISCV_HWPROBE_EXT_ZBB)
+ret |= AV_FLAG_RVB_BASIC;
+# endif
+} else
+#endif
 #if HAVE_GETAUXVAL
-const unsigned long hwcap = getauxval(AT_HWCAP);
+{
+const unsigned long hwcap = getauxval(AT_HWCAP);
 
-if (hwcap & HWCAP_RV('I'))
-ret |= AV_CPU_FLAG_RVI;
-if (hwcap & HWCAP_RV('F'))
-ret |= AV_CPU_FLAG_RVF;
-if (hwcap & HWCAP_RV('D'))
-ret |= AV_CPU_FLAG_RVD;
-if (hwcap & HWCAP_RV('B'))
-ret |= AV_CPU_FLAG_RVB_BASIC;
+if (hwcap & HWCAP_RV('I'))
+ret |= AV_CPU_FLAG_RVI;
+if (hwcap & HWCAP_RV('F'))
+ret |= AV_CPU_FLAG_RVF;
+if (hwcap & HWCAP_RV('D'))
+ret |= AV_CPU_FLAG_RVD;
+if (hwcap & HWCAP_RV('B'))
+ret |= AV_CPU_FLAG_RVB_BASIC;
 
-/* The V extension implies all Zve* functional subsets */
-if (hwcap & HWCAP_RV('V'))
-ret |= AV_CPU_FLAG_RVV_I32 | AV_CPU_FLAG_RVV_I64
- | AV_CPU_FLAG_RVV_F32 | AV_CPU_FLAG_RVV_F64;
+/* The V extension implies all Zve* functional subsets */
+if (hwcap & HWCAP_RV('V'))
+ ret |= AV_CPU_FLAG_RVV_I32 | AV_CPU_FLAG_RVV_I64
+  | AV_CPU_FLAG_RVV_F32 | AV_CPU_FLAG_RVV_F64;
+}
 #endif
 
 #ifdef __riscv_i
-- 
2.40.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] lavfi/vf_libplacebo: generalize to multiple inputs

2023-06-20 Thread Marvin Scholz
On 18 Jun 2023, at 13:16, Niklas Haas wrote:

> Changes since v1:
> - added explicit `if (s->inputs)` check to input_uninit() loop
> - added extra `!s->status` check to handle case of negative PTS on
>   status change (since `s->status_pts >= 0` would fail here)
>
>

Tested and LGTM from my side

> ___
> 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 9/9] avformat/evc: move NALU length and type parsing functions to a header

2023-06-20 Thread James Almer
Signed-off-by: James Almer 
---
 libavformat/evc.c|  5 ++---
 libavformat/evc.h| 30 ++
 libavformat/evcdec.c | 44 
 3 files changed, 36 insertions(+), 43 deletions(-)

diff --git a/libavformat/evc.c b/libavformat/evc.c
index 421ff84cb7..f6e53aa6cf 100644
--- a/libavformat/evc.c
+++ b/libavformat/evc.c
@@ -23,7 +23,6 @@
 #include "libavcodec/get_bits.h"
 #include "libavcodec/golomb.h"
 #include "libavcodec/evc.h"
-#include "libavcodec/evc_parse.h"
 #include "avformat.h"
 #include "avio.h"
 #include "evc.h"
@@ -361,7 +360,7 @@ int ff_isom_write_evcc(AVIOContext *pb, const uint8_t *data,
 evcc_init();
 
 while (bytes_to_read > EVC_NALU_LENGTH_PREFIX_SIZE) {
-nalu_size = evc_read_nal_unit_length(data, 
EVC_NALU_LENGTH_PREFIX_SIZE, pb);
+nalu_size = evc_read_nal_unit_length(data, 
EVC_NALU_LENGTH_PREFIX_SIZE);
 if (nalu_size == 0) break;
 
 data += EVC_NALU_LENGTH_PREFIX_SIZE;
@@ -369,7 +368,7 @@ int ff_isom_write_evcc(AVIOContext *pb, const uint8_t *data,
 
 if (bytes_to_read < nalu_size) break;
 
-nalu_type = evc_get_nalu_type(data, bytes_to_read, pb);
+nalu_type = evc_get_nalu_type(data, bytes_to_read);
 if (nalu_type < EVC_NOIDR_NUT || nalu_type > EVC_UNSPEC_NUT62) {
 ret = AVERROR_INVALIDDATA;
 goto end;
diff --git a/libavformat/evc.h b/libavformat/evc.h
index db56275fd8..46b27f7df7 100644
--- a/libavformat/evc.h
+++ b/libavformat/evc.h
@@ -24,9 +24,39 @@
 
 #include 
 #include "libavutil/rational.h"
+#include "libavcodec/evc.h"
 #include "avio.h"
 
+static inline int evc_get_nalu_type(const uint8_t *bits, int bits_size)
+{
+int unit_type_plus1 = 0;
 
+if (bits_size >= EVC_NALU_HEADER_SIZE) {
+unsigned char *p = (unsigned char *)bits;
+// forbidden_zero_bit
+if ((p[0] & 0x80) != 0)   // Cannot get bitstream information. 
Malformed bitstream.
+return -1;
+
+// nal_unit_type
+unit_type_plus1 = (p[0] >> 1) & 0x3F;
+}
+
+return unit_type_plus1 - 1;
+}
+
+static inline uint32_t evc_read_nal_unit_length(const uint8_t *bits, int 
bits_size)
+{
+uint32_t nalu_len = 0;
+
+if (bits_size >= EVC_NALU_LENGTH_PREFIX_SIZE) {
+unsigned char *p = (unsigned char *)bits;
+
+for (int i = 0; i < EVC_NALU_LENGTH_PREFIX_SIZE; i++)
+nalu_len = (nalu_len << 8) | p[i];
+}
+
+return nalu_len;
+}
 
 /**
  * Writes EVC sample metadata to the provided AVIOContext.
diff --git a/libavformat/evcdec.c b/libavformat/evcdec.c
index ef743028ae..73aab6c52f 100644
--- a/libavformat/evcdec.c
+++ b/libavformat/evcdec.c
@@ -31,6 +31,7 @@
 #include "rawdec.h"
 #include "avformat.h"
 #include "avio_internal.h"
+#include "evc.h"
 #include "internal.h"
 
 
@@ -59,43 +60,6 @@ static const AVClass evc_demuxer_class = {
 .version= LIBAVUTIL_VERSION_INT,
 };
 
-static int get_nalu_type(const uint8_t *bits, int bits_size)
-{
-int unit_type_plus1 = 0;
-
-if (bits_size >= EVC_NALU_HEADER_SIZE) {
-unsigned char *p = (unsigned char *)bits;
-// forbidden_zero_bit
-if ((p[0] & 0x80) != 0)   // Cannot get bitstream information. 
Malformed bitstream.
-return -1;
-
-// nal_unit_type
-unit_type_plus1 = (p[0] >> 1) & 0x3F;
-}
-
-return unit_type_plus1 - 1;
-}
-
-static uint32_t read_nal_unit_length(const uint8_t *bits, int bits_size)
-{
-uint32_t nalu_len = 0;
-
-if (bits_size >= EVC_NALU_LENGTH_PREFIX_SIZE) {
-
-int t = 0;
-unsigned char *p = (unsigned char *)bits;
-
-for (int i = 0; i < EVC_NALU_LENGTH_PREFIX_SIZE; i++)
-t = (t << 8) | p[i];
-
-nalu_len = t;
-if (nalu_len == 0)   // Invalid bitstream size
-return 0;
-}
-
-return nalu_len;
-}
-
 static int annexb_probe(const AVProbeData *p)
 {
 int nalu_type;
@@ -106,7 +70,7 @@ static int annexb_probe(const AVProbeData *p)
 
 while (bytes_to_read > EVC_NALU_LENGTH_PREFIX_SIZE) {
 
-nalu_size = read_nal_unit_length(bits, EVC_NALU_LENGTH_PREFIX_SIZE);
+nalu_size = evc_read_nal_unit_length(bits, 
EVC_NALU_LENGTH_PREFIX_SIZE);
 if (nalu_size == 0) break;
 
 bits += EVC_NALU_LENGTH_PREFIX_SIZE;
@@ -114,7 +78,7 @@ static int annexb_probe(const AVProbeData *p)
 
 if(bytes_to_read < nalu_size) break;
 
-nalu_type = get_nalu_type(bits, bytes_to_read);
+nalu_type = evc_get_nalu_type(bits, bytes_to_read);
 
 if (nalu_type == EVC_SPS_NUT)
 got_sps++;
@@ -199,7 +163,7 @@ static int evc_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 if (ret < 0)
 return ret;
 
-nalu_size = read_nal_unit_length((const uint8_t *), 
EVC_NALU_LENGTH_PREFIX_SIZE);
+nalu_size = evc_read_nal_unit_length((const uint8_t *), 
EVC_NALU_LENGTH_PREFIX_SIZE);
 if (!nalu_size || nalu_size > 

[FFmpeg-devel] [PATCH 8/9] avcodec/evc_parser: use a GetBitContext to parse entire NALUs

2023-06-20 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/evc_parse.c  | 22 --
 libavcodec/evc_parse.h  | 22 --
 libavcodec/evc_parser.c | 30 --
 3 files changed, 12 insertions(+), 62 deletions(-)

diff --git a/libavcodec/evc_parse.c b/libavcodec/evc_parse.c
index dee48e947b..eff4b7bc38 100644
--- a/libavcodec/evc_parse.c
+++ b/libavcodec/evc_parse.c
@@ -21,28 +21,6 @@
 #include "evc.h"
 #include "evc_parse.h"
 
-// nuh_temporal_id specifies a temporal identifier for the NAL unit
-int ff_evc_get_temporal_id(const uint8_t *bits, int bits_size, void *logctx)
-{
-int temporal_id = 0;
-uint16_t t = 0;
-
-if (bits_size < EVC_NALU_HEADER_SIZE) {
-av_log(logctx, AV_LOG_ERROR, "Can't read NAL unit header\n");
-return 0;
-}
-
-// forbidden_zero_bit
-if ((bits[0] & 0x80) != 0)
-return -1;
-
-t = AV_RB16(bits);
-
-temporal_id = (t >> 6) & 0x0007;
-
-return temporal_id;
-}
-
 // @see ISO_IEC_23094-1 (7.3.2.6 Slice layer RBSP syntax)
 int ff_evc_parse_slice_header(GetBitContext *gb, EVCParserSliceHeader *sh,
   const EVCParamSets *ps, enum EVCNALUnitType 
nalu_type)
diff --git a/libavcodec/evc_parse.h b/libavcodec/evc_parse.h
index 322f52c928..0f142976f5 100644
--- a/libavcodec/evc_parse.h
+++ b/libavcodec/evc_parse.h
@@ -81,25 +81,6 @@ typedef struct EVCParserPoc {
 int DocOffset;  // the decoding order count of the previous picture
 } EVCParserPoc;
 
-static inline int evc_get_nalu_type(const uint8_t *bits, int bits_size, void 
*logctx)
-{
-int unit_type_plus1 = 0;
-
-if (bits_size >= EVC_NALU_HEADER_SIZE) {
-unsigned char *p = (unsigned char *)bits;
-// forbidden_zero_bit
-if ((p[0] & 0x80) != 0) {
-av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit header\n");
-return -1;
-}
-
-// nal_unit_type
-unit_type_plus1 = (p[0] >> 1) & 0x3F;
-}
-
-return unit_type_plus1 - 1;
-}
-
 static inline uint32_t evc_read_nal_unit_length(const uint8_t *bits, int 
bits_size, void *logctx)
 {
 uint32_t nalu_len = 0;
@@ -114,9 +95,6 @@ static inline uint32_t evc_read_nal_unit_length(const 
uint8_t *bits, int bits_si
 return nalu_len;
 }
 
-// nuh_temporal_id specifies a temporal identifier for the NAL unit
-int ff_evc_get_temporal_id(const uint8_t *bits, int bits_size, void *logctx);
-
 int ff_evc_parse_slice_header(GetBitContext *gb, EVCParserSliceHeader *sh,
   const EVCParamSets *ps, enum EVCNALUnitType 
nalu_type);
 
diff --git a/libavcodec/evc_parser.c b/libavcodec/evc_parser.c
index ae399ef8cc..76790d8111 100644
--- a/libavcodec/evc_parser.c
+++ b/libavcodec/evc_parser.c
@@ -71,28 +71,29 @@ static int parse_nal_unit(AVCodecParserContext *s, 
AVCodecContext *avctx,
 return AVERROR_INVALIDDATA;
 }
 
+ret = init_get_bits8(, buf, buf_size);
+if (ret < 0)
+return ret;
+
 // @see ISO_IEC_23094-1_2020, 7.4.2.2 NAL unit header semantic (Table 4 - 
NAL unit type codes and NAL unit type classes)
 // @see enum EVCNALUnitType in evc.h
-nalu_type = evc_get_nalu_type(buf, buf_size, avctx);
-if (nalu_type < EVC_NOIDR_NUT || nalu_type > EVC_UNSPEC_NUT62) {
-av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit type: (%d)\n", 
nalu_type);
+if (get_bits1()) {// forbidden_zero_bit
+av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit header\n");
 return AVERROR_INVALIDDATA;
 }
 
-tid = ff_evc_get_temporal_id(buf, buf_size, avctx);
-if (tid < 0) {
-av_log(avctx, AV_LOG_ERROR, "Invalid temporial id: (%d)\n", tid);
+nalu_type = get_bits(, 6) - 1;
+if (nalu_type < EVC_NOIDR_NUT || nalu_type > EVC_UNSPEC_NUT62) {
+av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit type: (%d)\n", 
nalu_type);
 return AVERROR_INVALIDDATA;
 }
 
-buf += EVC_NALU_HEADER_SIZE;
-buf_size -= EVC_NALU_HEADER_SIZE;
+tid = get_bits(, 3);
+skip_bits(, 5); // nuh_reserved_zero_5bits
+skip_bits1();   // nuh_extension_flag
 
 switch (nalu_type) {
 case EVC_SPS_NUT:
-ret = init_get_bits8(, buf, buf_size);
-if (ret < 0)
-return ret;
 ret = ff_evc_parse_sps(, >ps);
 if (ret < 0) {
 av_log(avctx, AV_LOG_ERROR, "SPS parsing error\n");
@@ -100,9 +101,6 @@ static int parse_nal_unit(AVCodecParserContext *s, 
AVCodecContext *avctx,
 }
 break;
 case EVC_PPS_NUT:
-ret = init_get_bits8(, buf, buf_size);
-if (ret < 0)
-return ret;
 ret = ff_evc_parse_pps(, >ps);
 if (ret < 0) {
 av_log(avctx, AV_LOG_ERROR, "PPS parsing error\n");
@@ -116,10 +114,6 @@ static int parse_nal_unit(AVCodecParserContext *s, 
AVCodecContext *avctx,
 EVCParserSliceHeader sh;
 int bit_depth;
 
-ret = init_get_bits8(, buf, buf_size);
-if (ret < 0)
-return 

[FFmpeg-devel] [PATCH 7/9] avcodec/evc_frame_merge: use a GetBitContext to parse entire NALUs

2023-06-20 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/evc_frame_merge_bsf.c | 48 +++-
 1 file changed, 17 insertions(+), 31 deletions(-)

diff --git a/libavcodec/evc_frame_merge_bsf.c b/libavcodec/evc_frame_merge_bsf.c
index 3904170ebd..a9b44f4d10 100644
--- a/libavcodec/evc_frame_merge_bsf.c
+++ b/libavcodec/evc_frame_merge_bsf.c
@@ -74,57 +74,50 @@ static int evc_frame_merge_filter(AVBSFContext *bsf, 
AVPacket *out)
 {
 EVCFMergeContext *ctx = bsf->priv_data;
 AVPacket *in = ctx->in;
-uint8_t *buffer, *nalu = NULL;
+uint8_t *buffer;
 GetBitContext gb;
 enum EVCNALUnitType nalu_type;
-int tid, nalu_size = 0;
-int au_end_found = 0;
+uint32_t nalu_size;
+int tid, au_end_found = 0;
 int err;
 
 err = ff_bsf_get_packet_ref(bsf, in);
 if (err < 0)
 return err;
 
-nalu_size = evc_read_nal_unit_length(in->data, 
EVC_NALU_LENGTH_PREFIX_SIZE, bsf);
-if (nalu_size <= 0) {
-err = AVERROR_INVALIDDATA;
-goto end;
-}
-
-nalu = in->data + EVC_NALU_LENGTH_PREFIX_SIZE;
-nalu_size = in->size - EVC_NALU_LENGTH_PREFIX_SIZE;
-
 // NAL unit parsing needed to determine if end of AU was found
-if (nalu_size <= 0) {
+nalu_size = evc_read_nal_unit_length(in->data, 
EVC_NALU_LENGTH_PREFIX_SIZE, bsf);
+if (!nalu_size || nalu_size > INT_MAX) {
 av_log(bsf, AV_LOG_ERROR, "Invalid NAL unit size: (%d)\n", nalu_size);
 err = AVERROR_INVALIDDATA;
 goto end;
 }
 
+err = init_get_bits8(, in->data + EVC_NALU_LENGTH_PREFIX_SIZE, 
nalu_size);
+if (err < 0)
+return err;
+
 // @see ISO_IEC_23094-1_2020, 7.4.2.2 NAL unit header semantic (Table 4 - 
NAL unit type codes and NAL unit type classes)
 // @see enum EVCNALUnitType in evc.h
-nalu_type = evc_get_nalu_type(nalu, nalu_size, bsf);
-if (nalu_type < EVC_NOIDR_NUT || nalu_type > EVC_UNSPEC_NUT62) {
-av_log(bsf, AV_LOG_ERROR, "Invalid NAL unit type: (%d)\n", nalu_type);
+if (get_bits1()) {// forbidden_zero_bit
+av_log(bsf, AV_LOG_ERROR, "Invalid NAL unit header\n");
 err = AVERROR_INVALIDDATA;
 goto end;
 }
 
-tid = ff_evc_get_temporal_id(nalu, nalu_size, bsf);
-if (tid < 0) {
-av_log(bsf, AV_LOG_ERROR, "Invalid temporial id: (%d)\n", tid);
+nalu_type = get_bits(, 6) - 1;
+if (nalu_type < EVC_NOIDR_NUT || nalu_type > EVC_UNSPEC_NUT62) {
+av_log(bsf, AV_LOG_ERROR, "Invalid NAL unit type: (%d)\n", nalu_type);
 err = AVERROR_INVALIDDATA;
 goto end;
 }
 
-nalu += EVC_NALU_HEADER_SIZE;
-nalu_size -= EVC_NALU_HEADER_SIZE;
+tid = get_bits(, 3);
+skip_bits(, 5); // nuh_reserved_zero_5bits
+skip_bits1();   // nuh_extension_flag
 
 switch (nalu_type) {
 case EVC_SPS_NUT:
-err = init_get_bits8(, nalu, nalu_size);
-if (err < 0)
-return err;
 err = ff_evc_parse_sps(, >ps);
 if (err < 0) {
 av_log(bsf, AV_LOG_ERROR, "SPS parsing error\n");
@@ -132,9 +125,6 @@ static int evc_frame_merge_filter(AVBSFContext *bsf, 
AVPacket *out)
 }
 break;
 case EVC_PPS_NUT:
-err = init_get_bits8(, nalu, nalu_size);
-if (err < 0)
-return err;
 err = ff_evc_parse_pps(, >ps);
 if (err < 0) {
 av_log(bsf, AV_LOG_ERROR, "PPS parsing error\n");
@@ -145,10 +135,6 @@ static int evc_frame_merge_filter(AVBSFContext *bsf, 
AVPacket *out)
 case EVC_NOIDR_NUT: {
 EVCParserSliceHeader sh;
 
-err = init_get_bits8(, nalu, nalu_size);
-if (err < 0)
-return err;
-
 err = ff_evc_parse_slice_header(, , >ps, nalu_type);
 if (err < 0) {
 av_log(bsf, AV_LOG_ERROR, "Slice header parsing error\n");
-- 
2.41.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 6/9] avcodec/evc_parse: pass a GetBitContext to the slice header parsing function

2023-06-20 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/evc_frame_merge_bsf.c |  6 +++-
 libavcodec/evc_parse.c   | 52 ++--
 libavcodec/evc_parse.h   |  4 +--
 libavcodec/evc_parser.c  |  6 +++-
 4 files changed, 35 insertions(+), 33 deletions(-)

diff --git a/libavcodec/evc_frame_merge_bsf.c b/libavcodec/evc_frame_merge_bsf.c
index bd30a09b15..3904170ebd 100644
--- a/libavcodec/evc_frame_merge_bsf.c
+++ b/libavcodec/evc_frame_merge_bsf.c
@@ -145,7 +145,11 @@ static int evc_frame_merge_filter(AVBSFContext *bsf, 
AVPacket *out)
 case EVC_NOIDR_NUT: {
 EVCParserSliceHeader sh;
 
-err = ff_evc_parse_slice_header(, >ps, nalu_type, nalu, 
nalu_size);
+err = init_get_bits8(, nalu, nalu_size);
+if (err < 0)
+return err;
+
+err = ff_evc_parse_slice_header(, , >ps, nalu_type);
 if (err < 0) {
 av_log(bsf, AV_LOG_ERROR, "Slice header parsing error\n");
 goto end;
diff --git a/libavcodec/evc_parse.c b/libavcodec/evc_parse.c
index 0c35e40b47..dee48e947b 100644
--- a/libavcodec/evc_parse.c
+++ b/libavcodec/evc_parse.c
@@ -44,21 +44,15 @@ int ff_evc_get_temporal_id(const uint8_t *bits, int 
bits_size, void *logctx)
 }
 
 // @see ISO_IEC_23094-1 (7.3.2.6 Slice layer RBSP syntax)
-int ff_evc_parse_slice_header(EVCParserSliceHeader *sh, const EVCParamSets *ps,
-  enum EVCNALUnitType nalu_type, const uint8_t 
*bs, int bs_size)
+int ff_evc_parse_slice_header(GetBitContext *gb, EVCParserSliceHeader *sh,
+  const EVCParamSets *ps, enum EVCNALUnitType 
nalu_type)
 {
-GetBitContext gb;
 const EVCParserPPS *pps;
 const EVCParserSPS *sps;
-
 int num_tiles_in_slice = 0;
 int slice_pic_parameter_set_id;
-int ret;
-
-if ((ret = init_get_bits8(, bs, bs_size)) < 0)
-return ret;
 
-slice_pic_parameter_set_id = get_ue_golomb();
+slice_pic_parameter_set_id = get_ue_golomb(gb);
 
 if (slice_pic_parameter_set_id < 0 || slice_pic_parameter_set_id >= 
EVC_MAX_PPS_COUNT)
 return AVERROR_INVALIDDATA;
@@ -75,47 +69,47 @@ int ff_evc_parse_slice_header(EVCParserSliceHeader *sh, 
const EVCParamSets *ps,
 sh->slice_pic_parameter_set_id = slice_pic_parameter_set_id;
 
 if (!pps->single_tile_in_pic_flag) {
-sh->single_tile_in_slice_flag = get_bits1();
-sh->first_tile_id = get_bits(, pps->tile_id_len_minus1 + 1);
+sh->single_tile_in_slice_flag = get_bits1(gb);
+sh->first_tile_id = get_bits(gb, pps->tile_id_len_minus1 + 1);
 } else
 sh->single_tile_in_slice_flag = 1;
 
 if (!sh->single_tile_in_slice_flag) {
 if (pps->arbitrary_slice_present_flag)
-sh->arbitrary_slice_flag = get_bits1();
+sh->arbitrary_slice_flag = get_bits1(gb);
 
 if (!sh->arbitrary_slice_flag)
-sh->last_tile_id = get_bits(, pps->tile_id_len_minus1 + 1);
+sh->last_tile_id = get_bits(gb, pps->tile_id_len_minus1 + 1);
 else {
-sh->num_remaining_tiles_in_slice_minus1 = get_ue_golomb();
+sh->num_remaining_tiles_in_slice_minus1 = get_ue_golomb(gb);
 num_tiles_in_slice = sh->num_remaining_tiles_in_slice_minus1 + 2;
 for (int i = 0; i < num_tiles_in_slice - 1; ++i)
-sh->delta_tile_id_minus1[i] = get_ue_golomb();
+sh->delta_tile_id_minus1[i] = get_ue_golomb(gb);
 }
 }
 
-sh->slice_type = get_ue_golomb();
+sh->slice_type = get_ue_golomb(gb);
 
 if (nalu_type == EVC_IDR_NUT)
-sh->no_output_of_prior_pics_flag = get_bits1();
+sh->no_output_of_prior_pics_flag = get_bits1(gb);
 
 if (sps->sps_mmvd_flag && ((sh->slice_type == EVC_SLICE_TYPE_B) || 
(sh->slice_type == EVC_SLICE_TYPE_P)))
-sh->mmvd_group_enable_flag = get_bits1();
+sh->mmvd_group_enable_flag = get_bits1(gb);
 else
 sh->mmvd_group_enable_flag = 0;
 
 if (sps->sps_alf_flag) {
 int ChromaArrayType = sps->chroma_format_idc;
 
-sh->slice_alf_enabled_flag = get_bits1();
+sh->slice_alf_enabled_flag = get_bits1(gb);
 
 if (sh->slice_alf_enabled_flag) {
-sh->slice_alf_luma_aps_id = get_bits(, 5);
-sh->slice_alf_map_flag = get_bits1();
-sh->slice_alf_chroma_idc = get_bits(, 2);
+sh->slice_alf_luma_aps_id = get_bits(gb, 5);
+sh->slice_alf_map_flag = get_bits1(gb);
+sh->slice_alf_chroma_idc = get_bits(gb, 2);
 
 if ((ChromaArrayType == 1 || ChromaArrayType == 2) && 
sh->slice_alf_chroma_idc > 0)
-sh->slice_alf_chroma_aps_id =  get_bits(, 5);
+sh->slice_alf_chroma_aps_id =  get_bits(gb, 5);
 }
 if (ChromaArrayType == 3) {
 int sliceChromaAlfEnabledFlag = 0;
@@ -136,23 +130,23 @@ int ff_evc_parse_slice_header(EVCParserSliceHeader *sh, 
const EVCParamSets *ps,

[FFmpeg-devel] [PATCH 5/9] avcodec/evc_ps: pass a GetBitContext to the SPS and PPS parsing functions

2023-06-20 Thread James Almer
This is in preparation for the following patch.

Signed-off-by: James Almer 
---
 libavcodec/evc_frame_merge_bsf.c |  11 +-
 libavcodec/evc_parser.c  |  11 +-
 libavcodec/evc_ps.c  | 186 +++
 libavcodec/evc_ps.h  |   5 +-
 4 files changed, 109 insertions(+), 104 deletions(-)

diff --git a/libavcodec/evc_frame_merge_bsf.c b/libavcodec/evc_frame_merge_bsf.c
index 8e7ce9a2ab..bd30a09b15 100644
--- a/libavcodec/evc_frame_merge_bsf.c
+++ b/libavcodec/evc_frame_merge_bsf.c
@@ -75,6 +75,7 @@ static int evc_frame_merge_filter(AVBSFContext *bsf, AVPacket 
*out)
 EVCFMergeContext *ctx = bsf->priv_data;
 AVPacket *in = ctx->in;
 uint8_t *buffer, *nalu = NULL;
+GetBitContext gb;
 enum EVCNALUnitType nalu_type;
 int tid, nalu_size = 0;
 int au_end_found = 0;
@@ -121,14 +122,20 @@ static int evc_frame_merge_filter(AVBSFContext *bsf, 
AVPacket *out)
 
 switch (nalu_type) {
 case EVC_SPS_NUT:
-err = ff_evc_parse_sps(>ps, nalu, nalu_size);
+err = init_get_bits8(, nalu, nalu_size);
+if (err < 0)
+return err;
+err = ff_evc_parse_sps(, >ps);
 if (err < 0) {
 av_log(bsf, AV_LOG_ERROR, "SPS parsing error\n");
 goto end;
 }
 break;
 case EVC_PPS_NUT:
-err = ff_evc_parse_pps(>ps, nalu, nalu_size);
+err = init_get_bits8(, nalu, nalu_size);
+if (err < 0)
+return err;
+err = ff_evc_parse_pps(, >ps);
 if (err < 0) {
 av_log(bsf, AV_LOG_ERROR, "PPS parsing error\n");
 goto end;
diff --git a/libavcodec/evc_parser.c b/libavcodec/evc_parser.c
index 5c8fcc5970..8dd6b5fda7 100644
--- a/libavcodec/evc_parser.c
+++ b/libavcodec/evc_parser.c
@@ -62,6 +62,7 @@ static int parse_nal_unit(AVCodecParserContext *s, 
AVCodecContext *avctx,
   const uint8_t *buf, int buf_size)
 {
 EVCParserContext *ctx = s->priv_data;
+GetBitContext gb;
 int nalu_type, tid;
 int ret;
 
@@ -89,14 +90,20 @@ static int parse_nal_unit(AVCodecParserContext *s, 
AVCodecContext *avctx,
 
 switch (nalu_type) {
 case EVC_SPS_NUT:
-ret = ff_evc_parse_sps(>ps, buf, buf_size);
+ret = init_get_bits8(, buf, buf_size);
+if (ret < 0)
+return ret;
+ret = ff_evc_parse_sps(, >ps);
 if (ret < 0) {
 av_log(avctx, AV_LOG_ERROR, "SPS parsing error\n");
 return ret;
 }
 break;
 case EVC_PPS_NUT:
-ret = ff_evc_parse_pps(>ps, buf, buf_size);
+ret = init_get_bits8(, buf, buf_size);
+if (ret < 0)
+return ret;
+ret = ff_evc_parse_pps(, >ps);
 if (ret < 0) {
 av_log(avctx, AV_LOG_ERROR, "PPS parsing error\n");
 return ret;
diff --git a/libavcodec/evc_ps.c b/libavcodec/evc_ps.c
index ed39af104e..156f76554a 100644
--- a/libavcodec/evc_ps.c
+++ b/libavcodec/evc_ps.c
@@ -132,18 +132,13 @@ static int vui_parameters(GetBitContext *gb, 
VUIParameters *vui)
 }
 
 // @see ISO_IEC_23094-1 (7.3.2.1 SPS RBSP syntax)
-int ff_evc_parse_sps(EVCParamSets *ps, const uint8_t *bs, int bs_size)
+int ff_evc_parse_sps(GetBitContext *gb, EVCParamSets *ps)
 {
-GetBitContext gb;
 EVCParserSPS *sps;
 int sps_seq_parameter_set_id;
 int ret;
 
-ret = init_get_bits8(, bs, bs_size);
-if (ret < 0)
-return ret;
-
-sps_seq_parameter_set_id = get_ue_golomb();
+sps_seq_parameter_set_id = get_ue_golomb(gb);
 
 if (sps_seq_parameter_set_id >= EVC_MAX_SPS_COUNT)
 return AVERROR_INVALIDDATA;
@@ -158,74 +153,74 @@ int ff_evc_parse_sps(EVCParamSets *ps, const uint8_t *bs, 
int bs_size)
 
 // the Baseline profile is indicated by profile_idc eqal to 0
 // the Main profile is indicated by profile_idc eqal to 1
-sps->profile_idc = get_bits(, 8);
+sps->profile_idc = get_bits(gb, 8);
 
-sps->level_idc = get_bits(, 8);
+sps->level_idc = get_bits(gb, 8);
 
-skip_bits_long(, 32); /* skip toolset_idc_h */
-skip_bits_long(, 32); /* skip toolset_idc_l */
+skip_bits_long(gb, 32); /* skip toolset_idc_h */
+skip_bits_long(gb, 32); /* skip toolset_idc_l */
 
 // 0 - monochrome
 // 1 - 4:2:0
 // 2 - 4:2:2
 // 3 - 4:4:4
-sps->chroma_format_idc = get_ue_golomb();
+sps->chroma_format_idc = get_ue_golomb(gb);
 
-sps->pic_width_in_luma_samples = get_ue_golomb();
-sps->pic_height_in_luma_samples = get_ue_golomb();
+sps->pic_width_in_luma_samples = get_ue_golomb(gb);
+sps->pic_height_in_luma_samples = get_ue_golomb(gb);
 
-sps->bit_depth_luma_minus8 = get_ue_golomb();
-sps->bit_depth_chroma_minus8 = get_ue_golomb();
+sps->bit_depth_luma_minus8 = get_ue_golomb(gb);
+sps->bit_depth_chroma_minus8 = get_ue_golomb(gb);
 
-sps->sps_btt_flag = get_bits1();
+sps->sps_btt_flag = get_bits1(gb);
 if (sps->sps_btt_flag) {
-

[FFmpeg-devel] [PATCH 4/9] avformat/evcdec: use an unsigned type for nalu_size

2023-06-20 Thread James Almer
But ensure the value returned by evc_read_nal_unit_length() fits in an int.
Should prevent integer overflows later in the code.

Signed-off-by: James Almer 
---
 libavformat/evcdec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/evcdec.c b/libavformat/evcdec.c
index 842258d229..ef743028ae 100644
--- a/libavformat/evcdec.c
+++ b/libavformat/evcdec.c
@@ -181,7 +181,7 @@ fail:
 static int evc_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
 int ret;
-int32_t nalu_size;
+uint32_t nalu_size;
 int au_end_found = 0;
 EVCDemuxContext *const c = s->priv_data;
 
@@ -200,7 +200,7 @@ static int evc_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 return ret;
 
 nalu_size = read_nal_unit_length((const uint8_t *), 
EVC_NALU_LENGTH_PREFIX_SIZE);
-if (nalu_size <= 0)
+if (!nalu_size || nalu_size > INT_MAX)
 return AVERROR_INVALIDDATA;
 
 avio_seek(s->pb, -EVC_NALU_LENGTH_PREFIX_SIZE, SEEK_CUR);
-- 
2.41.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 3/9] avformat/evcdec: flush the bsf on EOF

2023-06-20 Thread James Almer
Signed-off-by: James Almer 
---
 libavformat/evcdec.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/evcdec.c b/libavformat/evcdec.c
index 68f3a91e53..842258d229 100644
--- a/libavformat/evcdec.c
+++ b/libavformat/evcdec.c
@@ -183,15 +183,14 @@ static int evc_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 int ret;
 int32_t nalu_size;
 int au_end_found = 0;
-
 EVCDemuxContext *const c = s->priv_data;
 
-if (avio_feof(s->pb))
-return AVERROR_EOF;
-
 while(!au_end_found) {
 uint8_t buf[EVC_NALU_LENGTH_PREFIX_SIZE];
 
+if (avio_feof(s->pb))
+goto end;
+
 ret = ffio_ensure_seekback(s->pb, EVC_NALU_LENGTH_PREFIX_SIZE);
 if (ret < 0)
 return ret;
@@ -212,6 +211,7 @@ static int evc_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 if (ret != (nalu_size + EVC_NALU_LENGTH_PREFIX_SIZE))
 return AVERROR_INVALIDDATA;
 
+end:
 ret = av_bsf_send_packet(c->bsf, pkt);
 if (ret < 0) {
 av_log(s, AV_LOG_ERROR, "Failed to send packet to "
-- 
2.41.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/9] avformat/evcdec: remove unnecessary av_packet_unref() calls

2023-06-20 Thread James Almer
And return proper error codes.

Signed-off-by: James Almer 
---
 libavformat/evcdec.c | 17 +
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/libavformat/evcdec.c b/libavformat/evcdec.c
index 9c4969e78f..68f3a91e53 100644
--- a/libavformat/evcdec.c
+++ b/libavformat/evcdec.c
@@ -186,11 +186,8 @@ static int evc_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 
 EVCDemuxContext *const c = s->priv_data;
 
-int eof = avio_feof (s->pb);
-if(eof) {
-av_packet_unref(pkt);
+if (avio_feof(s->pb))
 return AVERROR_EOF;
-}
 
 while(!au_end_found) {
 uint8_t buf[EVC_NALU_LENGTH_PREFIX_SIZE];
@@ -200,16 +197,12 @@ static int evc_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 return ret;
 
 ret = avio_read(s->pb, (unsigned char *), 
EVC_NALU_LENGTH_PREFIX_SIZE);
-if (ret < 0) {
-av_packet_unref(pkt);
+if (ret < 0)
 return ret;
-}
 
 nalu_size = read_nal_unit_length((const uint8_t *), 
EVC_NALU_LENGTH_PREFIX_SIZE);
-if(nalu_size <= 0) {
-av_packet_unref(pkt);
-return -1;
-}
+if (nalu_size <= 0)
+return AVERROR_INVALIDDATA;
 
 avio_seek(s->pb, -EVC_NALU_LENGTH_PREFIX_SIZE, SEEK_CUR);
 
@@ -217,7 +210,7 @@ static int evc_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 if (ret < 0)
 return ret;
 if (ret != (nalu_size + EVC_NALU_LENGTH_PREFIX_SIZE))
-return AVERROR(EIO);
+return AVERROR_INVALIDDATA;
 
 ret = av_bsf_send_packet(c->bsf, pkt);
 if (ret < 0) {
-- 
2.41.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 1/9] avformat/evcdec: ensure there are enough bytes to seekback

2023-06-20 Thread James Almer
Signed-off-by: James Almer 
---
 libavformat/evcdec.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavformat/evcdec.c b/libavformat/evcdec.c
index 890babd3cb..9c4969e78f 100644
--- a/libavformat/evcdec.c
+++ b/libavformat/evcdec.c
@@ -30,6 +30,7 @@
 
 #include "rawdec.h"
 #include "avformat.h"
+#include "avio_internal.h"
 #include "internal.h"
 
 
@@ -192,8 +193,12 @@ static int evc_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 }
 
 while(!au_end_found) {
-
 uint8_t buf[EVC_NALU_LENGTH_PREFIX_SIZE];
+
+ret = ffio_ensure_seekback(s->pb, EVC_NALU_LENGTH_PREFIX_SIZE);
+if (ret < 0)
+return ret;
+
 ret = avio_read(s->pb, (unsigned char *), 
EVC_NALU_LENGTH_PREFIX_SIZE);
 if (ret < 0) {
 av_packet_unref(pkt);
-- 
2.41.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 11/17] avformat/evc: don't use an AVIOContext as log context

2023-06-20 Thread James Almer

On 6/18/2023 8:43 PM, James Almer wrote:

Signed-off-by: James Almer 
---
  libavcodec/evc_parse.h | 3 ++-
  libavformat/evc.c  | 4 ++--
  2 files changed, 4 insertions(+), 3 deletions(-)


Dropped patches 11 and 12, pushed patches 13 to 17.
___
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/3] closed caption decoder: accept and decode a new codec type of 'raw 608 byte pairs'

2023-06-20 Thread Devin Heitmueller
Hi Roger,

On Mon, Jun 19, 2023 at 8:50 PM Roger Pack  wrote:
>
> OK updated patches to work with latest git master, made coded id less verbose.
> These have been tested against a "real device" and seem to work properly.
> I'd like to get feedback on the Closed caption decoder first if that's 
> possible.
> I pinged the decoder "maintainer" about it once and didn't get a
> response so seems it's up to us.
>
> Thank you.
> -=roger=-

First off, to be clear, I'm generally supportive of your efforts to
extend the DirectShow interface to support delivery of 608 captions.
That said, I have some concerns about the specific approach you've
taken, and in particular the notion of introducing a new codec type.

It's been a while since I've looked at the BDA interface for the VBI
slicer, but IIRC there are two CC output pins, and the first one
delivers the sliced byte pairs for CC1/CC2 and the second pin delivers
CC3/CC4.  Your patch to the Directshow driver though only operates on
the first pin, so any captions on CC3/CC4 would be lost.

Further, your new codec provides no way to know whether the packets
containing the byte pairs are for CC1/CC2 or CC3/CC4.  We need to be
able to distinguish between the two, since knowing which service is
carrying the captions is important and some data types (e.g. XDS) are
only delivered on certain services.  The original AV_CODEC_ID_EIA_608
codec allows downstream components processing the packets to know
which pair it is based on the prefix byte.

My inclination is that adding a new codec type creates additional
maintenance headaches, as various components needs to be modified to
handle both codecs, and in fact the *only* difference between your
codec and the existing one is the presence of the prefix byte (which
is actually needed in order to tell which pair it is).  So why not
simply have the directshow component add the 0xFC byte to the front of
the payload for CC1/CC2 and 0xFD for CC3/CC4?  Doing this would allow
everything else to stay the same and no additional codec would be
required?  It would also allow you to add support for CC3/CC4 after
wiring it up to the other CC output pin on the BDA VBI slicer?

In other words, it seems like a 1-line change to the dshow patch would
eliminate the need for the first patch completely.

On a side-note, it's probably worth noting that using a three-byte
payload predates CEA-708.  The prefix byte was present in earlier
standards such as use in DVD GOPs, although the actual structure of
the prefix byte differs in various standards.  While the format for
the ffmpeg codec does match what's found in CEA-708, that's mostly
just for the sake of consistency.

Devin

-- 
Devin Heitmueller, Senior Software Engineer
LTN Global Communications
o: +1 (301) 363-1001
w: https://ltnglobal.com  e: devin.heitmuel...@ltnglobal.com
___
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] libavfilter/vf_drawtext: add letter_spacing as an evaluated parameter

2023-06-20 Thread Francesco Carusi

You can find an overview of the changes here:

https://github.com/yethie/FFmpeg/blob/master/drawtext/CHANGES.md

and the new code here:

https://github.com/yethie/FFmpeg/blob/master/libavfilter/vf_drawtext.c


On 19/06/2023 19:56, Mark Ren wrote:

Ah alright I see. When might that push come through and is there somewhere
I can look at the kind of changes in the meantime?

On Mon, Jun 19, 2023 at 12:39 PM Paul B Mahol  wrote:



On Mon, Jun 19, 2023 at 6:34 PM Mark Ren  wrote:


When enabled it will add pixels (or subtract if given a negative value)
between each letters,
set use_kerning to false,
and add the pixels to text_w.


Conflicts with big drawtext filter set that will be pushed soon.



Signed-off-by: Mark Ren 
---
  libavfilter/vf_drawtext.c | 24 
  1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 71ab851462..ec8313820d 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -183,6 +183,7 @@ typedef struct DrawTextContext {
  unsigned int fontsize;  ///< font size to use
  unsigned int default_fontsize;  ///< default font size to use

+int letter_spacing; ///< letter spacing in pixels
  int line_spacing;   ///< lines spacing in pixels
  short int draw_box; ///< draw box around text - true or
false
  int boxborderw; ///< box border width
@@ -208,6 +209,8 @@ typedef struct DrawTextContext {
  char   *a_expr;
  AVExpr *a_pexpr;
  int alpha;
+char* letter_spacing_expr;  ///< expression for letter spacing
+AVExpr* letter_spacing_pexpr;   ///< parsed expression for letter
spacing
  AVLFG  prng;///< random
  char   *tc_opt_string;  ///< specified timecode option string
  AVRational  tc_rate;///< frame rate for timecode
@@ -237,6 +240,7 @@ static const AVOption drawtext_options[]= {
  {"shadowcolor", "set shadow color", OFFSET(shadowcolor.rgba),
  AV_OPT_TYPE_COLOR,  {.str="black"}, 0, 0, FLAGS},
  {"box", "set box",  OFFSET(draw_box),
  AV_OPT_TYPE_BOOL,   {.i64=0}, 0,1   , FLAGS},
  {"boxborderw",  "set box border width", OFFSET(boxborderw),
  AV_OPT_TYPE_INT,{.i64=0}, INT_MIN,  INT_MAX , FLAGS},
+{"letter_spacing", "set letter spacing in pixels",
OFFSET(letter_spacing_expr), AV_OPT_TYPE_STRING, {.str="0"}, 0, 0, FLAGS},
  {"line_spacing",  "set line spacing in pixels",
OFFSET(line_spacing),   AV_OPT_TYPE_INT,{.i64=0}, INT_MIN,
INT_MAX,FLAGS},
  {"fontsize","set font size",OFFSET(fontsize_expr),
AV_OPT_TYPE_STRING, {.str=NULL},  0, 0 , FLAGS},
  {"x",   "set x expression", OFFSET(x_expr),
  AV_OPT_TYPE_STRING, {.str="0"},   0, 0, FLAGS},
@@ -812,7 +816,7 @@ static av_cold int init(AVFilterContext *ctx)
 FT_STROKER_LINEJOIN_ROUND, 0);
  }

-s->use_kerning = FT_HAS_KERNING(s->face);
+s->use_kerning = FT_HAS_KERNING(s->face) && !s->letter_spacing;

  /* load the fallback glyph with code 0 */
  load_glyph(ctx, NULL, 0);
@@ -857,8 +861,9 @@ static av_cold void uninit(AVFilterContext *ctx)
  av_expr_free(s->y_pexpr);
  av_expr_free(s->a_pexpr);
  av_expr_free(s->fontsize_pexpr);
+av_expr_free(s->letter_spacing_pexpr);

-s->x_pexpr = s->y_pexpr = s->a_pexpr = s->fontsize_pexpr = NULL;
+s->x_pexpr = s->y_pexpr = s->a_pexpr = s->fontsize_pexpr =
s->letter_spacing_pexpr = NULL;

  av_freep(>positions);
  s->nb_positions = 0;
@@ -903,13 +908,16 @@ static int config_input(AVFilterLink *inlink)
  av_expr_free(s->x_pexpr);
  av_expr_free(s->y_pexpr);
  av_expr_free(s->a_pexpr);
-s->x_pexpr = s->y_pexpr = s->a_pexpr = NULL;
+av_expr_free(s->letter_spacing_pexpr);
+s->x_pexpr = s->y_pexpr = s->a_pexpr = s->letter_spacing_pexpr =
NULL;

  if ((ret = av_expr_parse(>x_pexpr, expr = s->x_expr, var_names,
   NULL, NULL, fun2_names, fun2, 0, ctx)) < 0
||
  (ret = av_expr_parse(>y_pexpr, expr = s->y_expr, var_names,
   NULL, NULL, fun2_names, fun2, 0, ctx)) < 0
||
  (ret = av_expr_parse(>a_pexpr, expr = s->a_expr, var_names,
+ NULL, NULL, fun2_names, fun2, 0, ctx)) < 0
||
+(ret = av_expr_parse(>letter_spacing_pexpr, expr =
s->letter_spacing_expr, var_names,
   NULL, NULL, fun2_names, fun2, 0, ctx)) < 0)
{
  av_log(ctx, AV_LOG_ERROR, "Failed to parse expression: %s \n",
expr);
  return AVERROR(EINVAL);
@@ -1525,6 +1533,9 @@ continue_on_invalid2:
  dummy.fontsize = s->fontsize;
  glyph = av_tree_find(s->glyphs, , glyph_cmp, NULL);

+/* letter spacing */
+x += s->letter_spacing;
+
  /* kerning */
  if (s->use_kerning && prev_glyph && glyph->code) {
 

[FFmpeg-devel] [PATCH 5/9] lavc: add generic-encode-layer private data

2023-06-20 Thread Anton Khirnov
Move AVCodecInternal.intra_only_flag to it, should should not be visible
outside of encode.c.
---
 libavcodec/avcodec.c  |  2 +-
 libavcodec/avcodec_internal.h |  1 +
 libavcodec/encode.c   | 26 --
 libavcodec/internal.h | 13 ++---
 4 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index ff251d2dae..21d1e42c10 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -152,7 +152,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext 
*avctx, const AVCodec *code
 
 avci = av_codec_is_decoder(codec) ?
 ff_decode_internal_alloc():
-av_mallocz(sizeof(AVCodecInternal));
+ff_encode_internal_alloc();
 if (!avci) {
 ret = AVERROR(ENOMEM);
 goto end;
diff --git a/libavcodec/avcodec_internal.h b/libavcodec/avcodec_internal.h
index f52f91e07c..9b93ff3d81 100644
--- a/libavcodec/avcodec_internal.h
+++ b/libavcodec/avcodec_internal.h
@@ -54,5 +54,6 @@ void ff_decode_flush_buffers(struct AVCodecContext *avctx);
 void ff_encode_flush_buffers(struct AVCodecContext *avctx);
 
 struct AVCodecInternal *ff_decode_internal_alloc(void);
+struct AVCodecInternal *ff_encode_internal_alloc(void);
 
 #endif // AVCODEC_AVCODEC_INTERNAL_H
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 6d0ef2be10..4273dceb31 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -33,6 +33,15 @@
 #include "frame_thread_encoder.h"
 #include "internal.h"
 
+struct EncodeContext {
+/**
+ * This is set to AV_PKT_FLAG_KEY for encoders that encode intra-only
+ * formats (i.e. whose codec descriptor has AV_CODEC_PROP_INTRA_ONLY set).
+ * This is used to set said flag generically for said encoders.
+ */
+int intra_only_flag;
+};
+
 int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
 {
 if (size < 0 || size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE) {
@@ -372,7 +381,7 @@ static int encode_receive_packet_internal(AVCodecContext 
*avctx, AVPacket *avpkt
 } else
 ret = encode_simple_receive_packet(avctx, avpkt);
 if (ret >= 0)
-avpkt->flags |= avci->intra_only_flag;
+avpkt->flags |= avci->e->intra_only_flag;
 
 if (ret == AVERROR_EOF)
 avci->draining_done = 1;
@@ -710,7 +719,7 @@ int ff_encode_preinit(AVCodecContext *avctx)
 avctx->rc_initial_buffer_occupancy = avctx->rc_buffer_size * 3LL / 4;
 
 if (avctx->codec_descriptor->props & AV_CODEC_PROP_INTRA_ONLY)
-avctx->internal->intra_only_flag = AV_PKT_FLAG_KEY;
+avctx->internal->e->intra_only_flag = AV_PKT_FLAG_KEY;
 
 if (ffcodec(avctx->codec)->cb_type == FF_CODEC_CB_TYPE_ENCODE) {
 avci->in_frame = av_frame_alloc();
@@ -803,3 +812,16 @@ void ff_encode_flush_buffers(AVCodecContext *avctx)
 if (avci->recon_frame)
 av_frame_unref(avci->recon_frame);
 }
+
+AVCodecInternal *ff_encode_internal_alloc(void)
+{
+struct Dummy {
+AVCodecInternal   i;
+EncodeContext e;
+} *dummy = av_mallocz(sizeof(*dummy));
+if (!dummy)
+return NULL;
+dummy->i.e = >e;
+
+return >i;
+}
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index b672092ac4..2f4aee8ecc 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -50,6 +50,7 @@
 #endif
 
 typedef struct DecodeContext DecodeContext;
+typedef struct EncodeContext EncodeContext;
 
 typedef struct AVCodecInternal {
 /**
@@ -57,6 +58,11 @@ typedef struct AVCodecInternal {
  */
 DecodeContext *d;
 
+/**
+ * Generic decoding private data.
+ */
+EncodeContext *e;
+
 /**
  * When using frame-threaded decoding, this field is set for the first
  * worker thread (e.g. to decode extradata just once).
@@ -102,13 +108,6 @@ typedef struct AVCodecInternal {
 uint8_t *byte_buffer;
 unsigned int byte_buffer_size;
 
-/**
- * This is set to AV_PKT_FLAG_KEY for encoders that encode intra-only
- * formats (i.e. whose codec descriptor has AV_CODEC_PROP_INTRA_ONLY set).
- * This is used to set said flag generically for said encoders.
- */
-int intra_only_flag;
-
 void *frame_thread_encoder;
 
 /**
-- 
2.40.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 2/9] lavc/avcodec: split flushing into decode- and encode-specific functions

2023-06-20 Thread Anton Khirnov
Will allow making some state private to encoding/decoding in the future.
---
 libavcodec/avcodec.c  | 26 ++
 libavcodec/avcodec_internal.h |  3 +++
 libavcodec/decode.c   | 15 +++
 libavcodec/encode.c   | 18 ++
 4 files changed, 38 insertions(+), 24 deletions(-)

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index 638cb55146..a5cb6035b6 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -373,33 +373,11 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
 {
 AVCodecInternal *avci = avctx->internal;
 
-if (av_codec_is_encoder(avctx->codec)) {
-int caps = avctx->codec->capabilities;
-
-if (!(caps & AV_CODEC_CAP_ENCODER_FLUSH)) {
-// Only encoders that explicitly declare support for it can be
-// flushed. Otherwise, this is a no-op.
-av_log(avctx, AV_LOG_WARNING, "Ignoring attempt to flush encoder "
-   "that doesn't support it\n");
-return;
-}
-if (avci->in_frame)
-av_frame_unref(avci->in_frame);
-if (avci->recon_frame)
-av_frame_unref(avci->recon_frame);
-} else {
-av_packet_unref(avci->last_pkt_props);
-av_packet_unref(avci->in_pkt);
-
-avctx->pts_correction_last_pts =
-avctx->pts_correction_last_dts = INT64_MIN;
-
-av_bsf_flush(avci->bsf);
-}
+av_codec_is_encoder(avctx->codec) ?
+ff_encode_flush_buffers(avctx) : ff_decode_flush_buffers(avctx);
 
 avci->draining  = 0;
 avci->draining_done = 0;
-avci->nb_draining_errors = 0;
 av_frame_unref(avci->buffer_frame);
 av_packet_unref(avci->buffer_pkt);
 
diff --git a/libavcodec/avcodec_internal.h b/libavcodec/avcodec_internal.h
index be60a36644..6ffe575c3e 100644
--- a/libavcodec/avcodec_internal.h
+++ b/libavcodec/avcodec_internal.h
@@ -50,4 +50,7 @@ int ff_encode_preinit(struct AVCodecContext *avctx);
  */
 int ff_decode_preinit(struct AVCodecContext *avctx);
 
+void ff_decode_flush_buffers(struct AVCodecContext *avctx);
+void ff_encode_flush_buffers(struct AVCodecContext *avctx);
+
 #endif // AVCODEC_AVCODEC_INTERNAL_H
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 8adb532616..7d000fec32 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1739,3 +1739,18 @@ AVBufferRef *ff_hwaccel_frame_priv_alloc(AVCodecContext 
*avctx,
 
 return ref;
 }
+
+void ff_decode_flush_buffers(AVCodecContext *avctx)
+{
+AVCodecInternal *avci = avctx->internal;
+
+av_packet_unref(avci->last_pkt_props);
+av_packet_unref(avci->in_pkt);
+
+avctx->pts_correction_last_pts =
+avctx->pts_correction_last_dts = INT64_MIN;
+
+av_bsf_flush(avci->bsf);
+
+avci->nb_draining_errors = 0;
+}
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 3a016b14c1..3341a79c9b 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -785,3 +785,21 @@ int ff_encode_receive_frame(AVCodecContext *avctx, AVFrame 
*frame)
 av_frame_move_ref(frame, avci->recon_frame);
 return 0;
 }
+
+void ff_encode_flush_buffers(AVCodecContext *avctx)
+{
+AVCodecInternal *avci = avctx->internal;
+int caps = avctx->codec->capabilities;
+
+if (!(caps & AV_CODEC_CAP_ENCODER_FLUSH)) {
+// Only encoders that explicitly declare support for it can be
+// flushed. Otherwise, this is a no-op.
+av_log(avctx, AV_LOG_WARNING, "Ignoring attempt to flush encoder "
+   "that doesn't support it\n");
+return;
+}
+if (avci->in_frame)
+av_frame_unref(avci->in_frame);
+if (avci->recon_frame)
+av_frame_unref(avci->recon_frame);
+}
-- 
2.40.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 9/9] lavc/decode: do not perform decoding when sending draining packets

2023-06-20 Thread Anton Khirnov
This way decoding error will not be returned when the user starts
draining the decoder, avoiding confusion over whether draining did or
did not start.

Fixes failures of fate-h264-attachment-631 for certain numbers of frame
threads (e.g. 5).
---
 libavcodec/decode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 8d892432be..67f2f052e5 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -665,7 +665,7 @@ int attribute_align_arg avcodec_send_packet(AVCodecContext 
*avctx, const AVPacke
 } else
 avci->d->draining_started = 1;
 
-if (!avci->buffer_frame->buf[0]) {
+if (!avci->buffer_frame->buf[0] && !avci->d->draining_started) {
 ret = decode_receive_frame_internal(avctx, avci->buffer_frame);
 if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF)
 return ret;
-- 
2.40.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 7/9] lavc/decode: track whether the caller started draining with a separate flag

2023-06-20 Thread Anton Khirnov
Decoding pipeline has multiple stages, some of which may have their own
delay (e.g. bitstream filters). The code currently uses
AVCodecInternal.draining to track all of them, but they do not have to
all be in sync.
---
 libavcodec/decode.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index c070148b58..c61ce74fb8 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -53,6 +53,11 @@
 struct DecodeContext {
 /* to prevent infinite loop on errors when draining */
 int nb_draining_errors;
+
+/**
+ * The caller has submitted a NULL packet on input.
+ */
+int draining_started;
 };
 
 static int apply_param_change(AVCodecContext *avctx, const AVPacket *avpkt)
@@ -624,7 +629,7 @@ int attribute_align_arg avcodec_send_packet(AVCodecContext 
*avctx, const AVPacke
 if (!avcodec_is_open(avctx) || !av_codec_is_decoder(avctx->codec))
 return AVERROR(EINVAL);
 
-if (avctx->internal->draining)
+if (avci->d->draining_started)
 return AVERROR_EOF;
 
 if (avpkt && !avpkt->size && avpkt->data)
@@ -635,7 +640,8 @@ int attribute_align_arg avcodec_send_packet(AVCodecContext 
*avctx, const AVPacke
 ret = av_packet_ref(avci->buffer_pkt, avpkt);
 if (ret < 0)
 return ret;
-}
+} else
+avci->d->draining_started = 1;
 
 ret = av_bsf_send_packet(avci->bsf, avci->buffer_pkt);
 if (ret < 0) {
@@ -1758,6 +1764,7 @@ void ff_decode_flush_buffers(AVCodecContext *avctx)
 av_bsf_flush(avci->bsf);
 
 avci->d->nb_draining_errors = 0;
+avci->d->draining_started   = 0;
 }
 
 AVCodecInternal *ff_decode_internal_alloc(void)
-- 
2.40.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 8/9] lavc/decode: move submitting input packets to bitstream filters

2023-06-20 Thread Anton Khirnov
Do it from ff_decode_get_packet() rather than from
avcodec_send_packet(). This way all nontrivial stages of the decoding
pipeline (i.e. other than just placing a packet at its entrance) are
pull-based rather than a mix of push an pull.
---
 libavcodec/decode.c | 36 ++--
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index c61ce74fb8..8d892432be 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -193,14 +193,11 @@ fail:
 return ret;
 }
 
-int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
+static int decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
 {
 AVCodecInternal *avci = avctx->internal;
 int ret;
 
-if (avci->draining)
-return AVERROR_EOF;
-
 ret = av_bsf_receive_packet(avci->bsf, pkt);
 if (ret == AVERROR_EOF)
 avci->draining = 1;
@@ -223,6 +220,31 @@ finish:
 return ret;
 }
 
+int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
+{
+AVCodecInternal *avci = avctx->internal;
+
+if (avci->draining)
+return AVERROR_EOF;
+
+while (1) {
+int ret = decode_get_packet(avctx, pkt);
+if (ret == AVERROR(EAGAIN) &&
+(avci->buffer_pkt->data || avci->buffer_pkt->side_data_elems ||
+ avci->d->draining_started)) {
+ret = av_bsf_send_packet(avci->bsf, avci->buffer_pkt);
+if (ret < 0) {
+av_packet_unref(avci->buffer_pkt);
+return ret;
+}
+
+continue;
+}
+
+return ret;
+}
+}
+
 /**
  * Attempt to guess proper monotonic timestamps for decoded video frames
  * which might have incorrect times. Input timestamps may wrap around, in
@@ -643,12 +665,6 @@ int attribute_align_arg avcodec_send_packet(AVCodecContext 
*avctx, const AVPacke
 } else
 avci->d->draining_started = 1;
 
-ret = av_bsf_send_packet(avci->bsf, avci->buffer_pkt);
-if (ret < 0) {
-av_packet_unref(avci->buffer_pkt);
-return ret;
-}
-
 if (!avci->buffer_frame->buf[0]) {
 ret = decode_receive_frame_internal(avctx, avci->buffer_frame);
 if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF)
-- 
2.40.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 1/9] lavc: add a header for internal generic-layer APIs

2023-06-20 Thread Anton Khirnov
The goal is to distinguish between APIs provided by the generic layer to
individual codecs and APIs internal to the generic layer.

Start by moving ff_{decode,encode}_receive_frame() and
ff_{decode,encode}_preinit() into this new header, as those functions
are called from generic code and should not be visible to individual
codecs.
---
 libavcodec/avcodec.c  |  1 +
 libavcodec/avcodec_internal.h | 53 +++
 libavcodec/decode.c   |  1 +
 libavcodec/decode.h   | 11 
 libavcodec/encode.c   |  1 +
 libavcodec/encode.h   | 11 
 6 files changed, 56 insertions(+), 22 deletions(-)
 create mode 100644 libavcodec/avcodec_internal.h

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index db8226f9b3..638cb55146 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -34,6 +34,7 @@
 #include "libavutil/opt.h"
 #include "libavutil/thread.h"
 #include "avcodec.h"
+#include "avcodec_internal.h"
 #include "bsf.h"
 #include "codec_internal.h"
 #include "decode.h"
diff --git a/libavcodec/avcodec_internal.h b/libavcodec/avcodec_internal.h
new file mode 100644
index 00..be60a36644
--- /dev/null
+++ b/libavcodec/avcodec_internal.h
@@ -0,0 +1,53 @@
+/*
+ * 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
+ */
+
+/*
+ * APIs internal to the generic codec layer.
+ *
+ * MUST NOT be included by individual encoders or decoders.
+ */
+
+#ifndef AVCODEC_AVCODEC_INTERNAL_H
+#define AVCODEC_AVCODEC_INTERNAL_H
+
+struct AVCodecContext;
+struct AVFrame;
+
+/**
+ * avcodec_receive_frame() implementation for decoders.
+ */
+int ff_decode_receive_frame(struct AVCodecContext *avctx, struct AVFrame 
*frame);
+
+/**
+ * avcodec_receive_frame() implementation for encoders.
+ */
+int ff_encode_receive_frame(struct AVCodecContext *avctx, struct AVFrame 
*frame);
+
+/*
+ * Perform encoder initialization and validation.
+ * Called when opening the encoder, before the FFCodec.init() call.
+ */
+int ff_encode_preinit(struct AVCodecContext *avctx);
+
+/**
+ * Perform decoder initialization and validation.
+ * Called when opening the decoder, before the FFCodec.init() call.
+ */
+int ff_decode_preinit(struct AVCodecContext *avctx);
+
+#endif // AVCODEC_AVCODEC_INTERNAL_H
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index a7c130207c..8adb532616 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -41,6 +41,7 @@
 #include "libavutil/opt.h"
 
 #include "avcodec.h"
+#include "avcodec_internal.h"
 #include "bytestream.h"
 #include "bsf.h"
 #include "codec_internal.h"
diff --git a/libavcodec/decode.h b/libavcodec/decode.h
index aaa29bc7f5..2b9fe59907 100644
--- a/libavcodec/decode.h
+++ b/libavcodec/decode.h
@@ -53,11 +53,6 @@ typedef struct FrameDecodeData {
 void (*hwaccel_priv_free)(void *priv);
 } FrameDecodeData;
 
-/**
- * avcodec_receive_frame() implementation for decoders.
- */
-int ff_decode_receive_frame(AVCodecContext *avctx, AVFrame *frame);
-
 /**
  * Called by decoders to get the next packet for decoding.
  *
@@ -99,12 +94,6 @@ int ff_attach_decode_data(AVFrame *frame);
  */
 int ff_copy_palette(void *dst, const AVPacket *src, void *logctx);
 
-/**
- * Perform decoder initialization and validation.
- * Called when opening the decoder, before the FFCodec.init() call.
- */
-int ff_decode_preinit(AVCodecContext *avctx);
-
 /**
  * Check that the provided frame dimensions are valid and set them on the codec
  * context.
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index ab5f889615..3a016b14c1 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -27,6 +27,7 @@
 #include "libavutil/samplefmt.h"
 
 #include "avcodec.h"
+#include "avcodec_internal.h"
 #include "codec_internal.h"
 #include "encode.h"
 #include "frame_thread_encoder.h"
diff --git a/libavcodec/encode.h b/libavcodec/encode.h
index 26a3304045..dfaab7c976 100644
--- a/libavcodec/encode.h
+++ b/libavcodec/encode.h
@@ -26,11 +26,6 @@
 #include "avcodec.h"
 #include "packet.h"
 
-/**
- * avcodec_receive_frame() implementation for encoders.
- */
-int ff_encode_receive_frame(AVCodecContext *avctx, AVFrame *frame);
-
 /**
  * Called by encoders to get the next frame for encoding.
  *
@@ -75,12 +70,6 @@ int ff_alloc_packet(AVCodecContext *avctx, 

[FFmpeg-devel] [PATCH 4/9] lavc: add generic-decode-layer private data

2023-06-20 Thread Anton Khirnov
Move AVCodecInternal.nb_draining_errors to it, should should not be
visible outside of decode.c.
---
 libavcodec/avcodec.c  |  4 +++-
 libavcodec/avcodec_internal.h |  2 ++
 libavcodec/decode.c   | 22 --
 libavcodec/internal.h | 10 +++---
 libavcodec/pthread_frame.c|  3 ++-
 5 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index a5cb6035b6..ff251d2dae 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -150,7 +150,9 @@ int attribute_align_arg avcodec_open2(AVCodecContext 
*avctx, const AVCodec *code
 if (avctx->extradata_size < 0 || avctx->extradata_size >= 
FF_MAX_EXTRADATA_SIZE)
 return AVERROR(EINVAL);
 
-avci = av_mallocz(sizeof(*avci));
+avci = av_codec_is_decoder(codec) ?
+ff_decode_internal_alloc():
+av_mallocz(sizeof(AVCodecInternal));
 if (!avci) {
 ret = AVERROR(ENOMEM);
 goto end;
diff --git a/libavcodec/avcodec_internal.h b/libavcodec/avcodec_internal.h
index 6ffe575c3e..f52f91e07c 100644
--- a/libavcodec/avcodec_internal.h
+++ b/libavcodec/avcodec_internal.h
@@ -53,4 +53,6 @@ int ff_decode_preinit(struct AVCodecContext *avctx);
 void ff_decode_flush_buffers(struct AVCodecContext *avctx);
 void ff_encode_flush_buffers(struct AVCodecContext *avctx);
 
+struct AVCodecInternal *ff_decode_internal_alloc(void);
+
 #endif // AVCODEC_AVCODEC_INTERNAL_H
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index b5e5b4a2db..c070148b58 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -50,6 +50,11 @@
 #include "internal.h"
 #include "thread.h"
 
+struct DecodeContext {
+/* to prevent infinite loop on errors when draining */
+int nb_draining_errors;
+};
+
 static int apply_param_change(AVCodecContext *avctx, const AVPacket *avpkt)
 {
 int ret;
@@ -439,7 +444,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 int nb_errors_max = 20 + (HAVE_THREADS && 
avctx->active_thread_type & FF_THREAD_FRAME ?
 avctx->thread_count : 1);
 
-if (avci->nb_draining_errors++ >= nb_errors_max) {
+if (avci->d->nb_draining_errors++ >= nb_errors_max) {
 av_log(avctx, AV_LOG_ERROR, "Too many errors when draining, 
this is a bug. "
"Stop draining and force EOF.\n");
 avci->draining_done = 1;
@@ -1752,5 +1757,18 @@ void ff_decode_flush_buffers(AVCodecContext *avctx)
 
 av_bsf_flush(avci->bsf);
 
-avci->nb_draining_errors = 0;
+avci->d->nb_draining_errors = 0;
+}
+
+AVCodecInternal *ff_decode_internal_alloc(void)
+{
+struct Dummy {
+AVCodecInternal   i;
+DecodeContext d;
+} *dummy = av_mallocz(sizeof(*dummy));
+if (!dummy)
+return NULL;
+dummy->i.d = >d;
+
+return >i;
 }
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index dceae182c0..b672092ac4 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -49,7 +49,14 @@
 #   define STRIDE_ALIGN 8
 #endif
 
+typedef struct DecodeContext DecodeContext;
+
 typedef struct AVCodecInternal {
+/**
+ * Generic decoding private data.
+ */
+DecodeContext *d;
+
 /**
  * When using frame-threaded decoding, this field is set for the first
  * worker thread (e.g. to decode extradata just once).
@@ -148,9 +155,6 @@ typedef struct AVCodecInternal {
 AVFrame *buffer_frame;
 int draining_done;
 
-/* to prevent infinite loop on errors when draining */
-int nb_draining_errors;
-
 /* used when avctx flag AV_CODEC_FLAG_DROPCHANGED is set */
 int changed_frames_dropped;
 int initial_format;
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 008f3da43b..bc305f561f 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -28,6 +28,7 @@
 #include 
 
 #include "avcodec.h"
+#include "avcodec_internal.h"
 #include "codec_internal.h"
 #include "decode.h"
 #include "hwconfig.h"
@@ -815,7 +816,7 @@ static av_cold int init_thread(PerThreadContext *p, int 
*threads_to_free,
 p->parent = fctx;
 p->avctx  = copy;
 
-copy->internal = av_mallocz(sizeof(*copy->internal));
+copy->internal = ff_decode_internal_alloc();
 if (!copy->internal)
 return AVERROR(ENOMEM);
 copy->internal->thread_ctx = p;
-- 
2.40.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 3/9] lavc: reindent after previous commit

2023-06-20 Thread Anton Khirnov
---
 libavcodec/decode.c | 10 +-
 libavcodec/encode.c | 24 
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 7d000fec32..b5e5b4a2db 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1744,13 +1744,13 @@ void ff_decode_flush_buffers(AVCodecContext *avctx)
 {
 AVCodecInternal *avci = avctx->internal;
 
-av_packet_unref(avci->last_pkt_props);
-av_packet_unref(avci->in_pkt);
+av_packet_unref(avci->last_pkt_props);
+av_packet_unref(avci->in_pkt);
 
-avctx->pts_correction_last_pts =
-avctx->pts_correction_last_dts = INT64_MIN;
+avctx->pts_correction_last_pts =
+avctx->pts_correction_last_dts = INT64_MIN;
 
-av_bsf_flush(avci->bsf);
+av_bsf_flush(avci->bsf);
 
 avci->nb_draining_errors = 0;
 }
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 3341a79c9b..6d0ef2be10 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -789,17 +789,17 @@ int ff_encode_receive_frame(AVCodecContext *avctx, 
AVFrame *frame)
 void ff_encode_flush_buffers(AVCodecContext *avctx)
 {
 AVCodecInternal *avci = avctx->internal;
-int caps = avctx->codec->capabilities;
+int caps = avctx->codec->capabilities;
 
-if (!(caps & AV_CODEC_CAP_ENCODER_FLUSH)) {
-// Only encoders that explicitly declare support for it can be
-// flushed. Otherwise, this is a no-op.
-av_log(avctx, AV_LOG_WARNING, "Ignoring attempt to flush encoder "
-   "that doesn't support it\n");
-return;
-}
-if (avci->in_frame)
-av_frame_unref(avci->in_frame);
-if (avci->recon_frame)
-av_frame_unref(avci->recon_frame);
+if (!(caps & AV_CODEC_CAP_ENCODER_FLUSH)) {
+// Only encoders that explicitly declare support for it can be
+// flushed. Otherwise, this is a no-op.
+av_log(avctx, AV_LOG_WARNING, "Ignoring attempt to flush encoder "
+   "that doesn't support it\n");
+return;
+}
+if (avci->in_frame)
+av_frame_unref(avci->in_frame);
+if (avci->recon_frame)
+av_frame_unref(avci->recon_frame);
 }
-- 
2.40.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 6/9] lavc: move AVCodecInternal.last_audio_frame to EncodeContext

2023-06-20 Thread Anton Khirnov
It does not need to be visible outside of encode.c.
---
 libavcodec/encode.c   | 12 +---
 libavcodec/internal.h |  6 --
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 4273dceb31..2b304d0771 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -40,6 +40,12 @@ struct EncodeContext {
  * This is used to set said flag generically for said encoders.
  */
 int intra_only_flag;
+
+/**
+ * An audio frame with less than required samples has been submitted (and
+ * potentially padded with silence). Reject all subsequent frames.
+ */
+int last_audio_frame;
 };
 
 int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
@@ -167,7 +173,7 @@ static int pad_last_frame(AVCodecContext *s, AVFrame 
*frame, const AVFrame *src,
 
 fail:
 av_frame_unref(frame);
-s->internal->last_audio_frame = 0;
+s->internal->e->last_audio_frame = 0;
 return ret;
 }
 
@@ -451,7 +457,7 @@ static int encode_send_frame_internal(AVCodecContext 
*avctx, const AVFrame *src)
 /* check for valid frame size */
 if (!(avctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) {
 /* if we already got an undersized frame, that must have been the 
last */
-if (avctx->internal->last_audio_frame) {
+if (avctx->internal->e->last_audio_frame) {
 av_log(avctx, AV_LOG_ERROR, "frame_size (%d) was not respected 
for a non-last frame\n", avctx->frame_size);
 return AVERROR(EINVAL);
 }
@@ -460,7 +466,7 @@ static int encode_send_frame_internal(AVCodecContext 
*avctx, const AVFrame *src)
 return AVERROR(EINVAL);
 }
 if (src->nb_samples < avctx->frame_size) {
-avctx->internal->last_audio_frame = 1;
+avctx->internal->e->last_audio_frame = 1;
 if (!(avctx->codec->capabilities & 
AV_CODEC_CAP_SMALL_LAST_FRAME)) {
 int pad_samples = avci->pad_samples ? avci->pad_samples : 
avctx->frame_size;
 int out_samples = (src->nb_samples + pad_samples - 1) / 
pad_samples * pad_samples;
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 2f4aee8ecc..2673c7d494 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -69,12 +69,6 @@ typedef struct AVCodecInternal {
  */
 int is_copy;
 
-/**
- * An audio frame with less than required samples has been submitted (and
- * potentially padded with silence). Reject all subsequent frames.
- */
-int last_audio_frame;
-
 /**
  * Audio encoders can set this flag during init to indicate that they
  * want the small last frame to be padded to a multiple of pad_samples.
-- 
2.40.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 3/3] Add Changelog entry

2023-06-20 Thread Tomas Härdin
Squashed with patch 2/2, trailing whitespaces fixed and pushed

/Tomas

___
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 04/10] avcodec/evc_parse: split off Parameter Set parsing into its own file

2023-06-20 Thread James Almer
On 6/20/2023 4:37 AM, Dawid Kozinski/Multimedia (PLT) /SRPOL/Staff 
Engineer/Samsung Electronics wrote:

Why have you split off the parameter set parsing into its own file? Just
asking what's the reason.
I copied the design from h264. Smaller source files are better than 
monolith ones. And an eventual native decoder will benefit from this 
being already in place.

___
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] lavu/tx: make 32-bit fixed-point transforms more bitexact

2023-06-20 Thread Martin Storsjö

On Tue, 20 Jun 2023, Lynne wrote:


Using the sqrt/cos/sin approximations we have, the only parts left
which may be inexact are multiplies and divisions in some transforms.


This seems to help somewhat, but there still are cases of inexactness, 
somewhere.


The content of the tables that are initialized here does become bitexact 
(at least across some of the configs that otherwise disagree with the 
output), but despite that, the output differs.


With the test references generated on linux/x86_64 compiled with GCC, run 
on an Intel CPU, I get the following set of machines that either agree or 
disagree with the reference:


matching
- linux x86_64 gcc11 Intel
- linux aarch64 gcc12 on Apple M1
- linux aarch64 clang10 Neoverse N1
- linux aarch64 gcc9 Neoverse N1
- linux armv7 gcc9 Neoverse N1

disagreeing
- macos x86_64 clang Xcode14 Intel
- mingw x86_64 clang trunk Dragonboard
- macos aarch64 clang Xcode12 Apple M1
- macos aarch64 clang Xcode14 Apple M1
- linux i686 gcc11 Intel
- mingw aarch64 clang trunk Dragonboard
- linux aarch64 gcc7 Dragonboard
- mingw armv7 clang trunk Dragonboard
- mingw i686 clang trunk Intel
- mingw i686 clang trunk -march=i686 Intel


The configs that are easiest to reproduce are probably the ones on macOS 
on Apple M1, or macOS on x86_64 if you happen to have access to that, or 
GCC/i686 on Linux (just configure with --extra-cflags=-m32 
--extra-ldflags=-m32).


// 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 04/10] avcodec/evc_parse: split off Parameter Set parsing into its own file

2023-06-20 Thread Dawid Kozinski/Multimedia (PLT) /SRPOL/Staff Engineer/Samsung Electronics
Why have you split off the parameter set parsing into its own file? Just
asking what's the reason.



> -Original Message-
> From: ffmpeg-devel  On Behalf Of James
> Almer
> Sent: niedziela, 18 czerwca 2023 00:00
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH 04/10] avcodec/evc_parse: split off
Parameter
> Set parsing into its own file
> 
> Signed-off-by: James Almer 
> ---
>  libavcodec/Makefile  |   2 +-
>  libavcodec/evc_frame_merge_bsf.c |   4 +-
>  libavcodec/evc_parse.c   | 371 +-
>  libavcodec/evc_parse.h   | 198 +---
>  libavcodec/evc_parser.c  |   2 +-
>  libavcodec/evc_ps.c  | 381 +++
>  libavcodec/evc_ps.h  | 228 ++
>  7 files changed, 621 insertions(+), 565 deletions(-)
>  create mode 100644 libavcodec/evc_ps.c
>  create mode 100644 libavcodec/evc_ps.h
> 
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 0ce8fe5b9c..723bfa25c7 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -84,7 +84,7 @@ OBJS-$(CONFIG_DCT) += dct.o
dct32_fixed.o
> dct32_float.o
>  OBJS-$(CONFIG_DEFLATE_WRAPPER) += zlib_wrapper.o
>  OBJS-$(CONFIG_DOVI_RPU)+= dovi_rpu.o
>  OBJS-$(CONFIG_ERROR_RESILIENCE)+= error_resilience.o
> -OBJS-$(CONFIG_EVCPARSE)+= evc_parse.o
> +OBJS-$(CONFIG_EVCPARSE)+= evc_parse.o evc_ps.o
>  OBJS-$(CONFIG_EXIF)+= exif.o tiff_common.o
>  OBJS-$(CONFIG_FAANDCT) += faandct.o
>  OBJS-$(CONFIG_FAANIDCT)+= faanidct.o
> diff --git a/libavcodec/evc_frame_merge_bsf.c
> b/libavcodec/evc_frame_merge_bsf.c
> index 540bb63631..f497780afb 100644
> --- a/libavcodec/evc_frame_merge_bsf.c
> +++ b/libavcodec/evc_frame_merge_bsf.c
> @@ -58,7 +58,7 @@ static void evc_frame_merge_flush(AVBSFContext *bsf)
>  {
>  EVCFMergeContext *ctx = bsf->priv_data;
> 
> -ff_evc_parse_free(>parser_ctx);
> +ff_evc_ps_free(>parser_ctx.ps);
>  av_packet_unref(ctx->in);
>  ctx->au_buffer.data_size = 0;
>  }
> @@ -147,7 +147,7 @@ static void evc_frame_merge_close(AVBSFContext *bsf)
>  EVCFMergeContext *ctx = bsf->priv_data;
> 
>  av_packet_free(>in);
> -ff_evc_parse_free(>parser_ctx);
> +ff_evc_ps_free(>parser_ctx.ps);
> 
>  ctx->au_buffer.capacity = 0;
>  av_freep(>au_buffer.data);
> diff --git a/libavcodec/evc_parse.c b/libavcodec/evc_parse.c
> index 44be5c5291..a8e6356b96 100644
> --- a/libavcodec/evc_parse.c
> +++ b/libavcodec/evc_parse.c
> @@ -21,8 +21,6 @@
>  #include "evc.h"
>  #include "evc_parse.h"
> 
> -#define EXTENDED_SAR255
> -
>  #define NUM_CHROMA_FORMATS  4   // @see ISO_IEC_23094-1 section 6.2
> table 2
> 
>  static const enum AVPixelFormat pix_fmts_8bit[NUM_CHROMA_FORMATS] = {
> @@ -71,355 +69,6 @@ int ff_evc_get_temporal_id(const uint8_t *bits, int
> bits_size, void *logctx)
>  return temporal_id;
>  }
> 
> -// @see ISO_IEC_23094-1 (7.3.7 Reference picture list structure syntax)
> -static int ref_pic_list_struct(GetBitContext *gb, RefPicListStruct *rpl)
> -{
> -uint32_t delta_poc_st, strp_entry_sign_flag = 0;
> -rpl->ref_pic_num = get_ue_golomb(gb);
> -if (rpl->ref_pic_num > 0) {
> -delta_poc_st = get_ue_golomb(gb);
> -
> -rpl->ref_pics[0] = delta_poc_st;
> -if (rpl->ref_pics[0] != 0) {
> -strp_entry_sign_flag = get_bits(gb, 1);
> -
> -rpl->ref_pics[0] *= 1 - (strp_entry_sign_flag << 1);
> -}
> -}
> -
> -for (int i = 1; i < rpl->ref_pic_num; ++i) {
> -delta_poc_st = get_ue_golomb(gb);
> -if (delta_poc_st != 0)
> -strp_entry_sign_flag = get_bits(gb, 1);
> -rpl->ref_pics[i] = rpl->ref_pics[i - 1] + delta_poc_st * (1 -
> (strp_entry_sign_flag << 1));
> -}
> -
> -return 0;
> -}
> -
> -// @see  ISO_IEC_23094-1 (E.2.2 HRD parameters syntax)
> -static int hrd_parameters(GetBitContext *gb, HRDParameters *hrd)
> -{
> -hrd->cpb_cnt_minus1 = get_ue_golomb(gb);
> -hrd->bit_rate_scale = get_bits(gb, 4);
> -hrd->cpb_size_scale = get_bits(gb, 4);
> -for (int SchedSelIdx = 0; SchedSelIdx <= hrd->cpb_cnt_minus1;
SchedSelIdx++)
> {
> -hrd->bit_rate_value_minus1[SchedSelIdx] = get_ue_golomb(gb);
> -hrd->cpb_size_value_minus1[SchedSelIdx] = get_ue_golomb(gb);
> -hrd->cbr_flag[SchedSelIdx] = get_bits(gb, 1);
> -}
> -hrd->initial_cpb_removal_delay_length_minus1 = get_bits(gb, 5);
> -hrd->cpb_removal_delay_length_minus1 = get_bits(gb, 5);
> -hrd->cpb_removal_delay_length_minus1 = get_bits(gb, 5);
> -hrd->time_offset_length = get_bits(gb, 5);
> -
> -return 0;
> -}
> -
> -// @see  ISO_IEC_23094-1 (E.2.1 VUI parameters syntax)
> -static int vui_parameters(GetBitContext *gb, VUIParameters *vui)
> -{
> -vui->aspect_ratio_info_present_flag = get_bits(gb, 1);
> -if 

Re: [FFmpeg-devel] [PATCH] libavformat/mpegts.c: fix hardcoded 5-bytes skip for metadata streams.

2023-06-20 Thread Paul B Mahol
On Tue, Jun 20, 2023 at 7:19 AM  wrote:

> From: Romain Beauxis 
>
> Before the introduction of AV_CODEC_ID_TIMED_ID3 for timed_id3 metadata
> streams
> in mpegts (commit 4a4437c0fbc8f7afe0c533070395a42e56b4ee75),
> AV_CODEC_ID_SMPTE_KLV
> was the only existing codec for metadata.
>
> It seems that this codec has a 5-bytes metadata header[1] that, for some
> reason,
> was always skipped when decoding data packets.
>
> However, when working with a AV_CODEC_ID_TIMED_ID3 streams, this results
> in the
> 5 first bytes of the payload being cut-off, which includes essential
> informations
> such as the ID3 tag version.
>
> This patch fixes the issue by keeping the 5-bytes skip only for
> AV_CODEC_ID_SMPTE_KLV
> streams.
>
> To test:
> 1. download this file:
> https://www.dropbox.com/s/jy8sih3pe8qskxb/bla.ts?dl=1
>
> This file was download from:
> http://playertest.longtailvideo.com/adaptive/wowzaid3/playlist.m3u8
>
> 2. run this command:
>   ffprobe -show_streams -select_streams 0 -show_packets -show_private_data
> \
>   -show_data /path/to/bla.ts
>
> Before:
> [PACKET]
> codec_type=data
> stream_index=0
> pts=494646418
> pts_time=5496.071311
> dts=494646418
> dts_time=5496.071311
> duration=N/A
> duration_time=N/A
> size=21
> pos=482784
> flags=K__
> data=
> :   1054 4954 3200  0600 0003  .TIT2...
> 0010: 7465 7374 00 test.
>
> After:
> [PACKET]
> codec_type=data
> stream_index=0
> pts=494646418
> pts_time=5496.071311
> dts=494646418
> dts_time=5496.071311
> duration=N/A
> duration_time=N/A
> size=26
> pos=482784
> flags=K__
> data=
> : 4944 3304   0010 5449 5432   ID3...TIT2..
> 0010: 0006  0374 6573 7400 .test.
>
> ---
>  libavformat/mpegts.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> index fb8b0bf8fd..0b3edda817 100644
> --- a/libavformat/mpegts.c
> +++ b/libavformat/mpegts.c
> @@ -1305,7 +1305,7 @@ skip:
>  p += sl_header_bytes;
>  buf_size -= sl_header_bytes;
>  }
> -if (pes->stream_type == 0x15 && buf_size >= 5) {
> +if (pes->st->codecpar->codec_id == AV_CODEC_ID_SMPTE_KLV
> && buf_size >= 5) {
>  /* skip metadata access unit header */
>  pes->pes_header_size += 5;
>  p += 5;
> --
> 2.39.2 (Apple Git-143)
>

LGTM


>
> ___
> 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/3] closed caption decoder: accept and decode a new codec type of 'raw 608 byte pairs'

2023-06-20 Thread Paul B Mahol
On Tue, Jun 20, 2023 at 2:50 AM Roger Pack  wrote:

> OK updated patches to work with latest git master, made coded id less
> verbose.
> These have been tested against a "real device" and seem to work properly.
> I'd like to get feedback on the Closed caption decoder first if that's
> possible.
> I pinged the decoder "maintainer" about it once and didn't get a
> response so seems it's up to us.
>
>
Please remove '_dec_' part, its really not needed.

Thank you.
> -=roger=-
>
> On Thu, May 7, 2020 at 7:06 AM Paul B Mahol  wrote:
> >
> > Is it just me, or the coded id is too much verbose?
> >
> > On 5/7/20, Anton Khirnov  wrote:
> > > Quoting Roger Pack (2020-04-28 08:15:19)
> > >> From 5d7c12a3f703e794e1092087355bc9523d5f4d93 Mon Sep 17 00:00:00 2001
> > >> From: rogerdpack 
> > >> Date: Tue, 28 Apr 2020 05:15:15 +
> > >> Subject: [PATCH 1/3] closed caption decoder: accept and decode a new
> codec
> > >>  type of 'raw 608 byte pairs'
> > >>
> > >> Signed-off-by: rogerdpack 
> > >> ---
> > >> diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
> > >> index e7d6e059db..805e18758b 100644
> > >> --- a/libavcodec/codec_id.h
> > >> +++ b/libavcodec/codec_id.h
> > >> @@ -513,6 +513,7 @@ enum AVCodecID {
> > >>
> > >>  AV_CODEC_ID_MICRODVD   = 0x17800,
> > >>  AV_CODEC_ID_EIA_608,
> > >> +AV_CODEC_ID_EIA_608_RAW_BYTE_PAIRS,
> > >
> > > You can't just add new IDs in the middle of the table, it changes the
> > > IDs of all the following codecs which breaks ABI.
> > > Add it to the end of the subtitle block.
> > >
> > > --
> > > Anton Khirnov
> > > ___
> > > 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 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".