[FFmpeg-cvslog] libavformat/dvdvideo: add DVD-Video demuxer, powered by libdvdread and libdvdnav

2024-03-02 Thread Marth64
ffmpeg | branch: master | Marth64  | Sun Feb 18 22:01:44 
2024 -0600| [a1304272c3a0ef7c3d77c702dd466b3f11bf300f] | committer: Anton 
Khirnov

libavformat/dvdvideo: add DVD-Video demuxer, powered by libdvdread and libdvdnav

Signed-off-by: Marth64 
Signed-off-by: Anton Khirnov 

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

 Changelog |1 +
 configure |8 +
 doc/demuxers.texi |  130 +
 libavformat/Makefile  |1 +
 libavformat/allformats.c  |1 +
 libavformat/dvdvideodec.c | 1411 +
 6 files changed, 1552 insertions(+)

diff --git a/Changelog b/Changelog
index c65ef492be..fedad5782c 100644
--- a/Changelog
+++ b/Changelog
@@ -29,6 +29,7 @@ version :
   build environment if it lacks C17 support
 - Change the default bitrate control method from VBR to CQP for QSV encoders.
 - removed deprecated ffmpeg CLI options -psnr and -map_channel
+- DVD-Video demuxer, powered by libdvdnav and libdvdread
 
 version 6.1:
 - libaribcaption decoder
diff --git a/configure b/configure
index b5b233e852..db7dc89755 100755
--- a/configure
+++ b/configure
@@ -227,6 +227,8 @@ External library support:
   --enable-libdavs2enable AVS2 decoding via libdavs2 [no]
   --enable-libdc1394   enable IIDC-1394 grabbing using libdc1394
and libraw1394 [no]
+  --enable-libdvdnav   enable libdvdnav, needed for DVD demuxing [no]
+  --enable-libdvdread  enable libdvdread, needed for DVD demuxing [no]
   --enable-libfdk-aac  enable AAC de/encoding via libfdk-aac [no]
   --enable-libfliteenable flite (voice synthesis) support via libflite 
[no]
   --enable-libfontconfig   enable libfontconfig, useful for drawtext filter 
[no]
@@ -1806,6 +1808,8 @@ EXTERNAL_LIBRARY_GPL_LIST="
 frei0r
 libcdio
 libdavs2
+libdvdnav
+libdvdread
 librubberband
 libvidstab
 libx264
@@ -3526,6 +3530,8 @@ dts_demuxer_select="dca_parser"
 dtshd_demuxer_select="dca_parser"
 dv_demuxer_select="dvprofile"
 dv_muxer_select="dvprofile"
+dvdvideo_demuxer_select="mpegps_demuxer"
+dvdvideo_demuxer_deps="libdvdnav libdvdread"
 dxa_demuxer_select="riffdec"
 eac3_demuxer_select="ac3_parser"
 evc_demuxer_select="evc_frame_merge_bsf evc_parser"
@@ -6775,6 +6781,8 @@ enabled libdav1d  && require_pkg_config libdav1d 
"dav1d >= 0.5.0" "dav1d
 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
+enabled libdvdnav && require_pkg_config libdvdnav "dvdnav >= 6.1.1" 
dvdnav/dvdnav.h dvdnav_open2
+enabled libdvdread&& require_pkg_config libdvdread "dvdread >= 6.1.2" 
dvdread/dvd_reader.h DVDOpen2 -ldvdread
 enabled libfdk_aac&& { check_pkg_config libfdk_aac fdk-aac 
"fdk-aac/aacenc_lib.h" aacEncOpen ||
{ require libfdk_aac fdk-aac/aacenc_lib.h 
aacEncOpen -lfdk-aac &&
  warn "using libfdk without pkg-config"; } }
diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index e4c5b560a6..062ea2ea42 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -285,6 +285,136 @@ This demuxer accepts the following option:
 
 @end table
 
+@section dvdvideo
+
+DVD-Video demuxer, powered by libdvdnav and libdvdread.
+
+Can directly ingest DVD titles, specifically sequential PGCs,
+into a conversion pipeline. Menus and seeking are not supported at this time.
+
+Block devices (DVD drives), ISO files, and directory structures are accepted.
+Activate with @code{-f dvdvideo} in front of one of these inputs.
+
+Underlying playback is handled by libdvdnav, and structure parsing by 
libdvdread.
+FFmpeg must be built with GPL library support available as well as the
+configure switches @code{--enable-libdvdnav} and @code{--enable-libdvdread}.
+
+You will need to provide either the desired "title number" or exact PGC/PG 
coordinates.
+Many open-source DVD players and tools can aid in providing this information.
+If not specified, the demuxer will default to title 1 which works for many 
discs.
+However, due to the flexibility of the format, it is recommended to check 
manually.
+There are many discs that are authored strangely or with invalid headers.
+
+If the input is a real DVD drive, please note that there are some drives which 
may
+silently fail on reading bad sectors from the disc, returning random bits 
instead
+which is effectively corrupt data. This is especially prominent on aging or 
rotting discs.
+A second pass and integrity checks would be needed to detect the corruption.
+This is not an FFmpeg issue.
+
+@subsection Background
+
+DVD-Video is not a directly accessible, linear container format in the
+traditional sense. Instead, it al

