[FFmpeg-devel] [PATCH 3/3] fftools/ffmpeg: auto insert enhancement filters when available

2024-09-20 Thread James Almer
This is an alternative to 
https://ffmpeg.org//pipermail/ffmpeg-devel/2024-September/96.html
where things are left to the caller and we don't rely on lavc applying the 
LCEVC metadata at
the end of the decoding process.

Signed-off-by: James Almer 
---
 configure   |  2 +-
 fftools/ffmpeg.h|  2 ++
 fftools/ffmpeg_demux.c  |  5 +
 fftools/ffmpeg_filter.c | 22 +-
 fftools/ffmpeg_opt.c|  3 +++
 5 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index f07f6c7c46..fb009d0c3f 100755
--- a/configure
+++ b/configure
@@ -4058,7 +4058,7 @@ ffmpeg_deps="avcodec avfilter avformat threads"
 ffmpeg_select="aformat_filter anull_filter atrim_filter crop_filter
format_filter hflip_filter null_filter rotate_filter
transpose_filter trim_filter vflip_filter"
-ffmpeg_suggest="ole32 psapi shell32"
+ffmpeg_suggest="lcevc_filter ole32 psapi shell32"
 ffplay_deps="avcodec avformat avfilter swscale swresample sdl2"
 ffplay_select="crop_filter transpose_filter hflip_filter vflip_filter 
rotate_filter"
 ffplay_suggest="shell32 libplacebo vulkan"
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index f4a10b2a66..44c7ca08ed 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -154,6 +154,7 @@ typedef struct OptionsContext {
 SpecifierOptList hwaccels;
 SpecifierOptList hwaccel_devices;
 SpecifierOptList hwaccel_output_formats;
+SpecifierOptList autoenhance;
 SpecifierOptList autorotate;
 SpecifierOptList apply_cropping;
 
@@ -241,6 +242,7 @@ enum IFilterFlags {
 IFILTER_FLAG_REINIT = (1 << 1),
 IFILTER_FLAG_CFR= (1 << 2),
 IFILTER_FLAG_CROP   = (1 << 3),
+IFILTER_FLAG_AUTOENHANCE= (1 << 4),
 };
 
 typedef struct InputFilterOptions {
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 0b639f2b60..f0290fa286 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -66,6 +66,7 @@ typedef struct DemuxStream {
 int  have_sub2video;
 int  reinit_filters;
 int  autorotate;
+int  autoenhance;
 int  apply_cropping;
 
 
@@ -1072,6 +1073,7 @@ int ist_filter_add(InputStream *ist, InputFilter 
*ifilter, int is_simple,
 return AVERROR(ENOMEM);
 
 opts->flags |= IFILTER_FLAG_AUTOROTATE * !!(ds->autorotate) |
+   IFILTER_FLAG_AUTOENHANCE * !!(ds->autoenhance) |
IFILTER_FLAG_REINIT * !!(ds->reinit_filters);
 
 return ds->sch_idx_dec;
@@ -1253,6 +1255,9 @@ static int ist_add(const OptionsContext *o, Demuxer *d, 
AVStream *st, AVDictiona
 ds->ts_scale = 1.0;
 opt_match_per_stream_dbl(ist, &o->ts_scale, ic, st, &ds->ts_scale);
 
+ds->autoenhance = 1;
+opt_match_per_stream_int(ist, &o->autoenhance, ic, st, &ds->autoenhance);
+
 ds->autorotate = 1;
 opt_match_per_stream_int(ist, &o->autorotate, ic, st, &ds->autorotate);
 
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 529e631781..6a64b5a091 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -147,6 +147,8 @@ typedef struct InputFilterPriv {
 int displaymatrix_applied;
 int32_t displaymatrix[9];
 
+int enhancement_present;
+
 struct {
 AVFrame *frame;
 
@@ -1697,6 +1699,15 @@ static int configure_input_video_filter(FilterGraph *fg, 
AVFilterGraph *graph,
 desc = av_pix_fmt_desc_get(ifp->format);
 av_assert0(desc);
 
+if ((ifp->opts.flags & IFILTER_FLAG_AUTOENHANCE) &&
+!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
+ret = insert_filter(&last_filter, &pad_idx, "lcevc", NULL);
+if (ret == AVERROR_BUG) // this filter is optional
+ret = 0;
+if (ret < 0)
+return ret;
+}
+
 if ((ifp->opts.flags & IFILTER_FLAG_CROP)) {
 char crop_buf[64];
 snprintf(crop_buf, sizeof(crop_buf), "w=iw-%u-%u:h=ih-%u-%u:x=%u:y=%u",
@@ -2028,6 +2039,8 @@ static int ifilter_parameters_from_frame(InputFilter 
*ifilter, const AVFrame *fr
 memcpy(ifp->displaymatrix, sd->data, sizeof(ifp->displaymatrix));
 ifp->displaymatrix_present = !!sd;
 
+ifp->enhancement_present = !!(av_frame_get_side_data(frame, 
AV_FRAME_DATA_LCEVC));
+
 return 0;
 }
 
@@ -2727,7 +2740,8 @@ enum ReinitReason {
 VIDEO_CHANGED   = (1 << 0),
 AUDIO_CHANGED   = (1 << 1),
 MATRIX_CHANGED  = (1 << 2),
-HWACCEL_CHANGED = (1 << 3)
+HWACCEL_CHANGED = (1 << 3),
+ENHANCEMENT_CHANGED = (1 << 4),
 };
 
 static const char *unknown_if_null(const char *str

Re: [FFmpeg-devel] [PATCH 2/2] fftools/ffmpeg_filter: ensure that the inserted filters exist

2024-09-20 Thread James Almer

On 9/20/2024 10:30 AM, James Almer wrote:

If not, report it as a bug. avfilter_graph_create_filter() will return ENOMEM 
if the
passed filter argument is NULL, which is misleading.

Signed-off-by: James Almer 
---
  fftools/ffmpeg_filter.c | 6 +-
  1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 8b420e68ab..27d74341b5 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1444,11 +1444,15 @@ static int insert_filter(AVFilterContext **last_filter, 
int *pad_idx,
   const char *filter_name, const char *args)
  {
  AVFilterGraph *graph = (*last_filter)->graph;
+const AVFilter *filter = avfilter_get_by_name(filter_name)


Missing colon added locally...


  AVFilterContext *ctx;
  int ret;
  
+if (!filter)

+return AVERROR_BUG;
+
  ret = avfilter_graph_create_filter(&ctx,
-   avfilter_get_by_name(filter_name),
+   filter,
 filter_name, args, NULL, graph);
  if (ret < 0)
  return ret;




OpenPGP_signature.asc
Description: OpenPGP digital 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] fftools/ffmpeg_filter: ensure that the inserted filters exist

2024-09-20 Thread James Almer
If not, report it as a bug. avfilter_graph_create_filter() will return ENOMEM 
if the
passed filter argument is NULL, which is misleading.

Signed-off-by: James Almer 
---
 fftools/ffmpeg_filter.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 8b420e68ab..27d74341b5 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1444,11 +1444,15 @@ static int insert_filter(AVFilterContext **last_filter, 
int *pad_idx,
  const char *filter_name, const char *args)
 {
 AVFilterGraph *graph = (*last_filter)->graph;
+const AVFilter *filter = avfilter_get_by_name(filter_name)
 AVFilterContext *ctx;
 int ret;
 
+if (!filter)
+return AVERROR_BUG;
+
 ret = avfilter_graph_create_filter(&ctx,
-   avfilter_get_by_name(filter_name),
+   filter,
filter_name, args, NULL, graph);
 if (ret < 0)
 return ret;
-- 
2.46.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/2] configure: add missing filter dependencies to ffmpeg

2024-09-20 Thread James Almer
Signed-off-by: James Almer 
---
 configure | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index d568739bf9..f07f6c7c46 100755
--- a/configure
+++ b/configure
@@ -4055,8 +4055,8 @@ avutil_extralibs="d3d11va_extralibs d3d12va_extralibs 
mediacodec_extralibs nanos
 
 # programs
 ffmpeg_deps="avcodec avfilter avformat threads"
-ffmpeg_select="aformat_filter anull_filter atrim_filter format_filter
-   hflip_filter null_filter
+ffmpeg_select="aformat_filter anull_filter atrim_filter crop_filter
+   format_filter hflip_filter null_filter rotate_filter
transpose_filter trim_filter vflip_filter"
 ffmpeg_suggest="ole32 psapi shell32"
 ffplay_deps="avcodec avformat avfilter swscale swresample sdl2"
-- 
2.46.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 sample tests for DNxUncompressed

2024-09-19 Thread James Almer

On 9/13/2024 10:01 AM, martin schitter wrote:

Here are the necessary samples for the fate checks.

Please upload them to the fate sample collection.

thanks
martin


Done.



OpenPGP_signature.asc
Description: OpenPGP digital 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 5/9] avcodec/cbs_h266_syntax_template: Check bit depth with range extension

2024-09-19 Thread James Almer

On 9/19/2024 9:34 PM, Michael Niedermayer wrote:

On Thu, Sep 19, 2024 at 08:53:07PM -0300, James Almer wrote:

On 9/19/2024 7:56 PM, Michael Niedermayer wrote:

Fixes: shift exponent 62 is too large for 32-bit type 'int'
Fixes: 
71020/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VVC_fuzzer-6444916325023744

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
   libavcodec/cbs_h266_syntax_template.c | 3 +++
   1 file changed, 3 insertions(+)

diff --git a/libavcodec/cbs_h266_syntax_template.c 
b/libavcodec/cbs_h266_syntax_template.c
index a8f5af04d02..1c26563 100644
--- a/libavcodec/cbs_h266_syntax_template.c
+++ b/libavcodec/cbs_h266_syntax_template.c
@@ -1041,6 +1041,9 @@ static int 
FUNC(sps_range_extension)(CodedBitstreamContext *ctx, RWContext *rw,
   {
   int err;
+if (current->sps_bitdepth_minus8 < 10)


sps_bitdepth_minus8 can only be between 0 and 8, so this is basically making
it abort on any and every sample with SPS range extension.


+ if (current->sps_bitdepth_minus8 < 10 - 8)


Ok, this is different.



Its supposed to check this:
"When BitDepth is less
  than or equal to 10, the value of sps_range_extension_flag shall be equal to 
0."


Should be "<= (10 - 8)" then, and LGTM.






Also, it doesn't seem to be used here at all, so i don't see how this is
fixing anything. Can you share the sample?


its used here:
libavcodec/vvc/ctu.c:persistent_rice_adaptation_enabled_flag ? 2 * 
(av_log2(bit_depth - 10)) : 0;

I can send you the file but i think this case is quite clear

thx

[...]


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




OpenPGP_signature.asc
Description: OpenPGP digital 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 5/9] avcodec/cbs_h266_syntax_template: Check bit depth with range extension

2024-09-19 Thread James Almer

On 9/19/2024 7:56 PM, Michael Niedermayer wrote:

Fixes: shift exponent 62 is too large for 32-bit type 'int'
Fixes: 
71020/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VVC_fuzzer-6444916325023744

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
  libavcodec/cbs_h266_syntax_template.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/libavcodec/cbs_h266_syntax_template.c 
b/libavcodec/cbs_h266_syntax_template.c
index a8f5af04d02..1c26563 100644
--- a/libavcodec/cbs_h266_syntax_template.c
+++ b/libavcodec/cbs_h266_syntax_template.c
@@ -1041,6 +1041,9 @@ static int 
FUNC(sps_range_extension)(CodedBitstreamContext *ctx, RWContext *rw,
  {
  int err;
  
+if (current->sps_bitdepth_minus8 < 10)


sps_bitdepth_minus8 can only be between 0 and 8, so this is basically 
making it abort on any and every sample with SPS range extension.


Also, it doesn't seem to be used here at all, so i don't see how this is 
fixing anything. Can you share the sample?



+return AVERROR_INVALIDDATA;
+
  flag(sps_extended_precision_flag);
  if (current->sps_transform_skip_enabled_flag)
  flag(sps_ts_residual_coding_rice_present_in_sh_flag);




OpenPGP_signature.asc
Description: OpenPGP digital 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] [RFC PATCH] avcodec/vvc: Don't use large array on stack

2024-09-19 Thread James Almer

On 9/19/2024 2:27 PM, Zhao Zhili wrote:

From: Zhao Zhili 

tmp_array in dmvr_hv takes 33024 bytes on stack, which can be
dangerous. This patch fixed the C version and comment out the
x86 asm version.
You don't need to comment it out. The x86 versions don't use the new 
argument, so just update the prototypes, like so:



diff --git a/libavcodec/x86/vvc/vvcdsp_init.c b/libavcodec/x86/vvc/vvcdsp_init.c
index c50eaf25ce..7ff3e2bdff 100644
--- a/libavcodec/x86/vvc/vvcdsp_init.c
+++ b/libavcodec/x86/vvc/vvcdsp_init.c
@@ -90,13 +90,13 @@ AVG_PROTOTYPES(12, avx2)

 #define DMVR_PROTOTYPES(bd, opt)   
 \
 void ff_vvc_dmvr_##bd##_##opt(int16_t *dst, const uint8_t *src, ptrdiff_t 
src_stride,   \
- int height, intptr_t mx, intptr_t my, int width); 
 \
+ int height, intptr_t mx, intptr_t my, int width, int16_t *unused);
 \
 void ff_vvc_dmvr_h_##bd##_##opt(int16_t *dst, const uint8_t *src, ptrdiff_t 
src_stride, \
- int height, intptr_t mx, intptr_t my, int width); 
 \
+ int height, intptr_t mx, intptr_t my, int width, int16_t *unused);
 \
 void ff_vvc_dmvr_v_##bd##_##opt(int16_t *dst, const uint8_t *src, ptrdiff_t 
src_stride, \
- int height, intptr_t mx, intptr_t my, int width); 
 \
+ int height, intptr_t mx, intptr_t my, int width, int16_t *unused);
 \
 void ff_vvc_dmvr_hv_##bd##_##opt(int16_t *dst, const uint8_t *src, ptrdiff_t 
src_stride,\
- int height, intptr_t mx, intptr_t my, int width); 
 \
+ int height, intptr_t mx, intptr_t my, int width, int16_t *unused);
 \

 DMVR_PROTOTYPES( 8, avx2)
 DMVR_PROTOTYPES(10, avx2)
@@ -371,8 +371,7 @@ void ff_vvc_dsp_init_x86(VVCDSPContext *const c, const int 
bd)
 AVG_INIT(8, avx2);
 MC_LINKS_AVX2(8);
 OF_INIT(8);
-// TODO:
-// DMVR_INIT(8);
+DMVR_INIT(8);
 SAD_INIT();
 }
 break;
@@ -386,7 +385,7 @@ void ff_vvc_dsp_init_x86(VVCDSPContext *const c, const int 
bd)
 MC_LINKS_AVX2(10);
 MC_LINKS_16BPC_AVX2(10);
 OF_INIT(10);
-// DMVR_INIT(10);
+DMVR_INIT(10);
 SAD_INIT();
 }
 break;
@@ -400,7 +399,7 @@ void ff_vvc_dsp_init_x86(VVCDSPContext *const c, const int 
bd)
 MC_LINKS_AVX2(12);
 MC_LINKS_16BPC_AVX2(12);
 OF_INIT(12);
-// DMVR_INIT(12);
+DMVR_INIT(12);
 SAD_INIT();
 }
 break;





OpenPGP_signature.asc
Description: OpenPGP digital 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] avcodec/h2645_parse: add a flag to store skipped byte positions

2024-09-17 Thread James Almer
This is only used by two out of several modules, so it's a waste of resources
for the rest.

Signed-off-by: James Almer 
---
 libavcodec/cbs_h2645.c|  6 --
 libavcodec/h2645_parse.c  | 10 ++
 libavcodec/h2645_parse.h  |  1 +
 libavcodec/hevc/hevcdec.c |  2 +-
 4 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 4abd9e0c2e..75c1d1c4cf 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -725,7 +725,8 @@ static int cbs_h2645_split_fragment(CodedBitstreamContext 
*ctx,
 err = ff_h2645_packet_split(&priv->read_packet,
 frag->data + start, end - start,
 ctx->log_ctx, 2, AV_CODEC_ID_VVC,
-H2645_FLAG_IS_NALFF | 
H2645_FLAG_SMALL_PADDING | H2645_FLAG_USE_REF);
+H2645_FLAG_IS_NALFF | 
H2645_FLAG_SMALL_PADDING |
+H2645_FLAG_USE_REF | 
H2645_FLAG_SKIPPED_BYTES);
 if (err < 0) {
 av_log(ctx->log_ctx, AV_LOG_ERROR, "Failed to split "
"VVCC array %d (%d NAL units of type %d).\n",
@@ -737,7 +738,8 @@ static int cbs_h2645_split_fragment(CodedBitstreamContext 
*ctx,
 return err;
 }
 } else {
-int flags = (H2645_FLAG_IS_NALFF * !!priv->mp4) | 
H2645_FLAG_SMALL_PADDING | H2645_FLAG_USE_REF;
+int flags = (H2645_FLAG_IS_NALFF * !!priv->mp4) | 
H2645_FLAG_SMALL_PADDING | H2645_FLAG_USE_REF |
+(H2645_FLAG_SKIPPED_BYTES * (codec_id == AV_CODEC_ID_VVC));
 // Annex B, or later MP4 with already-known parameters.
 
 err = ff_h2645_packet_split(&priv->read_packet,
diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
index 7b48fcae17..f8eb301680 100644
--- a/libavcodec/h2645_parse.c
+++ b/libavcodec/h2645_parse.c
@@ -540,10 +540,12 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t 
*buf, int length,
 memset(pkt->nals + pkt->nals_allocated, 0, sizeof(*pkt->nals));
 
 nal = &pkt->nals[pkt->nb_nals];
-nal->skipped_bytes_pos_size = FFMIN(1024, extract_length/3+1); // 
initial buffer size
-nal->skipped_bytes_pos = 
av_malloc_array(nal->skipped_bytes_pos_size, sizeof(*nal->skipped_bytes_pos));
-if (!nal->skipped_bytes_pos)
-return AVERROR(ENOMEM);
+if (flags & H2645_FLAG_SKIPPED_BYTES) {
+nal->skipped_bytes_pos_size = FFMIN(1024, extract_length/3+1); 
// initial buffer size
+nal->skipped_bytes_pos = 
av_malloc_array(nal->skipped_bytes_pos_size, sizeof(*nal->skipped_bytes_pos));
+if (!nal->skipped_bytes_pos)
+return AVERROR(ENOMEM);
+}
 
 pkt->nals_allocated = new_size;
 }
diff --git a/libavcodec/h2645_parse.h b/libavcodec/h2645_parse.h
index e27ccf7523..975000aeb7 100644
--- a/libavcodec/h2645_parse.h
+++ b/libavcodec/h2645_parse.h
@@ -97,6 +97,7 @@ enum {
 H2645_FLAG_IS_NALFF = (1 << 0),
 H2645_FLAG_SMALL_PADDING =(1 << 1),
 H2645_FLAG_USE_REF =  (1 << 2),
+H2645_FLAG_SKIPPED_BYTES =(1 << 3),
 };
 
 /**
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index d915d74d22..8e2d52c51a 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3321,7 +3321,7 @@ static int decode_nal_units(HEVCContext *s, const uint8_t 
*buf, int length)
 {
 int i, ret = 0;
 int eos_at_start = 1;
-int flags = (H2645_FLAG_IS_NALFF * !!s->is_nalff) | 
H2645_FLAG_SMALL_PADDING;
+int flags = (H2645_FLAG_IS_NALFF * !!s->is_nalff) | 
H2645_FLAG_SMALL_PADDING | H2645_FLAG_SKIPPED_BYTES;
 
 s->cur_frame = s->collocated_ref = NULL;
 s->last_eos = s->eos;
-- 
2.46.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 16/23] avcodec/hevc/refs: export Stereo 3D side data

2024-09-17 Thread James Almer

On 9/17/2024 8:53 AM, Anton Khirnov wrote:

Quoting James Almer (2024-09-15 00:12:52)

(is there a reason you wanted the view_id side data and this one
applied to the frame before get_buffer()?),


So that the caller knows what view is get_buffer() called for.


As this is now being called before ff_progress_frame_get_buffer() it
became a no-op and any stereo 3d side data in the input packet will be
appended to the frame, resulting in something like:


[Parsed_showinfo_0 @ 0281481551c0]   side data - View ID: view id: 0
[Parsed_showinfo_0 @ 0281481551c0]   side data - Stereo 3D: type - frame 
alternate, view - right, primary_eye - none
[Parsed_showinfo_0 @ 0281481551c0]   side data - Spherical Mapping: 
rectilinear
[Parsed_showinfo_0 @ 0281481551c0]   side data - Stereo 3D: type - 
unspecified, view - packed, primary_eye - none, baseline: 19240, 
horizontal_disparity_adjustment: 0.0200, horizontal_field_of_view: 63.400


We don't really want to lose the information that's coded in the
container but not in the bitstream (Which happened in the previous
version of the patch too), so we should instead amend the container
level side data with the bitstream information.

Something like:


That results in this information NOT being available to caller in
get_buffer().

The least bad solution I see is have ff_decode_frame_props() merge
container information into existing side data, if set.


We need to ensure two things:

- Frame side data as output by lavc should contain the stereo3d 
information from the decoder alongside any from avctx. This should be in 
a single frame side data entry.
- Output stream side data as passed to lavf by the CLI should contain 
information that applies to the entire stream, which includes all the 
views packets may contain. This obviously also applies to what is passed 
to the encoder beforehand.


The former can be done, like you said above, having 
ff_decode_frame_props() merge the side data. The latter however would 
require changes to the CLI so the output encoder is not blindly 
initialized with the side data from the first frame that comes out of 
lavfi, which for mv-hevc always reports one specific view (and frame 
alternate type).
The CLI would need to use the knowledge of what the user requested to 
the decoder (one view? all views?) to update the global side data that's 
passed to the encoder and ultimately makes it to the muxer.




OpenPGP_signature.asc
Description: OpenPGP digital 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/7] avformat/mov_chan: Check for FF_SANE_NB_CHANNELS

2024-09-16 Thread James Almer

On 9/13/2024 2:48 PM, Michael Niedermayer wrote:

On Fri, Sep 13, 2024 at 12:08:45PM +0200, Anton Khirnov wrote:

Quoting Michael Niedermayer (2024-09-13 01:33:31)

We do not support more channels. For example avcodec_open2() limits channels 
this way too

The example file contains multiple chunks with over 16 million channels


We had this discussion already.


I remembered something too, but couldnt find the thread within teh time i was 
looking for it



Ad-hoc checks like this are only
addressing a symptom (probably one of many), and hide the actual bug.


If you have a better fix, submit it.

Does the following help with this sample?


diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c
index cc5b333129..4484a22a10 100644
--- a/libavformat/mov_chan.c
+++ b/libavformat/mov_chan.c
@@ -543,10 +543,22 @@ int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, 
AVStream *st,
 return 0;

 if (layout_tag == MOV_CH_LAYOUT_USE_DESCRIPTIONS) {
-int nb_channels = ch_layout->nb_channels ? ch_layout->nb_channels : 
num_descr;
+int nb_channels = ch_layout->nb_channels;
+
+if (!num_descr || num_descr < nb_channels) {
+av_log(s, AV_LOG_ERROR, "got %d channel descriptions when at least %d 
were needed\n",
+   num_descr, nb_channels);
+return AVERROR_INVALIDDATA;
+}
+
 if (num_descr > nb_channels) {
-av_log(s, AV_LOG_WARNING, "got %d channel descriptions, capping to the 
number of channels %d\n",
+int strict = s->strict_std_compliance >= FF_COMPLIANCE_STRICT;
+av_log(s, strict ? AV_LOG_ERROR : AV_LOG_WARNING,
+   "got %d channel descriptions when number of channels is 
%d\n",
num_descr, nb_channels);
+if (strict)
+return AVERROR_INVALIDDATA;
+av_log(s, AV_LOG_WARNING, "capping channel descriptions to the number 
of channels\n");
 num_descr = nb_channels;
 }




OpenPGP_signature.asc
Description: OpenPGP digital 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 21/23] tests/fate/hevc: add a test for nontrivial values of nuh_layer_id

2024-09-15 Thread James Almer

On 9/14/2024 7:45 AM, Anton Khirnov wrote:

Typical files use 0 for the base layer and 1 for the secondary one, but
any value for the secondary layer should be supported.
---
  tests/fate/hevc.mak |  4 
  tests/ref/fate/hevc-mv-nuh-layer-id | 15 +++
  2 files changed, 19 insertions(+)
  create mode 100644 tests/ref/fate/hevc-mv-nuh-layer-id

diff --git a/tests/fate/hevc.mak b/tests/fate/hevc.mak
index eb9d3a875c..df827d821f 100644
--- a/tests/fate/hevc.mak
+++ b/tests/fate/hevc.mak
@@ -272,6 +272,10 @@ FATE_HEVC-$(call FRAMECRC, HEVC, HEVC, HEVC_PARSER 
SCALE_FILTER) += fate-hevc-sm
  fate-hevc-pir: CMD = framecrc -i $(TARGET_SAMPLES)/hevc/pir.hevc
  FATE_HEVC-$(call FRAMECRC, HEVC, HEVC) += fate-hevc-pir
  
+# multiview stream, where the secondary layer has a nontrivial nuh_layer_id=6

+fate-hevc-mv-nuh-layer-id: CMD = framecrc -i 
$(TARGET_SAMPLES)/hevc/mv_nuh_layer_id.bit -map 0:view:all


Can you put this sample somewhere?


+FATE_HEVC-$(call FRAMECRC, HEVC, HEVC) += fate-hevc-mv-nuh-layer-id
+
  FATE_SAMPLES_AVCONV += $(FATE_HEVC-yes)
  FATE_SAMPLES_FFPROBE += $(FATE_HEVC_FFPROBE-yes)
  
diff --git a/tests/ref/fate/hevc-mv-nuh-layer-id b/tests/ref/fate/hevc-mv-nuh-layer-id

new file mode 100644
index 00..3cbefe17f6
--- /dev/null
+++ b/tests/ref/fate/hevc-mv-nuh-layer-id
@@ -0,0 +1,15 @@
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 128x128
+#sar 0: 0/1
+0,  0,  0,1,24576, 0xdfd350a6
+0,  1,  1,1,24576, 0xf8f638da
+0,  2,  2,1,24576, 0x8ac574d5
+0,  3,  3,1,24576, 0xd22675a4
+0,  4,  4,1,24576, 0xdd0f4704
+0,  5,  5,1,24576, 0x60da42e6
+0,  6,  6,1,24576, 0x8bf28fdd
+0,  7,  7,1,24576, 0xe0577f6e
+0,  8,  8,1,24576, 0x8b3e3c29
+0,  9,  9,1,24576, 0x8d9944bd




OpenPGP_signature.asc
Description: OpenPGP digital 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 20/23] tests/fate/hevc: add MV-HEVC conformance sample tests

2024-09-15 Thread James Almer

On 9/14/2024 7:45 AM, Anton Khirnov wrote:

Only those that can be decoded with our implementation, so excluding
* C and D - independent layers
* G, H, I - more than 2 layers

Frame hashes verified against the reference implementation from
https://hevc.hhi.fraunhofer.de/svn/svn_3DVCSoftware/
---
  tests/fate/hevc.mak   |  13 +-
  tests/ref/fate/hevc-conformance-MVHEVCS_A | 106 +
  tests/ref/fate/hevc-conformance-MVHEVCS_B | 138 ++
  tests/ref/fate/hevc-conformance-MVHEVCS_E | 106 +
  tests/ref/fate/hevc-conformance-MVHEVCS_F | 106 +
  5 files changed, 468 insertions(+), 1 deletion(-)
  create mode 100644 tests/ref/fate/hevc-conformance-MVHEVCS_A
  create mode 100644 tests/ref/fate/hevc-conformance-MVHEVCS_B
  create mode 100644 tests/ref/fate/hevc-conformance-MVHEVCS_E
  create mode 100644 tests/ref/fate/hevc-conformance-MVHEVCS_F


I uploaded these samples.



OpenPGP_signature.asc
Description: OpenPGP digital 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 19/23] fftools/ffmpeg: add support for multiview video

2024-09-15 Thread James Almer

On 9/14/2024 7:45 AM, Anton Khirnov wrote:

This extends the syntax for specifying input streams in -map and complex
filtergraph labels, to allow selecting a view by view ID, index, or
position. The corresponding decoder is then set up to decode the
appropriate view and send frames for that view to the correct
filtergraph input(s).
---
  doc/ffmpeg.texi   |  30 ++-
  fftools/cmdutils.c|   2 +-
  fftools/cmdutils.h|   2 +
  fftools/ffmpeg.h  |  45 -
  fftools/ffmpeg_dec.c  | 387 +-
  fftools/ffmpeg_demux.c|  24 ++-
  fftools/ffmpeg_filter.c   |  71 ---
  fftools/ffmpeg_mux_init.c |  34 ++--
  fftools/ffmpeg_opt.c  |  70 ++-
  9 files changed, 610 insertions(+), 55 deletions(-)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 842e92ad1a..34007f7ea2 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1799,7 +1799,7 @@ Set the size of the canvas used to render subtitles.
  @section Advanced options
  
  @table @option

-@item -map [-]@var{input_file_id}[:@var{stream_specifier}][?] | 
@var{[linklabel]} (@emph{output})
+@item -map 
[-]@var{input_file_id}[:@var{stream_specifier}][:@var{view_specifier}][?] | 
@var{[linklabel]} (@emph{output})
  
  Create one or more streams in the output file. This option has two forms for

  specifying the data source(s): the first selects one or more streams from some
@@ -1814,6 +1814,26 @@ only those streams that match the specifier are used 
(see the
  A @code{-} character before the stream identifier creates a "negative" 
mapping.
  It disables matching streams from already created mappings.
  
+An optional @var{view_specifier} may be given after the stream specifier, which

+for multiview video specifies the view to be used. The view specifier may have
+one of the following formats:
+@table @option
+@item view:@var{view_id}
+select a view by its ID; @var{view_id} may be set to 'all' to use all the views
+interleaved into one stream;
+
+@item vidx:@var{view_idx}
+select a view by its index; i.e. 0 is the base view, 1 is the first non-base
+view, etc.


I tried

./ffmpeg -i ../build/multiview.mov -map 0:v:view:1 -an -sn -f null -

and

./ffmpeg -i ../build/multiview.mov -map 0:v:vidx:1 -an -sn -f null -

with multiview.mov and in both cases both views are output. Am i missing 
something? I recall this working before.
view:0 and vidx:0 work the same as not setting any map (Just the base 
view is output), which is intended.




OpenPGP_signature.asc
Description: OpenPGP digital 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 03/23] lavu/frame: add side data storing view ID for multi-view video

2024-09-15 Thread James Almer

On 9/14/2024 7:45 AM, Anton Khirnov wrote:

---
  doc/APIchanges| 3 +++
  fftools/ffprobe.c | 2 ++
  libavfilter/vf_showinfo.c | 2 ++
  libavutil/frame.c | 1 +
  libavutil/frame.h | 9 +
  libavutil/version.h   | 2 +-
  6 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 830a38cd69..189932c99c 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
  
  API changes, most recent first:
  
+2024-xx-xx - xxx - lavu 59.37.100 - frame.h

+  Add AV_FRAME_DATA_VIEW_ID.
+
  2024-09-xx - xx - lavc 61.13.100 - avcodec.h
Add avcodec_get_supported_config() and enum AVCodecConfig; deprecate
AVCodec.pix_fmts, AVCodec.sample_fmts, AVCodec.supported_framerates,
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index bf5ebe3ce0..14b98d22a1 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2920,6 +2920,8 @@ static void print_frame_side_data(WriterContext *w,
  } else if (sd->type == AV_FRAME_DATA_FILM_GRAIN_PARAMS) {
  AVFilmGrainParams *fgp = (AVFilmGrainParams *)sd->data;
  print_film_grain_params(w, fgp);
+} else if (sd->type == AV_FRAME_DATA_VIEW_ID) {
+print_int("view_id", *(int*)sd->data);
  }
  writer_print_section_footer(w);
  }
diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index f81df9d1bf..77082505f5 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -857,6 +857,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
  case AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT:
  dump_ambient_viewing_environment(ctx, sd);
  break;
+case AV_FRAME_DATA_VIEW_ID:
+av_log(ctx, AV_LOG_INFO, "view id: %d\n", *(int*)sd->data);
  default:
  if (name)
  av_log(ctx, AV_LOG_INFO,
diff --git a/libavutil/frame.c b/libavutil/frame.c
index 5cbfc6a48b..891909fc2a 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -46,6 +46,7 @@ static const AVSideDataDescriptor sd_props[] = {
  [AV_FRAME_DATA_DETECTION_BBOXES]= { "Bounding boxes for object 
detection and classification" },
  [AV_FRAME_DATA_DOVI_RPU_BUFFER] = { "Dolby Vision RPU Data" },
  [AV_FRAME_DATA_DOVI_METADATA]   = { "Dolby Vision Metadata" },
+[AV_FRAME_DATA_VIEW_ID] = { "View ID" },
  [AV_FRAME_DATA_STEREO3D]= { "Stereo 3D",  
  AV_SIDE_DATA_PROP_GLOBAL },
  [AV_FRAME_DATA_REPLAYGAIN]  = { "AVReplayGain",   
  AV_SIDE_DATA_PROP_GLOBAL },
  [AV_FRAME_DATA_DISPLAYMATRIX]   = { "3x3 displaymatrix",  
  AV_SIDE_DATA_PROP_GLOBAL },
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 60bb966f8b..cea1c68df5 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -228,6 +228,15 @@ enum AVFrameSideDataType {
   * encoding.
   */
  AV_FRAME_DATA_VIDEO_HINT,
+
+/**
+ * This side data must be associated with a video frame.
+ * The presence of this side data indicates that the video stream is
+ * composed of multiple views (e.g. stereoscopic 3D content,
+ * cf. H.264 Annex H or H.265 Annex G).
+ * The data is an int storing the view ID.


What is the use case for AVFrame->metadata? What gets written there and 
what is expected by library users? Is it documented at all? Because a 
single int like this feels like would fit better there rather than as 
side data.



+ */
+AV_FRAME_DATA_VIEW_ID,
  };
  
  enum AVActiveFormatDescription {

diff --git a/libavutil/version.h b/libavutil/version.h
index 25a6f5531b..7900379c12 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
   */
  
  #define LIBAVUTIL_VERSION_MAJOR  59

-#define LIBAVUTIL_VERSION_MINOR  36
+#define LIBAVUTIL_VERSION_MINOR  37
  #define LIBAVUTIL_VERSION_MICRO 100
  
  #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \




OpenPGP_signature.asc
Description: OpenPGP digital 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 01/23] compat: drop gcc, suncc, and pthreads stdatomic emulation

2024-09-15 Thread James Almer

On 9/14/2024 7:45 AM, Anton Khirnov wrote:

Since we now require a C11-compliant compiler, there should be no
supported configurations where any of these is used.
---
  compat/atomics/gcc/stdatomic.h | 173 -
  compat/atomics/pthread/stdatomic.c |  39 --
  compat/atomics/pthread/stdatomic.h | 197 -
  compat/atomics/suncc/stdatomic.h   | 186 ---


Is there any SunCC version we support now? Because there's a lot of 
bitrotting checks for it in configure.



  configure  |  19 +--
  5 files changed, 1 insertion(+), 613 deletions(-)
  delete mode 100644 compat/atomics/gcc/stdatomic.h
  delete mode 100644 compat/atomics/pthread/stdatomic.c
  delete mode 100644 compat/atomics/pthread/stdatomic.h
  delete mode 100644 compat/atomics/suncc/stdatomic.h


Ok.



OpenPGP_signature.asc
Description: OpenPGP digital 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 v2 02/23] compat: add a fallback implementation of C23 stdbit.h

2024-09-15 Thread James Almer

On 9/14/2024 11:56 AM, Anton Khirnov wrote:

From: Rémi Denis-Courmont 

Header contents taken from VLC commit 7a970a33329c9836d169727ddbaf49a33240d587.

Signed-off-by: Anton Khirnov 
---
  compat/stdbit/stdbit.h | 596 +
  configure  |   4 +
  tests/ref/fate/source  |   1 +
  3 files changed, 601 insertions(+)
  create mode 100644 compat/stdbit/stdbit.h


Should be ok.



OpenPGP_signature.asc
Description: OpenPGP digital 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 v3 2/2] fate/vvc: Add a sample which lose frames before b02b411

2024-09-15 Thread James Almer

On 9/15/2024 1:54 AM, Zhao Zhili wrote:

From: Zhao Zhili 

---
sample:
8054b4b8e62c0171476b40206d044590  Hierarchical.bit
https://drive.google.com/file/d/1U5WGWeSsMFiEkhsl_vL4NiMma-LLh02t/view?usp=sharing

  tests/fate/vvc.mak  |  1 +
  tests/ref/fate/vvc-conformance-Hierarchical | 35 +
  2 files changed, 36 insertions(+)
  create mode 100644 tests/ref/fate/vvc-conformance-Hierarchical

diff --git a/tests/fate/vvc.mak b/tests/fate/vvc.mak
index 5335460263..7fd0a47214 100644
--- a/tests/fate/vvc.mak
+++ b/tests/fate/vvc.mak
@@ -1,5 +1,6 @@
  VVC_SAMPLES_8BIT =\
  CodingToolsSets_A_2   \
+Hierarchical  \


If this sample is not part of the conformance suite, then it needs to be 
in a separate folder called vvc.


  
  VVC_SAMPLES_10BIT =   \

  APSALF_A_2\
diff --git a/tests/ref/fate/vvc-conformance-Hierarchical 
b/tests/ref/fate/vvc-conformance-Hierarchical
new file mode 100644
index 00..0797305b9a
--- /dev/null
+++ b/tests/ref/fate/vvc-conformance-Hierarchical
@@ -0,0 +1,35 @@
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 480x320
+#sar 0: 0/1
+0,  0,  0,1,   230400, 0x3293f7f1
+0,  1,  1,1,   230400, 0xe2570fa4
+0,  2,  2,1,   230400, 0xecd608fb
+0,  3,  3,1,   230400, 0xea46f9f4
+0,  4,  4,1,   230400, 0xb715d24a
+0,  5,  5,1,   230400, 0x69faaf46
+0,  6,  6,1,   230400, 0xf9a362db
+0,  7,  7,1,   230400, 0x2dcd19ca
+0,  8,  8,1,   230400, 0xf8fda185
+0,  9,  9,1,   230400, 0x48a35bfd
+0, 10, 10,1,   230400, 0x27efe832
+0, 11, 11,1,   230400, 0x74279617
+0, 12, 12,1,   230400, 0x91935248
+0, 13, 13,1,   230400, 0x29b621e6
+0, 14, 14,1,   230400, 0x89b1ec0b
+0, 15, 15,1,   230400, 0x898fdba1
+0, 16, 16,1,   230400, 0xc6d18e6f
+0, 17, 17,1,   230400, 0xedff651b
+0, 18, 18,1,   230400, 0x677e2260
+0, 19, 19,1,   230400, 0x930918ef
+0, 20, 20,1,   230400, 0x70da2c30
+0, 21, 21,1,   230400, 0x699a3b9d
+0, 22, 22,1,   230400, 0xff3b1b3a
+0, 23, 23,1,   230400, 0xca11d9a5
+0, 24, 24,1,   230400, 0x904394e0
+0, 25, 25,1,   230400, 0x392e5445
+0, 26, 26,1,   230400, 0x6191f4d8
+0, 27, 27,1,   230400, 0xa7d7be12
+0, 28, 28,1,   230400, 0xbb29752c
+0, 29, 29,1,   230400, 0x14ff297e




OpenPGP_signature.asc
Description: OpenPGP digital 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 16/23] avcodec/hevc/refs: export Stereo 3D side data

2024-09-14 Thread James Almer

On 9/14/2024 7:12 PM, James Almer wrote:

On 9/14/2024 7:45 AM, Anton Khirnov wrote:

From: James Almer 

Use the 3D Reference Displays Info SEI message to link a view_id with
an eye.

Signed-off-by: James Almer 
---
  libavcodec/hevc/hevcdec.c |  1 +
  libavcodec/hevc/refs.c    | 19 +++
  2 files changed, 20 insertions(+)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 692f19e97e..b784b10bcf 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3968,6 +3968,7 @@ static int 
hevc_update_thread_context(AVCodecContext *dst,
  s->sei.common.mastering_display    = s0- 
>sei.common.mastering_display;

  s->sei.common.content_light    = s0->sei.common.content_light;
  s->sei.common.aom_film_grain   = s0->sei.common.aom_film_grain;
+    s->sei.tdrdi   = s0->sei.tdrdi;
  return 0;
  }
diff --git a/libavcodec/hevc/refs.c b/libavcodec/hevc/refs.c
index b9b08ca416..ac1b07a308 100644
--- a/libavcodec/hevc/refs.c
+++ b/libavcodec/hevc/refs.c
@@ -22,6 +22,7 @@
   */
  #include "libavutil/mem.h"
+#include "libavutil/stereo3d.h"
  #include "container_fifo.h"
  #include "decode.h"