[FFmpeg-cvslog] avformat/mxfdec: track metadata sets by their type

2024-03-02 Thread Marton Balint
ffmpeg | branch: master | Marton Balint  | Sat Feb 17 22:53:00 
2024 +0100| [4ebf478f4c5c31535f36ad648e7a8615441b90a5] | committer: Marton 
Balint

avformat/mxfdec: track metadata sets by their type

We typically are only interesed in a single type of metadata set, so it is
better to keep them separated instead of always filtering for them.

Also use av_dynarray_add for increasing their array.

Signed-off-by: Marton Balint 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4ebf478f4c5c31535f36ad648e7a8615441b90a5
---

 libavformat/mxf.h|   1 +
 libavformat/mxfdec.c | 128 ---
 2 files changed, 60 insertions(+), 69 deletions(-)

diff --git a/libavformat/mxf.h b/libavformat/mxf.h
index e16843214c..673703f6bc 100644
--- a/libavformat/mxf.h
+++ b/libavformat/mxf.h
@@ -55,6 +55,7 @@ enum MXFMetadataSetType {
 GroupOfSoundfieldGroupsLabelSubDescriptor,
 FFV1SubDescriptor,
 JPEG2000SubDescriptor,
+MetadataSetTypeNB
 };
 
 enum MXFFrameLayout {
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index b7b9207a5b..49387881b7 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -116,9 +116,13 @@ typedef struct MXFPartition {
 typedef struct MXFMetadataSet {
 UID uid;
 uint64_t partition_score;
-enum MXFMetadataSetType type;
 } MXFMetadataSet;
 
+typedef struct MXFMetadataSetGroup {
+MXFMetadataSet **metadata_sets;
+int metadata_sets_count;
+} MXFMetadataSetGroup;
+
 typedef struct MXFCryptoContext {
 MXFMetadataSet meta;
 UID source_container_ul;
@@ -302,8 +306,7 @@ typedef struct MXFContext {
 int packages_count;
 UID *essence_container_data_refs;
 int essence_container_data_count;
-MXFMetadataSet **metadata_sets;
-int metadata_sets_count;
+MXFMetadataSetGroup metadata_set_groups[MetadataSetTypeNB];
 AVFormatContext *fc;
 struct AVAES *aesc;
 uint8_t *local_tags;
@@ -374,10 +377,10 @@ static const uint8_t mxf_mastering_display_uls[4][16] = {
 
 #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))
 
-static void mxf_free_metadataset(MXFMetadataSet **ctx, int freectx)
+static void mxf_free_metadataset(MXFMetadataSet **ctx, enum MXFMetadataSetType 
type)
 {
 MXFIndexTableSegment *seg;
-switch ((*ctx)->type) {
+switch (type) {
 case Descriptor:
 case MultipleDescriptor:
 av_freep(&((MXFDescriptor *)*ctx)->extradata);
@@ -422,9 +425,7 @@ static void mxf_free_metadataset(MXFMetadataSet **ctx, int 
freectx)
 default:
 break;
 }
-if (freectx) {
-av_freep(ctx);
-}
+av_freep(ctx);
 }
 
 static int64_t klv_decode_ber_length(AVIOContext *pb)
@@ -915,34 +916,32 @@ static uint64_t partition_score(MXFPartition *p)
 return (score << 60) | ((uint64_t)p->pack_ofs >> 4);
 }
 
-static int mxf_add_metadata_set(MXFContext *mxf, MXFMetadataSet **metadata_set)
+static int mxf_add_metadata_set(MXFContext *mxf, MXFMetadataSet 
**metadata_set, enum MXFMetadataSetType type)
 {
-MXFMetadataSet **tmp;
-enum MXFMetadataSetType type = (*metadata_set)->type;
+MXFMetadataSetGroup *mg = &mxf->metadata_set_groups[type];
+int ret;
 
 // Index Table is special because it might be added manually without
 // partition and we iterate thorugh all instances of them. Also some files
 // use the same Instance UID for different index tables...
 if (type != IndexTableSegment) {
-for (int i = 0; i < mxf->metadata_sets_count; i++) {
-if (!memcmp((*metadata_set)->uid, mxf->metadata_sets[i]->uid, 16) 
&& type == mxf->metadata_sets[i]->type) {
-uint64_t old_s = mxf->metadata_sets[i]->partition_score;
+for (int i = 0; i < mg->metadata_sets_count; i++) {
+if (!memcmp((*metadata_set)->uid, mg->metadata_sets[i]->uid, 16)) {
+uint64_t old_s = mg->metadata_sets[i]->partition_score;
 uint64_t new_s = (*metadata_set)->partition_score;
 if (old_s > new_s) {
- mxf_free_metadataset(metadata_set, 1);
+ mxf_free_metadataset(metadata_set, type);
  return 0;
 }
 }
 }
 }
-tmp = av_realloc_array(mxf->metadata_sets, mxf->metadata_sets_count + 1, 
sizeof(*mxf->metadata_sets));
-if (!tmp) {
-mxf_free_metadataset(metadata_set, 1);
-return AVERROR(ENOMEM);
+
+ret = av_dynarray_add_nofree(&mg->metadata_sets, &mg->metadata_sets_count, 
*metadata_set);
+if (ret < 0) {
+mxf_free_metadataset(metadata_set, type);
+return ret;
 }
-mxf->metadata_sets = tmp;
-mxf->metadata_sets[mxf->metadata_sets_count] = *metadata_set;
-mxf->metadata_sets_count++;
 return 0;
 }
 
@@ -1576,16 +1575,14 @@ static const MXFCodecUL *mxf_get_codec_ul(const 
MXFCodecUL *uls, UID *uid)
 
 static void *mxf_resolve_strong_ref(MXFContext *mxf, UID *strong_ref, enum 
MXFMetadataSetType type)
 {
-int i

[FFmpeg-cvslog] avformat/mxfdec: remove resolve_strong_ref usage with AnyType

2024-03-02 Thread Marton Balint
ffmpeg | branch: master | Marton Balint  | Sat Feb 17 00:06:03 
2024 +0100| [aa299faa9ad2b01010acc4641b1f215d60a1336b] | committer: Marton 
Balint

avformat/mxfdec: remove resolve_strong_ref usage with AnyType

UUIDs do not have to be unique if their type sets them apart, so avoid using
AnyType, since we are only interested in specific types.

Signed-off-by: Marton Balint 

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

 libavformat/mxf.h|  3 +--
 libavformat/mxfdec.c | 54 ++--
 2 files changed, 20 insertions(+), 37 deletions(-)

diff --git a/libavformat/mxf.h b/libavformat/mxf.h
index 7dd1681e60..e16843214c 100644
--- a/libavformat/mxf.h
+++ b/libavformat/mxf.h
@@ -30,8 +30,7 @@
 typedef AVUUID UID;
 
 enum MXFMetadataSetType {
-AnyType,
-MaterialPackage,
+MaterialPackage = 1,
 SourcePackage,
 SourceClip,
 TimecodeComponent,
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 446bcf3276..b7b9207a5b 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -1582,7 +1582,7 @@ static void *mxf_resolve_strong_ref(MXFContext *mxf, UID 
*strong_ref, enum MXFMe
 return NULL;
 for (i = mxf->metadata_sets_count - 1; i >= 0; i--) {
 if (!memcmp(*strong_ref, mxf->metadata_sets[i]->uid, 16) &&
-(type == AnyType || mxf->metadata_sets[i]->type == type)) {
+(mxf->metadata_sets[i]->type == type)) {
 return mxf->metadata_sets[i];
 }
 }
@@ -2221,22 +2221,17 @@ static int mxf_add_timecode_metadata(AVDictionary **pm, 
const char *key, AVTimec
 
 static MXFTimecodeComponent* mxf_resolve_timecode_component(MXFContext *mxf, 
UID *strong_ref)
 {
-MXFStructuralComponent *component = NULL;
-MXFPulldownComponent *pulldown = NULL;
+MXFTimecodeComponent *timecode;
+MXFPulldownComponent *pulldown;
 
-component = mxf_resolve_strong_ref(mxf, strong_ref, AnyType);
-if (!component)
-return NULL;
+timecode = mxf_resolve_strong_ref(mxf, strong_ref, TimecodeComponent);
+if (timecode)
+return timecode;
 
-switch (component->meta.type) {
-case TimecodeComponent:
-return (MXFTimecodeComponent*)component;
-case PulldownComponent: /* timcode component may be located on a pulldown 
component */
-pulldown = (MXFPulldownComponent*)component;
+pulldown = mxf_resolve_strong_ref(mxf, strong_ref, PulldownComponent);
+if (pulldown)
 return mxf_resolve_strong_ref(mxf, &pulldown->input_segment_ref, 
TimecodeComponent);
-default:
-break;
-}
+
 return NULL;
 }
 
@@ -2280,14 +2275,20 @@ static MXFDescriptor* mxf_resolve_descriptor(MXFContext 
*mxf, UID *strong_ref, i
 return NULL;
 }
 
-static MXFStructuralComponent* mxf_resolve_essence_group_choice(MXFContext 
*mxf, MXFEssenceGroup *essence_group)
+static MXFStructuralComponent* mxf_resolve_sourceclip(MXFContext *mxf, UID 
*strong_ref)
 {
 MXFStructuralComponent *component = NULL;
 MXFPackage *package = NULL;
 MXFDescriptor *descriptor = NULL;
+MXFEssenceGroup *essence_group;
 int i;
 
-if (!essence_group || !essence_group->structural_components_count)
+component = mxf_resolve_strong_ref(mxf, strong_ref, SourceClip);
+if (component)
+return component;
+
+essence_group = mxf_resolve_strong_ref(mxf, strong_ref, EssenceGroup);
+if (!essence_group)
 return NULL;
 
 /* essence groups contains multiple representations of the same media,
@@ -2304,24 +2305,7 @@ static MXFStructuralComponent* 
mxf_resolve_essence_group_choice(MXFContext *mxf,
 if (descriptor)
 return component;
 }
-return NULL;
-}
-
-static MXFStructuralComponent* mxf_resolve_sourceclip(MXFContext *mxf, UID 
*strong_ref)
-{
-MXFStructuralComponent *component = NULL;
 
-component = mxf_resolve_strong_ref(mxf, strong_ref, AnyType);
-if (!component)
-return NULL;
-switch (component->meta.type) {
-case SourceClip:
-return component;
-case EssenceGroup:
-return mxf_resolve_essence_group_choice(mxf, (MXFEssenceGroup*) 
component);
-default:
-break;
-}
 return NULL;
 }
 
@@ -3243,7 +3227,7 @@ static const MXFMetadataReadTableEntry 
mxf_metadata_read_table[] = {
 { { 
0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x04,0x04,0x00 
}, mxf_read_partition_pack },
 { { 
0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x2f,0x00 
}, mxf_read_preface_metadata },
 { { 
0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x30,0x00 
}, mxf_read_identification_metadata },
-{ { 
0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x18,0x00 
}, mxf_read_content_storage, 0, AnyType },
+{ { 
0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x18,0x00 
},

[FFmpeg-cvslog] fate/libswresample: force number of samples for the input of aresample async tests

2024-03-02 Thread Marton Balint
ffmpeg | branch: master | Marton Balint  | Mon Feb 26 01:07:44 
2024 +0100| [315be8b27926fb46338a8fc10cf39cbb9f99dcc8] | committer: Marton 
Balint

fate/libswresample: force number of samples for the input of aresample async 
tests

Since PTS is changed randomly for every audio frame, it matters. Also add some
forgotten filter dependencies.

Signed-off-by: Marton Balint 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=315be8b27926fb46338a8fc10cf39cbb9f99dcc8
---

 tests/fate/libswresample.mak | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tests/fate/libswresample.mak b/tests/fate/libswresample.mak
index 0971a6b3ba..405328797e 100644
--- a/tests/fate/libswresample.mak
+++ b/tests/fate/libswresample.mak
@@ -357,9 +357,9 @@ fate-swr-resample_nn-s16p-8000-44100: CMP_TARGET = 3156.61
 fate-swr-resample_nn-s16p-8000-44100: SIZE_TOLERANCE = 96000 - 20480
 
 define ARESAMPLE_ASYNC
-FATE_SWR_RESAMPLE += fate-swr-resample_async-$(3)-$(1)-$(2)
+FATE_SWR_RESAMPLE-$(call FILTERDEMDECENCMUX, ATRIM ASETNSAMPLES ASETPTS 
ARESAMPLE, WAV, PCM_S16LE, PCM_S16LE, WAV) += 
fate-swr-resample_async-$(3)-$(1)-$(2)
 fate-swr-resample_async-$(3)-$(1)-$(2): tests/data/asynth-$(1)-1.wav
-fate-swr-resample_async-$(3)-$(1)-$(2): CMD = ffmpeg -i 
$(TARGET_PATH)/tests/data/asynth-$(1)-1.wav -af 
atrim=end_sample=10240,asetpts=PTS+random\(0\)*200-100,aresample=$(2):async=50:min_hard_comp=0.10:first_pts=0:linear_interp=0:exact_rational=0:internal_sample_fmt=$(3),aformat=$(3),aresample=$(1):linear_interp=0:exact_rational=0:internal_sample_fmt=$(3)
 -f wav -c:a pcm_s16le -
+fate-swr-resample_async-$(3)-$(1)-$(2): CMD = ffmpeg -i 
$(TARGET_PATH)/tests/data/asynth-$(1)-1.wav -af 
atrim=end_sample=10240,asetnsamples=2048,asetpts=PTS+random\(0\)*200-100,aresample=$(2):async=50:min_hard_comp=0.10:first_pts=0:linear_interp=0:exact_rational=0:internal_sample_fmt=$(3),aformat=$(3),aresample=$(1):linear_interp=0:exact_rational=0:internal_sample_fmt=$(3)
 -f wav -c:a pcm_s16le -
 
 fate-swr-resample_async-$(3)-$(1)-$(2): CMP = stddev
 fate-swr-resample_async-$(3)-$(1)-$(2): CMP_UNIT = $(5)
@@ -631,9 +631,9 @@ fate-swr-resample_exact-s32p-96000-8000: CMP_TARGET = 58.54
 fate-swr-resample_exact-s32p-96000-8000: SIZE_TOLERANCE = 1152000 - 20496
 
 define ARESAMPLE_EXACT_ASYNC
-FATE_SWR_RESAMPLE += fate-swr-resample_exact_async-$(3)-$(1)-$(2)
+FATE_SWR_RESAMPLE-$(call FILTERDEMDECENCMUX, ATRIM ASETNSAMPLES ASETPTS 
ARESAMPLE, WAV, PCM_S16LE, PCM_S16LE, WAV) += 
fate-swr-resample_exact_async-$(3)-$(1)-$(2)
 fate-swr-resample_exact_async-$(3)-$(1)-$(2): tests/data/asynth-$(1)-1.wav
-fate-swr-resample_exact_async-$(3)-$(1)-$(2): CMD = ffmpeg -i 
$(TARGET_PATH)/tests/data/asynth-$(1)-1.wav -af 
atrim=end_sample=10240,asetpts=PTS+random\(0\)*200-100,aresample=$(2):async=50:min_hard_comp=0.10:first_pts=0:internal_sample_fmt=$(3):exact_rational=on:linear_interp=0,aformat=$(3),aresample=$(1):internal_sample_fmt=$(3):exact_rational=on:linear_interp=0
 -f wav -c:a pcm_s16le -
+fate-swr-resample_exact_async-$(3)-$(1)-$(2): CMD = ffmpeg -i 
$(TARGET_PATH)/tests/data/asynth-$(1)-1.wav -af 
atrim=end_sample=10240,asetnsamples=2048,asetpts=PTS+random\(0\)*200-100,aresample=$(2):async=50:min_hard_comp=0.10:first_pts=0:internal_sample_fmt=$(3):exact_rational=on:linear_interp=0,aformat=$(3),aresample=$(1):internal_sample_fmt=$(3):exact_rational=on:linear_interp=0
 -f wav -c:a pcm_s16le -
 
 fate-swr-resample_exact_async-$(3)-$(1)-$(2): CMP = stddev
 fate-swr-resample_exact_async-$(3)-$(1)-$(2): CMP_UNIT = $(5)
@@ -965,9 +965,9 @@ fate-swr-resample_exact_lin-s32p-96000-8000: CMP_TARGET = 
58.54
 fate-swr-resample_exact_lin-s32p-96000-8000: SIZE_TOLERANCE = 1152000 - 20496
 
 define ARESAMPLE_EXACT_LIN_ASYNC
-FATE_SWR_RESAMPLE += fate-swr-resample_exact_lin_async-$(3)-$(1)-$(2)
+FATE_SWR_RESAMPLE-$(call FILTERDEMDECENCMUX, ATRIM ASETNSAMPLES ASETPTS 
ARESAMPLE, WAV, PCM_S16LE, PCM_S16LE, WAV) += 
fate-swr-resample_exact_lin_async-$(3)-$(1)-$(2)
 fate-swr-resample_exact_lin_async-$(3)-$(1)-$(2): tests/data/asynth-$(1)-1.wav
-fate-swr-resample_exact_lin_async-$(3)-$(1)-$(2): CMD = ffmpeg -i 
$(TARGET_PATH)/tests/data/asynth-$(1)-1.wav -af 
atrim=end_sample=10240,asetpts=PTS+random\(0\)*200-100,aresample=$(2):async=50:min_hard_comp=0.10:first_pts=0:internal_sample_fmt=$(3):exact_rational=on:linear_interp=on,aformat=$(3),aresample=$(1):internal_sample_fmt=$(3):exact_rational=on:linear_interp=on
 -f wav -c:a pcm_s16le -
+fate-swr-resample_exact_lin_async-$(3)-$(1)-$(2): CMD = ffmpeg -i 
$(TARGET_PATH)/tests/data/asynth-$(1)-1.wav -af 
atrim=end_sample=10240,asetnsamples=2048,asetpts=PTS+random\(0\)*200-100,aresample=$(2):async=50:min_hard_comp=0.10:first_pts=0:internal_sample_fmt=$(3):exact_rational=on:linear_interp=on,aformat=$(3),aresample=$(1):internal_sample_fmt=$(3):exact_rational=on:linear_interp=on
 -f wav -c:a pcm_s16le -
 
 fate-swr-resample_exact_lin_async-$(3)-$(1)-$(2): CMP = stddev
 fate-swr-resamp

[FFmpeg-cvslog] fate: never generate auto-generated references

2024-03-02 Thread Marton Balint
ffmpeg | branch: master | Marton Balint  | Sun Feb 25 15:02:32 
2024 +0100| [0b98f28c46a7e3e914c51debc461fa05861ae666] | committer: Marton 
Balint

fate: never generate auto-generated references

GEN=1 is used to generate reference files in the source tree, not
auto-generated reference samples.

Without this patch GEN=1 could overwrite the auto generated reference files
in each test where they are used causing failures.

Signed-off-by: Marton Balint 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0b98f28c46a7e3e914c51debc461fa05861ae666
---

 tests/fate-run.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/fate-run.sh b/tests/fate-run.sh
index 4b85fbf464..7a7344e645 100755
--- a/tests/fate-run.sh
+++ b/tests/fate-run.sh
@@ -658,7 +658,7 @@ else
 fi
 echo "${test}:${sig:-$err}:$cmpo:$erro" >$repfile
 
-if test $err != 0 && test $gen != "no" ; then
+if test $err != 0 && test $gen != "no" && test "${ref#tests/data/}" == "$ref" 
; then
 echo "GEN $ref"
 cp -f "$outfile" "$ref"
 err=$?

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

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


[FFmpeg-cvslog] swresample/resample: fix rounding errors with filter_size=1 and phase_shift=0

2024-03-02 Thread Marton Balint
ffmpeg | branch: master | Marton Balint  | Tue Feb 27 10:31:31 
2024 +0100| [7b1b9bb31f04fb9ba06e79c767c1084f0e229bb6] | committer: Marton 
Balint

swresample/resample: fix rounding errors with filter_size=1 and phase_shift=0

Depending on input chunk size noticable corrpution was hearable, here is an
example command line:

ffplay -f lavfi -i 
"sine=440:r=8000:samples_per_frame=32,aresample=24000:filter_size=1:phase_shift=0"

Fix this by rounding the fixed point fractions up instead of down.

Signed-off-by: Marton Balint 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7b1b9bb31f04fb9ba06e79c767c1084f0e229bb6
---

 libswresample/resample.c | 4 ++--
 tests/fate/libswresample.mak | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libswresample/resample.c b/libswresample/resample.c
index bd54a7002f..17cebad01b 100644
--- a/libswresample/resample.c
+++ b/libswresample/resample.c
@@ -357,8 +357,8 @@ static int multiple_resample(ResampleContext *c, AudioData 
*dst, int dst_size, A
 *consumed = 0;
 
 if (c->filter_length == 1 && c->phase_count == 1) {
-int64_t index2= (1LL<<32)*c->frac/c->src_incr + (1LL<<32)*c->index;
-int64_t incr= (1LL<<32) * c->dst_incr / c->src_incr;
+int64_t index2= (1LL<<32)*c->frac/c->src_incr + (1LL<<32)*c->index + 1;
+int64_t incr= (1LL<<32) * c->dst_incr / c->src_incr + 1;
 int new_size = (src_size * (int64_t)c->src_incr - c->frac + 
c->dst_incr - 1) / c->dst_incr;
 
 dst_size = FFMAX(FFMIN(dst_size, new_size), 0);
diff --git a/tests/fate/libswresample.mak b/tests/fate/libswresample.mak
index 2fc55ea61a..0971a6b3ba 100644
--- a/tests/fate/libswresample.mak
+++ b/tests/fate/libswresample.mak
@@ -347,13 +347,13 @@ endef
 fate-swr-resample_nn-fltp-44100-8000: CMP_TARGET = 591.03
 fate-swr-resample_nn-fltp-44100-8000: SIZE_TOLERANCE = 529200 - 20486
 
-fate-swr-resample_nn-fltp-8000-44100: CMP_TARGET = 3163.32
+fate-swr-resample_nn-fltp-8000-44100: CMP_TARGET = 3156.61
 fate-swr-resample_nn-fltp-8000-44100: SIZE_TOLERANCE = 96000 - 20480
 
 fate-swr-resample_nn-s16p-44100-8000: CMP_TARGET = 590.98
 fate-swr-resample_nn-s16p-44100-8000: SIZE_TOLERANCE = 529200 - 20486
 
-fate-swr-resample_nn-s16p-8000-44100: CMP_TARGET = 3163.39
+fate-swr-resample_nn-s16p-8000-44100: CMP_TARGET = 3156.61
 fate-swr-resample_nn-s16p-8000-44100: SIZE_TOLERANCE = 96000 - 20480
 
 define ARESAMPLE_ASYNC

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

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


[FFmpeg-cvslog] avformat/wavdec: dynamically set max_size by default

2024-03-02 Thread Marton Balint
ffmpeg | branch: master | Marton Balint  | Mon Feb 26 01:12:23 
2024 +0100| [3a09c2122d1f77c3e14c43855b21ef1da9f7fa27] | committer: Marton 
Balint

avformat/wavdec: dynamically set max_size by default

The wav demuxer by default tried to demux 4096-byte packets which caused
packets with very few number of samples for files with high channel count.
This caused a significant overhead especially since the latest ffmpeg.c
threading changes.

So let's use a similar approach for selecting audio frame size which is already
used in the PCM demuxer, which is to read 25 times per second but at most 1024
samples.

Signed-off-by: Marton Balint 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3a09c2122d1f77c3e14c43855b21ef1da9f7fa27
---

 doc/demuxers.texi  |  23 ++
 libavformat/wavdec.c   |  19 +-
 tests/ref/fate/dcinema-encode  |  40 +--
 tests/ref/fate/filter-amerge   | 387 +++--
 tests/ref/fate/filter-chorus   |  20 +-
 tests/ref/fate/filter-pan-downmix1 |  40 +--
 tests/ref/fate/filter-pan-downmix2 |  40 +--
 tests/ref/fate/filter-pan-stereo1  |  40 +--
 tests/ref/fate/filter-pan-stereo2  |  40 +--
 tests/ref/fate/filter-pan-upmix2   |  40 +--
 tests/ref/fate/g722-encode |  87 ++-
 tests/ref/fate/g726-encode-2bit|  41 ++-
 tests/ref/fate/g726-encode-3bit|  24 +-
 tests/ref/fate/g726-encode-4bit|  81 +-
 tests/ref/fate/g726-encode-5bit|  27 +-
 tests/ref/fate/matroska-move-cues-to-front | 100 +++-
 tests/ref/fate/mov-channel-description |   4 +-
 tests/ref/fate/mov-mp4-pcm |   4 +-
 tests/ref/fate/mov-mp4-pcm-float   |   2 +-
 tests/ref/seek/acodec-pcm-alaw |  54 ++--
 tests/ref/seek/acodec-pcm-f32le|  54 ++--
 tests/ref/seek/acodec-pcm-f64le|  54 ++--
 tests/ref/seek/acodec-pcm-mulaw|  54 ++--
 tests/ref/seek/acodec-pcm-s24le|  54 ++--
 tests/ref/seek/acodec-pcm-s32le|  54 ++--
 tests/ref/seek/acodec-pcm-u8   |  54 ++--
 tests/ref/seek/lavf-wav|  30 +--
 27 files changed, 904 insertions(+), 563 deletions(-)

diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 062ea2ea42..905828d852 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -1073,4 +1073,27 @@ which in turn, acts as a ceiling for the size of scripts 
that can be read.
 Default is 1 MiB.
 @end table
 
+@section w64
+
+Sony Wave64 Audio demuxer.
+
+This demuxer accepts the following options:
+@table @option
+@item max_size
+See the same option for the @ref{wav} demuxer.
+@end table
+
+@anchor{wav}
+@section wav
+
+RIFF Wave Audio demuxer.
+
+This demuxer accepts the following options:
+@table @option
+@item max_size
+Specify the maximum packet size in bytes for the demuxed packets. By default
+this is set to 0, which means that a sensible value is chosen based on the
+input format.
+@end table
+
 @c man end DEMUXERS
diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index 0c6629b157..5ceb8bef23 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -73,10 +73,25 @@ static const AVOption demux_options[] = {
 #if CONFIG_WAV_DEMUXER
 { "ignore_length", "Ignore length", OFFSET(ignore_length), 
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, DEC },
 #endif
-{ "max_size",  "max size of single packet", OFFSET(max_size), 
AV_OPT_TYPE_INT, { .i64 = 4096 }, 1024, 1 << 22, DEC },
+{ "max_size",  "max size of single packet", OFFSET(max_size), 
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1 << 22, DEC },
 { NULL },
 };
 
+static void set_max_size(AVStream *st, WAVDemuxContext *wav)
+{
+if (wav->max_size <= 0) {
+int64_t nb_samples = av_clip(st->codecpar->sample_rate / 25, 1, 1024);
+if (st->codecpar->block_align > 0 &&
+st->codecpar->block_align * nb_samples < INT_MAX &&
+st->codecpar->ch_layout.nb_channels > 0 &&
+st->codecpar->block_align <= 8LL * 
st->codecpar->ch_layout.nb_channels) {
+wav->max_size = st->codecpar->block_align * nb_samples;
+} else {
+wav->max_size = 4096;
+}
+}
+}
+
 static void set_spdif(AVFormatContext *s, WAVDemuxContext *wav)
 {
 if (CONFIG_SPDIF_DEMUXER && s->streams[0]->codecpar->codec_tag == 1) {
@@ -669,6 +684,7 @@ break_loop:
 ff_metadata_conv_ctx(s, NULL, ff_riff_info_conv);
 
 set_spdif(s, wav);
+set_max_size(st, wav);
 
 return 0;
 }
@@ -981,6 +997,7 @@ static int w64_read_header(AVFormatContext *s)
 avio_seek(pb, data_ofs, SEEK_SET);
 
 set_spdif(s, wav);
+set_max_size(st, wav);
 
 return 0;
 }
diff --git a/tests/ref/fate/dcinema-encode b/tests/ref/fate/dcinema-encode
index fabbc034f0..566d8f5091 100644
--- a/tests/ref/fate/dcinema-encode
+++ b/tests/ref/fate/dcinema-encode
@@ -7,23 +7,23 @@
 #sample_rate 0: 96000
 

[FFmpeg-cvslog] avformat/iamf_writer: constify some function parameters

2024-03-02 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Mar  2 21:40:10 
2024 -0300| [f8caf388fb80c109909e1e6365d4b814291156e0] | committer: James Almer

avformat/iamf_writer: constify some function parameters

Signed-off-by: James Almer 

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

 libavformat/iamf_writer.c | 4 ++--
 libavformat/iamf_writer.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/iamf_writer.c b/libavformat/iamf_writer.c
index 9ed20fc562..18dc0e284b 100644
--- a/libavformat/iamf_writer.c
+++ b/libavformat/iamf_writer.c
@@ -979,7 +979,7 @@ static int write_parameter_block(const IAMFContext *iamf, 
AVIOContext *pb,
 }
 
 int ff_iamf_write_parameter_blocks(const IAMFContext *iamf, AVIOContext *pb,
-   AVPacket *pkt, void *log_ctx)
+   const AVPacket *pkt, void *log_ctx)
 {
 AVIAMFParamDefinition *mix =
 (AVIAMFParamDefinition *)av_packet_get_side_data(pkt,
@@ -1014,7 +1014,7 @@ int ff_iamf_write_parameter_blocks(const IAMFContext 
*iamf, AVIOContext *pb,
 }
 
 int ff_iamf_write_audio_frame(const IAMFContext *iamf, AVIOContext *pb,
-  unsigned audio_substream_id, AVPacket *pkt)
+  unsigned audio_substream_id, const AVPacket *pkt)
 {
 uint8_t header[MAX_IAMF_OBU_HEADER_SIZE];
 PutBitContext pbc;
diff --git a/libavformat/iamf_writer.h b/libavformat/iamf_writer.h
index 8e2949d8f2..05f3d322b8 100644
--- a/libavformat/iamf_writer.h
+++ b/libavformat/iamf_writer.h
@@ -35,8 +35,8 @@ int ff_iamf_add_mix_presentation(IAMFContext *iamf, const 
AVStreamGroup *stg, vo
 int ff_iamf_write_descriptors(const IAMFContext *iamf, AVIOContext *pb, void 
*log_ctx);
 
 int ff_iamf_write_parameter_blocks(const IAMFContext *iamf, AVIOContext *pb,
-   AVPacket *pkt, void *log_ctx);
+   const AVPacket *pkt, void *log_ctx);
 int ff_iamf_write_audio_frame(const IAMFContext *iamf, AVIOContext *pb,
-  unsigned audio_substream_id, AVPacket *pkt);
+  unsigned audio_substream_id, const AVPacket 
*pkt);
 
 #endif /* AVFORMAT_IAMF_WRITER_H */

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

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