@@ -94,6 +95,7 @@ static HEVCFrame *alloc_frame(HEVCContext *s, 
HEVCLayerContext *l)

  // add view ID side data if it's nontrivial
  if (vps->nb_layers > 1 || view_id) {
+    HEVCSEITDRDI *tdrdi = &s->sei.tdrdi;
  AVFrameSideData *sd = av_frame_side_data_new(&frame->f- 
>side_data,
   &frame->f- 
>nb_side_data,
   
AV_FRAME_DATA_VIEW_ID,
@@ -101,6 +103,23 @@ static HEVCFrame *alloc_frame(HEVCContext *s, 
HEVCLayerContext *l)

  if (!sd)
  goto fail;
  *(int*)sd->data = view_id;
+
+    if (tdrdi->num_ref_displays) {
+    AVStereo3D *stereo_3d;
+
+    av_frame_remove_side_data(frame->f, 
AV_FRAME_DATA_STEREO3D);


As this is now being called before ff_progress_frame_get_buffer() (is 
there a reason you wanted the view_id side data and this one applied to 
the frame before get_buffer()?), it became a no-op and any stereo 3d 
side data in the input packet will be appended to the frame, resulting 
in something like:



[Parsed_showinfo_0 @ 0281481551c0]   side data - View ID: view id: 0
[Parsed_showinfo_0 @ 0281481551c0]   side data - Stereo 3D: type - 
frame alternate, view - right, primary_eye - none
[Parsed_showinfo_0 @ 0281481551c0]   side data - Spherical 
Mapping: rectilinear
[Parsed_showinfo_0 @ 0281481551c0]   side data - Stereo 3D: type - 
unspecified, view - packed, primary_eye - none, baseline: 19240, 
horizontal_disparity_adjustment: 0.0200, horizontal_field_of_view: 63.400


We don't really want to lose the information that's coded in the 
container but not in the bitstream (Which happened in the previous 
version of the patch too), so we should instead amend the container 
level side data with the bitstream information.


Something like:


diff --git a/libavcodec/hevc/refs.c b/libavcodec/hevc/refs.c
index ac1b07a308..f4c2b18e83 100644
--- a/libavcodec/hevc/refs.c
+++ b/libavcodec/hevc/refs.c
@@ -93,21 +93,32 @@ static HEVCFrame *alloc_frame(HEVCContext *s, 
HEVCLayerContext *l)

 if (ret < 0)
 return NULL;

+    if (!(s->layers_active_output & (1 << s->cur_layer)))
+    frame->f->flags |= AV_FRAME_FLAG_DISCARD;
+
+    ret = ff_progress_frame_get_buffer(s->avctx, &frame->tf,
+   AV_GET_BUFFER_FLAG_REF);
+    if (ret < 0)
+    return NULL;
+
 // add view ID side data if it's nontrivial
 if (vps->nb_layers > 1 || view_id) {
 HEVCSEITDRDI *tdrdi = &s->sei.tdrdi;
-    AVFrameSideData *sd = av_frame_side_data_new(&frame->f- 
>side_data,
- &frame->f- 
>nb_side_data,
- 
AV_FRAME_DATA_VIEW_ID,
- sizeof(int), 
0);

+    AVFrameSideData *sd;
+
+    av_frame_remove_side_data(frame->f, AV_FRAME_DATA_VIEW_ID);
+    sd = av_frame_new_side_data(frame->f, 
AV_FRAME_DATA_VIEW_ID, sizeof(int));

 if (!sd)
 goto fail;
 *(int*)sd->data = view_id;

 if (tdrdi->num_ref_displays) {
-    AVStereo3D *stereo_3d;
+    AVStereo3D *stereo_3d = NULL;

-    av_frame_remove_side_data(frame->f, 
AV_FRAME_DATA_STEREO3D);
+    sd = av_frame_get_side_data(frame->f, 
AV_FRAME_DATA_STEREO3D);

+    if (

Re: [FFmpeg-devel] [PATCH 16/23] avcodec/hevc/refs: export Stereo 3D side data

2024-09-14 Thread James Almer

On 9/14/2024 7:45 AM, Anton Khirnov wrote:

From: James Almer 

Use the 3D Reference Displays Info SEI message to link a view_id with
an eye.

Signed-off-by: James Almer 
---
  libavcodec/hevc/hevcdec.c |  1 +
  libavcodec/hevc/refs.c| 19 +++
  2 files changed, 20 insertions(+)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 692f19e97e..b784b10bcf 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3968,6 +3968,7 @@ static int hevc_update_thread_context(AVCodecContext *dst,
  s->sei.common.mastering_display= s0->sei.common.mastering_display;
  s->sei.common.content_light= s0->sei.common.content_light;
  s->sei.common.aom_film_grain   = s0->sei.common.aom_film_grain;
+s->sei.tdrdi   = s0->sei.tdrdi;
  
  return 0;

  }
diff --git a/libavcodec/hevc/refs.c b/libavcodec/hevc/refs.c
index b9b08ca416..ac1b07a308 100644
--- a/libavcodec/hevc/refs.c
+++ b/libavcodec/hevc/refs.c
@@ -22,6 +22,7 @@
   */
  
  #include "libavutil/mem.h"

+#include "libavutil/stereo3d.h"
  
  #include "container_fifo.h"

  #include "decode.h"
@@ -94,6 +95,7 @@ static HEVCFrame *alloc_frame(HEVCContext *s, 
HEVCLayerContext *l)
  
  // add view ID side data if it's nontrivial

  if (vps->nb_layers > 1 || view_id) {
+HEVCSEITDRDI *tdrdi = &s->sei.tdrdi;
  AVFrameSideData *sd = av_frame_side_data_new(&frame->f->side_data,
   
&frame->f->nb_side_data,
   
AV_FRAME_DATA_VIEW_ID,
@@ -101,6 +103,23 @@ static HEVCFrame *alloc_frame(HEVCContext *s, 
HEVCLayerContext *l)
  if (!sd)
  goto fail;
  *(int*)sd->data = view_id;
+
+if (tdrdi->num_ref_displays) {
+AVStereo3D *stereo_3d;
+
+av_frame_remove_side_data(frame->f, AV_FRAME_DATA_STEREO3D);


As this is now being called before ff_progress_frame_get_buffer() (is 
there a reason you wanted the view_id side data and this one applied to 
the frame before get_buffer()?), it became a no-op and any stereo 3d 
side data in the input packet will be appended to the frame, resulting 
in something like:



[Parsed_showinfo_0 @ 0281481551c0]   side data - View ID: view id: 0
[Parsed_showinfo_0 @ 0281481551c0]   side data - Stereo 3D: type - frame 
alternate, view - right, primary_eye - none
[Parsed_showinfo_0 @ 0281481551c0]   side data - Spherical Mapping: 
rectilinear
[Parsed_showinfo_0 @ 0281481551c0]   side data - Stereo 3D: type - 
unspecified, view - packed, primary_eye - none, baseline: 19240, 
horizontal_disparity_adjustment: 0.0200, horizontal_field_of_view: 63.400


We don't really want to lose the information that's coded in the 
container but not in the bitstream (Which happened in the previous 
version of the patch too), so we should instead amend the container 
level side data with the bitstream information.


Something like:


diff --git a/libavcodec/hevc/refs.c b/libavcodec/hevc/refs.c
index ac1b07a308..f4c2b18e83 100644
--- a/libavcodec/hevc/refs.c
+++ b/libavcodec/hevc/refs.c
@@ -93,21 +93,32 @@ static HEVCFrame *alloc_frame(HEVCContext *s, 
HEVCLayerContext *l)
 if (ret < 0)
 return NULL;

+if (!(s->layers_active_output & (1 << s->cur_layer)))
+frame->f->flags |= AV_FRAME_FLAG_DISCARD;
+
+ret = ff_progress_frame_get_buffer(s->avctx, &frame->tf,
+   AV_GET_BUFFER_FLAG_REF);
+if (ret < 0)
+return NULL;
+
 // add view ID side data if it's nontrivial
 if (vps->nb_layers > 1 || view_id) {
 HEVCSEITDRDI *tdrdi = &s->sei.tdrdi;
-AVFrameSideData *sd = av_frame_side_data_new(&frame->f->side_data,
- 
&frame->f->nb_side_data,
- AV_FRAME_DATA_VIEW_ID,
- sizeof(int), 0);
+AVFrameSideData *sd;
+
+av_frame_remove_side_data(frame->f, AV_FRAME_DATA_VIEW_ID);
+sd = av_frame_new_side_data(frame->f, AV_FRAME_DATA_VIEW_ID, 
sizeof(int));
 if (!sd)
 goto fail;
 *(int*)sd->data = view_id;

 if (tdrdi->num_ref_displays) {
-AVStereo3D *stereo_3d;
+AVStereo3D *stereo_3d = NULL;

-av_frame_remove_side_data(frame->f, AV_FRAME_DATA_STEREO3D);
+sd = av_frame_get_side_data(frame->f, AV_FRAME_DATA_STEREO3D);
+if (sd)
+stereo_3d = (A

Re: [FFmpeg-devel] [PATCH 02/23] compat: add a fallback implementation of C23 stdbit.h

2024-09-14 Thread James Almer

On 9/14/2024 7:45 AM, Anton Khirnov wrote:

From: Rémi Denis-Courmont 

Header contents taken from VLC commit 7a970a33329c9836d169727ddbaf49a33240d587.

Signed-off-by: Anton Khirnov 
---
  compat/stdbit/stdbit.h | 594 +
  configure  |   4 +
  tests/ref/fate/source  |   1 +
  3 files changed, 599 insertions(+)
  create mode 100644 compat/stdbit/stdbit.h

diff --git a/compat/stdbit/stdbit.h b/compat/stdbit/stdbit.h
new file mode 100644
index 00..b6a2c7e945
--- /dev/null
+++ b/compat/stdbit/stdbit.h
@@ -0,0 +1,594 @@
+/*
+ * Copyright (C) 2023 Rémi Denis-Courmont
+ *
+ * This program 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.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ */
+
+#ifndef __STDC_VERSION_STDBIT_H__
+#define __STDC_VERSION_STDBIT_H__ 202311L
+
+#include 
+#include  /* CHAR_BIT */
+
+#define __STDC_ENDIAN_LITTLE__ 1234
+#define __STDC_ENDIAN_BIG__4321
+
+#ifdef __BYTE_ORDER__


This doesn't seem to be defined in msvc. I looked at VLC and their CI 
seems to use gcc only for Windows, which would explain why it's written 
as is.


It should be safe to just hardcode little endian for it (or Windows in 
general, even for aarch64).




OpenPGP_signature.asc
Description: OpenPGP digital 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] avcodec/bsf/dts2pts: use a RefStruct pool to allocate nodes

2024-09-13 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/bsf/dts2pts.c | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/libavcodec/bsf/dts2pts.c b/libavcodec/bsf/dts2pts.c
index ba4dc43f84..2be79c624b 100644
--- a/libavcodec/bsf/dts2pts.c
+++ b/libavcodec/bsf/dts2pts.c
@@ -34,6 +34,7 @@
 #include "cbs_h264.h"
 #include "h264_parse.h"
 #include "h264_ps.h"
+#include "refstruct.h"
 
 typedef struct DTS2PTSNode {
 int64_t  dts;
@@ -61,6 +62,7 @@ typedef struct DTS2PTSH264Context {
 typedef struct DTS2PTSContext {
 struct AVTreeNode *root;
 AVFifo *fifo;
+FFRefStructPool *node_pool;
 
 // Codec specific function pointers and constants
 int (*init)(AVBSFContext *ctx);
@@ -110,7 +112,7 @@ static int dec_poc(void *opaque, void *elem)
 static int free_node(void *opaque, void *elem)
 {
 DTS2PTSNode *node = elem;
-av_free(node);
+ff_refstruct_unref(&node);
 return 0;
 }
 
@@ -124,7 +126,7 @@ static int alloc_and_insert_node(AVBSFContext *ctx, int64_t 
ts, int64_t duration
 DTS2PTSNode *poc_node, *ret;
 if (!node)
 return AVERROR(ENOMEM);
-poc_node = av_malloc(sizeof(*poc_node));
+poc_node = ff_refstruct_pool_get(s->node_pool);
 if (!poc_node) {
 av_free(node);
 return AVERROR(ENOMEM);
@@ -135,7 +137,7 @@ static int alloc_and_insert_node(AVBSFContext *ctx, int64_t 
ts, int64_t duration
 ret = av_tree_insert(&s->root, poc_node, cmp_insert, &node);
 if (ret && ret != poc_node) {
 *ret = *poc_node;
-av_free(poc_node);
+ff_refstruct_unref(&poc_node);
 av_free(node);
 }
 }
@@ -394,6 +396,11 @@ static int dts2pts_init(AVBSFContext *ctx)
 if (!s->fifo)
 return AVERROR(ENOMEM);
 
+s->node_pool = ff_refstruct_pool_alloc(sizeof(DTS2PTSNode), 0);
+
+if (!s->node_pool)
+return AVERROR(ENOMEM);
+
 ret = ff_cbs_init(&s->cbc, ctx->par_in->codec_id, ctx);
 if (ret < 0)
 return ret;
@@ -459,7 +466,7 @@ static int dts2pts_filter(AVBSFContext *ctx, AVPacket *out)
 if (!poc_node || poc_node->dts != out->pts)
 continue;
 av_tree_insert(&s->root, poc_node, cmp_insert, &node);
-av_free(poc_node);
+ff_refstruct_unref(&poc_node);
 av_free(node);
 poc_node = av_tree_find(s->root, &dup, cmp_find, NULL);
 }
@@ -521,6 +528,7 @@ static void dts2pts_close(AVBSFContext *ctx)
 dts2pts_flush(ctx);
 
 av_fifo_freep2(&s->fifo);
+ff_refstruct_pool_uninit(&s->node_pool);
 ff_cbs_fragment_free(&s->au);
 ff_cbs_close(&s->cbc);
 }
-- 
2.46.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] avcodec/refstruct: inline ff_refstruct_pool_alloc()

2024-09-13 Thread James Almer
Much like ff_refstruct_pool_alloc_ext(), it's a wrapper around
ff_refstruct_pool_alloc_ext_c().

Signed-off-by: James Almer 
---
 libavcodec/refstruct.c |  5 -
 libavcodec/refstruct.h | 17 -
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/libavcodec/refstruct.c b/libavcodec/refstruct.c
index f89af156c2..13778f3f58 100644
--- a/libavcodec/refstruct.c
+++ b/libavcodec/refstruct.c
@@ -332,11 +332,6 @@ static void refstruct_pool_uninit(FFRefStructOpaque 
unused, void *obj)
 }
 }
 
-FFRefStructPool *ff_refstruct_pool_alloc(size_t size, unsigned flags)
-{
-return ff_refstruct_pool_alloc_ext(size, flags, NULL, NULL, NULL, NULL, 
NULL);
-}
-
 FFRefStructPool *ff_refstruct_pool_alloc_ext_c(size_t size, unsigned flags,
FFRefStructOpaque opaque,
int  
(*init_cb)(FFRefStructOpaque opaque, void *obj),
diff --git a/libavcodec/refstruct.h b/libavcodec/refstruct.h
index c64ad62b6b..f9cd406bf2 100644
--- a/libavcodec/refstruct.h
+++ b/libavcodec/refstruct.h
@@ -220,11 +220,6 @@ typedef struct FFRefStructPool FFRefStructPool;
  */
 #define FF_REFSTRUCT_POOL_FLAG_ZERO_EVERY_TIME   (1 << 18)
 
-/**
- * Equivalent to ff_refstruct_pool_alloc(size, flags, NULL, NULL, NULL, NULL, 
NULL)
- */
-FFRefStructPool *ff_refstruct_pool_alloc(size_t size, unsigned flags);
-
 /**
  * Allocate an FFRefStructPool, potentially using complex callbacks.
  *
@@ -266,6 +261,18 @@ FFRefStructPool *ff_refstruct_pool_alloc_ext(size_t size, 
unsigned flags,
  init_cb, reset_cb, free_entry_cb, 
free_cb);
 }
 
+/**
+ * A wrapper around ff_refstruct_pool_alloc_ext_c() for the common case
+ * of no custom callbacks.
+ *
+ * @see ff_refstruct_pool_alloc_ext_c()
+ */
+static inline
+FFRefStructPool *ff_refstruct_pool_alloc(size_t size, unsigned flags)
+{
+return ff_refstruct_pool_alloc_ext(size, flags, NULL, NULL, NULL, NULL, 
NULL);
+}
+
 /**
  * Get an object from the pool, reusing an old one from the pool when
  * available.
-- 
2.46.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] [RFC/PATCH] MV-HEVC decoding

2024-09-13 Thread James Almer

On 9/13/2024 5:51 PM, Danny Hong wrote:

Quoting James Almer (2024-09-13 22:19:35)

Are you talking about decoding the resulting raw bitstream created from
doing stream copy from the source mov? If so, what's happening is
probably that the parser is splitting AUs when the second SEI with
layer_id == 0 shows up in those non-conformant samples.
This doesn't happen if you try to decode directly from the mov as the
parser does not attempt to do any packetization then.


Yes, this is due to hevc_find_frame_end (in libavcodec/hevc/parser.c)
correctly marking a new AU when prefix NAL with layer ID 0 is detected.  I
think Apple is incorrectly placing the prefix NAL to precede the VCL NAL
with layer ID 1.


It's probably not misplaced but mistagged as nuh_layer_id == 0 when it 
should be 1 (Can SEI NALUs be in anything other than the base layer?).
The SEI is User Data Unregistered, and its contents are different than 
the one preceding the base layer VCL NALU. so i guess it's some Apple 
specific metadata that applies to each corresponding view that they 
didn't bother to document.


Can this issue be raised to them?



OpenPGP_signature.asc
Description: OpenPGP digital 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] [RFC/PATCH] MV-HEVC decoding

2024-09-13 Thread James Almer

On 9/13/2024 2:58 PM, Danny Hong wrote:

  Quoting Anton Khirnov (2024-09-13 12:44:55)

Note that -view_ids is a decoder option and does nothing with
streamcopy.
Also, that option is intended for API users, with ffmpeg CLI you should
be using view specifiers instead.


Thanks!  Tried with "-map 0:v:view:all" and the result is the same.  The
resulting elementary stream cannot be decoded by ffmpeg as the stream is
not conformant.


Are you talking about decoding the resulting raw bitstream created from 
doing stream copy from the source mov? If so, what's happening is 
probably that the parser is splitting AUs when the second SEI with 
layer_id == 0 shows up in those non-conformant samples.
This doesn't happen if you try to decode directly from the mov as the 
parser does not attempt to do any packetization then.





Use view specifiers to split the views into their own streams. I do not
want too much multiview-speficic logic into ffmpeg CLI, as it is a
rather obscure feature.


But the "-map 0:v:view:all" option is still available to output both views
as a single stream with alternating views, no?
Using "-map 0:v:vidx:0 -f rawvideo out0.yuv420p -map 0:v:vidx:1 -f rawvideo
out1.yuv420p" to split the views into separate streams seems to work fine
without the issues mentioned before.
___
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".




OpenPGP_signature.asc
Description: OpenPGP digital 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 11/11] avfilter: add an LCEVC decoding filter via LCEVCdec

2024-09-12 Thread James Almer
Signed-off-by: James Almer 
---
 configure|   1 +
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/version.h|   4 +-
 libavfilter/vf_lcevc.c   | 434 +++
 5 files changed, 439 insertions(+), 2 deletions(-)
 create mode 100644 libavfilter/vf_lcevc.c

diff --git a/configure b/configure
index e528714735..e88f4490b4 100755
--- a/configure
+++ b/configure
@@ -3891,6 +3891,7 @@ identity_filter_select="scene_sad"
 interlace_filter_deps="gpl"
 kerndeint_filter_deps="gpl"
 ladspa_filter_deps="ladspa libdl"
+lcevc_filter_deps="liblcevc_dec"
 lensfun_filter_deps="liblensfun version3"
 libplacebo_filter_deps="libplacebo vulkan"
 lv2_filter_deps="lv2"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index ac6a8d5783..91487afb21 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -360,6 +360,7 @@ OBJS-$(CONFIG_INTERLEAVE_FILTER) += 
f_interleave.o
 OBJS-$(CONFIG_KERNDEINT_FILTER)  += vf_kerndeint.o
 OBJS-$(CONFIG_KIRSCH_FILTER) += vf_convolution.o
 OBJS-$(CONFIG_LAGFUN_FILTER) += vf_lagfun.o
+OBJS-$(CONFIG_LCEVC_FILTER)  += vf_lcevc.o
 OBJS-$(CONFIG_LATENCY_FILTER)+= f_latency.o
 OBJS-$(CONFIG_LENSCORRECTION_FILTER) += vf_lenscorrection.o
 OBJS-$(CONFIG_LENSFUN_FILTER)+= vf_lensfun.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 8e7d912c9f..9819f0f95b 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -337,6 +337,7 @@ extern const AVFilter ff_vf_kerndeint;
 extern const AVFilter ff_vf_kirsch;
 extern const AVFilter ff_vf_lagfun;
 extern const AVFilter ff_vf_latency;
+extern const AVFilter ff_vf_lcevc;
 extern const AVFilter ff_vf_lenscorrection;
 extern const AVFilter ff_vf_lensfun;
 extern const AVFilter ff_vf_libplacebo;
diff --git a/libavfilter/version.h b/libavfilter/version.h
index d8cd8a2cfb..7e0eb9af97 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -31,8 +31,8 @@
 
 #include "version_major.h"
 
-#define LIBAVFILTER_VERSION_MINOR   2
-#define LIBAVFILTER_VERSION_MICRO 102
+#define LIBAVFILTER_VERSION_MINOR   3
+#define LIBAVFILTER_VERSION_MICRO 100
 
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
diff --git a/libavfilter/vf_lcevc.c b/libavfilter/vf_lcevc.c
new file mode 100644
index 00..843692cf40
--- /dev/null
+++ b/libavfilter/vf_lcevc.c
@@ -0,0 +1,434 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * Copyright (c) 2024 James Almer 
+ *
+ * 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 
+
+#include 
+
+#include "libavutil/internal.h"
+#include "libavutil/opt.h"
+#include "filters.h"
+#include "video.h"
+
+typedef struct LCEVCContext {
+LCEVC_DecoderHandle decoder;
+LCEVC_PictureHandle base;
+int w, h;
+} LCEVCContext;
+
+static LCEVC_ColorFormat map_format(int format)
+{
+switch (format) {
+case AV_PIX_FMT_YUV420P:
+return LCEVC_I420_8;
+case AV_PIX_FMT_YUV420P10:
+return LCEVC_I420_10_LE;
+case AV_PIX_FMT_NV12:
+return LCEVC_NV12_8;
+case AV_PIX_FMT_NV21:
+return LCEVC_NV21_8;
+case AV_PIX_FMT_GRAY8:
+return LCEVC_GRAY_8;
+case AV_PIX_FMT_GRAY10LE:
+return LCEVC_GRAY_10_LE;
+}
+
+return LCEVC_ColorFormat_Unknown;
+}
+
+static inline LCEVC_ColorRange map_range(int range)
+{
+switch (range) {
+case AVCOL_RANGE_MPEG:
+return LCEVC_ColorRange_Limited;
+case AVCOL_RANGE_JPEG:
+return LCEVC_ColorRange_Full;
+}
+
+return LCEVC_ColorRange_Unknown;
+}
+
+static inline enum AVColorRange map_av_range(int range)
+{
+switch (range) {
+case LCEVC_ColorRange_Limited:
+return AVCOL_RANGE_MPEG;
+case LCEVC_ColorRange_Full:
+return AVCOL_RANGE_JPEG;
+}
+
+return AVCOL_RANGE_UNSPECIFIED;
+}
+
+static int alloc_base_frame(AVFilterLink *inlink, const AVFrame *in,
+LCEVC_PictureHandle *picture)
+{
+AVFilterContext *ctx = inlink->dst;
+LCEVCContext *lcevc = ctx->priv;
+LCEVC_PictureDesc de

Re: [FFmpeg-devel] [PATCH] tests/checkasm/sw_rgb: don't write random data past the end of the buffer

2024-09-12 Thread James Almer

On 9/12/2024 5:16 AM, Ramiro Polla wrote:

On Thu, Sep 12, 2024 at 8:44 AM James Almer  wrote:


Should fix fate-checkasm-sw_rgb under gcc-ubsan.

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

diff --git a/tests/checkasm/sw_rgb.c b/tests/checkasm/sw_rgb.c
index af9434073a..cdd43df8ba 100644
--- a/tests/checkasm/sw_rgb.c
+++ b/tests/checkasm/sw_rgb.c
@@ -287,7 +287,7 @@ static void check_deinterleave_bytes(void)
 int width, int height, int srcStride,
 int dst1Stride, int dst2Stride);

-randomize_buffers(src, 2*MAX_STRIDE*MAX_HEIGHT+2);
+randomize_buffers(src, 2*MAX_STRIDE*MAX_HEIGHT);


Thank you for spotting it.

The issue is that randomize_buffers() writes 4 bytes at a time. I
think the proper fix is to change randomize_buffers() to not write
past the end of the buffer. It would be even better to move


2*MAX_STRIDE*MAX_HEIGHT is a multiple of 4 and the exact size of the 
available buffer, whereas 2*MAX_STRIDE*MAX_HEIGHT+2 isn't.



randomize_buffers() to checkasm.h or checkasm.c so it doesn't have to
be copied around so many times.
___
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".




OpenPGP_signature.asc
Description: OpenPGP digital 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 09/10] avcodec/hevc/refs: ensure LCEVC SEI payloads are exported as frame side data before get_buffer() calls

2024-09-11 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/hevc/refs.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/libavcodec/hevc/refs.c b/libavcodec/hevc/refs.c
index 09d759f936..a75153c462 100644
--- a/libavcodec/hevc/refs.c
+++ b/libavcodec/hevc/refs.c
@@ -86,6 +86,19 @@ static HEVCFrame *alloc_frame(HEVCContext *s, 
HEVCLayerContext *l)
 if (frame->f)
 continue;
 
+ret = ff_progress_frame_alloc(s->avctx, &frame->tf);
+if (ret < 0)
+return NULL;
+
+// Add LCEVC SEI metadata here, as it's needed in get_buffer()
+if (s->sei.common.lcevc.info) {
+HEVCSEILCEVC *lcevc = &s->sei.common.lcevc;
+ret = ff_frame_new_side_data_from_buf(s->avctx, frame->tf.f,
+  AV_FRAME_DATA_LCEVC, 
&lcevc->info);
+if (ret < 0)
+goto fail;
+}
+
 ret = ff_progress_frame_get_buffer(s->avctx, &frame->tf,
AV_GET_BUFFER_FLAG_REF);
 if (ret < 0)
-- 
2.46.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 08/10 v2] avcodec/decode: split ProgressFrame allocator into two functions

2024-09-11 Thread James Almer
Signed-off-by: James Almer 
---
No changes since last version.

 libavcodec/decode.c| 11 +++
 libavcodec/progressframe.h | 16 ++--
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 18ddd28690..e4e92e34e4 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1725,7 +1725,7 @@ static void check_progress_consistency(const 
ProgressFrame *f)
 av_assert1(!f->progress || f->progress->f == f->f);
 }
 
-static int progress_frame_get(AVCodecContext *avctx, ProgressFrame *f)
+int ff_progress_frame_alloc(AVCodecContext *avctx, ProgressFrame *f)
 {
 FFRefStructPool *pool = avctx->internal->progress_frame_pool;
 
@@ -1743,9 +1743,12 @@ int ff_progress_frame_get_buffer(AVCodecContext *avctx, 
ProgressFrame *f, int fl
 {
 int ret;
 
-ret = progress_frame_get(avctx, f);
-if (ret < 0)
-return ret;
+check_progress_consistency(f);
+if (!f->f) {
+ret = ff_progress_frame_alloc(avctx, f);
+if (ret < 0)
+return ret;
+}
 
 ret = ff_thread_get_buffer(avctx, f->progress->f, flags);
 if (ret < 0) {
diff --git a/libavcodec/progressframe.h b/libavcodec/progressframe.h
index 428a461659..32a345beec 100644
--- a/libavcodec/progressframe.h
+++ b/libavcodec/progressframe.h
@@ -102,12 +102,24 @@ void ff_progress_frame_report(ProgressFrame *f, int 
progress);
 void ff_progress_frame_await(const ProgressFrame *f, int progress);
 
 /**
- * This function sets up the ProgressFrame, i.e. gets ProgressFrame.f
- * and also calls ff_thread_get_buffer() on the frame.
+ * This function allocates ProgressFrame.f
+ * May be called before ff_progress_frame_get_buffer() in the cases where the
+ * AVFrame needs to be accessed before the ff_thread_get_buffer() call in
+ * ff_progress_frame_alloc().
  *
  * @note: This must only be called by codecs with the
  *FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap.
  */
+int ff_progress_frame_alloc(struct AVCodecContext *avctx, ProgressFrame *f);
+
+/**
+ * This function sets up the ProgressFrame, i.e. allocates ProgressFrame.f
+ * if needed, and also calls ff_thread_get_buffer() on the frame.
+ *
+ * @note: This must only be called by codecs with the
+ *FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap.
+ * @see ff_progress_frame_alloc
+ */
 int ff_progress_frame_get_buffer(struct AVCodecContext *avctx,
  ProgressFrame *f, int flags);
 
-- 
2.46.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 07/10 v2] avcodec/packet: add an LCEVC enhancement data payload side data type

2024-09-11 Thread James Almer
Signed-off-by: James Almer 
---
No changes since last version.

 doc/APIchanges   | 3 +++
 libavcodec/decode.c  | 1 +
 libavcodec/packet.c  | 1 +
 libavcodec/packet.h  | 6 ++
 libavcodec/version.h | 2 +-
 5 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index c151041da1..b71ceb010c 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
 
 API changes, most recent first:
 
+2024-09-08 - xx - lavc 61.15.100 - packet.h
+  Add AV_PKT_DATA_LCEVC.
+
 2024-09-08 - xx - lavf 61.5.100 - avformat.h
   Add AVStreamGroupLCEVC
   Add AV_STREAM_GROUP_PARAMS_LCEVC
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 27dba8a1f3..18ddd28690 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1434,6 +1434,7 @@ int ff_decode_frame_props_from_pkt(const AVCodecContext 
*avctx,
 { AV_PKT_DATA_DYNAMIC_HDR10_PLUS, 
AV_FRAME_DATA_DYNAMIC_HDR_PLUS },
 { AV_PKT_DATA_S12M_TIMECODE,  AV_FRAME_DATA_S12M_TIMECODE 
},
 { AV_PKT_DATA_SKIP_SAMPLES,   AV_FRAME_DATA_SKIP_SAMPLES },
+{ AV_PKT_DATA_LCEVC,  AV_FRAME_DATA_LCEVC },
 };
 
 frame->pts  = pkt->pts;
diff --git a/libavcodec/packet.c b/libavcodec/packet.c
index 032f270777..381001fd65 100644
--- a/libavcodec/packet.c
+++ b/libavcodec/packet.c
@@ -306,6 +306,7 @@ const char *av_packet_side_data_name(enum 
AVPacketSideDataType type)
 case AV_PKT_DATA_IAMF_DEMIXING_INFO_PARAM:   return "IAMF Demixing Info 
Parameter Data";
 case AV_PKT_DATA_IAMF_RECON_GAIN_INFO_PARAM: return "IAMF Recon Gain Info 
Parameter Data";
 case AV_PKT_DATA_FRAME_CROPPING: return "Frame Cropping";
+case AV_PKT_DATA_LCEVC:  return "LCEVC NAL data";
 }
 return NULL;
 }
diff --git a/libavcodec/packet.h b/libavcodec/packet.h
index 13667ffa36..0a28010542 100644
--- a/libavcodec/packet.h
+++ b/libavcodec/packet.h
@@ -339,6 +339,12 @@ enum AVPacketSideDataType {
  */
 AV_PKT_DATA_FRAME_CROPPING,
 
+/**
+ * Raw LCEVC payload data, as a uint8_t array, with NAL emulation
+ * bytes intact.
+ */
+AV_PKT_DATA_LCEVC,
+
 /**
  * The number of side data types.
  * This is not part of the public API/ABI in the sense that it may
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 7531c6c42a..9b8c267529 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #include "version_major.h"
 
-#define LIBAVCODEC_VERSION_MINOR  14
+#define LIBAVCODEC_VERSION_MINOR  15
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
2.46.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 10/10 v4] avcodec: add LCEVC decoding support via LCEVCdec

2024-09-11 Thread James Almer
Signed-off-by: James Almer 
---
Somewhat improved the glue, making it all internal to decode.c and no longer
touching AVCodecInternal.

I also tried abstracting the delayed processing API in FrameDecodeData by
moving it into a standalone API, but the result was quite a bit of complexity
that may only become worth applying once there's more than just a few hwaccels
and LCEVC using it.

I can send a PoC of it if there's interest.

 configure |   5 +-
 doc/general_contents.texi |  13 ++
 libavcodec/Makefile   |   1 +
 libavcodec/avcodec_internal.h |   4 +
 libavcodec/decode.c   |  65 ++-
 libavcodec/lcevcdec.c | 318 ++
 libavcodec/lcevcdec.h |  42 +
 libavcodec/pthread_frame.c|   3 +
 8 files changed, 449 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/lcevcdec.c
 create mode 100644 libavcodec/lcevcdec.h

diff --git a/configure b/configure
index d3bd46f382..db9638a1ae 100755
--- a/configure
+++ b/configure
@@ -225,6 +225,7 @@ External library support:
   --enable-libcdio enable audio CD grabbing with libcdio [no]
   --enable-libcodec2   enable codec2 en/decoding using libcodec2 [no]
   --enable-libdav1denable AV1 decoding via libdav1d [no]
+  --enable-liblcevc-decenable LCEVC decoding via liblcevc-dec [no]
   --enable-libdavs2enable AVS2 decoding via libdavs2 [no]
   --enable-libdc1394   enable IIDC-1394 grabbing using libdc1394
and libraw1394 [no]
@@ -1914,6 +1915,7 @@ EXTERNAL_LIBRARY_LIST="
 libcelt
 libcodec2
 libdav1d
+liblcevc_dec
 libdc1394
 libflite
 libfontconfig
@@ -4027,7 +4029,7 @@ cws2fws_extralibs="zlib_extralibs"
 
 # libraries, in any order
 avcodec_deps="avutil"
-avcodec_suggest="libm stdatomic"
+avcodec_suggest="libm stdatomic liblcevc_dec"
 avdevice_deps="avformat avcodec avutil"
 avdevice_suggest="libm stdatomic"
 avfilter_deps="avutil"
@@ -6870,6 +6872,7 @@ enabled libcelt   && require libcelt celt/celt.h 
celt_decode -lcelt0 &&
 enabled libcaca   && require_pkg_config libcaca caca caca.h 
caca_create_canvas
 enabled libcodec2 && require libcodec2 codec2/codec2.h codec2_create 
-lcodec2
 enabled libdav1d  && require_pkg_config libdav1d "dav1d >= 0.5.0" 
"dav1d/dav1d.h" dav1d_version
+enabled liblcevc_dec  && require_pkg_config liblcevc_dec "lcevc_dec >= 
2.0.0" "LCEVC/lcevc_dec.h" LCEVC_CreateDecoder
 enabled libdavs2  && require_pkg_config libdavs2 "davs2 >= 1.6.0" 
davs2.h davs2_decoder_open
 enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 
dc1394/dc1394.h dc1394_new
 enabled libdrm&& check_pkg_config libdrm libdrm xf86drm.h 
drmGetVersion
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index e7cf4f8239..5309db9ba8 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -245,6 +245,19 @@ Go to @url{https://github.com/google/liblc3/} and follow 
the instructions for
 installing the library.
 Then pass @code{--enable-liblc3} to configure to enable it.
 
+@section LCEVCdec
+
+FFmpeg can make use of the liblcevc_dec library for LCEVC enhacement layer
+decoding on supported bitstreams.
+
+Go to @url{https://github.com/v-novaltd/LCEVCdec} and follow the instructions
+for installing the library. Then pass @code{--enable-liblcevc-dec} to 
configure to
+enable it.
+
+@float NOTE
+LCEVCdec is under the BSD-3-Clause-Clear License.
+@end float
+
 @section OpenH264
 
 FFmpeg can make use of the OpenH264 library for H.264 decoding and encoding.
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 1d27e554c8..18663e332f 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -46,6 +46,7 @@ OBJS = ac3_parser.o   
  \
get_buffer.o \
imgconvert.o \
jni.o\
+   lcevcdec.o   \
mathtables.o \
mediacodec.o \
mpeg12framerate.o\
diff --git a/libavcodec/avcodec_internal.h b/libavcodec/avcodec_internal.h
index 31745b89b1..f4ec3595c5 100644
--- a/libavcodec/avcodec_internal.h
+++ b/libavcodec/avcodec_internal.h
@@ -68,6 +68,10 @@ void ff_decode_flush_buffers(struct AVCodecContext *avctx);
 void ff_encode_flush_buffers(struct AVCodecContext *avctx);
 
 struct AVCodecInternal *ff_decode_internal_alloc(vo

[FFmpeg-devel] [PATCH 06/10 v2] avformat/mov: support for LCEVC tracks

2024-09-11 Thread James Almer
Co-authored-by: V-Nova Team 
Signed-off-by: James Almer 
---
 libavformat/isom.h  |  3 ++
 libavformat/isom_tags.c |  2 +
 libavformat/mov.c   | 86 +
 3 files changed, 91 insertions(+)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index 15e9466e41..4723397048 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -212,6 +212,8 @@ typedef struct MOVStreamContext {
 unsigned drefs_count;
 MOVDref *drefs;
 int dref_id;
+unsigned tref_flags;
+int tref_id;
 int timecode_track;
 int width;///< tkhd width
 int height;   ///< tkhd height
@@ -408,6 +410,7 @@ void ff_mp4_parse_es_descr(AVIOContext *pb, int *es_id);
 #define MOV_SAMPLE_DEPENDENCY_YES 0x1
 #define MOV_SAMPLE_DEPENDENCY_NO  0x2
 
+#define MOV_TREF_FLAG_ENHANCEMENT 0x1
 
 #define TAG_IS_AVCI(tag)\
 ((tag) == MKTAG('a', 'i', '5', 'p') ||  \
diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c
index 058f0f2a59..5dd72d570e 100644
--- a/libavformat/isom_tags.c
+++ b/libavformat/isom_tags.c
@@ -290,6 +290,8 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
 
 { AV_CODEC_ID_CFHD, MKTAG('C', 'F', 'H', 'D') },
 
+{ AV_CODEC_ID_LCEVC, MKTAG('l', 'v', 'c', '1') }, /* LCEVC raw payload */
+
 { AV_CODEC_ID_NONE, 0 },
 };
 
diff --git a/libavformat/mov.c b/libavformat/mov.c
index d57c4f150b..e42f40e212 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2434,6 +2434,30 @@ static int mov_read_dvc1(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 return 0;
 }
 
+static int mov_read_sbas(MOVContext* c, AVIOContext* pb, MOVAtom atom)
+{
+AVStream* st;
+MOVStreamContext* sc;
+
+if (c->fc->nb_streams < 1)
+return 0;
+
+/* For SBAS this should be fine - though beware if someone implements a
+ * tref atom processor that doesn't drop down to default then this may
+ * be lost. */
+if (atom.size > 4) {
+av_log(c->fc, AV_LOG_ERROR, "Only a single tref of type sbas is 
supported\n");
+return AVERROR_PATCHWELCOME;
+}
+
+st = c->fc->streams[c->fc->nb_streams - 1];
+sc = st->priv_data;
+sc->tref_id = avio_rb32(pb);
+sc->tref_flags |= MOV_TREF_FLAG_ENHANCEMENT;
+
+return 0;
+}
+
 /**
  * An strf atom is a BITMAPINFOHEADER struct. This struct is 40 bytes itself,
  * but can have extradata appended at the end after the 40 bytes belonging
@@ -4995,6 +5019,8 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
 sc->ffindex = st->index;
 c->trak_index = st->index;
+sc->tref_flags = 0;
+sc->tref_id = -1;
 sc->refcount = 1;
 
 if ((ret = mov_read_default(c, pb, atom)) < 0)
@@ -9052,6 +9078,7 @@ static const MOVParseTableEntry mov_default_parse_table[] 
= {
 { MKTAG('a','v','c','C'), mov_read_glbl },
 { MKTAG('p','a','s','p'), mov_read_pasp },
 { MKTAG('c','l','a','p'), mov_read_clap },
+{ MKTAG('s','b','a','s'), mov_read_sbas },
 { MKTAG('s','i','d','x'), mov_read_sidx },
 { MKTAG('s','t','b','l'), mov_read_default },
 { MKTAG('s','t','c','o'), mov_read_stco },
@@ -9132,6 +9159,7 @@ static const MOVParseTableEntry mov_default_parse_table[] 
= {
 { MKTAG('i','i','n','f'), mov_read_iinf },
 { MKTAG('a','m','v','e'), mov_read_amve }, /* ambient viewing environment box 
*/
 { MKTAG('l','h','v','C'), mov_read_lhvc },
+{ MKTAG('l','v','c','C'), mov_read_glbl },
 #if CONFIG_IAMFDEC
 { MKTAG('i','a','c','b'), mov_read_iacb },
 #endif
@@ -10029,6 +10057,21 @@ static int mov_parse_tiles(AVFormatContext *s)
 return 0;
 }
 
+static AVStream *mov_find_reference_track(AVFormatContext *s, AVStream *st,
+  int first_index)
+{
+MOVStreamContext *sc = st->priv_data;
+
+if (sc->tref_id < 0)
+return NULL;
+
+for (int i = first_index; i < s->nb_streams; i++)
+if (s->streams[i]->id == sc->tref_id)
+return s->streams[i];
+
+return NULL;
+}
+
 static int mov_read_header(AVFormatContext *s)
 {
 MOVContext *mov = s->priv_data;
@@ -10154,6 +10197,49 @@ static int mov_read_header(AVFormatContext *s)
 }
 export_orphan_timecode(s);
 
+/* Create LCEVC stream groups. *

[FFmpeg-devel] [PATCH 05/10 v2] avformat: add an LCEVC stream group

2024-09-11 Thread James Almer
Signed-off-by: James Almer 
---
Added some documentation and an index field to easily find the enhancement
layer stream.

 doc/APIchanges |  5 +
 libavformat/avformat.c |  5 +
 libavformat/avformat.h | 27 +++
 libavformat/dump.c | 27 +++
 libavformat/options.c  | 29 -
 libavformat/version.h  |  4 ++--
 6 files changed, 94 insertions(+), 3 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 9d7480e5ee..c151041da1 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,11 @@ The last version increases of all libraries were on 2024-03-07
 
 API changes, most recent first:
 
+2024-09-08 - xx - lavf 61.5.100 - avformat.h
+  Add AVStreamGroupLCEVC
+  Add AV_STREAM_GROUP_PARAMS_LCEVC
+  Add AVStreamGroup.params.lcevc
+
 2024-09-08 - xx - lavc 61.14.100 - avcodec.h
   Add AV_CODEC_ID_LCEVC.
 
diff --git a/libavformat/avformat.c b/libavformat/avformat.c
index b4f20502fb..06dcde0565 100644
--- a/libavformat/avformat.c
+++ b/libavformat/avformat.c
@@ -104,6 +104,10 @@ void ff_free_stream_group(AVStreamGroup **pstg)
 av_freep(&stg->params.tile_grid->offsets);
 av_freep(&stg->params.tile_grid);
 break;
+case AV_STREAM_GROUP_PARAMS_LCEVC:
+av_opt_free(stg->params.lcevc);
+av_freep(&stg->params.lcevc);
+break;
 default:
 break;
 }
@@ -327,6 +331,7 @@ const char *avformat_stream_group_name(enum 
AVStreamGroupParamsType type)
 case AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT:return "IAMF Audio 
Element";
 case AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION: return "IAMF Mix 
Presentation";
 case AV_STREAM_GROUP_PARAMS_TILE_GRID: return "Tile Grid";
+case AV_STREAM_GROUP_PARAMS_LCEVC: return "LCEVC 
(Split video and enhancement)";
 }
 return NULL;
 }
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 4a3fb00529..56c1c80289 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1084,11 +1084,37 @@ typedef struct AVStreamGroupTileGrid {
 int height;
 } AVStreamGroupTileGrid;
 
+/**
+ * AVStreamGroupLCEVC is meant to define the relation between video streams
+ * and a data stream containing LCEVC enhancement layer NALUs.
+ *
+ * No more than one stream of @ref AVCodecParameters.codec_type "codec_type"
+ * AVMEDIA_TYPE_DATA shall be present, and it must be of
+ * @ref AVCodecParameters.codec_id "codec_id" AV_CODEC_ID_LCEVC.
+ */
+typedef struct AVStreamGroupLCEVC {
+const AVClass *av_class;
+
+/**
+ * Index of the LCEVC data stream in AVStreamGroup.
+ */
+unsigned int lcevc_index;
+/**
+ * Width of the final stream for presentation.
+ */
+int width;
+/**
+ * Height of the final image for presentation.
+ */
+int height;
+} AVStreamGroupLCEVC;
+
 enum AVStreamGroupParamsType {
 AV_STREAM_GROUP_PARAMS_NONE,
 AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT,
 AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION,
 AV_STREAM_GROUP_PARAMS_TILE_GRID,
+AV_STREAM_GROUP_PARAMS_LCEVC,
 };
 
 struct AVIAMFAudioElement;
@@ -1130,6 +1156,7 @@ typedef struct AVStreamGroup {
 struct AVIAMFAudioElement *iamf_audio_element;
 struct AVIAMFMixPresentation *iamf_mix_presentation;
 struct AVStreamGroupTileGrid *tile_grid;
+struct AVStreamGroupLCEVC *lcevc;
 } params;
 
 /**
diff --git a/libavformat/dump.c b/libavformat/dump.c
index 5e1f367742..f20c2c4953 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -789,6 +789,33 @@ static void dump_stream_group(const AVFormatContext *ic, 
uint8_t *printed,
 }
 break;
 }
+case AV_STREAM_GROUP_PARAMS_LCEVC: {
+const AVStreamGroupLCEVC *lcevc = stg->params.lcevc;
+AVCodecContext *avctx = avcodec_alloc_context3(NULL);
+const char *ptr = NULL;
+av_log(NULL, AV_LOG_INFO, " LCEVC:");
+if (avctx && stg->nb_streams && !avcodec_parameters_to_context(avctx, 
stg->streams[0]->codecpar)) {
+avctx->width  = lcevc->width;
+avctx->height = lcevc->height;
+avctx->coded_width  = lcevc->width;
+avctx->coded_height = lcevc->height;
+if (ic->dump_separator)
+av_opt_set(avctx, "dump_separator", ic->dump_separator, 0);
+buf[0] = 0;
+avcodec_string(buf, sizeof(buf), avctx, is_output);
+ptr = av_stristr(buf, " ");
+}
+avcodec_free_context(&avctx);
+if (ptr)
+av_log(NULL, AV_LOG_INFO, "%s", ptr);
+av_log(NULL, AV_LOG_INFO, "\n");
+for (int i = 0; i < stg->nb_streams; i++) {
+const AVStream *st

[FFmpeg-devel] [PATCH 04/10 v2] avcodec/codec_id: add an LCEVC codec id for raw LCEVC data

2024-09-11 Thread James Almer
Signed-off-by: James Almer 
---
No changes since last version.

 doc/APIchanges  | 3 +++
 libavcodec/codec_desc.c | 6 ++
 libavcodec/codec_id.h   | 1 +
 3 files changed, 10 insertions(+)

diff --git a/doc/APIchanges b/doc/APIchanges
index f937be87cc..9d7480e5ee 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
 
 API changes, most recent first:
 
+2024-09-08 - xx - lavc 61.14.100 - avcodec.h
+  Add AV_CODEC_ID_LCEVC.
+
 2024-09-08 - xx - lavc 61.14.100 - avcodec.h
   Adds a new flag AV_CODEC_EXPORT_DATA_ENHANCEMENTS for export_side_data.
 
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index a28ef68061..03dea5751a 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -3696,6 +3696,12 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .name  = "smpte_2038",
 .long_name = NULL_IF_CONFIG_SMALL("SMPTE ST 2038 VANC in MPEG-2 TS"),
 },
+{
+.id= AV_CODEC_ID_LCEVC,
+.type  = AVMEDIA_TYPE_DATA,
+.name  = "lcevc",
+.long_name = NULL_IF_CONFIG_SMALL("LCEVC (Low Complexity Enhancement 
Video Coding) / MPEG-5 LCEVC / MPEG-5 part 2"),
+},
 {
 .id= AV_CODEC_ID_MPEG2TS,
 .type  = AVMEDIA_TYPE_DATA,
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 0ab1e34a61..0a8d3bed1e 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -589,6 +589,7 @@ enum AVCodecID {
 AV_CODEC_ID_TIMED_ID3,
 AV_CODEC_ID_BIN_DATA,
 AV_CODEC_ID_SMPTE_2038,
+AV_CODEC_ID_LCEVC,
 
 
 AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like 
AV_CODEC_ID_NONE) but lavf should attempt to identify it
-- 
2.46.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 03/10] avcodec: add an export_side_data flag to export picture enhancement layers

2024-09-11 Thread James Almer
Signed-off-by: James Almer 
---
 doc/APIchanges | 3 +++
 libavcodec/avcodec.h   | 6 ++
 libavcodec/options_table.h | 1 +
 libavcodec/version.h   | 2 +-
 4 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 5d7b5ab91c..f937be87cc 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
 
 API changes, most recent first:
 
+2024-09-08 - xx - lavc 61.14.100 - avcodec.h
+  Adds a new flag AV_CODEC_EXPORT_DATA_ENHANCEMENTS for export_side_data.
+
 2024-09-08 - xx - lavu 59.37.100 - frame.h
   Add AV_FRAME_DATA_LCEVC.
 
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 376e130f7d..77ca8dee1f 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -419,6 +419,12 @@ typedef struct RcOverride{
  */
 #define AV_CODEC_EXPORT_DATA_FILM_GRAIN (1 << 3)
 
+/**
+ * Decoding only.
+ * Do not apply picture enhancement layers, export them instead.
+ */
+#define AV_CODEC_EXPORT_DATA_ENHANCEMENTS (1 << 4)
+
 /**
  * The decoder will keep a reference to the frame and may reuse it later.
  */
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 33f1bce887..47da41b0ad 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -93,6 +93,7 @@ static const AVOption avcodec_options[] = {
 {"prft", "export Producer Reference Time through packet side data", 0, 
AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_PRFT}, INT_MIN, INT_MAX, 
A|V|S|E, .unit = "export_side_data"},
 {"venc_params", "export video encoding parameters through frame side data", 0, 
AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS}, INT_MIN, 
INT_MAX, V|D, .unit = "export_side_data"},
 {"film_grain", "export film grain parameters through frame side data", 0, 
AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_FILM_GRAIN}, INT_MIN, INT_MAX, 
V|D, .unit = "export_side_data"},
+{"enhancements", "export picture enhancement metadata through frame side 
data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_ENHANCEMENTS}, 
INT_MIN, INT_MAX, V|D, .unit = "export_side_data"},
 {"time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, 
INT_MAX},
 {"g", "set the group of picture (GOP) size", OFFSET(gop_size), 
AV_OPT_TYPE_INT, {.i64 = 12 }, INT_MIN, INT_MAX, V|E},
 {"ar", "set audio sampling rate (in Hz)", OFFSET(sample_rate), 
AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, A|D|E},
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 755c90bbc1..7531c6c42a 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #include "version_major.h"
 
-#define LIBAVCODEC_VERSION_MINOR  13
+#define LIBAVCODEC_VERSION_MINOR  14
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
2.46.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 02/10 v4] avcodec/h2645_sei: export raw LCEVC metadata

2024-09-11 Thread James Almer
Signed-off-by: James Almer 
---
No changes since last version.

 libavcodec/h2645_sei.c | 34 ++
 libavcodec/h2645_sei.h |  5 +
 libavcodec/itut35.h|  2 ++
 3 files changed, 41 insertions(+)

diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c
index 7c83747cd0..c46a563308 100644
--- a/libavcodec/h2645_sei.c
+++ b/libavcodec/h2645_sei.c
@@ -99,6 +99,20 @@ static int 
decode_registered_user_data_dynamic_hdr_vivid(HEVCSEIDynamicHDRVivid
 }
 #endif
 
+static int decode_registered_user_data_lcevc(HEVCSEILCEVC *s,
+ GetByteContext *gb)
+{
+int size = bytestream2_get_bytes_left(gb);
+
+av_buffer_unref(&s->info);
+s->info = av_buffer_alloc(size);
+if (!s->info)
+return AVERROR(ENOMEM);
+
+bytestream2_get_bufferu(gb, s->info->data, size);
+return 0;
+}
+
 static int decode_registered_user_data_afd(H2645SEIAFD *h, GetByteContext *gb)
 {
 int flag;
@@ -142,6 +156,7 @@ static int decode_registered_user_data(H2645SEI *h, 
GetByteContext *gb,
 }
 
 if (country_code != ITU_T_T35_COUNTRY_CODE_US &&
+country_code != ITU_T_T35_COUNTRY_CODE_UK &&
 country_code != ITU_T_T35_COUNTRY_CODE_CN) {
 av_log(logctx, AV_LOG_VERBOSE,
"Unsupported User Data Registered ITU-T T35 SEI message 
(country_code = %d)\n",
@@ -173,6 +188,13 @@ static int decode_registered_user_data(H2645SEI *h, 
GetByteContext *gb,
 }
 break;
 }
+case ITU_T_T35_PROVIDER_CODE_LCEVC: {
+if (bytestream2_get_bytes_left(gb) < 2)
+return AVERROR_INVALIDDATA;
+
+bytestream2_skipu(gb, 1); // user_data_type_code
+return decode_registered_user_data_lcevc(&h->lcevc, gb);
+}
 #if CONFIG_HEVC_SEI
 case ITU_T_T35_PROVIDER_CODE_CUVA: {
 const uint16_t cuva_provider_oriented_code = 0x0005;
@@ -501,6 +523,10 @@ int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI 
*src)
 av_buffer_unref(&dst->unregistered.buf_ref[i]);
 dst->unregistered.nb_buf_ref = 0;
 
+ret = av_buffer_replace(&dst->lcevc.info, src->lcevc.info);
+if (ret < 0)
+return ret;
+
 if (src->unregistered.nb_buf_ref) {
 ret = av_reallocp_array(&dst->unregistered.buf_ref,
 src->unregistered.nb_buf_ref,
@@ -778,6 +804,13 @@ int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei,
 }
 }
 
+if (sei->lcevc.info) {
+HEVCSEILCEVC *lcevc = &sei->lcevc;
+ret = ff_frame_new_side_data_from_buf(avctx, frame, 
AV_FRAME_DATA_LCEVC, &lcevc->info);
+if (ret < 0)
+return ret;
+}
+
 if (sei->film_grain_characteristics.present) {
 H2645SEIFilmGrainCharacteristics *fgc = 
&sei->film_grain_characteristics;
 AVFilmGrainParams *fgp = av_film_grain_params_create_side_data(frame);
@@ -875,6 +908,7 @@ void ff_h2645_sei_reset(H2645SEI *s)
 av_freep(&s->unregistered.buf_ref);
 av_buffer_unref(&s->dynamic_hdr_plus.info);
 av_buffer_unref(&s->dynamic_hdr_vivid.info);
+av_buffer_unref(&s->lcevc.info);
 
 s->ambient_viewing_environment.present = 0;
 s->mastering_display.present = 0;
diff --git a/libavcodec/h2645_sei.h b/libavcodec/h2645_sei.h
index 488dbcad7e..598f78b585 100644
--- a/libavcodec/h2645_sei.h
+++ b/libavcodec/h2645_sei.h
@@ -50,6 +50,10 @@ typedef struct HEVCSEIDynamicHDRVivid {
 AVBufferRef *info;
 } HEVCSEIDynamicHDRVivid;
 
+typedef struct HEVCSEILCEVC {
+AVBufferRef *info;
+} HEVCSEILCEVC;
+
 typedef struct H2645SEIUnregistered {
 AVBufferRef **buf_ref;
 unsigned nb_buf_ref;
@@ -126,6 +130,7 @@ typedef struct H2645SEI {
 H2645SEIAFD afd;
 HEVCSEIDynamicHDRPlus  dynamic_hdr_plus; //< HEVC only
 HEVCSEIDynamicHDRVivid dynamic_hdr_vivid;//< HEVC only
+HEVCSEILCEVC lcevc;
 H2645SEIUnregistered unregistered;
 H2645SEIFramePacking frame_packing;
 H2645SEIDisplayOrientation display_orientation;
diff --git a/libavcodec/itut35.h b/libavcodec/itut35.h
index ffa7024981..a75ef37929 100644
--- a/libavcodec/itut35.h
+++ b/libavcodec/itut35.h
@@ -20,11 +20,13 @@
 #define AVCODEC_ITUT35_H
 
 #define ITU_T_T35_COUNTRY_CODE_CN 0x26
+#define ITU_T_T35_COUNTRY_CODE_UK 0xB4
 #define ITU_T_T35_COUNTRY_CODE_US 0xB5
 
 #define ITU_T_T35_PROVIDER_CODE_ATSC  0x31
 #define ITU_T_T35_PROVIDER_CODE_CUVA  0x04
 #define ITU_T_T35_PROVIDER_CODE_DOLBY 0x3B
+#define ITU_T_T35_PROVIDER_CODE_LCEVC 0x50
 #define ITU_T_T35_PROVIDER_CODE_SMTPE 0x3C
 
 #endif /* AVCODEC_ITUT35_H */
-- 
2.46.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 01/10 v4] avutil/frame: add an LCEVC enhancement data payload side data type

2024-09-11 Thread James Almer
Signed-off-by: James Almer 
---
No changes since last version

 doc/APIchanges  | 3 +++
 libavutil/frame.c   | 1 +
 libavutil/frame.h   | 6 ++
 libavutil/version.h | 2 +-
 4 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 830a38cd69..5d7b5ab91c 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
 
 API changes, most recent first:
 
+2024-09-08 - xx - lavu 59.37.100 - frame.h
+  Add AV_FRAME_DATA_LCEVC.
+
 2024-09-xx - xx - lavc 61.13.100 - avcodec.h
   Add avcodec_get_supported_config() and enum AVCodecConfig; deprecate
   AVCodec.pix_fmts, AVCodec.sample_fmts, AVCodec.supported_framerates,
diff --git a/libavutil/frame.c b/libavutil/frame.c
index 5cbfc6a48b..2758f90e27 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -46,6 +46,7 @@ static const AVSideDataDescriptor sd_props[] = {
 [AV_FRAME_DATA_DETECTION_BBOXES]= { "Bounding boxes for object 
detection and classification" },
 [AV_FRAME_DATA_DOVI_RPU_BUFFER] = { "Dolby Vision RPU Data" },
 [AV_FRAME_DATA_DOVI_METADATA]   = { "Dolby Vision Metadata" },
+[AV_FRAME_DATA_LCEVC]   = { "LCEVC NAL data" },
 [AV_FRAME_DATA_STEREO3D]= { "Stereo 3D",   
 AV_SIDE_DATA_PROP_GLOBAL },
 [AV_FRAME_DATA_REPLAYGAIN]  = { "AVReplayGain",
 AV_SIDE_DATA_PROP_GLOBAL },
 [AV_FRAME_DATA_DISPLAYMATRIX]   = { "3x3 displaymatrix",   
 AV_SIDE_DATA_PROP_GLOBAL },
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 60bb966f8b..5e0d8ae648 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -228,6 +228,12 @@ enum AVFrameSideDataType {
  * encoding.
  */
 AV_FRAME_DATA_VIDEO_HINT,
+
+/**
+ * Raw LCEVC payload data, as a uint8_t array, with NAL emulation
+ * bytes intact.
+ */
+AV_FRAME_DATA_LCEVC,
 };
 
 enum AVActiveFormatDescription {
diff --git a/libavutil/version.h b/libavutil/version.h
index 25a6f5531b..7900379c12 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  59
-#define LIBAVUTIL_VERSION_MINOR  36
+#define LIBAVUTIL_VERSION_MINOR  37
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
2.46.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] avfilter/af_join: pass the correct input layouts to ff_channel_layouts_ref

2024-09-11 Thread James Almer
Should fix memory leaks show in fate-filter-join and fate-filter-crazychannels.

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

diff --git a/libavfilter/af_join.c b/libavfilter/af_join.c
index db0320aa70..0ea53248b6 100644
--- a/libavfilter/af_join.c
+++ b/libavfilter/af_join.c
@@ -215,7 +215,7 @@ static int join_query_formats(const AVFilterContext *ctx,
 
 for (i = 0; i < ctx->nb_inputs; i++) {
 layouts = ff_all_channel_layouts();
-if ((ret = ff_channel_layouts_ref(layouts, 
&cfg_in[0]->channel_layouts)) < 0)
+if ((ret = ff_channel_layouts_ref(layouts, 
&cfg_in[i]->channel_layouts)) < 0)
 return ret;
 }
 
-- 
2.46.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] tests/checkasm/sw_rgb: don't write random data past the end of the buffer

2024-09-11 Thread James Almer
Should fix fate-checkasm-sw_rgb under gcc-ubsan.

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

diff --git a/tests/checkasm/sw_rgb.c b/tests/checkasm/sw_rgb.c
index af9434073a..cdd43df8ba 100644
--- a/tests/checkasm/sw_rgb.c
+++ b/tests/checkasm/sw_rgb.c
@@ -287,7 +287,7 @@ static void check_deinterleave_bytes(void)
int width, int height, int srcStride,
int dst1Stride, int dst2Stride);
 
-randomize_buffers(src, 2*MAX_STRIDE*MAX_HEIGHT+2);
+randomize_buffers(src, 2*MAX_STRIDE*MAX_HEIGHT);
 
 if (check_func(deinterleaveBytes, "deinterleave_bytes")) {
 for (int i = 0; i <= 16; i++) {
-- 
2.46.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 54/60] avformat/matroskadec: fix variable shadowing

2024-09-11 Thread James Almer

On 9/8/2024 9:23 PM, Marvin Scholz wrote:

---
  libavformat/matroskadec.c | 13 ++---
  1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index c8741ff2af..60b20e9658 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1281,8 +1281,8 @@ static int ebml_parse(MatroskaDemuxContext *matroska,
  MatroskaLevel *level = matroska->num_levels ? 
&matroska->levels[matroska->num_levels - 1] : NULL;
  
  if (!matroska->current_id) {

-uint64_t id;
-res = ebml_read_num(matroska, pb, 4, &id, 0);
+uint64_t tmp_id;
+res = ebml_read_num(matroska, pb, 4, &tmp_id, 0);
  if (res < 0) {
  if (pb->eof_reached && res == AVERROR_EOF) {
  if (matroska->is_live)
@@ -1301,7 +1301,7 @@ static int ebml_parse(MatroskaDemuxContext *matroska,
  }
  return res;
  }
-matroska->current_id = id | 1 << 7 * res;
+matroska->current_id = tmp_id | 1 << 7 * res;
  pos_alt = pos + res;
  } else {
  pos_alt = pos;
@@ -3039,7 +3039,7 @@ static int mkv_parse_video(MatroskaTrack *track, AVStream 
*st,
  if (track->video.stereo_mode < MATROSKA_VIDEO_STEREOMODE_TYPE_NB &&
  track->video.stereo_mode != MATROSKA_VIDEO_STEREOMODE_TYPE_ANAGLYPH_CYAN_RED 
&&
  track->video.stereo_mode != 
MATROSKA_VIDEO_STEREOMODE_TYPE_ANAGLYPH_GREEN_MAG) {
-int ret = mkv_stereo3d_conv(st, track->video.stereo_mode);
+ret = mkv_stereo3d_conv(st, track->video.stereo_mode);
  if (ret < 0)
  return ret;
  }
@@ -4683,8 +4683,7 @@ static int webm_dash_manifest_cues(AVFormatContext *s, 
int64_t init_range)
  AVBPrint bprint;
  char *buf;
  int64_t cues_start = -1, cues_end = -1, before_pos, bandwidth;
-int i;
-int ret;
+int i, ret;


Seems unrelated.

  
  // determine cues start and end positions

  for (i = 0; i < seekhead_list->nb_elem; i++)
@@ -4740,7 +4739,7 @@ static int webm_dash_manifest_cues(AVFormatContext *s, 
int64_t init_range)
  // Store cue point timestamps as a comma separated list
  // for checking subsegment alignment in the muxer.
  av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED);
-for (int i = 0; i < sti->nb_index_entries; i++)
+for (i = 0; i < sti->nb_index_entries; i++)
  av_bprintf(&bprint, "%" PRId64",", sti->index_entries[i].timestamp);
  if (!av_bprint_is_complete(&bprint)) {
  av_bprint_finalize(&bprint, NULL);




OpenPGP_signature.asc
Description: OpenPGP digital 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 09/13] avformat: add an LCEVC stream group

2024-09-11 Thread James Almer

On 9/9/2024 8:33 AM, Anton Khirnov wrote:

Quoting James Almer (2024-09-08 15:26:51)

On 9/6/2024 8:44 AM, Anton Khirnov wrote:

Quoting James Almer (2024-08-31 18:31:10)

+typedef struct AVStreamGroupLCEVC {
+const AVClass *av_class;
+
+/**
+ * Width of the final stream for presentation.
+ */
+int width;
+/**
+ * Height of the final image for presentation.
+ */
+int height;


What's the point of exporting these separately when they are the same as
the enhancement AVStream's dimensions?


The enhancement stream is of data type, so width/height are undefined in
it. Hence including these here.


Why not define them then? Seems simpler and more straightforward to me.


I personally don't think re-defining the AVStream API in order to have 
two fields start meaning something for DATA type streams for the sake of 
only one codec_id is better than just having said fields defined in the 
specific stream group.




OpenPGP_signature.asc
Description: OpenPGP digital 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 3/3] tests/fate/hevc: add a periodic intra refresh decode test

2024-09-10 Thread James Almer

On 9/10/2024 3:39 AM, Anton Khirnov wrote:

Would trigger #10887 before it was fixed, sample cut from the one
attached to the bug.
---
Please put 
https://ups.khirnov.net/3dc9efb9d882bbbf05876bfa67d5257fb0ee93065b43dc5512539ac3dfe91208/pir.hevc
to hevc/pir.hevc


Uploaded.



OpenPGP_signature.asc
Description: OpenPGP digital 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] avcodec/avcodec: remove usage of __typeof__()

2024-09-08 Thread James Almer
It's non-standard C.

Signed-off-by: James Almer 
---
 libavcodec/avcodec.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index cb89236549..78153d12f1 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -708,9 +708,9 @@ int attribute_align_arg 
avcodec_receive_frame(AVCodecContext *avctx, AVFrame *fr
 return ff_encode_receive_frame(avctx, frame);
 }
 
-#define WRAP_CONFIG(allowed_type, field, terminator)\
+#define WRAP_CONFIG(allowed_type, field, field_type, terminator)\
 do {\
-static const __typeof__(*(field)) end = terminator; \
+static const field_type end = terminator;   \
 if (codec->type != (allowed_type))  \
 return AVERROR(EINVAL); \
 *out_configs = (field); \
@@ -753,15 +753,15 @@ int ff_default_get_supported_config(const AVCodecContext 
*avctx,
 switch (config) {
 FF_DISABLE_DEPRECATION_WARNINGS
 case AV_CODEC_CONFIG_PIX_FORMAT:
-WRAP_CONFIG(AVMEDIA_TYPE_VIDEO, codec->pix_fmts, AV_PIX_FMT_NONE);
+WRAP_CONFIG(AVMEDIA_TYPE_VIDEO, codec->pix_fmts, enum AVPixelFormat, 
AV_PIX_FMT_NONE);
 case AV_CODEC_CONFIG_FRAME_RATE:
-WRAP_CONFIG(AVMEDIA_TYPE_VIDEO, codec->supported_framerates, 
(AVRational){0});
+WRAP_CONFIG(AVMEDIA_TYPE_VIDEO, codec->supported_framerates, 
AVRational, (AVRational){0});
 case AV_CODEC_CONFIG_SAMPLE_RATE:
-WRAP_CONFIG(AVMEDIA_TYPE_AUDIO, codec->supported_samplerates, 0);
+WRAP_CONFIG(AVMEDIA_TYPE_AUDIO, codec->supported_samplerates, int, 0);
 case AV_CODEC_CONFIG_SAMPLE_FORMAT:
-WRAP_CONFIG(AVMEDIA_TYPE_AUDIO, codec->sample_fmts, 
AV_SAMPLE_FMT_NONE);
+WRAP_CONFIG(AVMEDIA_TYPE_AUDIO, codec->sample_fmts, enum 
AVSampleFormat, AV_SAMPLE_FMT_NONE);
 case AV_CODEC_CONFIG_CHANNEL_LAYOUT:
-WRAP_CONFIG(AVMEDIA_TYPE_AUDIO, codec->ch_layouts, 
(AVChannelLayout){0});
+WRAP_CONFIG(AVMEDIA_TYPE_AUDIO, codec->ch_layouts, AVChannelLayout, 
(AVChannelLayout){0});
 FF_ENABLE_DEPRECATION_WARNINGS
 
 case AV_CODEC_CONFIG_COLOR_RANGE:
-- 
2.46.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 09/13] avformat: add an LCEVC stream group

2024-09-08 Thread James Almer

On 9/6/2024 8:44 AM, Anton Khirnov wrote:

Quoting James Almer (2024-08-31 18:31:10)

+typedef struct AVStreamGroupLCEVC {
+const AVClass *av_class;
+
+/**
+ * Width of the final stream for presentation.
+ */
+int width;
+/**
+ * Height of the final image for presentation.
+ */
+int height;


What's the point of exporting these separately when they are the same as
the enhancement AVStream's dimensions?


The enhancement stream is of data type, so width/height are undefined in 
it. Hence including these here.





+} AVStreamGroupLCEVC;
+
  enum AVStreamGroupParamsType {
  AV_STREAM_GROUP_PARAMS_NONE,
  AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT,
  AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION,
  AV_STREAM_GROUP_PARAMS_TILE_GRID,
+AV_STREAM_GROUP_PARAMS_LCEVC,


This seems like it could use some documentation.


Yes, will add something.



OpenPGP_signature.asc
Description: OpenPGP digital 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 10/13] avformat/mov: support for LCEVC tracks

2024-09-06 Thread James Almer

On 9/6/2024 8:48 AM, Anton Khirnov wrote:

Quoting James Almer (2024-08-31 18:31:11)

+st->codecpar->codec_type = AVMEDIA_TYPE_DATA;


Why not video?


Because it can not be decoded on its own, so you can't map any decoder 
to it.




OpenPGP_signature.asc
Description: OpenPGP digital 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 13/13] fftools/ffmpeg_demux: merge streams in a LCEVC stream group

2024-09-06 Thread James Almer

On 9/6/2024 10:33 AM, Anton Khirnov wrote:

Quoting James Almer (2024-09-06 14:15:36)

On 9/6/2024 8:56 AM, Anton Khirnov wrote:

Quoting James Almer (2024-08-31 18:31:14)

   static int demux_send(Demuxer *d, DemuxThreadContext *dt, DemuxStream *ds,
 AVPacket *pkt, unsigned flags)
   {
   InputFile  *f = &d->f;
-int ret;
+int ret = 0;
   
   // pkt can be NULL only when flushing BSFs

   av_assert0(ds->bsf || pkt);
   
+// a stream can only be disabled if it's needed by a group


This makes no sense to me.


I made av_read_frame() output packets for all the streams belonging to a
group, even if some of those streams are not selected/used for an
output. In the case of LCEVC groups, the normal scenario is to merge
enhancement stream packets into the video one, with the enhancement
stream not being used on its own by any output stream.
DemuxStream->discard is used for this, where it can be 0 (not used by
any output) when AVStream->discard is obviously going to be 1 for lavf
to export packets for the stream.

If a packet where DemuxStream->discard is 0 reaches this point, the only
valid scenario is that it's part of a group.




+av_assert0(ds->nb_stream_groups || !ds->discard);
+
+// create a reference for the packet to be filtered by group bsfs


What are "group bsfs"?


Bsfs that are used by and all (or some) of a group's streams, as is the
case of lcevc_merge, and stored in DemuxStreamGroup->bsf.




+if (pkt && ds->nb_stream_groups) {
+av_packet_unref(dt->pkt_group_bsf);
+ret = av_packet_ref(dt->pkt_group_bsf, pkt);
+if (ret < 0)
+return ret;
+}
+
   // send heartbeat for sub2video streams
-if (d->pkt_heartbeat && pkt && pkt->pts != AV_NOPTS_VALUE) {
+if (d->pkt_heartbeat && pkt && !ds->discard && pkt->pts != AV_NOPTS_VALUE) 
{


Random added checks for ds->discard are extremely confusing and tell me
you're overloading that poor field to mean something extremely
non-obvious.


I added this here to make sure I'm not sending a heartbeat packet when
handling a packet for a stream that's not used by any output on its own.


This is not the the only place where you're adding a check for discard,


Because it's the only code i don't want to trigger for non-standalone 
output packets.



and I strongly dislike that 'discard' now does not mean 'discard'
anymore.


No, the packet is discarded in the end, and never makes anywhere on its 
own unless it's used by an output. DemuxStream->discard is in fact the 
one field where you can check if a stream is effectively disabled, and 
that doesn't change with this patch. What changes is that lavf may now 
output packets not used by any output (AVStream->discard being 0), and 
the code needs to be aware of this.




Furthermore, I really dislike how invasive such an obscure feature is.


Ideally, lavf would export the LCEVC stream payload as packet side data 
in the video's stream, but that's apparently only possible with mov/mp4 
and maybe matroska, not TS. Hence a Stream Group is used and everything 
left to the caller.


That said, is this so invasive? This patch adds 
DemuxStreamGroup/InputStreamGroup, cleanly initializes them like we 
already do with DemuxStream/InputStream, and then factorizes the bsf 
packet loop so it can be used for the stream bsf and the group bsf.
The only truly big change is making libavformat output streams that are 
not strictly used by an output, which is achieved by making 
AVStream->discard not be set, and keep relying on DemuxStream->discard 
to know what stream is disabled or not.


You can try remuxing an LCEVC sample with split enhancement in different 
ways to test this:


# decode video stream only. Enhancement stream is output as well and 
merged into video stream as side data, which lavc will see and use.

ffmpeg -i input.mp4 output.mp4

# remux video stream only. Enhancement stream is output as well and 
merged into video stream as side data. Muxers will not care about it, 
but an hypothetical bsf could for example be inserted in the process to 
add it to the h264/hevc bitstream as a SEI message.

ffmpeg -i input.mp4 -c:v copy -dn -map 0:0 output.mp4

# remux enhancement stream only. Video stream is output by lavf but 
discarded by the CLI.

ffmpeg -i input.mp4 -c:d copy -vn -map 0:1 output.mp4

# remux both video and enhancement streams. Enhancement stream is merged 
into video stream as side data too.

ffmpeg -i input.mp4 -c:v copy -c:d copy -map 0 output.mp4




+int j;
+
+for (j = 0; j < f->nb_streams; j++)
+if (stg->streams[i] == f->streams[j]->st)
+break;
+
+if (j == f->nb_streams)
+return AVERROR_BUG;


Isn't all t

Re: [FFmpeg-devel] [PATCH 13/13] fftools/ffmpeg_demux: merge streams in a LCEVC stream group

2024-09-06 Thread James Almer

On 9/6/2024 8:56 AM, Anton Khirnov wrote:

Quoting James Almer (2024-08-31 18:31:14)

  static int demux_send(Demuxer *d, DemuxThreadContext *dt, DemuxStream *ds,
AVPacket *pkt, unsigned flags)
  {
  InputFile  *f = &d->f;
-int ret;
+int ret = 0;
  
  // pkt can be NULL only when flushing BSFs

  av_assert0(ds->bsf || pkt);
  
+// a stream can only be disabled if it's needed by a group


This makes no sense to me.


I made av_read_frame() output packets for all the streams belonging to a 
group, even if some of those streams are not selected/used for an 
output. In the case of LCEVC groups, the normal scenario is to merge 
enhancement stream packets into the video one, with the enhancement 
stream not being used on its own by any output stream.
DemuxStream->discard is used for this, where it can be 0 (not used by 
any output) when AVStream->discard is obviously going to be 1 for lavf 
to export packets for the stream.


If a packet where DemuxStream->discard is 0 reaches this point, the only 
valid scenario is that it's part of a group.





+av_assert0(ds->nb_stream_groups || !ds->discard);
+
+// create a reference for the packet to be filtered by group bsfs


What are "group bsfs"?


Bsfs that are used by and all (or some) of a group's streams, as is the 
case of lcevc_merge, and stored in DemuxStreamGroup->bsf.





+if (pkt && ds->nb_stream_groups) {
+av_packet_unref(dt->pkt_group_bsf);
+ret = av_packet_ref(dt->pkt_group_bsf, pkt);
+if (ret < 0)
+return ret;
+}
+
  // send heartbeat for sub2video streams
-if (d->pkt_heartbeat && pkt && pkt->pts != AV_NOPTS_VALUE) {
+if (d->pkt_heartbeat && pkt && !ds->discard && pkt->pts != AV_NOPTS_VALUE) 
{


Random added checks for ds->discard are extremely confusing and tell me
you're overloading that poor field to mean something extremely
non-obvious.


I added this here to make sure I'm not sending a heartbeat packet when 
handling a packet for a stream that's not used by any output on its own.





+static int istg_add(Demuxer *d, AVStreamGroup *stg)
+{
+InputFile*f = &d->f;
+DemuxStreamGroup *dsg;
+const AVBitStreamFilter *filter;
+int base_idx = -1, enhancement_idx = -1;
+int ret;
+
+// TODO: generic handling of groups, once support for more is added
+if (stg->type != AV_STREAM_GROUP_PARAMS_LCEVC)
+return 0;


I'd prefer this function to be essentially a switch that dispatches to
per-type handlers.


Ok.




+
+if (stg->nb_streams != 2)
+return AVERROR_BUG;
+
+filter = av_bsf_get_by_name("lcevc_merge");
+if (!filter)
+return 0;
+
+dsg = demux_stream_group_alloc(d, stg);
+if (!dsg)
+return AVERROR(ENOMEM);
+
+dsg->discard = 1;
+
+// set the main stream for the group
+for (int i = 0; i < stg->nb_streams; i++) {
+int j;
+
+for (j = 0; j < f->nb_streams; j++)
+if (stg->streams[i] == f->streams[j]->st)
+break;
+
+if (j == f->nb_streams)
+return AVERROR_BUG;


Isn't all this just "j = stg->streams[i]->index"?


Is f->streams guaranteed to have the same streams as ic->streams? If so, 
probably. Will change then.




OpenPGP_signature.asc
Description: OpenPGP digital 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 38/42] fftools/ffmpeg: add support for multiview video

2024-09-03 Thread James Almer

On 9/3/2024 9:44 AM, Anton Khirnov wrote:

Quoting James Almer (2024-09-03 14:26:21)

On 9/3/2024 6:47 AM, Anton Khirnov wrote:

Quoting James Almer (2024-08-31 15:56:24)

On 8/31/2024 4:44 AM, Anton Khirnov wrote:

Quoting James Almer (2024-08-30 02:40:49)

On 8/29/2024 8:26 PM, Michael Niedermayer wrote:

On Tue, Aug 27, 2024 at 05:05:18PM +0200, Anton Khirnov wrote:

This extends the syntax for specifying input streams in -map and complex
filtergraph labels, to allow selecting a view by view ID, index, or
position. The corresponding decoder is then set up to decode the
appropriate view and send frames for that view to the correct
filtergraph input(s).
---
 doc/ffmpeg.texi   |  30 +++-
 fftools/cmdutils.c|   2 +-
 fftools/cmdutils.h|   2 +
 fftools/ffmpeg.h  |  45 -
 fftools/ffmpeg_dec.c  | 355 +-
 fftools/ffmpeg_demux.c|  24 ++-
 fftools/ffmpeg_filter.c   |  71 +---
 fftools/ffmpeg_mux_init.c |  29 +++-
 fftools/ffmpeg_opt.c  |  70 +++-
 9 files changed, 575 insertions(+), 53 deletions(-)


breaks build on mingw64

src/fftools/ffmpeg_dec.c: In function ‘packet_decode’:
src/fftools/ffmpeg_dec.c:811:19: error: implicit declaration of function ‘ffs’ 
[-Werror=implicit-function-declaration]
  811 | pos = ffs(outputs_mask) - 1;
  |   ^~~
cc1: some warnings being treated as errors
make: *** [src/ffbuild/common.mak:81: fftools/ffmpeg_dec.o] Error 1
make: *** Waiting for unfinished jobs

thx


Would ff_clz(outputs_mask) work here?


In principle yes, but it's private and I'd rather not include a private
header in ffmpeg CLI.

We could either make it public, or I could add a ffs() implementation
for Windows to compat/. Anyone has a preference?


Also, ffs() is posix. Is Windows the only target that lacks it?


I think so, though I didn't test all that extensively.



I think i prefer making ff_clz public in common.h.


common.h is the wrong place for anything


It has an optimized version not exclusive to Windows using a gcc/clang
builtin, and even one specific for riscv.


Which would not be visible to ffmpeg CLI anyway.


True. We could make it aware of it by setting HAVE_AV_CONFIG_H during
compilation, but that's kinda dirty.


Yuck.

If we wanted to be fancy, we could add stdc_first_trailing_zero() from
C23. Possibly write/steal compatibility wrappers like we did for
atomics.


I prefer this over ffs() in compat/windows, yes. Good idea.



OpenPGP_signature.asc
Description: OpenPGP digital 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 28/42] lavc/hevc/ps: implement SPS parsing for nuh_layer_id>0

2024-09-03 Thread James Almer

On 9/3/2024 6:39 AM, Anton Khirnov wrote:

Quoting James Almer (2024-08-30 04:52:39)

On 8/27/2024 12:05 PM, Anton Khirnov wrote:

@@ -1167,16 +1167,26 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
unsigned int *sps_id,
   }
   
   sps->max_sub_layers = get_bits(gb, 3) + 1;

+multi_layer_ext = nuh_layer_id > 0 &&
+  sps->max_sub_layers == HEVC_MAX_SUB_LAYERS + 1;
+if (multi_layer_ext) {
+if (!sps->vps)
+return AVERROR(EINVAL);
+
+sps->max_sub_layers = sps->vps->vps_max_sub_layers;
+}
   if (sps->max_sub_layers > HEVC_MAX_SUB_LAYERS) {


Not strictly related to this patch, but sps->max_sub_layers should
always be <= vps->vps_max_sub_layers (see F.7.4.3.2.1). So the presence
of vps should be checked for.


   av_log(avctx, AV_LOG_ERROR, "sps_max_sub_layers out of range: %d\n",
  sps->max_sub_layers);
   return AVERROR_INVALIDDATA;
   }
   
+if (!multi_layer_ext) {

   sps->temporal_id_nesting = get_bits(gb, 1);


Similarly (not strictly related to this patch), this needs to be 1 if
sps->max_sub_layers is 0 or if vps->vps_temporal_id_nesting_flag is 1.

   
   if ((ret = parse_ptl(gb, avctx, 1, &sps->ptl, sps->max_sub_layers)) < 0)

   return ret;
+}


(Actually related this time) If multi_layer_ext is true,
sps->temporal_id_nesting needs to be set to
vps->vps_temporal_id_nesting_flag when sps->max_sub_layers > 1, or
hardcoded to 1 if it's 1.


Honestly this feels like pointless churn. We don't support any of this
temporal id stuff in the decoder, so why bother?


I see it used in videotoolbox.c and vulkan_hevc.c, so imo better make 
sure it's set right, just in case.




OpenPGP_signature.asc
Description: OpenPGP digital 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 38/42] fftools/ffmpeg: add support for multiview video

2024-09-03 Thread James Almer

On 9/3/2024 6:47 AM, Anton Khirnov wrote:

Quoting James Almer (2024-08-31 15:56:24)

On 8/31/2024 4:44 AM, Anton Khirnov wrote:

Quoting James Almer (2024-08-30 02:40:49)

On 8/29/2024 8:26 PM, Michael Niedermayer wrote:

On Tue, Aug 27, 2024 at 05:05:18PM +0200, Anton Khirnov wrote:

This extends the syntax for specifying input streams in -map and complex
filtergraph labels, to allow selecting a view by view ID, index, or
position. The corresponding decoder is then set up to decode the
appropriate view and send frames for that view to the correct
filtergraph input(s).
---
doc/ffmpeg.texi   |  30 +++-
fftools/cmdutils.c|   2 +-
fftools/cmdutils.h|   2 +
fftools/ffmpeg.h  |  45 -
fftools/ffmpeg_dec.c  | 355 +-
fftools/ffmpeg_demux.c|  24 ++-
fftools/ffmpeg_filter.c   |  71 +---
fftools/ffmpeg_mux_init.c |  29 +++-
fftools/ffmpeg_opt.c  |  70 +++-
9 files changed, 575 insertions(+), 53 deletions(-)


breaks build on mingw64

src/fftools/ffmpeg_dec.c: In function ‘packet_decode’:
src/fftools/ffmpeg_dec.c:811:19: error: implicit declaration of function ‘ffs’ 
[-Werror=implicit-function-declaration]
 811 | pos = ffs(outputs_mask) - 1;
 |   ^~~
cc1: some warnings being treated as errors
make: *** [src/ffbuild/common.mak:81: fftools/ffmpeg_dec.o] Error 1
make: *** Waiting for unfinished jobs

thx


Would ff_clz(outputs_mask) work here?


In principle yes, but it's private and I'd rather not include a private
header in ffmpeg CLI.

We could either make it public, or I could add a ffs() implementation
for Windows to compat/. Anyone has a preference?


Also, ffs() is posix. Is Windows the only target that lacks it?



I think i prefer making ff_clz public in common.h.


common.h is the wrong place for anything


It has an optimized version not exclusive to Windows using a gcc/clang
builtin, and even one specific for riscv.


Which would not be visible to ffmpeg CLI anyway.


True. We could make it aware of it by setting HAVE_AV_CONFIG_H during 
compilation, but that's kinda dirty.




OpenPGP_signature.asc
Description: OpenPGP digital 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 03/13] avcodec/decode: support applying LCEVC enhacements

2024-09-02 Thread James Almer

On 9/2/2024 9:03 AM, Derek Buitenhuis wrote:

On 8/31/2024 5:31 PM, James Almer wrote:

Signed-off-by: James Almer 
---
  libavcodec/avcodec.c   |  2 ++
  libavcodec/avcodec.h   |  5 +
  libavcodec/decode.c| 42 +-
  libavcodec/internal.h  |  2 ++
  libavcodec/lcevcdec.c  |  2 ++
  libavcodec/options_table.h |  1 +
  libavcodec/pthread_frame.c |  7 +++
  7 files changed, 60 insertions(+), 1 deletion(-)


No real opinion on the other patches, but this one feels really gross. I feel
liek we should not be adding new codec-specific things in AVCodecInternal or
in generic threding, decode, etc. It really feels quite wrong.


I could try to make it a bit more opaque to decode.c, making i call a 
function that would then set any needed post processing callback or 
something like that.




I probably missed discussion on this in previous revisions of this patch set,
but I wanted to get my thoughts in writing.





OpenPGP_signature.asc
Description: OpenPGP digital 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 07/13] avcodec/hevcdec: export LCEVC metadata as frame side data

2024-09-02 Thread James Almer

On 9/2/2024 9:00 AM, Derek Buitenhuis wrote:

On 8/31/2024 5:31 PM, James Almer wrote:

Signed-off-by: James Almer 
---
  configure |  1 +
  libavcodec/hevc/hevcdec.c |  3 +++
  libavcodec/hevc/refs.c| 15 ++-
  3 files changed, 18 insertions(+), 1 deletion(-)


Maybe I've misunderstood, but doesn't requiring every possible base layer
codec to explicitly support exporting LCEVC kind of defeat the point of
a 'generic' enhancement layer codec like LCEVC?
We don't require that. Those codecs that have it embedded in the 
bitstream do it, like hevc here. Those who don't will require the caller 
to insert the lcevc payload (which most likely came from the container) 
into the base layer packets as side data, which decode.c will make sure 
makes it to the frame for decoding.
The last patch in this set makes ffmpeg.c (the aforementioned caller) do 
exactly that for split variants (exported by mov/mp4 for now).




OpenPGP_signature.asc
Description: OpenPGP digital 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] fate/checkasm/sw_gbrp: don't randomly set internal values

2024-09-01 Thread James Almer
They are set by sws_init_context().
May help with signed integer overflows reported by gcc-usan.

Signed-off-by: James Almer 
---
 tests/checkasm/sw_gbrp.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/tests/checkasm/sw_gbrp.c b/tests/checkasm/sw_gbrp.c
index b845da32a6..d843730f3e 100644
--- a/tests/checkasm/sw_gbrp.c
+++ b/tests/checkasm/sw_gbrp.c
@@ -135,12 +135,6 @@ static void check_output_yuv2gbrp(void)
 fail();
 
 ctx->flags |= SWS_FULL_CHR_H_INT;
-ctx->yuv2rgb_y_offset  = rnd();
-ctx->yuv2rgb_y_coeff   = rnd();
-ctx->yuv2rgb_v2r_coeff = rnd();
-ctx->yuv2rgb_v2g_coeff = rnd();
-ctx->yuv2rgb_u2g_coeff = rnd();
-ctx->yuv2rgb_u2b_coeff = rnd();
 
 for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) {
 for (fsi = 0; fsi < FILTER_SIZES; fsi++) {
-- 
2.46.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] avformat/iamf_parse: Fix return of uninitialized value

2024-09-01 Thread James Almer

On 9/1/2024 12:12 PM, epira...@gmail.com wrote:



On 31 Aug 2024, at 23:17, James Almer wrote:


On 8/31/2024 5:45 PM, Marvin Scholz wrote:

The ret value here is not yet intialized so the return would return
uninitialized data. What was probably meant to be checked here was the
return value of ffio_read_size, which can return an error.

Introduced in 38bcb3ba7b3424abd772c72f8bdf445d75285e88

Fixes: CID1618758
---
   libavformat/iamf_parse.c | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c
index f13e76b147..8a0003634b 100644
--- a/libavformat/iamf_parse.c
+++ b/libavformat/iamf_parse.c
@@ -98,8 +98,8 @@ static int aac_decoder_config(IAMFCodecConfig *codec_config,
   return AVERROR(ENOMEM);
codec_config->extradata_size = ffio_read_size(pb, 
codec_config->extradata, left);
-if (ret < 0)
-return ret;
+if (codec_config->extradata_size < 0)
+return codec_config->extradata_size;
   memset(codec_config->extradata + codec_config->extradata_size, 0,
  AV_INPUT_BUFFER_PADDING_SIZE);


LGTM. Please backport to 7.0 too.


You (or someone else who can) will have to merge and backport as I have no 
commit access.
Thanks.


Already did, thanks.



OpenPGP_signature.asc
Description: OpenPGP digital 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 13/13] fftools/ffmpeg_demux: merge streams in a LCEVC stream group

2024-09-01 Thread James Almer

On 9/1/2024 10:18 AM, Anton Khirnov wrote:

Quoting James Almer (2024-08-31 18:31:14)

Add the LCEVC data stream payloads as packet side data to the main video
stream, ensuring the former is always output by the demuxer even if not
used by the process.

Signed-off-by: James Almer 
---
  configure  |   2 +-
  fftools/ffmpeg.h   |  17 +++
  fftools/ffmpeg_demux.c | 307 -
  3 files changed, 292 insertions(+), 34 deletions(-)

diff --git a/configure b/configure
index 3b7cf05bb5..3af3654483 100755
--- a/configure
+++ b/configure
@@ -4044,7 +4044,7 @@ ffmpeg_deps="avcodec avfilter avformat threads"
  ffmpeg_select="aformat_filter anull_filter atrim_filter format_filter
 hflip_filter null_filter
 transpose_filter trim_filter vflip_filter"
-ffmpeg_suggest="ole32 psapi shell32"
+ffmpeg_suggest="ole32 psapi shell32 lcevc_merge_bsf"
  ffplay_deps="avcodec avformat avfilter swscale swresample sdl2"
  ffplay_select="crop_filter transpose_filter hflip_filter vflip_filter 
rotate_filter"
  ffplay_suggest="shell32 libplacebo vulkan"
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 3c5d933e17..a9fb55fb6e 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -440,6 +440,17 @@ typedef struct InputStream {
  intnb_outputs;
  } InputStream;
  
+typedef struct InputStreamGroup {

+const AVClass*class;
+
+/* parent source */
+struct InputFile *file;
+
+int   index;
+
+AVStreamGroup*stg;
+} InputStreamGroup;


Any reason this is public? The patch doesn't touch anything outside of
ffmpeg_demux, so presumably no other code uses it.


Ok, locally moved to ffmpeg_demux.c

Eventually we'll need to do merges post decoding (xstack for heif 
images, amerge for iamf), and I assume that said struct will need to be 
public, but that can come later.




OpenPGP_signature.asc
Description: OpenPGP digital 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] avformat/iamf_parse: Fix return of uninitialized value

2024-08-31 Thread James Almer

On 8/31/2024 5:45 PM, Marvin Scholz wrote:

The ret value here is not yet intialized so the return would return
uninitialized data. What was probably meant to be checked here was the
return value of ffio_read_size, which can return an error.

Introduced in 38bcb3ba7b3424abd772c72f8bdf445d75285e88

Fixes: CID1618758
---
  libavformat/iamf_parse.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c
index f13e76b147..8a0003634b 100644
--- a/libavformat/iamf_parse.c
+++ b/libavformat/iamf_parse.c
@@ -98,8 +98,8 @@ static int aac_decoder_config(IAMFCodecConfig *codec_config,
  return AVERROR(ENOMEM);
  
  codec_config->extradata_size = ffio_read_size(pb, codec_config->extradata, left);

-if (ret < 0)
-return ret;
+if (codec_config->extradata_size < 0)
+return codec_config->extradata_size;
  memset(codec_config->extradata + codec_config->extradata_size, 0,
 AV_INPUT_BUFFER_PADDING_SIZE);


LGTM. Please backport to 7.0 too.



OpenPGP_signature.asc
Description: OpenPGP digital 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 13/13] fftools/ffmpeg_demux: merge streams in a LCEVC stream group

2024-08-31 Thread James Almer
Add the LCEVC data stream payloads as packet side data to the main video
stream, ensuring the former is always output by the demuxer even if not
used by the process.

Signed-off-by: James Almer 
---
 configure  |   2 +-
 fftools/ffmpeg.h   |  17 +++
 fftools/ffmpeg_demux.c | 307 -
 3 files changed, 292 insertions(+), 34 deletions(-)

diff --git a/configure b/configure
index 3b7cf05bb5..3af3654483 100755
--- a/configure
+++ b/configure
@@ -4044,7 +4044,7 @@ ffmpeg_deps="avcodec avfilter avformat threads"
 ffmpeg_select="aformat_filter anull_filter atrim_filter format_filter
hflip_filter null_filter
transpose_filter trim_filter vflip_filter"
-ffmpeg_suggest="ole32 psapi shell32"
+ffmpeg_suggest="ole32 psapi shell32 lcevc_merge_bsf"
 ffplay_deps="avcodec avformat avfilter swscale swresample sdl2"
 ffplay_select="crop_filter transpose_filter hflip_filter vflip_filter 
rotate_filter"
 ffplay_suggest="shell32 libplacebo vulkan"
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 3c5d933e17..a9fb55fb6e 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -440,6 +440,17 @@ typedef struct InputStream {
 intnb_outputs;
 } InputStream;
 
+typedef struct InputStreamGroup {
+const AVClass*class;
+
+/* parent source */
+struct InputFile *file;
+
+int   index;
+
+AVStreamGroup*stg;
+} InputStreamGroup;
+
 typedef struct InputFile {
 const AVClass   *class;
 
@@ -461,6 +472,12 @@ typedef struct InputFile {
  * if new streams appear dynamically during demuxing */
 InputStream**streams;
 int   nb_streams;
+
+/**
+ * stream groups that ffmpeg is aware of
+ */
+InputStreamGroup **stream_groups;
+int nb_stream_groups;
 } InputFile;
 
 enum forced_keyframes_const {
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 039ee0c785..eb7cc96f4c 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -90,12 +90,29 @@ typedef struct DemuxStream {
 
 AVBSFContext*bsf;
 
+InputStreamGroup   **stream_groups;
+int  nb_stream_groups;
+
 /* number of packets successfully read for this stream */
 uint64_t nb_packets;
 // combined size of all the packets read
 uint64_t data_size;
 } DemuxStream;
 
+typedef struct DemuxStreamGroup {
+InputStreamGroup istg;
+
+// main stream for merged output
+InputStream *stream;
+
+// name used for logging
+char log_name[32];
+
+int  discard;
+
+AVBSFContext*bsf;
+} DemuxStreamGroup;
+
 typedef struct Demuxer {
 InputFile f;
 
@@ -142,6 +159,7 @@ typedef struct DemuxThreadContext {
 AVPacket *pkt_demux;
 // packet for reading from BSFs
 AVPacket *pkt_bsf;
+AVPacket *pkt_group_bsf;
 } DemuxThreadContext;
 
 static DemuxStream *ds_from_ist(InputStream *ist)
@@ -149,6 +167,11 @@ static DemuxStream *ds_from_ist(InputStream *ist)
 return (DemuxStream*)ist;
 }
 
+static DemuxStreamGroup *dsg_from_istg(InputStreamGroup *istg)
+{
+return (DemuxStreamGroup*)istg;
+}
+
 static Demuxer *demuxer_from_ifile(InputFile *f)
 {
 return (Demuxer*)f;
@@ -537,17 +560,69 @@ static int do_send(Demuxer *d, DemuxStream *ds, AVPacket 
*pkt, unsigned flags,
 return 0;
 }
 
+static int demux_filter(Demuxer *d, DemuxThreadContext *dt, DemuxStream *ds,
+AVBSFContext *bsf, AVPacket *pkt, void *logctx)
+{
+int ret;
+
+if (pkt)
+av_packet_rescale_ts(pkt, pkt->time_base, bsf->time_base_in);
+
+ret = av_bsf_send_packet(bsf, pkt);
+if (ret < 0) {
+if (pkt)
+av_packet_unref(pkt);
+av_log(logctx, AV_LOG_ERROR, "Error submitting a packet for filtering: 
%s\n",
+   av_err2str(ret));
+return ret;
+}
+
+while (1) {
+ret = av_bsf_receive_packet(bsf, dt->pkt_bsf);
+if (ret == AVERROR(EAGAIN))
+return 0;
+else if (ret < 0) {
+if (ret != AVERROR_EOF)
+av_log(logctx, AV_LOG_ERROR,
+   "Error applying bitstream filters to a packet: %s\n",
+   av_err2str(ret));
+break;
+}
+
+dt->pkt_bsf->time_base = bsf->time_base_out;
+
+ret = do_send(d, ds, dt->pkt_bsf, 0, "filtered");
+if (ret < 0) {
+av_packet_unref(dt->pkt_bsf);
+break;
+}
+}
+
+return ret;
+}
+
 static int demux_send(Demuxer *d, DemuxThreadContext *dt, DemuxStream *ds,
   AVPacket *pkt, unsigned flags)
 {
 InputFile  *f = &d->f;
-int ret;
+int ret = 0;

[FFmpeg-devel] [PATCH 12/13] avcodec: add an LCEVC merger bsf

2024-08-31 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/bitstream_filters.c   |   1 +
 libavcodec/bsf/Makefile  |   3 +-
 libavcodec/bsf/lcevc_merge_bsf.c | 265 +++
 3 files changed, 268 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/bsf/lcevc_merge_bsf.c

diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index f923411bee..fdd4fcf01b 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -45,6 +45,7 @@ extern const FFBitStreamFilter ff_hapqa_extract_bsf;
 extern const FFBitStreamFilter ff_hevc_metadata_bsf;
 extern const FFBitStreamFilter ff_hevc_mp4toannexb_bsf;
 extern const FFBitStreamFilter ff_imx_dump_header_bsf;
+extern const FFBitStreamFilter ff_lcevc_merge_bsf;
 extern const FFBitStreamFilter ff_media100_to_mjpegb_bsf;
 extern const FFBitStreamFilter ff_mjpeg2jpeg_bsf;
 extern const FFBitStreamFilter ff_mjpega_dump_header_bsf;
diff --git a/libavcodec/bsf/Makefile b/libavcodec/bsf/Makefile
index 40b7fc6e9b..850bcaf377 100644
--- a/libavcodec/bsf/Makefile
+++ b/libavcodec/bsf/Makefile
@@ -1,4 +1,4 @@
-clean::
+\clean::
$(RM) $(CLEANSUFFIXES:%=libavcodec/bsf/%)
 
 OBJS-$(CONFIG_AAC_ADTSTOASC_BSF)  += bsf/aac_adtstoasc.o
@@ -22,6 +22,7 @@ OBJS-$(CONFIG_HEVC_METADATA_BSF)  += 
bsf/h265_metadata.o
 OBJS-$(CONFIG_DOVI_RPU_BSF)   += bsf/dovi_rpu.o
 OBJS-$(CONFIG_HEVC_MP4TOANNEXB_BSF)   += bsf/hevc_mp4toannexb.o
 OBJS-$(CONFIG_IMX_DUMP_HEADER_BSF)+= bsf/imx_dump_header.o
+OBJS-$(CONFIG_LCEVC_MERGE_BSF)+= bsf/lcevc_merge_bsf.o
 OBJS-$(CONFIG_MEDIA100_TO_MJPEGB_BSF) += bsf/media100_to_mjpegb.o
 OBJS-$(CONFIG_MJPEG2JPEG_BSF) += bsf/mjpeg2jpeg.o
 OBJS-$(CONFIG_MJPEGA_DUMP_HEADER_BSF) += bsf/mjpega_dump_header.o
diff --git a/libavcodec/bsf/lcevc_merge_bsf.c b/libavcodec/bsf/lcevc_merge_bsf.c
new file mode 100644
index 00..fcaeb7ef7f
--- /dev/null
+++ b/libavcodec/bsf/lcevc_merge_bsf.c
@@ -0,0 +1,265 @@
+/*
+ * Copyright (c) 2022 James Almer
+ *
+ * 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
+ * Derive PTS by reordering DTS from supported streams
+ */
+
+#include "libavutil/avassert.h"
+#include "libavutil/attributes.h"
+#include "libavutil/fifo.h"
+#include "libavutil/mem.h"
+#include "libavutil/opt.h"
+#include "libavutil/tree.h"
+
+#include "bsf.h"
+#include "bsf_internal.h"
+
+typedef struct LCEVCMergeContext {
+const AVClass *class;
+
+struct AVTreeNode *base;
+struct AVTreeNode *enhancement;
+AVFifo *nodes;
+
+int base_idx, enhancement_idx;
+} LCEVCMergeContext;
+
+// AVTreeNode callbacks
+static int cmp_insert(const void *_key, const void *_node)
+{
+const AVPacket *key = _key, *node = _node;
+
+return FFDIFFSIGN(key->pts, node->pts);
+}
+
+static int cmp_find(const void *_key, const void *_node)
+{
+int64_t key = *(const int64_t *)_key;
+const AVPacket *node = _node;
+
+return FFDIFFSIGN(key, node->pts);
+}
+
+#define WARN_BUFFERED(type)  \
+static int warn_##type##_buffered(void *logctx, void *elem)  \
+{\
+const AVPacket *pkt = (const AVPacket *)elem;\
+av_log(logctx, AV_LOG_WARNING, #type" packet with PTS %"PRId64   \
+   " left buffered at EOF\n", pkt->pts); \
+return 0;\
+}
+
+WARN_BUFFERED(base)
+WARN_BUFFERED(enhanced)
+
+static int lcevc_merge_init(AVBSFContext *ctx)
+{
+LCEVCMergeContext *s = ctx->priv_data;
+
+if (s->base_idx < 0 || s->enhancement_idx < 0) {
+av_log(ctx, AV_LOG_ERROR, "Both base and enhancement stream index must 
be set\n");
+return AVERROR(EINVAL);
+}
+
+s->nodes = av_fifo_alloc2(1, sizeof(struct AVTreeNode*), 
AV_FIFO_FLAG_AUTO_GROW);
+if (!s->nodes)
+return AVERROR(ENOMEM);
+
+return 0;
+}
+
+static int merge_packet(AVBSFContext *ctx, struct AVTreeNode **root,
+ 

[FFmpeg-devel] [PATCH 11/13] avcodec/packet: add a LCEVC packet side data type

2024-08-31 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/decode.c | 1 +
 libavcodec/packet.c | 1 +
 libavcodec/packet.h | 5 +
 3 files changed, 7 insertions(+)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 033c4913c0..7303a08dc1 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1435,6 +1435,7 @@ int ff_decode_frame_props_from_pkt(const AVCodecContext 
*avctx,
 { AV_PKT_DATA_DYNAMIC_HDR10_PLUS, 
AV_FRAME_DATA_DYNAMIC_HDR_PLUS },
 { AV_PKT_DATA_S12M_TIMECODE,  AV_FRAME_DATA_S12M_TIMECODE 
},
 { AV_PKT_DATA_SKIP_SAMPLES,   AV_FRAME_DATA_SKIP_SAMPLES },
+{ AV_PKT_DATA_LCEVC,  AV_FRAME_DATA_LCEVC },
 };
 
 frame->pts  = pkt->pts;
diff --git a/libavcodec/packet.c b/libavcodec/packet.c
index 032f270777..381001fd65 100644
--- a/libavcodec/packet.c
+++ b/libavcodec/packet.c
@@ -306,6 +306,7 @@ const char *av_packet_side_data_name(enum 
AVPacketSideDataType type)
 case AV_PKT_DATA_IAMF_DEMIXING_INFO_PARAM:   return "IAMF Demixing Info 
Parameter Data";
 case AV_PKT_DATA_IAMF_RECON_GAIN_INFO_PARAM: return "IAMF Recon Gain Info 
Parameter Data";
 case AV_PKT_DATA_FRAME_CROPPING: return "Frame Cropping";
+case AV_PKT_DATA_LCEVC:  return "LCEVC NAL data";
 }
 return NULL;
 }
diff --git a/libavcodec/packet.h b/libavcodec/packet.h
index 13667ffa36..6e9a301884 100644
--- a/libavcodec/packet.h
+++ b/libavcodec/packet.h
@@ -339,6 +339,11 @@ enum AVPacketSideDataType {
  */
 AV_PKT_DATA_FRAME_CROPPING,
 
+/**
+ * LCEVC raw NAL data.
+ */
+AV_PKT_DATA_LCEVC,
+
 /**
  * The number of side data types.
  * This is not part of the public API/ABI in the sense that it may
-- 
2.46.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 08/13] avcodec/codec_id: add an LCEVC codec id for raw LCEVC data

2024-08-31 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/codec_desc.c | 6 ++
 libavcodec/codec_id.h   | 1 +
 2 files changed, 7 insertions(+)

diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index a28ef68061..03dea5751a 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -3696,6 +3696,12 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .name  = "smpte_2038",
 .long_name = NULL_IF_CONFIG_SMALL("SMPTE ST 2038 VANC in MPEG-2 TS"),
 },
+{
+.id= AV_CODEC_ID_LCEVC,
+.type  = AVMEDIA_TYPE_DATA,
+.name  = "lcevc",
+.long_name = NULL_IF_CONFIG_SMALL("LCEVC (Low Complexity Enhancement 
Video Coding) / MPEG-5 LCEVC / MPEG-5 part 2"),
+},
 {
 .id= AV_CODEC_ID_MPEG2TS,
 .type  = AVMEDIA_TYPE_DATA,
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 0ab1e34a61..0a8d3bed1e 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -589,6 +589,7 @@ enum AVCodecID {
 AV_CODEC_ID_TIMED_ID3,
 AV_CODEC_ID_BIN_DATA,
 AV_CODEC_ID_SMPTE_2038,
+AV_CODEC_ID_LCEVC,
 
 
 AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like 
AV_CODEC_ID_NONE) but lavf should attempt to identify it
-- 
2.46.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 10/13] avformat/mov: support for LCEVC tracks

2024-08-31 Thread James Almer
Co-authored-by: V-Nova Team 
Signed-off-by: James Almer 
---
 libavformat/isom.h  |  3 ++
 libavformat/isom_tags.c |  2 +
 libavformat/mov.c   | 86 +
 3 files changed, 91 insertions(+)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index 15e9466e41..4723397048 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -212,6 +212,8 @@ typedef struct MOVStreamContext {
 unsigned drefs_count;
 MOVDref *drefs;
 int dref_id;
+unsigned tref_flags;
+int tref_id;
 int timecode_track;
 int width;///< tkhd width
 int height;   ///< tkhd height
@@ -408,6 +410,7 @@ void ff_mp4_parse_es_descr(AVIOContext *pb, int *es_id);
 #define MOV_SAMPLE_DEPENDENCY_YES 0x1
 #define MOV_SAMPLE_DEPENDENCY_NO  0x2
 
+#define MOV_TREF_FLAG_ENHANCEMENT 0x1
 
 #define TAG_IS_AVCI(tag)\
 ((tag) == MKTAG('a', 'i', '5', 'p') ||  \
diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c
index 058f0f2a59..5dd72d570e 100644
--- a/libavformat/isom_tags.c
+++ b/libavformat/isom_tags.c
@@ -290,6 +290,8 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
 
 { AV_CODEC_ID_CFHD, MKTAG('C', 'F', 'H', 'D') },
 
+{ AV_CODEC_ID_LCEVC, MKTAG('l', 'v', 'c', '1') }, /* LCEVC raw payload */
+
 { AV_CODEC_ID_NONE, 0 },
 };
 
diff --git a/libavformat/mov.c b/libavformat/mov.c
index d57c4f150b..7cb50fdbf8 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2434,6 +2434,30 @@ static int mov_read_dvc1(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 return 0;
 }
 
+static int mov_read_sbas(MOVContext* c, AVIOContext* pb, MOVAtom atom)
+{
+AVStream* st;
+MOVStreamContext* sc;
+
+if (c->fc->nb_streams < 1)
+return 0;
+
+/* For SBAS this should be fine - though beware if someone implements a
+ * tref atom processor that doesn't drop down to default then this may
+ * be lost. */
+if (atom.size > 4) {
+av_log(c->fc, AV_LOG_ERROR, "Only a single tref of type sbas is 
supported\n");
+return AVERROR_PATCHWELCOME;
+}
+
+st = c->fc->streams[c->fc->nb_streams - 1];
+sc = st->priv_data;
+sc->tref_id = avio_rb32(pb);
+sc->tref_flags |= MOV_TREF_FLAG_ENHANCEMENT;
+
+return 0;
+}
+
 /**
  * An strf atom is a BITMAPINFOHEADER struct. This struct is 40 bytes itself,
  * but can have extradata appended at the end after the 40 bytes belonging
@@ -4995,6 +5019,8 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
 sc->ffindex = st->index;
 c->trak_index = st->index;
+sc->tref_flags = 0;
+sc->tref_id = -1;
 sc->refcount = 1;
 
 if ((ret = mov_read_default(c, pb, atom)) < 0)
@@ -9052,6 +9078,7 @@ static const MOVParseTableEntry mov_default_parse_table[] 
= {
 { MKTAG('a','v','c','C'), mov_read_glbl },
 { MKTAG('p','a','s','p'), mov_read_pasp },
 { MKTAG('c','l','a','p'), mov_read_clap },
+{ MKTAG('s','b','a','s'), mov_read_sbas },
 { MKTAG('s','i','d','x'), mov_read_sidx },
 { MKTAG('s','t','b','l'), mov_read_default },
 { MKTAG('s','t','c','o'), mov_read_stco },
@@ -9132,6 +9159,7 @@ static const MOVParseTableEntry mov_default_parse_table[] 
= {
 { MKTAG('i','i','n','f'), mov_read_iinf },
 { MKTAG('a','m','v','e'), mov_read_amve }, /* ambient viewing environment box 
*/
 { MKTAG('l','h','v','C'), mov_read_lhvc },
+{ MKTAG('l','v','c','C'), mov_read_glbl },
 #if CONFIG_IAMFDEC
 { MKTAG('i','a','c','b'), mov_read_iacb },
 #endif
@@ -10029,6 +10057,20 @@ static int mov_parse_tiles(AVFormatContext *s)
 return 0;
 }
 
+static AVStream *mov_find_reference_track(AVFormatContext *s, AVStream *st)
+{
+MOVStreamContext *sc = st->priv_data;
+
+if (sc->tref_id < 0)
+return NULL;
+
+for (int i = 0; i < s->nb_streams; i++)
+if (s->streams[i]->id == sc->tref_id)
+return s->streams[i];
+
+return NULL;
+}
+
 static int mov_read_header(AVFormatContext *s)
 {
 MOVContext *mov = s->priv_data;
@@ -10154,6 +10196,50 @@ static int mov_read_header(AVFormatContext *s)
 }
 export_orphan_timecode(s);
 
+/* Update the LCEVC stream as a data stream. */
+for (i = 0; i < s->nb_streams; i++) {
+

[FFmpeg-devel] [PATCH 07/13] avcodec/hevcdec: export LCEVC metadata as frame side data

2024-08-31 Thread James Almer
Signed-off-by: James Almer 
---
 configure |  1 +
 libavcodec/hevc/hevcdec.c |  3 +++
 libavcodec/hevc/refs.c| 15 ++-
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 84f63bbb87..3b7cf05bb5 100755
--- a/configure
+++ b/configure
@@ -2975,6 +2975,7 @@ hap_decoder_select="snappy texturedsp"
 hap_encoder_deps="libsnappy"
 hap_encoder_select="texturedspenc"
 hevc_decoder_select="bswapdsp cabac dovi_rpudec golomb hevcparse hevc_sei 
videodsp"
+hevc_decoder_suggest="liblcevc_dec"
 huffyuv_decoder_select="bswapdsp huffyuvdsp llviddsp"
 huffyuv_encoder_select="bswapdsp huffman huffyuvencdsp llvidencdsp"
 hymt_decoder_select="huffyuv_decoder"
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 4077ed3ac5..41bb7fdfe1 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3459,6 +3459,9 @@ do_output:
 if (ff_container_fifo_read(s->output_fifo, frame) >= 0) {
 if (!(avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN))
 av_frame_remove_side_data(frame, AV_FRAME_DATA_FILM_GRAIN_PARAMS);
+if (!CONFIG_LIBLCEVC_DEC &&
+!(avctx->export_side_data & AV_CODEC_EXPORT_DATA_ENHANCEMENTS))
+av_frame_remove_side_data(frame, AV_FRAME_DATA_LCEVC);
 
 return 0;
 }
diff --git a/libavcodec/hevc/refs.c b/libavcodec/hevc/refs.c
index 65abd09a21..88c5c5ea52 100644
--- a/libavcodec/hevc/refs.c
+++ b/libavcodec/hevc/refs.c
@@ -83,10 +83,23 @@ static HEVCFrame *alloc_frame(HEVCContext *s)
 if (frame->f)
 continue;
 
+ret = ff_progress_frame_alloc(s->avctx, &frame->tf);
+if (ret < 0)
+return NULL;
+
+if (CONFIG_LIBLCEVC_DEC && s->sei.common.lcevc.info && 
!s->avctx->hwaccel &&
+!(s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_ENHANCEMENTS)) 
{
+HEVCSEILCEVC *lcevc = &s->sei.common.lcevc;
+ret = ff_frame_new_side_data_from_buf(s->avctx, frame->tf.f,
+  AV_FRAME_DATA_LCEVC, 
&lcevc->info);
+if (ret < 0)
+goto fail;
+}
+
 ret = ff_progress_frame_get_buffer(s->avctx, &frame->tf,
AV_GET_BUFFER_FLAG_REF);
 if (ret < 0)
-return NULL;
+goto fail;
 
 frame->rpl = ff_refstruct_allocz(s->pkt.nb_nals * sizeof(*frame->rpl));
 if (!frame->rpl)
-- 
2.46.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 09/13] avformat: add an LCEVC stream group

2024-08-31 Thread James Almer
Signed-off-by: James Almer 
---
 libavformat/avformat.c |  5 +
 libavformat/avformat.h | 15 +++
 libavformat/dump.c | 27 +++
 libavformat/options.c  | 29 -
 4 files changed, 75 insertions(+), 1 deletion(-)

diff --git a/libavformat/avformat.c b/libavformat/avformat.c
index b4f20502fb..06dcde0565 100644
--- a/libavformat/avformat.c
+++ b/libavformat/avformat.c
@@ -104,6 +104,10 @@ void ff_free_stream_group(AVStreamGroup **pstg)
 av_freep(&stg->params.tile_grid->offsets);
 av_freep(&stg->params.tile_grid);
 break;
+case AV_STREAM_GROUP_PARAMS_LCEVC:
+av_opt_free(stg->params.lcevc);
+av_freep(&stg->params.lcevc);
+break;
 default:
 break;
 }
@@ -327,6 +331,7 @@ const char *avformat_stream_group_name(enum 
AVStreamGroupParamsType type)
 case AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT:return "IAMF Audio 
Element";
 case AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION: return "IAMF Mix 
Presentation";
 case AV_STREAM_GROUP_PARAMS_TILE_GRID: return "Tile Grid";
+case AV_STREAM_GROUP_PARAMS_LCEVC: return "LCEVC 
(Split video and enhancement)";
 }
 return NULL;
 }
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 4a3fb00529..b611e110e1 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1084,11 +1084,25 @@ typedef struct AVStreamGroupTileGrid {
 int height;
 } AVStreamGroupTileGrid;
 
+typedef struct AVStreamGroupLCEVC {
+const AVClass *av_class;
+
+/**
+ * Width of the final stream for presentation.
+ */
+int width;
+/**
+ * Height of the final image for presentation.
+ */
+int height;
+} AVStreamGroupLCEVC;
+
 enum AVStreamGroupParamsType {
 AV_STREAM_GROUP_PARAMS_NONE,
 AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT,
 AV_STREAM_GROUP_PARAMS_IAMF_MIX_PRESENTATION,
 AV_STREAM_GROUP_PARAMS_TILE_GRID,
+AV_STREAM_GROUP_PARAMS_LCEVC,
 };
 
 struct AVIAMFAudioElement;
@@ -1130,6 +1144,7 @@ typedef struct AVStreamGroup {
 struct AVIAMFAudioElement *iamf_audio_element;
 struct AVIAMFMixPresentation *iamf_mix_presentation;
 struct AVStreamGroupTileGrid *tile_grid;
+struct AVStreamGroupLCEVC *lcevc;
 } params;
 
 /**
diff --git a/libavformat/dump.c b/libavformat/dump.c
index 5e1f367742..f20c2c4953 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -789,6 +789,33 @@ static void dump_stream_group(const AVFormatContext *ic, 
uint8_t *printed,
 }
 break;
 }
+case AV_STREAM_GROUP_PARAMS_LCEVC: {
+const AVStreamGroupLCEVC *lcevc = stg->params.lcevc;
+AVCodecContext *avctx = avcodec_alloc_context3(NULL);
+const char *ptr = NULL;
+av_log(NULL, AV_LOG_INFO, " LCEVC:");
+if (avctx && stg->nb_streams && !avcodec_parameters_to_context(avctx, 
stg->streams[0]->codecpar)) {
+avctx->width  = lcevc->width;
+avctx->height = lcevc->height;
+avctx->coded_width  = lcevc->width;
+avctx->coded_height = lcevc->height;
+if (ic->dump_separator)
+av_opt_set(avctx, "dump_separator", ic->dump_separator, 0);
+buf[0] = 0;
+avcodec_string(buf, sizeof(buf), avctx, is_output);
+ptr = av_stristr(buf, " ");
+}
+avcodec_free_context(&avctx);
+if (ptr)
+av_log(NULL, AV_LOG_INFO, "%s", ptr);
+av_log(NULL, AV_LOG_INFO, "\n");
+for (int i = 0; i < stg->nb_streams; i++) {
+const AVStream *st = stg->streams[i];
+dump_stream_format(ic, st->index, i, index, is_output, 
AV_LOG_VERBOSE);
+printed[st->index] = 1;
+}
+break;
+}
 default:
 break;
 }
diff --git a/libavformat/options.c b/libavformat/options.c
index 485265df52..039f1eea42 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -348,7 +348,6 @@ static const AVOption tile_grid_options[] = {
 { "vertical_offset",   NULL, OFFSET(vertical_offset),   AV_OPT_TYPE_INT, { 
.i64 = 0 }, 0, INT_MAX, FLAGS },
 { NULL },
 };
-#undef FLAGS
 #undef OFFSET
 
 static const AVClass tile_grid_class = {
@@ -357,6 +356,20 @@ static const AVClass tile_grid_class = {
 .option = tile_grid_options,
 };
 
+#define OFFSET(x) offsetof(AVStreamGroupLCEVC, x)
+static const AVOption lcevc_options[] = {
+{ "video_size", "size of video after LCEVC enhancement has been applied", 
OFFSET(width),
+AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, INT_MAX, FLAGS },
+{ NULL },
+};
+#undef OFFSET
+
+static const AVClass lcevc_class = {
+.class_name = &

[FFmpeg-devel] [PATCH 06/13] avcodec/h264dec: export LCEVC metadata as frame side data

2024-08-31 Thread James Almer
Signed-off-by: James Almer 
---
 configure   | 2 +-
 libavcodec/h264_slice.c | 8 
 libavcodec/h264dec.c| 2 ++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 261ab6252e..84f63bbb87 100755
--- a/configure
+++ b/configure
@@ -2970,7 +2970,7 @@ h263i_decoder_select="h263_decoder"
 h263p_decoder_select="h263_decoder"
 h263p_encoder_select="h263_encoder"
 h264_decoder_select="cabac golomb h264chroma h264dsp h264parse h264pred 
h264qpel h264_sei videodsp"
-h264_decoder_suggest="error_resilience"
+h264_decoder_suggest="error_resilience liblcevc_dec"
 hap_decoder_select="snappy texturedsp"
 hap_encoder_deps="libsnappy"
 hap_encoder_select="texturedspenc"
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index a66b75ca80..89172dc05a 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -518,6 +518,14 @@ static int h264_frame_start(H264Context *h)
 
 pic->needs_fg = h->sei.common.film_grain_characteristics.present && 
!h->avctx->hwaccel &&
 !(h->avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN);
+if (CONFIG_LIBLCEVC_DEC && h->sei.common.lcevc.info && !h->avctx->hwaccel 
&&
+!(h->avctx->export_side_data & AV_CODEC_EXPORT_DATA_ENHANCEMENTS)) {
+HEVCSEILCEVC *lcevc = &h->sei.common.lcevc;
+ret = ff_frame_new_side_data_from_buf(h->avctx, pic->f,
+  AV_FRAME_DATA_LCEVC, 
&lcevc->info);
+if (ret < 0)
+return ret;
+}
 
 if ((ret = alloc_picture(h, pic)) < 0)
 return ret;
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 0154fe17b6..976b21c30e 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -904,6 +904,8 @@ static int output_frame(H264Context *h, AVFrame *dst, 
H264Picture *srcp)
 
 if (!(h->avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN))
 av_frame_remove_side_data(dst, AV_FRAME_DATA_FILM_GRAIN_PARAMS);
+if (!CONFIG_LIBLCEVC_DEC && !(h->avctx->export_side_data & 
AV_CODEC_EXPORT_DATA_ENHANCEMENTS))
+av_frame_remove_side_data(dst, AV_FRAME_DATA_LCEVC);
 
 return 0;
 fail:
-- 
2.46.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 05/13 v3] avcodec/h2645_sei: export raw LCEVC metadata

2024-08-31 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/h2645_sei.c | 34 ++
 libavcodec/h2645_sei.h |  5 +
 libavcodec/itut35.h|  2 ++
 3 files changed, 41 insertions(+)

diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c
index 7c83747cd0..c46a563308 100644
--- a/libavcodec/h2645_sei.c
+++ b/libavcodec/h2645_sei.c
@@ -99,6 +99,20 @@ static int 
decode_registered_user_data_dynamic_hdr_vivid(HEVCSEIDynamicHDRVivid
 }
 #endif
 
+static int decode_registered_user_data_lcevc(HEVCSEILCEVC *s,
+ GetByteContext *gb)
+{
+int size = bytestream2_get_bytes_left(gb);
+
+av_buffer_unref(&s->info);
+s->info = av_buffer_alloc(size);
+if (!s->info)
+return AVERROR(ENOMEM);
+
+bytestream2_get_bufferu(gb, s->info->data, size);
+return 0;
+}
+
 static int decode_registered_user_data_afd(H2645SEIAFD *h, GetByteContext *gb)
 {
 int flag;
@@ -142,6 +156,7 @@ static int decode_registered_user_data(H2645SEI *h, 
GetByteContext *gb,
 }
 
 if (country_code != ITU_T_T35_COUNTRY_CODE_US &&
+country_code != ITU_T_T35_COUNTRY_CODE_UK &&
 country_code != ITU_T_T35_COUNTRY_CODE_CN) {
 av_log(logctx, AV_LOG_VERBOSE,
"Unsupported User Data Registered ITU-T T35 SEI message 
(country_code = %d)\n",
@@ -173,6 +188,13 @@ static int decode_registered_user_data(H2645SEI *h, 
GetByteContext *gb,
 }
 break;
 }
+case ITU_T_T35_PROVIDER_CODE_LCEVC: {
+if (bytestream2_get_bytes_left(gb) < 2)
+return AVERROR_INVALIDDATA;
+
+bytestream2_skipu(gb, 1); // user_data_type_code
+return decode_registered_user_data_lcevc(&h->lcevc, gb);
+}
 #if CONFIG_HEVC_SEI
 case ITU_T_T35_PROVIDER_CODE_CUVA: {
 const uint16_t cuva_provider_oriented_code = 0x0005;
@@ -501,6 +523,10 @@ int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI 
*src)
 av_buffer_unref(&dst->unregistered.buf_ref[i]);
 dst->unregistered.nb_buf_ref = 0;
 
+ret = av_buffer_replace(&dst->lcevc.info, src->lcevc.info);
+if (ret < 0)
+return ret;
+
 if (src->unregistered.nb_buf_ref) {
 ret = av_reallocp_array(&dst->unregistered.buf_ref,
 src->unregistered.nb_buf_ref,
@@ -778,6 +804,13 @@ int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei,
 }
 }
 
+if (sei->lcevc.info) {
+HEVCSEILCEVC *lcevc = &sei->lcevc;
+ret = ff_frame_new_side_data_from_buf(avctx, frame, 
AV_FRAME_DATA_LCEVC, &lcevc->info);
+if (ret < 0)
+return ret;
+}
+
 if (sei->film_grain_characteristics.present) {
 H2645SEIFilmGrainCharacteristics *fgc = 
&sei->film_grain_characteristics;
 AVFilmGrainParams *fgp = av_film_grain_params_create_side_data(frame);
@@ -875,6 +908,7 @@ void ff_h2645_sei_reset(H2645SEI *s)
 av_freep(&s->unregistered.buf_ref);
 av_buffer_unref(&s->dynamic_hdr_plus.info);
 av_buffer_unref(&s->dynamic_hdr_vivid.info);
+av_buffer_unref(&s->lcevc.info);
 
 s->ambient_viewing_environment.present = 0;
 s->mastering_display.present = 0;
diff --git a/libavcodec/h2645_sei.h b/libavcodec/h2645_sei.h
index 488dbcad7e..598f78b585 100644
--- a/libavcodec/h2645_sei.h
+++ b/libavcodec/h2645_sei.h
@@ -50,6 +50,10 @@ typedef struct HEVCSEIDynamicHDRVivid {
 AVBufferRef *info;
 } HEVCSEIDynamicHDRVivid;
 
+typedef struct HEVCSEILCEVC {
+AVBufferRef *info;
+} HEVCSEILCEVC;
+
 typedef struct H2645SEIUnregistered {
 AVBufferRef **buf_ref;
 unsigned nb_buf_ref;
@@ -126,6 +130,7 @@ typedef struct H2645SEI {
 H2645SEIAFD afd;
 HEVCSEIDynamicHDRPlus  dynamic_hdr_plus; //< HEVC only
 HEVCSEIDynamicHDRVivid dynamic_hdr_vivid;//< HEVC only
+HEVCSEILCEVC lcevc;
 H2645SEIUnregistered unregistered;
 H2645SEIFramePacking frame_packing;
 H2645SEIDisplayOrientation display_orientation;
diff --git a/libavcodec/itut35.h b/libavcodec/itut35.h
index ffa7024981..a75ef37929 100644
--- a/libavcodec/itut35.h
+++ b/libavcodec/itut35.h
@@ -20,11 +20,13 @@
 #define AVCODEC_ITUT35_H
 
 #define ITU_T_T35_COUNTRY_CODE_CN 0x26
+#define ITU_T_T35_COUNTRY_CODE_UK 0xB4
 #define ITU_T_T35_COUNTRY_CODE_US 0xB5
 
 #define ITU_T_T35_PROVIDER_CODE_ATSC  0x31
 #define ITU_T_T35_PROVIDER_CODE_CUVA  0x04
 #define ITU_T_T35_PROVIDER_CODE_DOLBY 0x3B
+#define ITU_T_T35_PROVIDER_CODE_LCEVC 0x50
 #define ITU_T_T35_PROVIDER_CODE_SMTPE 0x3C
 
 #endif /* AVCODEC_ITUT35_H */
-- 
2.46.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 04/13] avcodec/decode: split ProgressFrame allocator into two functions

2024-08-31 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/decode.c| 11 +++
 libavcodec/progressframe.h | 16 ++--
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index dc868714ac..033c4913c0 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1749,7 +1749,7 @@ static void check_progress_consistency(const 
ProgressFrame *f)
 av_assert1(!f->progress || f->progress->f == f->f);
 }
 
-static int progress_frame_get(AVCodecContext *avctx, ProgressFrame *f)
+int ff_progress_frame_alloc(AVCodecContext *avctx, ProgressFrame *f)
 {
 FFRefStructPool *pool = avctx->internal->progress_frame_pool;
 
@@ -1767,9 +1767,12 @@ int ff_progress_frame_get_buffer(AVCodecContext *avctx, 
ProgressFrame *f, int fl
 {
 int ret;
 
-ret = progress_frame_get(avctx, f);
-if (ret < 0)
-return ret;
+check_progress_consistency(f);
+if (!f->f) {
+ret = ff_progress_frame_alloc(avctx, f);
+if (ret < 0)
+return ret;
+}
 
 ret = ff_thread_get_buffer(avctx, f->progress->f, flags);
 if (ret < 0) {
diff --git a/libavcodec/progressframe.h b/libavcodec/progressframe.h
index 428a461659..32a345beec 100644
--- a/libavcodec/progressframe.h
+++ b/libavcodec/progressframe.h
@@ -102,12 +102,24 @@ void ff_progress_frame_report(ProgressFrame *f, int 
progress);
 void ff_progress_frame_await(const ProgressFrame *f, int progress);
 
 /**
- * This function sets up the ProgressFrame, i.e. gets ProgressFrame.f
- * and also calls ff_thread_get_buffer() on the frame.
+ * This function allocates ProgressFrame.f
+ * May be called before ff_progress_frame_get_buffer() in the cases where the
+ * AVFrame needs to be accessed before the ff_thread_get_buffer() call in
+ * ff_progress_frame_alloc().
  *
  * @note: This must only be called by codecs with the
  *FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap.
  */
+int ff_progress_frame_alloc(struct AVCodecContext *avctx, ProgressFrame *f);
+
+/**
+ * This function sets up the ProgressFrame, i.e. allocates ProgressFrame.f
+ * if needed, and also calls ff_thread_get_buffer() on the frame.
+ *
+ * @note: This must only be called by codecs with the
+ *FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap.
+ * @see ff_progress_frame_alloc
+ */
 int ff_progress_frame_get_buffer(struct AVCodecContext *avctx,
  ProgressFrame *f, int flags);
 
-- 
2.46.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 03/13] avcodec/decode: support applying LCEVC enhacements

2024-08-31 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/avcodec.c   |  2 ++
 libavcodec/avcodec.h   |  5 +
 libavcodec/decode.c| 42 +-
 libavcodec/internal.h  |  2 ++
 libavcodec/lcevcdec.c  |  2 ++
 libavcodec/options_table.h |  1 +
 libavcodec/pthread_frame.c |  7 +++
 7 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index 6065f1b689..380df267a0 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -446,6 +446,8 @@ av_cold void ff_codec_close(AVCodecContext *avctx)
 ff_refstruct_unref(&avci->pool);
 ff_refstruct_pool_uninit(&avci->progress_frame_pool);
 
+av_buffer_unref(&avci->lcevc);
+
 ff_hwaccel_uninit(avctx);
 
 av_bsf_free(&avci->bsf);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 7a67300134..f6e01da738 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -418,6 +418,11 @@ typedef struct RcOverride{
  * Do not apply film grain, export it instead.
  */
 #define AV_CODEC_EXPORT_DATA_FILM_GRAIN (1 << 3)
+/**
+ * Decoding only.
+ * Do not apply picture enhancement layers, export them instead.
+ */
+#define AV_CODEC_EXPORT_DATA_ENHANCEMENTS (1 << 4)
 
 /**
  * The decoder will keep a reference to the frame and may reuse it later.
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 27dba8a1f3..dc868714ac 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -48,6 +48,7 @@
 #include "hwaccel_internal.h"
 #include "hwconfig.h"
 #include "internal.h"
+#include "lcevcdec.h"
 #include "packet_internal.h"
 #include "progressframe.h"
 #include "refstruct.h"
@@ -1599,6 +1600,7 @@ int ff_attach_decode_data(AVFrame *frame)
 int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
 {
 const FFHWAccel *hwaccel = ffhwaccel(avctx->hwaccel);
+int lcevc = 0, width = 0, height = 0;
 int override_dimensions = 1;
 int ret;
 
@@ -1639,8 +1641,17 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, 
int flags)
 ret = hwaccel->alloc_frame(avctx, frame);
 goto end;
 }
-} else
+} else {
 avctx->sw_pix_fmt = avctx->pix_fmt;
+lcevc = CONFIG_LIBLCEVC_DEC && avctx->codec_type == AVMEDIA_TYPE_VIDEO 
&&
+avctx->internal->lcevc && av_frame_get_side_data(frame, 
AV_FRAME_DATA_LCEVC);
+if (lcevc) {
+width = frame->width;
+height= frame->height;
+frame->width  = frame->width  * 2 / 
FFMAX(frame->sample_aspect_ratio.den, 1);
+frame->height = frame->height * 2 / 
FFMAX(frame->sample_aspect_ratio.num, 1);
+}
+}
 
 ret = avctx->get_buffer2(avctx, frame, flags);
 if (ret < 0)
@@ -1652,6 +1663,20 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, 
int flags)
 if (ret < 0)
 goto fail;
 
+if (CONFIG_LIBLCEVC_DEC && lcevc) {
+FrameDecodeData *fdd = (FrameDecodeData*)frame->private_ref->data;
+fdd->post_process_opaque = av_buffer_ref(avctx->internal->lcevc);
+
+frame->width  = width;
+frame->height = height;
+if (!fdd->post_process_opaque) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
+fdd->post_process_opaque_free = ff_lcevc_unref;
+fdd->post_process = ff_lcevc_process;
+}
+
 end:
 if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && !override_dimensions &&
 !(ffcodec(avctx->codec)->caps_internal & 
FF_CODEC_CAP_EXPORTS_CROPPING)) {
@@ -1949,6 +1974,21 @@ int ff_decode_preinit(AVCodecContext *avctx)
 if (ret < 0)
 return ret;
 
+if (CONFIG_LIBLCEVC_DEC && !(avctx->export_side_data & 
AV_CODEC_EXPORT_DATA_ENHANCEMENTS)) {
+FFLCEVCContext *lcevc = av_mallocz(sizeof(*lcevc));
+
+if (!lcevc || !(avci->lcevc = av_buffer_create((uint8_t *)lcevc, 
sizeof(*lcevc),
+   ff_lcevc_free, lcevc, 
0))) {
+int explode = avctx->err_recognition & AV_EF_EXPLODE;
+av_log(avctx, explode ? AV_LOG_ERROR: AV_LOG_WARNING,
+   "Error allocating LCEVC context\n");
+if (explode) {
+av_free(lcevc);
+return AVERROR(ENOMEM);
+}
+}
+}
+
 #if FF_API_DROPCHANGED
 if (avctx->flags & AV_CODEC_FLAG_DROPCHANGED)
 av_log(avctx, AV_LOG_WARNING, "The dropchanged flag is deprecated.\n");
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 98ab2797ce..aae78854cc 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -158,6 +158,8 @@ typedef 

[FFmpeg-devel] [PATCH 02/13 v3] avcodec: add LCEVC decoding support via LCEVCdec

2024-08-31 Thread James Almer
Signed-off-by: James Almer 
---
 configure |   3 +
 doc/general_contents.texi |  13 ++
 libavcodec/Makefile   |   1 +
 libavcodec/lcevcdec.c | 289 ++
 libavcodec/lcevcdec.h |  45 ++
 5 files changed, 351 insertions(+)
 create mode 100644 libavcodec/lcevcdec.c
 create mode 100644 libavcodec/lcevcdec.h

diff --git a/configure b/configure
index 63f0429b02..261ab6252e 100755
--- a/configure
+++ b/configure
@@ -225,6 +225,7 @@ External library support:
   --enable-libcdio enable audio CD grabbing with libcdio [no]
   --enable-libcodec2   enable codec2 en/decoding using libcodec2 [no]
   --enable-libdav1denable AV1 decoding via libdav1d [no]
+  --enable-liblcevc-decenable LCEVC decoding via liblcevc-dec [no]
   --enable-libdavs2enable AVS2 decoding via libdavs2 [no]
   --enable-libdc1394   enable IIDC-1394 grabbing using libdc1394
and libraw1394 [no]
@@ -1914,6 +1915,7 @@ EXTERNAL_LIBRARY_LIST="
 libcelt
 libcodec2
 libdav1d
+liblcevc_dec
 libdc1394
 libflite
 libfontconfig
@@ -6859,6 +6861,7 @@ enabled libcelt   && require libcelt celt/celt.h 
celt_decode -lcelt0 &&
 enabled libcaca   && require_pkg_config libcaca caca caca.h 
caca_create_canvas
 enabled libcodec2 && require libcodec2 codec2/codec2.h codec2_create 
-lcodec2
 enabled libdav1d  && require_pkg_config libdav1d "dav1d >= 0.5.0" 
"dav1d/dav1d.h" dav1d_version
+enabled liblcevc_dec  && require_pkg_config liblcevc_dec "lcevc_dec >= 
2.0.0" "LCEVC/lcevc_dec.h" LCEVC_CreateDecoder
 enabled libdavs2  && require_pkg_config libdavs2 "davs2 >= 1.6.0" 
davs2.h davs2_decoder_open
 enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 
dc1394/dc1394.h dc1394_new
 enabled libdrm&& check_pkg_config libdrm libdrm xf86drm.h 
drmGetVersion
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index e7cf4f8239..5309db9ba8 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -245,6 +245,19 @@ Go to @url{https://github.com/google/liblc3/} and follow 
the instructions for
 installing the library.
 Then pass @code{--enable-liblc3} to configure to enable it.
 
+@section LCEVCdec
+
+FFmpeg can make use of the liblcevc_dec library for LCEVC enhacement layer
+decoding on supported bitstreams.
+
+Go to @url{https://github.com/v-novaltd/LCEVCdec} and follow the instructions
+for installing the library. Then pass @code{--enable-liblcevc-dec} to 
configure to
+enable it.
+
+@float NOTE
+LCEVCdec is under the BSD-3-Clause-Clear License.
+@end float
+
 @section OpenH264
 
 FFmpeg can make use of the OpenH264 library for H.264 decoding and encoding.
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3b4b8681f5..1333db82d0 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -121,6 +121,7 @@ OBJS-$(CONFIG_INTRAX8) += intrax8.o 
intrax8dsp.o msmpeg4_vc1_dat
 OBJS-$(CONFIG_IVIDSP)  += ivi_dsp.o
 OBJS-$(CONFIG_JNI) += ffjni.o jni.o
 OBJS-$(CONFIG_JPEGTABLES)  += jpegtables.o
+OBJS-$(CONFIG_LIBLCEVC_DEC)+= lcevcdec.o
 OBJS-$(CONFIG_LCMS2)   += fflcms2.o
 OBJS-$(CONFIG_LLAUDDSP)+= lossless_audiodsp.o
 OBJS-$(CONFIG_LLVIDDSP)+= lossless_videodsp.o
diff --git a/libavcodec/lcevcdec.c b/libavcodec/lcevcdec.c
new file mode 100644
index 00..ae1d150986
--- /dev/null
+++ b/libavcodec/lcevcdec.c
@@ -0,0 +1,289 @@
+/*
+ * 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/avassert.h"
+#include "libavutil/frame.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/log.h"
+#include "libavutil/mem.h"
+#include "decode.h"
+#include "lcevcdec.h"
+
+static LCEVC_ColorFormat map_format(int format)
+{
+switch (format) {
+case AV_PIX_FMT_YUV420P:
+return LCEVC_I420_8;
+case AV_PIX_FMT_YUV420P10:
+return LCEVC_I420_10_LE;
+case AV

[FFmpeg-devel] [PATCH 01/13 v3] avutil/frame: add an LCEVC enhancement data payload side data type

2024-08-31 Thread James Almer
Signed-off-by: James Almer 
---
 libavutil/frame.c | 1 +
 libavutil/frame.h | 5 +
 2 files changed, 6 insertions(+)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index 5cbfc6a48b..2758f90e27 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -46,6 +46,7 @@ static const AVSideDataDescriptor sd_props[] = {
 [AV_FRAME_DATA_DETECTION_BBOXES]= { "Bounding boxes for object 
detection and classification" },
 [AV_FRAME_DATA_DOVI_RPU_BUFFER] = { "Dolby Vision RPU Data" },
 [AV_FRAME_DATA_DOVI_METADATA]   = { "Dolby Vision Metadata" },
+[AV_FRAME_DATA_LCEVC]   = { "LCEVC NAL data" },
 [AV_FRAME_DATA_STEREO3D]= { "Stereo 3D",   
 AV_SIDE_DATA_PROP_GLOBAL },
 [AV_FRAME_DATA_REPLAYGAIN]  = { "AVReplayGain",
 AV_SIDE_DATA_PROP_GLOBAL },
 [AV_FRAME_DATA_DISPLAYMATRIX]   = { "3x3 displaymatrix",   
 AV_SIDE_DATA_PROP_GLOBAL },
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 60bb966f8b..973980ad58 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -228,6 +228,11 @@ enum AVFrameSideDataType {
  * encoding.
  */
 AV_FRAME_DATA_VIDEO_HINT,
+
+/**
+ * Raw LCEVC payload data, as a uint8_t array.
+ */
+AV_FRAME_DATA_LCEVC,
 };
 
 enum AVActiveFormatDescription {
-- 
2.46.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 38/42] fftools/ffmpeg: add support for multiview video

2024-08-31 Thread James Almer

On 8/31/2024 4:44 AM, Anton Khirnov wrote:

Quoting James Almer (2024-08-30 02:40:49)

On 8/29/2024 8:26 PM, Michael Niedermayer wrote:

On Tue, Aug 27, 2024 at 05:05:18PM +0200, Anton Khirnov wrote:

This extends the syntax for specifying input streams in -map and complex
filtergraph labels, to allow selecting a view by view ID, index, or
position. The corresponding decoder is then set up to decode the
appropriate view and send frames for that view to the correct
filtergraph input(s).
---
   doc/ffmpeg.texi   |  30 +++-
   fftools/cmdutils.c|   2 +-
   fftools/cmdutils.h|   2 +
   fftools/ffmpeg.h  |  45 -
   fftools/ffmpeg_dec.c  | 355 +-
   fftools/ffmpeg_demux.c|  24 ++-
   fftools/ffmpeg_filter.c   |  71 +---
   fftools/ffmpeg_mux_init.c |  29 +++-
   fftools/ffmpeg_opt.c  |  70 +++-
   9 files changed, 575 insertions(+), 53 deletions(-)


breaks build on mingw64

src/fftools/ffmpeg_dec.c: In function ‘packet_decode’:
src/fftools/ffmpeg_dec.c:811:19: error: implicit declaration of function ‘ffs’ 
[-Werror=implicit-function-declaration]
811 | pos = ffs(outputs_mask) - 1;
|   ^~~
cc1: some warnings being treated as errors
make: *** [src/ffbuild/common.mak:81: fftools/ffmpeg_dec.o] Error 1
make: *** Waiting for unfinished jobs

thx


Would ff_clz(outputs_mask) work here?


In principle yes, but it's private and I'd rather not include a private
header in ffmpeg CLI.

We could either make it public, or I could add a ffs() implementation
for Windows to compat/. Anyone has a preference?


I think i prefer making ff_clz public in common.h. It has an optimized 
version not exclusive to Windows using a gcc/clang builtin, and even one 
specific for riscv.




OpenPGP_signature.asc
Description: OpenPGP digital 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 25/42] avcodec/hevc/sei: add support for 3D Reference Displays Information SEI

2024-08-29 Thread James Almer

On 8/27/2024 12:05 PM, Anton Khirnov wrote:

From: James Almer 

Signed-off-by: James Almer 
---
  libavcodec/hevc/sei.c | 55 +++
  libavcodec/hevc/sei.h | 17 +
  2 files changed, 72 insertions(+)

diff --git a/libavcodec/hevc/sei.c b/libavcodec/hevc/sei.c
index e39ac0c38a..6c2b55b43c 100644
--- a/libavcodec/hevc/sei.c
+++ b/libavcodec/hevc/sei.c
@@ -150,6 +150,59 @@ static int decode_nal_sei_timecode(HEVCSEITimeCode *s, 
GetBitContext *gb)
  return 0;
  }
  
+static int decode_nal_sei_3d_reference_displays_info(HEVCSEITDRDI *s, GetBitContext *gb)

+{
+s->prec_ref_display_width = get_ue_golomb(gb);
+if (s->prec_ref_display_width > 31)
+return AVERROR_INVALIDDATA;
+s->ref_viewing_distance_flag = get_bits1(gb);
+if (s->ref_viewing_distance_flag) {
+s->prec_ref_viewing_dist = get_ue_golomb(gb);
+if (s->prec_ref_viewing_dist > 31)
+return AVERROR_INVALIDDATA;
+}
+s->num_ref_displays = get_ue_golomb(gb);
+if (s->num_ref_displays > 31)
+return AVERROR_INVALIDDATA;
+s->num_ref_displays += 1;
+
+for (int i = 0; i < s->num_ref_displays; i++) {
+int length;
+s->left_view_id[i] = get_ue_golomb(gb);
+s->right_view_id[i] = get_ue_golomb(gb);
+s->exponent_ref_display_width[i] = get_bits(gb, 6);
+if (s->exponent_ref_display_width[i] > 62)
+return AVERROR_INVALIDDATA;
+else if (!s->exponent_ref_display_width[i])
+length = FFMAX(0, (int)s->prec_ref_display_width - 30);
+else
+length = FFMAX(0, (int)s->exponent_ref_display_width[i] +
+  (int)s->prec_ref_display_width - 31);
+s->mantissa_ref_display_width[i] = get_bits_long(gb, length);
+if (s->ref_viewing_distance_flag) {
+s->exponent_ref_viewing_distance[i] = get_bits(gb, 6);
+if (s->exponent_ref_viewing_distance[i] > 62)
+return AVERROR_INVALIDDATA;
+else if (!s->exponent_ref_viewing_distance[i])
+length = FFMAX(0, (int)s->prec_ref_viewing_dist - 30);
+else
+length = FFMAX(0, (int)s->exponent_ref_viewing_distance[i] +
+  (int)s->prec_ref_viewing_dist - 31);
+s->mantissa_ref_viewing_distance[i] = get_bits_long(gb, length);
+}
+s->additional_shift_present_flag[i] = get_bits1(gb);
+if (s->additional_shift_present_flag[i]) {
+s->num_sample_shift[i] = get_bits(gb, 10);
+if (s->num_sample_shift[i] > 1023)
+return AVERROR_INVALIDDATA;
+s->num_sample_shift[i] -= 512;
+}
+}
+s->three_dimensional_reference_displays_extension_flag = get_bits1(gb);
+
+return 0;
+}
+
  static int decode_nal_sei_prefix(GetBitContext *gb, GetByteContext *gbyte,
   void *logctx, HEVCSEI *s,
   const HEVCParamSets *ps, int type)
@@ -163,6 +216,8 @@ static int decode_nal_sei_prefix(GetBitContext *gb, 
GetByteContext *gbyte,
  return decode_nal_sei_active_parameter_sets(s, gb, logctx);
  case SEI_TYPE_TIME_CODE:
  return decode_nal_sei_timecode(&s->timecode, gb);
+case SEI_TYPE_THREE_DIMENSIONAL_REFERENCE_DISPLAYS_INFO:
+return decode_nal_sei_3d_reference_displays_info(&s->tdrdi, gb);
  default: {
  int ret = ff_h2645_sei_message_decode(&s->common, type, 
AV_CODEC_ID_HEVC,
gb, gbyte, logctx);
diff --git a/libavcodec/hevc/sei.h b/libavcodec/hevc/sei.h
index c97d22d423..a233d432cc 100644
--- a/libavcodec/hevc/sei.h
+++ b/libavcodec/hevc/sei.h
@@ -79,12 +79,29 @@ typedef struct HEVCSEITimeCode {
  int32_t  time_offset_value[3];
  } HEVCSEITimeCode;
  
+typedef struct HEVCSEITDRDI {

+uint8_t prec_ref_display_width;
+uint8_t ref_viewing_distance_flag;
+uint8_t prec_ref_viewing_dist;
+uint8_t num_ref_displays;
+uint8_t left_view_id[31];
+uint8_t right_view_id[31];


Should be uint16_t, like you found out.


+uint8_t exponent_ref_display_width[31];
+uint8_t mantissa_ref_display_width[31];
+uint8_t exponent_ref_viewing_distance[31];
+uint8_t mantissa_ref_viewing_distance[31];
+uint8_t additional_shift_present_flag[31];
+int16_t num_sample_shift[31];
+uint8_t three_dimensional_reference_displays_extension_flag;
+} HEVCSEITDRDI;
+
  typedef struct HEVCSEI {
  H2645SEI common;
  HEVCSEIPictureHash picture_hash;
  HEVCSEIPictureTiming picture_timing;
  int active_seq_parameter_set_id;
  HEVCSEITimeCode timecode;
+HEVCSEITDRDI tdrdi;
  } HEVCSEI;
  
  struct HEVCParamSets;


___
ffmpeg-devel mailin

Re: [FFmpeg-devel] [PATCH 28/42] lavc/hevc/ps: implement SPS parsing for nuh_layer_id>0

2024-08-29 Thread James Almer

On 8/27/2024 12:05 PM, Anton Khirnov wrote:

Cf. F.7.3.2.2 "Sequence parameter set RBSP syntax", which extends normal
SPS parsing with special clauses depending on MultiLayerExtSpsFlag.
---
  libavcodec/hevc/hevcdec.c |  2 +-
  libavcodec/hevc/parse.c   |  3 +-
  libavcodec/hevc/parser.c  |  2 +-
  libavcodec/hevc/ps.c  | 62 +++
  libavcodec/hevc/ps.h  |  7 +++--
  libavcodec/qsvenc_hevc.c  |  2 +-
  6 files changed, 65 insertions(+), 13 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 6b596f1573..260b9abef0 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3256,7 +3256,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL 
*nal)
  break;
  case HEVC_NAL_SPS:
  ret = ff_hevc_decode_nal_sps(&gb, s->avctx, &s->ps,
- s->apply_defdispwin);
+ nal->nuh_layer_id, s->apply_defdispwin);
  if (ret < 0)
  goto fail;
  break;
diff --git a/libavcodec/hevc/parse.c b/libavcodec/hevc/parse.c
index ec8d1aeacf..ad84b7b152 100644
--- a/libavcodec/hevc/parse.c
+++ b/libavcodec/hevc/parse.c
@@ -49,7 +49,8 @@ static int hevc_decode_nal_units(const uint8_t *buf, int 
buf_size, HEVCParamSets
  goto done;
  break;
  case HEVC_NAL_SPS:
-ret = ff_hevc_decode_nal_sps(&nal->gb, logctx, ps, 
apply_defdispwin);
+ret = ff_hevc_decode_nal_sps(&nal->gb, logctx, ps,
+ nal->nuh_layer_id, apply_defdispwin);
  if (ret < 0)
  goto done;
  break;
diff --git a/libavcodec/hevc/parser.c b/libavcodec/hevc/parser.c
index 8db56e259e..a10f38941b 100644
--- a/libavcodec/hevc/parser.c
+++ b/libavcodec/hevc/parser.c
@@ -209,7 +209,7 @@ static int parse_nal_units(AVCodecParserContext *s, const 
uint8_t *buf,
  ff_hevc_decode_nal_vps(gb, avctx, ps);
  break;
  case HEVC_NAL_SPS:
-ff_hevc_decode_nal_sps(gb, avctx, ps, 1);
+ff_hevc_decode_nal_sps(gb, avctx, ps, nal->nuh_layer_id, 1);
  break;
  case HEVC_NAL_PPS:
  ff_hevc_decode_nal_pps(gb, avctx, ps);
diff --git a/libavcodec/hevc/ps.c b/libavcodec/hevc/ps.c
index 0e084958be..0b34dd10a8 100644
--- a/libavcodec/hevc/ps.c
+++ b/libavcodec/hevc/ps.c
@@ -1145,12 +1145,12 @@ static int map_pixel_format(AVCodecContext *avctx, 
HEVCSPS *sps)
  }
  
  int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,

-  int apply_defdispwin, const HEVCVPS * const *vps_list,
-  AVCodecContext *avctx)
+  unsigned nuh_layer_id, int apply_defdispwin,
+  const HEVCVPS * const *vps_list, AVCodecContext *avctx)
  {
  HEVCWindow *ow;
  int ret = 0;
-int bit_depth_chroma, start, num_comps;
+int bit_depth_chroma, num_comps, multi_layer_ext;
  int i;
  
  // Coded parameters

@@ -1167,16 +1167,26 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
unsigned int *sps_id,
  }
  
  sps->max_sub_layers = get_bits(gb, 3) + 1;

+multi_layer_ext = nuh_layer_id > 0 &&
+  sps->max_sub_layers == HEVC_MAX_SUB_LAYERS + 1;
+if (multi_layer_ext) {
+if (!sps->vps)
+return AVERROR(EINVAL);
+
+sps->max_sub_layers = sps->vps->vps_max_sub_layers;
+}
  if (sps->max_sub_layers > HEVC_MAX_SUB_LAYERS) {


Not strictly related to this patch, but sps->max_sub_layers should 
always be <= vps->vps_max_sub_layers (see F.7.4.3.2.1). So the presence 
of vps should be checked for.



  av_log(avctx, AV_LOG_ERROR, "sps_max_sub_layers out of range: %d\n",
 sps->max_sub_layers);
  return AVERROR_INVALIDDATA;
  }
  
+if (!multi_layer_ext) {

  sps->temporal_id_nesting = get_bits(gb, 1);


Similarly (not strictly related to this patch), this needs to be 1 if 
sps->max_sub_layers is 0 or if vps->vps_temporal_id_nesting_flag is 1.


  
  if ((ret = parse_ptl(gb, avctx, 1, &sps->ptl, sps->max_sub_layers)) < 0)

  return ret;
+}


(Actually related this time) If multi_layer_ext is true, 
sps->temporal_id_nesting needs to be set to 
vps->vps_temporal_id_nesting_flag when sps->max_sub_layers > 1, or 
hardcoded to 1 if it's 1.


  
  *sps_id = get_ue_golomb_long(gb);

  if (*sps_id >= HEVC_MAX_SPS_COUNT) {
@@ -1184,6 +1194,28 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
unsigned int *sps_id,
  return AVERROR_INVALIDDATA;
  }
  
+if (multi_layer_ext) {

+const RepFormat *rf = &sps->vps->rep_format;
+
+if (get_bits1(gb) &&// update_rep_format_flag
+get_bits(gb, 8)) {  // sps_rep_format_idx
+av_log(avctx, AV_LOG_ERROR, "sps_rep_format_idx!=0\n");
+return AVERROR_PATCHWELCOME;

[FFmpeg-devel] [PATCH 2/2] avformat/iamf_parse: fix parsing AAC DecoderConfigDescriptor

2024-08-29 Thread James Almer
Use ff_mp4_read_descr() to read both the tags and the vlc value
that comes after it, which was not being taken into account.

Ref: https://github.com/AOMediaCodec/libiamf/issues/119

Signed-off-by: James Almer 
---
 libavformat/iamf_parse.c | 21 +
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c
index 080c1a457a..8890bcf7ae 100644
--- a/libavformat/iamf_parse.c
+++ b/libavformat/iamf_parse.c
@@ -62,12 +62,12 @@ static int aac_decoder_config(IAMFCodecConfig *codec_config,
 {
 MPEG4AudioConfig cfg = { 0 };
 int object_type_id, codec_id, stream_type;
-int ret, tag, left;
+int ret, tag;
 
 if (codec_config->audio_roll_distance >= 0)
 return AVERROR_INVALIDDATA;
 
-tag = avio_r8(pb);
+ff_mp4_read_descr(logctx, pb, &tag);
 if (tag != MP4DecConfigDescrTag)
 return AVERROR_INVALIDDATA;
 
@@ -87,22 +87,19 @@ static int aac_decoder_config(IAMFCodecConfig *codec_config,
 if (codec_id && codec_id != codec_config->codec_id)
 return AVERROR_INVALIDDATA;
 
-tag = avio_r8(pb);
-if (tag != MP4DecSpecificDescrTag)
-return AVERROR_INVALIDDATA;
-
-left = len - avio_tell(pb);
-if (left <= 0)
+len = ff_mp4_read_descr(logctx, pb, &tag);
+if (tag != MP4DecSpecificDescrTag ||
+!len || (uint64_t)len > (1<<30))
 return AVERROR_INVALIDDATA;
 
 // We pad extradata here because avpriv_mpeg4audio_get_config2() needs it.
-codec_config->extradata = av_malloc((size_t)left + 
AV_INPUT_BUFFER_PADDING_SIZE);
+codec_config->extradata = av_malloc((size_t)len + 
AV_INPUT_BUFFER_PADDING_SIZE);
 if (!codec_config->extradata)
 return AVERROR(ENOMEM);
 
-codec_config->extradata_size = avio_read(pb, codec_config->extradata, 
left);
-if (codec_config->extradata_size < left)
-return AVERROR_INVALIDDATA;
+codec_config->extradata_size = ffio_read_size(pb, codec_config->extradata, 
len);
+if (ret < 0)
+return ret;
 memset(codec_config->extradata + codec_config->extradata_size, 0,
AV_INPUT_BUFFER_PADDING_SIZE);
 
-- 
2.46.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/2] avformat/isom: make the parameter used for loging in ff_mp4_read_descr() a pointer to void

2024-08-29 Thread James Almer
Signed-off-by: James Almer 
---
 libavformat/isom.c | 4 ++--
 libavformat/isom.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/isom.c b/libavformat/isom.c
index 74bb13dc96..65d71ed9d0 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -292,12 +292,12 @@ int ff_mp4_read_descr_len(AVIOContext *pb)
 return len;
 }
 
-int ff_mp4_read_descr(AVFormatContext *fc, AVIOContext *pb, int *tag)
+int ff_mp4_read_descr(void *logctx, AVIOContext *pb, int *tag)
 {
 int len;
 *tag = avio_r8(pb);
 len = ff_mp4_read_descr_len(pb);
-av_log(fc, AV_LOG_TRACE, "MPEG-4 description: tag=0x%02x len=%d\n", *tag, 
len);
+av_log(logctx, AV_LOG_TRACE, "MPEG-4 description: tag=0x%02x len=%d\n", 
*tag, len);
 return len;
 }
 
diff --git a/libavformat/isom.h b/libavformat/isom.h
index 5b6125a908..ceb3aa2f49 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -363,7 +363,7 @@ typedef struct MOVContext {
 } MOVContext;
 
 int ff_mp4_read_descr_len(AVIOContext *pb);
-int ff_mp4_read_descr(AVFormatContext *fc, AVIOContext *pb, int *tag);
+int ff_mp4_read_descr(void *logctx, AVIOContext *pb, int *tag);
 int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, 
AVIOContext *pb);
 void ff_mp4_parse_es_descr(AVIOContext *pb, int *es_id);
 
-- 
2.46.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 38/42] fftools/ffmpeg: add support for multiview video

2024-08-29 Thread James Almer

On 8/29/2024 8:26 PM, Michael Niedermayer wrote:

On Tue, Aug 27, 2024 at 05:05:18PM +0200, Anton Khirnov wrote:

This extends the syntax for specifying input streams in -map and complex
filtergraph labels, to allow selecting a view by view ID, index, or
position. The corresponding decoder is then set up to decode the
appropriate view and send frames for that view to the correct
filtergraph input(s).
---
  doc/ffmpeg.texi   |  30 +++-
  fftools/cmdutils.c|   2 +-
  fftools/cmdutils.h|   2 +
  fftools/ffmpeg.h  |  45 -
  fftools/ffmpeg_dec.c  | 355 +-
  fftools/ffmpeg_demux.c|  24 ++-
  fftools/ffmpeg_filter.c   |  71 +---
  fftools/ffmpeg_mux_init.c |  29 +++-
  fftools/ffmpeg_opt.c  |  70 +++-
  9 files changed, 575 insertions(+), 53 deletions(-)


breaks build on mingw64

src/fftools/ffmpeg_dec.c: In function ‘packet_decode’:
src/fftools/ffmpeg_dec.c:811:19: error: implicit declaration of function ‘ffs’ 
[-Werror=implicit-function-declaration]
   811 | pos = ffs(outputs_mask) - 1;
   |   ^~~
cc1: some warnings being treated as errors
make: *** [src/ffbuild/common.mak:81: fftools/ffmpeg_dec.o] Error 1
make: *** Waiting for unfinished jobs

thx


Would ff_clz(outputs_mask) work here?

___
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] configure: improve check for POSIX ioctl

2024-08-29 Thread James Almer

On 8/29/2024 2:18 PM, Ramiro Polla wrote:

On Thu, Aug 29, 2024 at 7:10 PM James Almer  wrote:

On 8/29/2024 10:40 AM, Ramiro Polla wrote:

Instead of relying on system #ifdefs which may or may not be correct,
detect the POSIX ioctl signature at configure time.
---
   configure  | 2 ++
   libavdevice/v4l2.c | 2 +-
   2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 63f0429b02..ebbec49993 100755
--- a/configure
+++ b/configure
@@ -2524,6 +2524,7 @@ HAVE_LIST="
   opencl_videotoolbox
   perl
   pod2man
+posix_ioctl
   texi2html
   xmllint
   zlib_gzip
@@ -7158,6 +7159,7 @@ xmllint --version  > /dev/null 2>&1 && enable xmllint   
|| disable xmllint
   check_headers linux/fb.h
   check_headers linux/videodev2.h
   test_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 
0;" && enable_sanitized struct_v4l2_frmivalenum_discrete
+test_code cc sys/ioctl.h "int ioctl(int, int, ...);" && enable posix_ioctl


Is this check going to fail for the targets where ioctl_f has request as
an unsigned long int?


Yes. This is from config.log:

/tmp/ffconf.S7gHklXc/test.c: In function 'main':
/tmp/ffconf.S7gHklXc/test.c:2:22: error: conflicting types for
'ioctl'; have 'int(int,  int, ...)'
 2 | int main(void) { int ioctl(int, int, ...);; return 0; }
   |  ^
In file included from /tmp/ffconf.S7gHklXc/test.c:1:
/usr/include/x86_64-linux-gnu/sys/ioctl.h:42:12: note: previous
declaration of 'ioctl' with type 'int(int,  long unsigned int, ...)'
42 | extern int ioctl (int __fd, unsigned long int __request, ...) __THROW;
   |^


Cool. Should be ok then. Just remove the colon at the end of the check 
since test_code() will add one. Some compiler settings like -pedantic 
may complain about it, so better safe than sorry.


___
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] configure: improve check for POSIX ioctl

2024-08-29 Thread James Almer

On 8/29/2024 10:40 AM, Ramiro Polla wrote:

Instead of relying on system #ifdefs which may or may not be correct,
detect the POSIX ioctl signature at configure time.
---
  configure  | 2 ++
  libavdevice/v4l2.c | 2 +-
  2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 63f0429b02..ebbec49993 100755
--- a/configure
+++ b/configure
@@ -2524,6 +2524,7 @@ HAVE_LIST="
  opencl_videotoolbox
  perl
  pod2man
+posix_ioctl
  texi2html
  xmllint
  zlib_gzip
@@ -7158,6 +7159,7 @@ xmllint --version  > /dev/null 2>&1 && enable xmllint   
|| disable xmllint
  check_headers linux/fb.h
  check_headers linux/videodev2.h
  test_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 
0;" && enable_sanitized struct_v4l2_frmivalenum_discrete
+test_code cc sys/ioctl.h "int ioctl(int, int, ...);" && enable posix_ioctl


Is this check going to fail for the targets where ioctl_f has request as 
an unsigned long int?


  
  # check V4L2 codecs available in the API

  if enabled v4l2_m2m; then
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 42d4b97c8f..0ae6872338 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -111,7 +111,7 @@ struct video_data {
  int (*open_f)(const char *file, int oflag, ...);
  int (*close_f)(int fd);
  int (*dup_f)(int fd);
-#if defined(__sun) || defined(__BIONIC__) || defined(__musl__) /* POSIX-like */
+#if HAVE_POSIX_IOCTL
  int (*ioctl_f)(int fd, int request, ...);
  #else
  int (*ioctl_f)(int fd, unsigned long int request, ...);


___
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] [RFC/PATCH] MV-HEVC decoding

2024-08-28 Thread James Almer

On 8/27/2024 12:04 PM, Anton Khirnov wrote:

One potential point of discussion is that the caller may want to know
the view ID in its get_buffer2() callback (this is actually used in the
ffmpeg CLI code). One potential option is attaching the view ID side
data before calling get_buffer2(), but that is quite unusual and would
require changes to the progress frame API. For now, I'm using another
read-only decoder-private AVOption for that. Opinions welcome.


I just sent a patch for this. I need the same thing for LC-EVC support.

___
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] avcodec/decode: split ProgressFrame allocator into two functions

2024-08-28 Thread James Almer
This will be useful for scenarios where we need certain frame properties
set by the decoder before get_buffer2() is called, like side data.

Signed-off-by: James Almer 
---
 libavcodec/decode.c| 11 +++
 libavcodec/progressframe.h | 16 ++--
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index dc868714ac..033c4913c0 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1749,7 +1749,7 @@ static void check_progress_consistency(const 
ProgressFrame *f)
 av_assert1(!f->progress || f->progress->f == f->f);
 }
 
-static int progress_frame_get(AVCodecContext *avctx, ProgressFrame *f)
+int ff_progress_frame_alloc(AVCodecContext *avctx, ProgressFrame *f)
 {
 FFRefStructPool *pool = avctx->internal->progress_frame_pool;
 
@@ -1767,9 +1767,12 @@ int ff_progress_frame_get_buffer(AVCodecContext *avctx, 
ProgressFrame *f, int fl
 {
 int ret;
 
-ret = progress_frame_get(avctx, f);
-if (ret < 0)
-return ret;
+check_progress_consistency(f);
+if (!f->f) {
+ret = ff_progress_frame_alloc(avctx, f);
+if (ret < 0)
+return ret;
+}
 
 ret = ff_thread_get_buffer(avctx, f->progress->f, flags);
 if (ret < 0) {
diff --git a/libavcodec/progressframe.h b/libavcodec/progressframe.h
index 428a461659..32a345beec 100644
--- a/libavcodec/progressframe.h
+++ b/libavcodec/progressframe.h
@@ -102,12 +102,24 @@ void ff_progress_frame_report(ProgressFrame *f, int 
progress);
 void ff_progress_frame_await(const ProgressFrame *f, int progress);
 
 /**
- * This function sets up the ProgressFrame, i.e. gets ProgressFrame.f
- * and also calls ff_thread_get_buffer() on the frame.
+ * This function allocates ProgressFrame.f
+ * May be called before ff_progress_frame_get_buffer() in the cases where the
+ * AVFrame needs to be accessed before the ff_thread_get_buffer() call in
+ * ff_progress_frame_alloc().
  *
  * @note: This must only be called by codecs with the
  *FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap.
  */
+int ff_progress_frame_alloc(struct AVCodecContext *avctx, ProgressFrame *f);
+
+/**
+ * This function sets up the ProgressFrame, i.e. allocates ProgressFrame.f
+ * if needed, and also calls ff_thread_get_buffer() on the frame.
+ *
+ * @note: This must only be called by codecs with the
+ *FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap.
+ * @see ff_progress_frame_alloc
+ */
 int ff_progress_frame_get_buffer(struct AVCodecContext *avctx,
  ProgressFrame *f, int flags);
 
-- 
2.46.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] avcodec/cbs_h265: fix valid range for {left, right}_view_id

2024-08-27 Thread James Almer
view_id_len in VPS is 4 bits, so view_id values can be up to 15 bits long.

Signed-off-by: James Almer 
---
 libavcodec/cbs_h265.h | 4 ++--
 libavcodec/cbs_h265_syntax_template.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/cbs_h265.h b/libavcodec/cbs_h265.h
index 892a35bd22..eec4bf0825 100644
--- a/libavcodec/cbs_h265.h
+++ b/libavcodec/cbs_h265.h
@@ -725,8 +725,8 @@ typedef struct H265RawSEI3DReferenceDisplaysInfo {
 uint8_t ref_viewing_distance_flag;
 uint8_t prec_ref_viewing_dist;
 uint8_t num_ref_displays_minus1;
-uint8_t left_view_id[31];
-uint8_t right_view_id[31];
+uint16_t left_view_id[31];
+uint16_t right_view_id[31];
 uint8_t exponent_ref_display_width[31];
 uint8_t mantissa_ref_display_width[31];
 uint8_t exponent_ref_viewing_distance[31];
diff --git a/libavcodec/cbs_h265_syntax_template.c 
b/libavcodec/cbs_h265_syntax_template.c
index 9f0281b8e8..e2805c7ff1 100644
--- a/libavcodec/cbs_h265_syntax_template.c
+++ b/libavcodec/cbs_h265_syntax_template.c
@@ -2299,8 +2299,8 @@ SEI_FUNC(sei_3d_reference_displays_info, 
(CodedBitstreamContext *ctx, RWContext
 ue(prec_ref_viewing_dist, 0, 31);
 ue(num_ref_displays_minus1, 0, 31);
 for (i = 0; i <= current->num_ref_displays_minus1; i++) {
-ues(left_view_id[i], 0, UINT8_MAX, 1, i);
-ues(right_view_id[i], 0, UINT8_MAX, 1, i);
+ues(left_view_id[i], 0, MAX_UINT_BITS(15), 1, i);
+ues(right_view_id[i], 0, MAX_UINT_BITS(15), 1, i);
 us(6, exponent_ref_display_width[i], 0, 62, 1, i);
 if (!current->exponent_ref_display_width[i])
 length = FFMAX(0, (int)current->prec_ref_display_width - 30);
-- 
2.46.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] lavc/vvc: Remove experimental flag

2024-08-23 Thread James Almer

On 8/23/2024 10:17 AM, Anton Khirnov wrote:

tsan reports races in the decoder, it would be nice if someone could
look at them before this goes in.


Not data races, but "lock-order-inversion (potential deadlock)", which 
sounds worse.


___
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 01/11] avcodec/vvcdec: thread, ensure the parse stage gets the highest priority

2024-08-21 Thread James Almer

On 7/28/2024 12:17 AM, Nuo Mi wrote:

The parser stage is not parallelizable.
We need to schedule it as soon as possible to create later stages, which are 
more parallelizable

clips   | before | after | delta
||---|--
RitualDance_1920x1080_60_10_420_37_RA.266   | 342.7  | 365.3 |  6.59%
NovosobornayaSquare_1920x1080.bin   | 321.7  | 400   | 24.34%
Tango2_3840x2160_60_10_420_27_LD.266|  82.3  |  91.7 | 11.42%
RitualDance_1920x1080_60_10_420_32_LD.266   | 323.7  | 319.3 | -1.36%
Chimera_8bit_1080P_1000_frames.vvc  | 364| 411.3 | 12.99%
BQTerrace_1920x1080_60_10_420_22_RA.vvc | 162.7  | 185.7 | 14.14%
---
  libavcodec/vvc/thread.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)


One of the patches from this set introduced use of uninitialized values. 
See 
https://fate.ffmpeg.org/report.cgi?time=20240821174441&slot=x86_64-archlinux-gcc-valgrind


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

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


Re: [FFmpeg-devel] [PATCH] avcodec/h2645_parse: replace three bool arguments in ff_h2645_packet_split with a single flags one

2024-08-19 Thread James Almer

On 8/19/2024 4:21 PM, Anton Khirnov wrote:

Quoting James Almer (2024-08-19 18:58:11)

diff --git a/libavcodec/h2645_parse.h b/libavcodec/h2645_parse.h
index 128dea09ef..849e772115 100644
--- a/libavcodec/h2645_parse.h
+++ b/libavcodec/h2645_parse.h
@@ -93,6 +93,10 @@ typedef struct H2645Packet {
  int ff_h2645_extract_rbsp(const uint8_t *src, int length, H2645RBSP *rbsp,
H2645NAL *nal, int small_padding);
  
+#define H2645_FLAG_IS_NALFF  (1 << 0)

+#define H2645_FLAG_SMALL_PADDING (1 << 1)
+#define H2645_FLAG_USE_REF   (1 << 2)


Make it an enum please


Changed locally.

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

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


[FFmpeg-devel] [PATCH] avcodec/h2645_parse: replace three bool arguments in ff_h2645_packet_split with a single flags one

2024-08-19 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/bsf/extract_extradata.c |  2 +-
 libavcodec/cbs_h2645.c | 17 +++--
 libavcodec/h2645_parse.c   | 15 ---
 libavcodec/h2645_parse.h   | 15 ++-
 libavcodec/h264_parse.c|  3 ++-
 libavcodec/h264dec.c   |  4 ++--
 libavcodec/hevc/hevcdec.c  |  5 +++--
 libavcodec/hevc/parse.c|  5 +++--
 libavcodec/hevc/parser.c   |  5 +++--
 9 files changed, 43 insertions(+), 28 deletions(-)

diff --git a/libavcodec/bsf/extract_extradata.c 
b/libavcodec/bsf/extract_extradata.c
index b037990562..43f4d62855 100644
--- a/libavcodec/bsf/extract_extradata.c
+++ b/libavcodec/bsf/extract_extradata.c
@@ -193,7 +193,7 @@ static int extract_extradata_h2645(AVBSFContext *ctx, 
AVPacket *pkt,
 }
 
 ret = ff_h2645_packet_split(&s->h2645_pkt, pkt->data, pkt->size,
-ctx, 0, 0, ctx->par_in->codec_id, 1, 0);
+ctx, 0, ctx->par_in->codec_id, 
H2645_FLAG_SMALL_PADDING);
 if (ret < 0)
 return ret;
 
diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index d73d77a985..4abd9e0c2e 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -573,7 +573,8 @@ static int cbs_h2645_split_fragment(CodedBitstreamContext 
*ctx,
 
 err = ff_h2645_packet_split(&priv->read_packet,
 frag->data + start, end - start,
-ctx->log_ctx, 1, 2, AV_CODEC_ID_H264, 1, 
1);
+ctx->log_ctx, 2, AV_CODEC_ID_H264,
+H2645_FLAG_IS_NALFF | 
H2645_FLAG_SMALL_PADDING | H2645_FLAG_USE_REF);
 if (err < 0) {
 av_log(ctx->log_ctx, AV_LOG_ERROR, "Failed to split AVCC SPS 
array.\n");
 return err;
@@ -597,7 +598,8 @@ static int cbs_h2645_split_fragment(CodedBitstreamContext 
*ctx,
 
 err = ff_h2645_packet_split(&priv->read_packet,
 frag->data + start, end - start,
-ctx->log_ctx, 1, 2, AV_CODEC_ID_H264, 1, 
1);
+ctx->log_ctx, 2, AV_CODEC_ID_H264,
+H2645_FLAG_IS_NALFF | 
H2645_FLAG_SMALL_PADDING | H2645_FLAG_USE_REF);
 if (err < 0) {
 av_log(ctx->log_ctx, AV_LOG_ERROR, "Failed to split AVCC PPS 
array.\n");
 return err;
@@ -651,7 +653,8 @@ static int cbs_h2645_split_fragment(CodedBitstreamContext 
*ctx,
 
 err = ff_h2645_packet_split(&priv->read_packet,
 frag->data + start, end - start,
-ctx->log_ctx, 1, 2, AV_CODEC_ID_HEVC, 
1, 1);
+ctx->log_ctx, 2, AV_CODEC_ID_HEVC,
+H2645_FLAG_IS_NALFF | 
H2645_FLAG_SMALL_PADDING | H2645_FLAG_USE_REF);
 if (err < 0) {
 av_log(ctx->log_ctx, AV_LOG_ERROR, "Failed to split "
"HVCC array %d (%d NAL units of type %d).\n",
@@ -721,7 +724,8 @@ static int cbs_h2645_split_fragment(CodedBitstreamContext 
*ctx,
 
 err = ff_h2645_packet_split(&priv->read_packet,
 frag->data + start, end - start,
-ctx->log_ctx, 1, 2, AV_CODEC_ID_VVC, 
1, 1);
+ctx->log_ctx, 2, AV_CODEC_ID_VVC,
+H2645_FLAG_IS_NALFF | 
H2645_FLAG_SMALL_PADDING | H2645_FLAG_USE_REF);
 if (err < 0) {
 av_log(ctx->log_ctx, AV_LOG_ERROR, "Failed to split "
"VVCC array %d (%d NAL units of type %d).\n",
@@ -733,13 +737,14 @@ static int cbs_h2645_split_fragment(CodedBitstreamContext 
*ctx,
 return err;
 }
 } else {
+int flags = (H2645_FLAG_IS_NALFF * !!priv->mp4) | 
H2645_FLAG_SMALL_PADDING | H2645_FLAG_USE_REF;
 // Annex B, or later MP4 with already-known parameters.
 
 err = ff_h2645_packet_split(&priv->read_packet,
 frag->data, frag->data_size,
 ctx->log_ctx,
-priv->mp4, priv->nal_length_size,
-codec_id, 1, 1);
+priv->nal_length_size,
+codec_id, flags);
 if (err < 0)
 return err;
 
diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
index 2341f0e0a7..4cb90ac0d0 100644
--- a/libavcodec/h2645_parse.c
+++ b/libavcodec/h2645_parse.c
@@ -463,16 +463,16 @

Re: [FFmpeg-devel] [PATCH 3/4] x86/vvcdec: inter, add optical flow avx2 code

2024-08-17 Thread James Almer

On 8/17/2024 10:48 PM, Nuo Mi wrote:

+pxorm6, m6
+phaddw m%2, m6
+phaddw m%2, m6


Horizonal adds are slow. Can't you do this with normal adds, shifts and 
blend?



+vpermq m%2, m%2, q0020
+pshufd m%2, m%2, q1120
+pmovsxwd   m%2, xmm%2   ; 4 sgxgy
+
+pmulld m%2, m11 ; 4 vx * sgxgy


Similarly, pmulld is super slow (Ten cycles in some architectures), and 
that's on top of a pmovsx.
Since you have m6 zeroed already, wouldn't pmaddwd work here? The pd_15 
and pd_m15 constants would need to be changed to words, as would the 
values to be clipped.



+psrad  m%2, 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] [h264] Use small padding with the checked bitstream reader.

2024-08-17 Thread James Almer

On 8/17/2024 3:04 PM, Michael Niedermayer wrote:

On Wed, Aug 14, 2024 at 04:32:36PM -0700, Dale Curtis wrote:

MAX_MBPAIR_SIZE was added in 23f5cff92cdcfa55a735c458fcb5f95c0e0f3b1f
to prevent CABAC/CAVLC overread issues. It adds 256kb of padding to
RBSP allocations. AFAICT it seems unnecessary with the checked
bitstream reader. Dropping this padding is a substantial memory
improvement for constrained devices.

782865bf3094e36cbb4bd9cfacda252307e6589d removed the small padding
when AV_CODEC_FLAG2_FAST was set, but I don't have access to that
fuzzer test case to check this patch. Does anyone have this for testing?


20978/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-5746381832847360
 sent privately

thx


Could the padding be changed to AV_INPUT_BUFFER_PADDING_SIZE instead of 
0 when small_padding is requested?


___
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] MV-HEVC support for decoding of Apple's stereo video

2024-08-17 Thread James Almer

On 8/16/2024 4:49 PM, Danny Hong wrote:

Quoting Anton Khirnov  (2024-08-16 09:32:28)

The way this will work is that different views will be output by decoder
as separate frames with side data indicating their view ID.


Thanks for the info again!  Wouldn't it be easier for the user/consumer of
the decoded frames to simply have the side data indicate "left" or "right"
view?  If only view ID is indicated, then the VPS and the 3D reference
displays information SEI have to be parsed again (by the user/consumer) to
get the mapping between view ID and left/right eye, no?
When present, 3D reference displays information SEI will be used to 
export a Stereo3D frame side data entry signaling the eye the frame 
belongs to based on the view ID, yes.


___
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] use proper macro to avoid issue with prior avutil/timestamp.c

2024-08-16 Thread James Almer

On 8/17/2024 12:09 AM, Mike Lieman wrote:

 From b2ddfdd9ed695a1f47ed6251369abca08864e3ab Mon Sep 17 00:00:00 2001
From: Mike Lieman 
Date: Fri, 16 Aug 2024 23:05:51 -0400
Subject: [PATCH] use proper macro to avoid issue with prior
avutil/timestamp.c
  patch causing long startup times with some files under mplayer
  (https://trac.mplayerhq.hu/ticket/2425)

---
  libavutil/timestamp.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/timestamp.c b/libavutil/timestamp.c
index 6c231a517d..eab2531538 100644
--- a/libavutil/timestamp.c
+++ b/libavutil/timestamp.c
@@ -24,7 +24,7 @@ char *av_ts_make_time_string2(char *buf, int64_t ts,
AVRational tb)
  snprintf(buf, AV_TS_MAX_STRING_SIZE, "NOPTS");
  } else {
  double val = av_q2d(tb) * ts;
-double log = (fpclassify(val) == FP_ZERO ? -INFINITY :
floor(log10(fabs(val;
+double log = (fpclassify(val) == FP_ZERO ? FP_INFINITE :


FP_INFINITE is a return value from fpclassify(), not a double.

Does maybe using av_int2double(UINT64_C(0xFFF) << 52) help your slow 
startup?



floor(log10(fabs(val;
  int precision = (isfinite(log) && log < 0) ? -log + 5 : 6;
  int last = snprintf(buf, AV_TS_MAX_STRING_SIZE, "%.*f", precision,
val);
  last = FFMIN(last, AV_TS_MAX_STRING_SIZE - 1) - 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/5] avcodec/cbs_h265_syntax_template:

2024-08-16 Thread James Almer

On 8/16/2024 8:15 PM, Michael Niedermayer wrote:

Fixes: Assertion width > 0 && width <= 32 failed
Fixes: 
71012/clusterfuzz-testcase-minimized-ffmpeg_BSF_HEVC_METADATA_fuzzer-6073354744823808

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
  libavcodec/cbs_h265_syntax_template.c | 8 
  1 file changed, 8 insertions(+)

diff --git a/libavcodec/cbs_h265_syntax_template.c 
b/libavcodec/cbs_h265_syntax_template.c
index 12fa185c774..d23cb58e863 100644
--- a/libavcodec/cbs_h265_syntax_template.c
+++ b/libavcodec/cbs_h265_syntax_template.c
@@ -2307,6 +2307,10 @@ SEI_FUNC(sei_3d_reference_displays_info, 
(CodedBitstreamContext *ctx, RWContext
  else
  length = FFMAX(0, (int)current->exponent_ref_display_width[i] +
(int)current->prec_ref_display_width - 31);
+
+if (length > 32)
+return AVERROR_PATCHWELCOME;


I guess this error code is fine since CBS currently can't read values > 
32 and this element can be up to 62 bits long.


Maybe also print an error that says something like "refDispWidthBits > 
32 is not supported".



+
  if (length)
  ubs(length, mantissa_ref_display_width[i], 1, i);
  else
@@ -2318,6 +2322,10 @@ SEI_FUNC(sei_3d_reference_displays_info, 
(CodedBitstreamContext *ctx, RWContext
  else
  length = FFMAX(0, 
(int)current->exponent_ref_viewing_distance[i] +
(int)current->prec_ref_viewing_dist - 31);
+
+if (length > 32)
+return AVERROR_PATCHWELCOME;


Ditto, "refViewDistBits > 32 is not supported".


+
  if (length)
  ubs(length, mantissa_ref_viewing_distance[i], 1, i);
  else


___
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 5/5] avcodec/hevc/ps: use unsigned shift

2024-08-16 Thread James Almer

On 8/16/2024 8:15 PM, Michael Niedermayer wrote:

Fixes: left shift of 1 by 31 places cannot be represented in type 'int'
Fixes: 
70726/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-6149928703819776

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
  libavcodec/hevc/ps.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/hevc/ps.c b/libavcodec/hevc/ps.c
index 80ac35a7dbf..cd5ece72b0a 100644
--- a/libavcodec/hevc/ps.c
+++ b/libavcodec/hevc/ps.c
@@ -1101,7 +1101,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
unsigned int *sps_id,
  sps->used_by_curr_pic_lt = 0;
  for (i = 0; i < sps->num_long_term_ref_pics_sps; i++) {
  sps->lt_ref_pic_poc_lsb_sps[i]   = get_bits(gb, 
sps->log2_max_poc_lsb);
-sps->used_by_curr_pic_lt|= get_bits1(gb) * (1 << i);
+sps->used_by_curr_pic_lt|= get_bits1(gb) * (1U << i);


Why not just get_bits1(gb) << i? get_bits1() returns an unsigned int 
(Either 0 or 1), so no chances for a left shift of negative number.


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

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


[FFmpeg-devel] [PATCH] avcodec/shorten: Fix discard of ‘const’ qualifier

2024-08-16 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/shorten.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
index 12a179156a..46d3b7a615 100644
--- a/libavcodec/shorten.c
+++ b/libavcodec/shorten.c
@@ -563,7 +563,6 @@ static int shorten_decode_frame(AVCodecContext *avctx, 
AVFrame *frame,
 buf   = &s->bitstream[s->bitstream_index];
 buf_size += s->bitstream_size;
 s->bitstream_size = buf_size;
-memset(buf + buf_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
 /* do not decode until buffer has at least max_framesize bytes or
  * the end of the file has been reached */
@@ -583,10 +582,9 @@ static int shorten_decode_frame(AVCodecContext *avctx, 
AVFrame *frame,
 return ret;
 
 if (avpkt->size) {
-int max_framesize;
+int max_framesize = s->blocksize * s->channels * 8;
 void *tmp_ptr;
 
-max_framesize = FFMAX(s->max_framesize, s->blocksize * s->channels 
* 8);
 tmp_ptr = av_fast_realloc(s->bitstream, 
&s->allocated_bitstream_size,
   max_framesize + 
AV_INPUT_BUFFER_PADDING_SIZE);
 if (!tmp_ptr) {
@@ -594,7 +592,10 @@ static int shorten_decode_frame(AVCodecContext *avctx, 
AVFrame *frame,
 return AVERROR(ENOMEM);
 }
 s->bitstream = tmp_ptr;
-s->max_framesize = max_framesize;
+if (max_framesize > s->max_framesize)
+memset(s->bitstream + s->max_framesize, 0, (max_framesize - 
s->max_framesize) +
+
AV_INPUT_BUFFER_PADDING_SIZE);
+s->max_framesize = FFMAX(s->max_framesize, max_framesize);
 *got_frame_ptr = 0;
 goto finish_frame;
 }
-- 
2.46.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] avformat/iamf_parse: ignore Audio Elements with an unsupported type

2024-08-14 Thread James Almer
Better fix for the NULL pointer dereference from d7f83fc2f423.

Signed-off-by: James Almer 
---
 libavformat/iamf_parse.c | 9 ++---
 libavformat/iamfdec.c| 3 ++-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c
index 296e49157b..e431f9a364 100644
--- a/libavformat/iamf_parse.c
+++ b/libavformat/iamf_parse.c
@@ -751,8 +751,8 @@ static int audio_element_obu(void *s, IAMFContext *c, 
AVIOContext *pb, int len)
 if (ret < 0)
 goto fail;
 } else {
-unsigned audio_element_config_size = ffio_read_leb(pbc);
-avio_skip(pbc, audio_element_config_size);
+ret = AVERROR(EAGAIN);
+goto fail;
 }
 
 c->audio_elements[c->nb_audio_elements++] = audio_element;
@@ -764,8 +764,11 @@ static int audio_element_obu(void *s, IAMFContext *c, 
AVIOContext *pb, int len)
 ret = 0;
 fail:
 av_free(buf);
-if (ret < 0)
+if (ret < 0) {
 ff_iamf_free_audio_element(&audio_element);
+if (ret == AVERROR(EAGAIN))
+ret = 0;
+}
 return ret;
 }
 
diff --git a/libavformat/iamfdec.c b/libavformat/iamfdec.c
index 2e6608b868..55b9d0f89d 100644
--- a/libavformat/iamfdec.c
+++ b/libavformat/iamfdec.c
@@ -107,7 +107,8 @@ static int iamf_read_header(AVFormatContext *s)
 if (ret < 0)
 return ret;
 
-if (!i && !j && audio_element->nb_layers && 
audio_element->layers[0].substream_count == 1)
+av_assert0(audio_element->layers);
+if (!i && !j && audio_element->layers[0].substream_count == 1)
 st->disposition |= AV_DISPOSITION_DEFAULT;
 else
 st->disposition |= AV_DISPOSITION_DEPENDENT;
-- 
2.46.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/3] avformat/iamf_parse: clear padding

2024-08-14 Thread James Almer

On 8/14/2024 11:34 AM, Michael Niedermayer wrote:

Fixes: use of uninitialized value
Fixes: 
70929/clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-5931276639469568

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

diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c
index 296e49157b0..f2b6d4fa518 100644
--- a/libavformat/iamf_parse.c
+++ b/libavformat/iamf_parse.c
@@ -1076,6 +1076,7 @@ int ff_iamfdec_read_descriptors(IAMFContext *c, 
AVIOContext *pb,
  size = avio_read(pb, header, FFMIN(MAX_IAMF_OBU_HEADER_SIZE, 
max_size));
  if (size < 0)
  return size;
+memset(header + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
  
  len = ff_iamf_parse_obu_header(header, size, &obu_size, &start_pos, &type, NULL, NULL);

  if (len < 0 || obu_size > max_size) {


I assume get_bits() reads into the padding?

Should be ok.

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

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


[FFmpeg-devel] [PATCH] avcodec/snowenc: sign extend a variable before shifting

2024-08-13 Thread James Almer
Fixes "libavcodec/snowenc.c:718:27: runtime error: left shift of 8509032 by 8 
places cannot be represented in type 'int'"
as seen in fate-vsynth2-snow-hpel under ubsan.

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

diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index 0b87d751b8..eac81d0d7c 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -715,7 +715,7 @@ static int get_dc(SnowEncContext *enc, int mb_x, int mb_y, 
int plane_index)
 }
 *b= backup;
 
-return av_clip_uint8( ROUNDED_DIV(ab<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] Make H.274 film grain support optional for H.264. Saves ~779kb.

2024-08-13 Thread James Almer

On 8/13/2024 4:31 PM, Dale Curtis wrote:

Film grain support adds a huge amount of overhead to the H264Context
structure for a feature that is rarely used. On low end devices or
pages that have lots of media this bloats memory usage rapidly.

This introduces a --disable-h264-film-grain option which makes
these fields optional and reduces the H264Context size from
851808 bytes to 53444 bytes.

Bug: https://crbug.com/359358875
Signed-off-by: Dale Curtis 

Note: I'm not sure this is the right way to go about making this optional,
please
let me know if there's a better way.

- dale


The proper name for the option and define should be H274, or simply 
film_grain if you're also including AV1FG in it.
I'm not against a change like this, but it needs to be thorough like we 
did with iamfenc and iamfdec, and there's more code handling film grain 
in other modules.


Not sure what Niklas thinks.

___
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] swscale/output: don't leave the alpha channel undefined in vuyx and xv36le

2024-08-13 Thread James Almer

On 8/13/2024 11:25 AM, James Almer wrote:

It's non-determistic, as shown by poisoning avfilter buffers instead of zeroing 
them.

Signed-off-by: James Almer 
---
  libswscale/output.c  | 6 +++---
  tests/ref/fate/filter-pixfmts-copy   | 4 ++--
  tests/ref/fate/filter-pixfmts-crop   | 4 ++--
  tests/ref/fate/filter-pixfmts-field  | 4 ++--
  tests/ref/fate/filter-pixfmts-fieldorder | 4 ++--
  tests/ref/fate/filter-pixfmts-hflip  | 4 ++--
  tests/ref/fate/filter-pixfmts-il | 4 ++--
  tests/ref/fate/filter-pixfmts-null   | 4 ++--
  tests/ref/fate/filter-pixfmts-pad| 2 +-
  tests/ref/fate/filter-pixfmts-scale  | 4 ++--
  tests/ref/fate/filter-pixfmts-transpose  | 4 ++--
  tests/ref/fate/filter-pixfmts-vflip  | 4 ++--
  12 files changed, 24 insertions(+), 24 deletions(-)


Will apply soon to remove all the yellow from fate.

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

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


Re: [FFmpeg-devel] [PATCH] avcodec/rpzaenc: don't use buffer data beyond the end of a row

2024-08-13 Thread James Almer

On 8/13/2024 11:05 AM, James Almer wrote:

Fixes use of uninitized data (masked by the default zeroing of image buffers).

Signed-off-by: James Almer 
---
  libavcodec/rpzaenc.c | 8 ++--
  1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/rpzaenc.c b/libavcodec/rpzaenc.c
index d84555d6c6..3a1924d385 100644
--- a/libavcodec/rpzaenc.c
+++ b/libavcodec/rpzaenc.c
@@ -749,20 +749,24 @@ post_skip :
  
  if (err > s->sixteen_color_thresh) { // DO SIXTEEN COLOR BLOCK

  const uint16_t *row_ptr;
-int y_size, rgb555;
+int y_size, x_size, rgb555;
  
  block_offset  = get_block_info(&bi, block_counter, 0);

  pblock_offset = get_block_info(&bi, block_counter, 1);
  
  row_ptr = &src_pixels[block_offset];

  y_size = FFMIN(4, bi.image_height - bi.row * 4);
+x_size = FFMIN(4, bi.image_width  - bi.col * 4);
  
  for (int y = 0; y < y_size; y++) {

-for (int x = 0; x < 4; x++) {
+for (int x = 0; x < x_size; x++) {
  rgb555 = row_ptr[x] & ~0x8000;
  
  put_bits(&s->pb, 16, rgb555);

  }
+for (int x = x_size; x < 4; x++)
+put_bits(&s->pb, 16, 0);
+
  row_ptr += bi.rowstride;
  }


Will apply soon to remove all the yellow from fate.

___
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] swscale/output: don't leave the alpha channel undefined in vuyx and xv36le

2024-08-13 Thread James Almer

On 8/13/2024 12:08 PM, Timo Rothenpieler wrote:

On 13/08/2024 16:25, James Almer wrote:
It's non-determistic, as shown by poisoning avfilter buffers instead 
of zeroing them.


Signed-off-by: James Almer 
---
  libswscale/output.c  | 6 +++---
  tests/ref/fate/filter-pixfmts-copy   | 4 ++--
  tests/ref/fate/filter-pixfmts-crop   | 4 ++--
  tests/ref/fate/filter-pixfmts-field  | 4 ++--
  tests/ref/fate/filter-pixfmts-fieldorder | 4 ++--
  tests/ref/fate/filter-pixfmts-hflip  | 4 ++--
  tests/ref/fate/filter-pixfmts-il | 4 ++--
  tests/ref/fate/filter-pixfmts-null   | 4 ++--
  tests/ref/fate/filter-pixfmts-pad    | 2 +-
  tests/ref/fate/filter-pixfmts-scale  | 4 ++--
  tests/ref/fate/filter-pixfmts-transpose  | 4 ++--
  tests/ref/fate/filter-pixfmts-vflip  | 4 ++--
  12 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/libswscale/output.c b/libswscale/output.c
index e8dd2145ce..fb21e79f47 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -2650,7 +2650,7 @@ yuv2xv36le_X_c(SwsContext *c, const int16_t 
*lumFilter,

  {
  int i;
  for (i = 0; i < dstW; i++) {
-    int Y = 1 << 14, U = 1 << 14, V = 1 << 14;
+    int Y = 1 << 14, U = 1 << 14, V = 1 << 14, A = 255;
  int j;
  for (j = 0; j < lumFilterSize; j++)
@@ -2664,6 +2664,7 @@ yuv2xv36le_X_c(SwsContext *c, const int16_t 
*lumFilter,

  AV_WL16(dest + 8 * i + 2, av_clip_uintp2(Y >> 15, 12) << 4);
  AV_WL16(dest + 8 * i + 0, av_clip_uintp2(U >> 15, 12) << 4);
  AV_WL16(dest + 8 * i + 4, av_clip_uintp2(V >> 15, 12) << 4);
+    AV_WL16(dest + 8 * i + 6, A);
  }
  }
@@ -2718,8 +2719,7 @@ yuv2vuyX_X_c(SwsContext *c, const int16_t 
*lumFilter,

  dest[4 * i    ] = V;
  dest[4 * i + 1] = U;
  dest[4 * i + 2] = Y;
-    if (destHasAlpha)
-    dest[4 * i + 3] = A;
+    dest[4 * i + 3] = A;


Couldn't this in theory break reading of existing files that rely on 
their random data in the alpha channel not being read?
As in, if !destHasAlpha, shouldn't it rather be set to a safe default 
value, i.e. 255?


A is initialized to 255, which is why all the tests below change. If it 
was zero, they wouldn't be affected.





  }
  }
diff --git a/tests/ref/fate/filter-pixfmts-copy b/tests/ref/fate/ 
filter-pixfmts-copy

index eb3e61b4f2..120129dc1e 100644
--- a/tests/ref/fate/filter-pixfmts-copy
+++ b/tests/ref/fate/filter-pixfmts-copy
@@ -98,11 +98,11 @@ rgba64be    ae2ae04b5efedca3505f47c4dd6ea6ea
  rgba64le    b91e1d77f799eb92241a2d2d28437b15
  uyvy422 3bcf3c80047592f2211fae3260b1b65d
  vuya    3d5e934651cae1ce334001cb1829ad22
-vuyx    3f68ea6ec492b30d867cb5401562264e
+vuyx    0af13a42f9d0932c5a9bb6a8a5d1c5ee
  x2bgr10le   550c0d190cf695afa4eaacb644db6b75
  x2rgb10le   c1e3ac21be04a16bb157b22784524520
  xv30le  c14b5a953bf3be56346f66ca174a5b1b
-xv36le  3f8ced42a081639a39ec5929dd77b017
+xv36le  6b8e46832aa8537a774e93dd7503c700
  xyz12be a1ef56bf746d71f59669c28e48fc8450
  xyz12le 831ff03c1ba4ef19374686f16a064d8c
  y210le  0736b017e0814daf38d3350c42796f7a
diff --git a/tests/ref/fate/filter-pixfmts-crop b/tests/ref/fate/ 
filter-pixfmts-crop

index 01cb88bc54..4731e96fc0 100644
--- a/tests/ref/fate/filter-pixfmts-crop
+++ b/tests/ref/fate/filter-pixfmts-crop
@@ -95,11 +95,11 @@ rgba    9488ac85abceaf99a9309eac5a87697e
  rgba64be    89910046972ab3c68e2a348302cc8ca9
  rgba64le    fea8ebfc869b52adf353778f29eac7a7
  vuya    76578a705ff3a37559653c1289bd03dd
-vuyx    5d2bae51a2f4892bd5f177f190cc323b
+vuyx    615241c5406eb556fca0ad8606c23a02
  x2bgr10le   84de725b85662c362862820dc4a309aa
  x2rgb10le   f4265aca7a67dbfa9354370098ca6f33
  xv30le  a9edb820819b900a4a897fee4562a4fb
-xv36le  90a187adf00a1b15c33d064ae2582804
+xv36le  567af630bf0209e026e0909b3ca9c436
  xyz12be cb4571f9aaa7b59f999ef327276104b7
  xyz12le cd6aae8d26b18bdb4b9d068586276d91
  ya16be  a3d18014454942a96f15a49947c0c55d
diff --git a/tests/ref/fate/filter-pixfmts-field b/tests/ref/fate/ 
filter-pixfmts-field

index c7d9b8f133..0727d733f2 100644
--- a/tests/ref/fate/filter-pixfmts-field
+++ b/tests/ref/fate/filter-pixfmts-field
@@ -98,11 +98,11 @@ rgba64be    23c8c0edaabe3eaec89ce69633fb0048
  rgba64le    dfdba4de4a7cac9abf08852666c341d3
  uyvy422 1c49e44ab3f060e85fc4a3a9464f045e
  vuya    f72bcf29d75cd143d0c565f7cc49119a
-vuyx    6257cd1ce11330660e9fa9c675acbdcc
+vuyx    3d02eeab336d0a8106f6fdd91be61073
  x2bgr10le   dbe21538d7cb1744914f6bd46ec09b55
  x2rgb10le

[FFmpeg-devel] [PATCH] swscale/output: don't leave the alpha channel undefined in vuyx and xv36le

2024-08-13 Thread James Almer
It's non-determistic, as shown by poisoning avfilter buffers instead of zeroing 
them.

Signed-off-by: James Almer 
---
 libswscale/output.c  | 6 +++---
 tests/ref/fate/filter-pixfmts-copy   | 4 ++--
 tests/ref/fate/filter-pixfmts-crop   | 4 ++--
 tests/ref/fate/filter-pixfmts-field  | 4 ++--
 tests/ref/fate/filter-pixfmts-fieldorder | 4 ++--
 tests/ref/fate/filter-pixfmts-hflip  | 4 ++--
 tests/ref/fate/filter-pixfmts-il | 4 ++--
 tests/ref/fate/filter-pixfmts-null   | 4 ++--
 tests/ref/fate/filter-pixfmts-pad| 2 +-
 tests/ref/fate/filter-pixfmts-scale  | 4 ++--
 tests/ref/fate/filter-pixfmts-transpose  | 4 ++--
 tests/ref/fate/filter-pixfmts-vflip  | 4 ++--
 12 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/libswscale/output.c b/libswscale/output.c
index e8dd2145ce..fb21e79f47 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -2650,7 +2650,7 @@ yuv2xv36le_X_c(SwsContext *c, const int16_t *lumFilter,
 {
 int i;
 for (i = 0; i < dstW; i++) {
-int Y = 1 << 14, U = 1 << 14, V = 1 << 14;
+int Y = 1 << 14, U = 1 << 14, V = 1 << 14, A = 255;
 int j;
 
 for (j = 0; j < lumFilterSize; j++)
@@ -2664,6 +2664,7 @@ yuv2xv36le_X_c(SwsContext *c, const int16_t *lumFilter,
 AV_WL16(dest + 8 * i + 2, av_clip_uintp2(Y >> 15, 12) << 4);
 AV_WL16(dest + 8 * i + 0, av_clip_uintp2(U >> 15, 12) << 4);
 AV_WL16(dest + 8 * i + 4, av_clip_uintp2(V >> 15, 12) << 4);
+AV_WL16(dest + 8 * i + 6, A);
 }
 }
 
@@ -2718,8 +2719,7 @@ yuv2vuyX_X_c(SwsContext *c, const int16_t *lumFilter,
 dest[4 * i] = V;
 dest[4 * i + 1] = U;
 dest[4 * i + 2] = Y;
-if (destHasAlpha)
-dest[4 * i + 3] = A;
+dest[4 * i + 3] = A;
 }
 }
 
diff --git a/tests/ref/fate/filter-pixfmts-copy 
b/tests/ref/fate/filter-pixfmts-copy
index eb3e61b4f2..120129dc1e 100644
--- a/tests/ref/fate/filter-pixfmts-copy
+++ b/tests/ref/fate/filter-pixfmts-copy
@@ -98,11 +98,11 @@ rgba64beae2ae04b5efedca3505f47c4dd6ea6ea
 rgba64leb91e1d77f799eb92241a2d2d28437b15
 uyvy422 3bcf3c80047592f2211fae3260b1b65d
 vuya3d5e934651cae1ce334001cb1829ad22
-vuyx3f68ea6ec492b30d867cb5401562264e
+vuyx0af13a42f9d0932c5a9bb6a8a5d1c5ee
 x2bgr10le   550c0d190cf695afa4eaacb644db6b75
 x2rgb10le   c1e3ac21be04a16bb157b22784524520
 xv30le  c14b5a953bf3be56346f66ca174a5b1b
-xv36le  3f8ced42a081639a39ec5929dd77b017
+xv36le  6b8e46832aa8537a774e93dd7503c700
 xyz12be a1ef56bf746d71f59669c28e48fc8450
 xyz12le 831ff03c1ba4ef19374686f16a064d8c
 y210le  0736b017e0814daf38d3350c42796f7a
diff --git a/tests/ref/fate/filter-pixfmts-crop 
b/tests/ref/fate/filter-pixfmts-crop
index 01cb88bc54..4731e96fc0 100644
--- a/tests/ref/fate/filter-pixfmts-crop
+++ b/tests/ref/fate/filter-pixfmts-crop
@@ -95,11 +95,11 @@ rgba9488ac85abceaf99a9309eac5a87697e
 rgba64be89910046972ab3c68e2a348302cc8ca9
 rgba64lefea8ebfc869b52adf353778f29eac7a7
 vuya76578a705ff3a37559653c1289bd03dd
-vuyx5d2bae51a2f4892bd5f177f190cc323b
+vuyx615241c5406eb556fca0ad8606c23a02
 x2bgr10le   84de725b85662c362862820dc4a309aa
 x2rgb10le   f4265aca7a67dbfa9354370098ca6f33
 xv30le  a9edb820819b900a4a897fee4562a4fb
-xv36le  90a187adf00a1b15c33d064ae2582804
+xv36le  567af630bf0209e026e0909b3ca9c436
 xyz12be cb4571f9aaa7b59f999ef327276104b7
 xyz12le cd6aae8d26b18bdb4b9d068586276d91
 ya16be  a3d18014454942a96f15a49947c0c55d
diff --git a/tests/ref/fate/filter-pixfmts-field 
b/tests/ref/fate/filter-pixfmts-field
index c7d9b8f133..0727d733f2 100644
--- a/tests/ref/fate/filter-pixfmts-field
+++ b/tests/ref/fate/filter-pixfmts-field
@@ -98,11 +98,11 @@ rgba64be23c8c0edaabe3eaec89ce69633fb0048
 rgba64ledfdba4de4a7cac9abf08852666c341d3
 uyvy422 1c49e44ab3f060e85fc4a3a9464f045e
 vuyaf72bcf29d75cd143d0c565f7cc49119a
-vuyx6257cd1ce11330660e9fa9c675acbdcc
+vuyx3d02eeab336d0a8106f6fdd91be61073
 x2bgr10le   dbe21538d7cb1744914f6bd46ec09b55
 x2rgb10le   a18bc4ae5274e0a8cca9137ecd50c677
 xv30le  e940366c78efc9e292e9de28cf04dba9
-xv36le  aa5a867879a70e1040dfafe3e03167d5
+xv36le  e05a99fc3edc8f26cb2dbd287c0a0fcf
 xyz12be d2fa69ec91d3ed862f2dac3f8e7a3437
 xyz12le 02bccd5e0b6824779a1f848b0ea3e3b5
 y210le  025beb25f047a762e3788dbea4b60864
diff --git a/tests/ref/fate/filter-pixfmts-fieldorder 
b/tests/ref/fate/filter-pixfmts-fieldorder
index 2f64bd3b14..1d7a98ce11 100644

[FFmpeg-devel] [PATCH] avcodec/rpzaenc: don't use buffer data beyond the end of a row

2024-08-13 Thread James Almer
Fixes use of uninitized data (masked by the default zeroing of image buffers).

Signed-off-by: James Almer 
---
 libavcodec/rpzaenc.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/rpzaenc.c b/libavcodec/rpzaenc.c
index d84555d6c6..3a1924d385 100644
--- a/libavcodec/rpzaenc.c
+++ b/libavcodec/rpzaenc.c
@@ -749,20 +749,24 @@ post_skip :
 
 if (err > s->sixteen_color_thresh) { // DO SIXTEEN COLOR BLOCK
 const uint16_t *row_ptr;
-int y_size, rgb555;
+int y_size, x_size, rgb555;
 
 block_offset  = get_block_info(&bi, block_counter, 0);
 pblock_offset = get_block_info(&bi, block_counter, 1);
 
 row_ptr = &src_pixels[block_offset];
 y_size = FFMIN(4, bi.image_height - bi.row * 4);
+x_size = FFMIN(4, bi.image_width  - bi.col * 4);
 
 for (int y = 0; y < y_size; y++) {
-for (int x = 0; x < 4; x++) {
+for (int x = 0; x < x_size; x++) {
 rgb555 = row_ptr[x] & ~0x8000;
 
 put_bits(&s->pb, 16, rgb555);
 }
+for (int x = x_size; x < 4; x++)
+put_bits(&s->pb, 16, 0);
+
 row_ptr += bi.rowstride;
 }
 
-- 
2.46.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".


  1   2   3   4   5   6   7   8   9   10   >