Re: [FFmpeg-devel] [PATCH v2 1/2] avutil/wchar_filename, file_open: Support long file names on Windows

2022-05-16 Thread nil-admirari
> +static inline int path_is_extended(const wchar_t *path)
> +{
> + size_t len = wcslen(path);
> + if (len >= 4 && path[0] == L'\\' && (path[1] == L'\\' || path[1] == L'?') 
> && path[2] == L'?' && path[3] == L'\\')

Length check is probably unnecessary: comparisons will reject '\0'
and further comparisons won't run due to short-circuiting.

> + // The length of unc_prefix is 6 plus 1 for terminating zeros
> + temp_w = (wchar_t *)av_calloc(len + 6 + 1, sizeof(wchar_t));

Not really true. The length of unc_prefix is 8.
2 is subtracted because UNC path already has \\ at the beginning.

> + if (len >= 260 || (*ppath_w)[len - 1] == L' ' || (*ppath_w)[len - 1] == 
> L'.') {

1. Please change 260 to MAX_PATH.
2. GetFullPathName removes trailing spaces and dots, so the second part is 
always false.



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

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


Re: [FFmpeg-devel] [PATCH 2/2] avformat/os_support: Support long file names on Windows

2022-05-16 Thread nil-admirari
> We already have win32_stat, but what's a bit tricky is that the 
> struct that this function takes as a parameter is named the same 
> as the function itself.

Sorry, I thought is was a definition of a function, not a struct.
Since stat function is already defined as win32_stat,
It's better to revert the changes.



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

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


Re: [FFmpeg-devel] [PATCH 1/2] avutil/wchar_filename, file_open: Support long file names on Windows

2022-05-16 Thread nil-admirari
> The functions are needed in both. file_open.c cannot be included
> in libavformat/os_support.h and neither the other way round, 
> so they need to be in a 3rd place. How about renaming
> wchar_filename.h to windows_filename.h ?

Probably it's better to rename.

> I have skipped those checks because we won't have partially qualified
> paths at this point (due to having called GetFullPathNameW) and
> device paths are not allowed to be longer than 260, so this it might
> happen that the UNC prefix gets added, but only when it's a long
> path which doesn't work anyway (I've tested those cases).

I think it's better to test for \\.\ explicitly in path_is_extended:
1. It's not obvious that \\.\ aren't allowed to be long.
2. Probably FFmpeg is not going to have a longPathAware manifest,
   but it can be linked with an EXE with such a manifest.
   Would MAX_PATH restriction still apply?

You have the checks inside of get_extended_win32_path and none
inside of add_extended_prefix. Yet add_extended_prefix can be called
by anyone: it's not private. Thus add_extended_prefix either should be inlined,
or it should have the necessary checks in place. Otherwise you end up with
an API that's easy to use incorrectly and hard to use correctly, and it should 
be
the other way around.



___
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 0/2] Support long file names on Windows

2022-05-16 Thread nil-admirari
> I have left those out by intention because they are pending removal
> and are only for debugging.

Is dvdsubdec.c parse_ifo_palette pending removal? What about
- vf_pnsr.c init()
- vf_vidstabdetect.c config_input()
- vf_vidstabtransform.c config_input()?



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

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


Re: [FFmpeg-devel] [PATCH v4 06/10] libavformat/asfdec: fix macro definition and use

2022-05-16 Thread Andreas Rheinhardt
Soft Works:
> 
> 
>> -Original Message-
>> From: ffmpeg-devel  On Behalf Of
>> Andreas Rheinhardt
>> Sent: Sunday, May 15, 2022 8:12 PM
>> To: ffmpeg-devel@ffmpeg.org
>> Subject: Re: [FFmpeg-devel] [PATCH v4 06/10] libavformat/asfdec: fix
>> macro definition and use
>>
>> softworkz:
>>> From: softworkz 
>>>
>>> Signed-off-by: softworkz 
>>> ---
>>>  libavformat/asfdec_f.c | 24 
>>>  1 file changed, 12 insertions(+), 12 deletions(-)
>>>
>>> diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
>>> index 81a29f99d5..91c3874ac7 100644
>>> --- a/libavformat/asfdec_f.c
>>> +++ b/libavformat/asfdec_f.c
>>> @@ -906,21 +906,21 @@ static int asf_read_header(AVFormatContext *s)
>>>  }
>>>
>>>  #define DO_2BITS(bits, var, defval) \
>>> -switch (bits & 3) { \
>>> +switch ((bits) & 3) {   \
>>>  case 3: \
>>> -var = avio_rl32(pb);\
>>> +(var) = avio_rl32(pb);  \
>>>  rsize += 4; \
>>>  break;  \
>>>  case 2: \
>>> -var = avio_rl16(pb);\
>>> +(var) = avio_rl16(pb);  \
>>>  rsize += 2; \
>>>  break;  \
>>>  case 1: \
>>> -var = avio_r8(pb);  \
>>> +(var) = avio_r8(pb);\
>>>  rsize++;\
>>>  break;  \
>>>  default:\
>>> -var = defval;   \
>>> +(var) = (defval);   \
>>>  break;  \
>>>  }
>>>
>>> @@ -1003,9 +1003,9 @@ static int asf_get_packet(AVFormatContext *s,
>> AVIOContext *pb)
>>>  asf->packet_flags= c;
>>>  asf->packet_property = d;
>>>
>>> -DO_2BITS(asf->packet_flags >> 5, packet_length, s-
>>> packet_size);
>>> -DO_2BITS(asf->packet_flags >> 1, padsize, 0); // sequence
>> ignored
>>> -DO_2BITS(asf->packet_flags >> 3, padsize, 0); // padding length
>>> +DO_2BITS(asf->packet_flags >> 5, packet_length, s->packet_size)
>>> +DO_2BITS(asf->packet_flags >> 1, padsize, 0) // sequence
>> ignored
>>> +DO_2BITS(asf->packet_flags >> 3, padsize, 0) // padding length
>>>
>>>  // the following checks prevent overflows and infinite loops
>>>  if (!packet_length || packet_length >= (1U << 29)) {
>>> @@ -1066,9 +1066,9 @@ static int
>> asf_read_frame_header(AVFormatContext *s, AVIOContext *pb)
>>>  asf->stream_index = asf->asfid2avid[num & 0x7f];
>>>  asfst = &asf->streams[num & 0x7f];
>>>  // sequence should be ignored!
>>> -DO_2BITS(asf->packet_property >> 4, asf->packet_seq, 0);
>>> -DO_2BITS(asf->packet_property >> 2, asf->packet_frag_offset,
>> 0);
>>> -DO_2BITS(asf->packet_property, asf->packet_replic_size, 0);
>>> +DO_2BITS(asf->packet_property >> 4, asf->packet_seq, 0)
>>> +DO_2BITS(asf->packet_property >> 2, asf->packet_frag_offset, 0)
>>> +DO_2BITS(asf->packet_property, asf->packet_replic_size, 0)
>>>  av_log(asf, AV_LOG_TRACE, "key:%d stream:%d seq:%d offset:%d
>> replic_size:%d num:%X packet_property %X\n",
>>>  asf->packet_key_frame, asf->stream_index, asf-
>>> packet_seq,
>>>  asf->packet_frag_offset, asf->packet_replic_size, num,
>> asf->packet_property);
>>> @@ -1144,7 +1144,7 @@ static int
>> asf_read_frame_header(AVFormatContext *s, AVIOContext *pb)
>>>  return AVERROR_INVALIDDATA;
>>>  }
>>>  if (asf->packet_flags & 0x01) {
>>> -DO_2BITS(asf->packet_segsizetype >> 6, asf-
>>> packet_frag_size, 0); // 0 is illegal
>>> +DO_2BITS(asf->packet_segsizetype >> 6, asf-
>>> packet_frag_size, 0) // 0 is illegal
>>>  if (rsize > asf->packet_size_left) {
>>>  av_log(s, AV_LOG_ERROR, "packet_replic_size is
>> invalid\n");
>>>  return AVERROR_INVALIDDATA;
>>
>> While protecting macro arguments is good, it is not really a "fix"
>> unless current usage is buggy.
> 
> Ok, I will rephrase the commit message.
> 
>> Which it isn't here, because >> has higher precedence than &.
> 
> Could you explain which change you are referring to?
> 

Putting "bits" in parentheses. It doesn't change anything, because >>
has higher precedence than &.

> All this patch does is to put macro variables in brackets
> and remove semicolons..
> 
>> Furthermore I am not really sure whether removing the ';' is even
>> something worthwhile; they are surely unnecessary (being null
>> statements), but does this matter?
> 
> It causes a warning
> 
> https://releases.llvm.org/13.0.0/tools/clang/docs/DiagnosticsReference.html#wextr

Re: [FFmpeg-devel] [PATCH v11 1/6] libavutil/wchar_filename.h: Add whcartoutf8, wchartoansi and utf8toansi

2022-05-16 Thread nil-admirari
> And what's the point about this?

Point is obvious: extended paths are difficult to handle correctly.
get_extended_win32_path cannot be used on its own, only as a final step
before getting FILE* or a file descriptor.



___
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] avcodec/mpeg4videodec: Replace always true check by assert

2022-05-16 Thread Andreas Rheinhardt
James Almer:
> 
> 
> On 5/15/2022 10:16 PM, Michael Niedermayer wrote:
>> Maybe helps coverity
>> Helps: CID1433771
>>
>> Signed-off-by: Michael Niedermayer 
>> ---
>>   libavcodec/mpeg4videodec.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
>> index e2bde73639..715cb606c9 100644
>> --- a/libavcodec/mpeg4videodec.c
>> +++ b/libavcodec/mpeg4videodec.c
>> @@ -1981,7 +1981,8 @@ static int
>> mpeg4_decode_studio_block(MpegEncContext *s, int32_t block[64], int n
>>   return AVERROR_INVALIDDATA;
>>   j = scantable[idx++];
>>   block[j] = get_xbits(&s->gb, additional_code_len);
>> -    } else if (group == 21) {
>> +    } else {
>> +    av_assert2(group == 21);
> 
> Group is used as index to access two arrays with 22 elements each at the
> beginning of the while loop here. Maybe just also check for group > 21
> and abort like we're doing for < 0, since it's clearly not a valid or
> expected value.
> 

Looking at ff_mpeg4_studio_intra shows that this is not a possible
value, so it should be an assert, not an ordinary check. So I'd move the
av_assert2 to before group is used in conjunction with ac_state_tab.

>>   /* Escape */
>>   if (idx > 63)
>>   return AVERROR_INVALIDDATA;



___
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/formats: Constify channel_layout in ff_add_channel_layout()

2022-05-16 Thread Andreas Rheinhardt
It copies, not moves the channel layout.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/formats.c | 3 ++-
 libavfilter/formats.h | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index f2c474e279..e8c2888c0c 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -464,7 +464,8 @@ do {
  \
 (*f)->nb++;   \
 } while (0)
 
-int ff_add_channel_layout(AVFilterChannelLayouts **l, AVChannelLayout 
*channel_layout)
+int ff_add_channel_layout(AVFilterChannelLayouts **l,
+  const AVChannelLayout *channel_layout)
 {
 av_assert1(!(*l && (*l)->all_layouts));
 ADD_FORMAT(l, channel_layout, ff_channel_layouts_unref, AVChannelLayout, 
channel_layouts, nb_channel_layouts);
diff --git a/libavfilter/formats.h b/libavfilter/formats.h
index caf23d0792..4dce2d 100644
--- a/libavfilter/formats.h
+++ b/libavfilter/formats.h
@@ -180,7 +180,8 @@ av_warn_unused_result
 int ff_set_common_formats_from_list(AVFilterContext *ctx, const int *fmts);
 
 av_warn_unused_result
-int ff_add_channel_layout(AVFilterChannelLayouts **l, AVChannelLayout 
*channel_layout);
+int ff_add_channel_layout(AVFilterChannelLayouts **l,
+  const AVChannelLayout *channel_layout);
 
 /**
  * Add *ref as a new reference to f.
-- 
2.32.0

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

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


Re: [FFmpeg-devel] [PATCH] lavc: fix h264 parser bug

2022-05-16 Thread Lingjiang Fang
On Fri, 13 May 2022 00:22:02 +0800
Lingjiang Fang  wrote:

ping for review
padding zero after pps may lead to decode crash in same ipads
btw, I am working on update fate cases to fit this bugfix

> will give a wrong nalu length(+1) when next nalu start with 0001
> this bug will lead to an padding zero to pps in AVC Sequence
> header(flv) or in avc1(mpr)
> 
> ---
> 
>  libavcodec/h2645_parse.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
> index 03780680c6..2e941a2bd0 100644
> --- a/libavcodec/h2645_parse.c
> +++ b/libavcodec/h2645_parse.c
> @@ -134,6 +134,10 @@ int ff_h2645_extract_rbsp(const uint8_t *src,
> int length, dst[di++] = src[si++];
>  
>  nsc:
> +if (src[si-1] == 0) {
> +--di;
> +--si;
> +}
>  memset(dst + di, 0, AV_INPUT_BUFFER_PADDING_SIZE);
>  
>  nal->data = dst;



Regards,
Lingjiang Fang
___
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] avcodec/mpeg4videodec: Replace always true check by assert

2022-05-16 Thread Andreas Rheinhardt
Michael Niedermayer:
> Maybe helps coverity
> Helps: CID1433771
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/mpeg4videodec.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
> index e2bde73639..715cb606c9 100644
> --- a/libavcodec/mpeg4videodec.c
> +++ b/libavcodec/mpeg4videodec.c
> @@ -1981,7 +1981,8 @@ static int mpeg4_decode_studio_block(MpegEncContext *s, 
> int32_t block[64], int n
>  return AVERROR_INVALIDDATA;
>  j = scantable[idx++];
>  block[j] = get_xbits(&s->gb, additional_code_len);
> -} else if (group == 21) {
> +} else {
> +av_assert2(group == 21);
>  /* Escape */
>  if (idx > 63)
>  return AVERROR_INVALIDDATA;

This also reminds me of an old attempt of mine to add an AV_UNREACHABLE
macro for such scenarios:
https://github.com/mkver/FFmpeg/commits/unreachable. There are two
reasons why I never sent it to the ML:
a) It uses ASSERT_LEVEL (i.e. with a high ASSERT_LEVEL it degenarates
into an actual assert). But this is only defined internally, so useless
to an API user. Therefore I wonder whether this should be in a public
header (the same issue exists for av_assert1 and av_assert2).
b) Both Clang and MSVC have something more, namely a
__builtin_assume(cond)  resp. __assume(cond). I was unsure whether this
should not be added, too. It could be translated to "if (!(cond))
__builtin_unreachable()" to GCC, but would be more natural in general.
(Of course, cond must not have any side effects.)

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

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


[FFmpeg-devel] [PATCH v1] avformat/mpegts: fix avformat_find_stream_info take too time with open single video/audio TS stream

2022-05-16 Thread gaojiangjie
From: Jiangjie Gao 

1. ref https://trac.ffmpeg.org/ticket/9782.
2. just check `codec_type`.
3. remove `pos > 10`, we have AVFormatContext::probesize.

Signed-off-by: Jiangjie Gao 
---
 libavformat/mpegts.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 6e761c07f1..80ffee0f41 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2870,13 +2870,12 @@ static int handle_packet(MpegTSContext *ts, const 
uint8_t *packet, int64_t pos)
 break;
 }
 if (i == ts->nb_prg && ts->nb_prg > 0) {
-int types = 0;
 for (i = 0; i < ts->stream->nb_streams; i++) {
 AVStream *st = ts->stream->streams[i];
-if (st->codecpar->codec_type >= 0)
-types |= 1codec_type;
+if (st->codecpar->codec_type < 0)
+break;
 }
-if ((types & (1< 10) {
+if (i == ts->stream->nb_streams) {
 av_log(ts->stream, AV_LOG_DEBUG, "All programs have pmt, 
headers found\n");
 ts->stream->ctx_flags &= ~AVFMTCTX_NOHEADER;
 }
-- 
2.27.0.windows.1

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

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


[FFmpeg-devel] [PATCH] AV1 VDPAU hwaccel Decode support

2022-05-16 Thread ManojGuptaBonda
Support for VDPAU accelerated AV1 decoding was added with libvdpau-1.5.
Support for the same in ffmpeg is added with this patch. Profiles
related to VDPAU AV1 can be found in latest vdpau.h present in
libvdpau-1.5.

Add AV1 VDPAU to list of hwaccels and supported formats
Added file vdpau_av1.c and Modified configure to add VDPAU AV1 support.
Mapped AV1 profiles to VDPAU AV1 profiles. Populated the codec specific
params that need to be passed to VDPAU.
---
 Changelog   |   1 +
 configure   |   3 +
 libavcodec/Makefile |   1 +
 libavcodec/av1dec.c |  13 +-
 libavcodec/hwaccels.h   |   1 +
 libavcodec/vdpau_av1.c  | 370 
 libavcodec/vdpau_internal.h |   3 +
 libavcodec/version.h|   2 +-
 8 files changed, 392 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/vdpau_av1.c

diff --git a/Changelog b/Changelog
index 4d42a0f681..a713edf566 100644
--- a/Changelog
+++ b/Changelog
@@ -16,6 +16,7 @@ version 5.1:
 - blurdetect filter
 - multiply video filter
 - PGS subtitle frame merge bitstream filter
+- VDPAU AV1 hwaccel
 
 
 version 5.0:
diff --git a/configure b/configure
index 0faf2455b7..702fb4d741 100755
--- a/configure
+++ b/configure
@@ -3025,6 +3025,8 @@ av1_nvdec_hwaccel_deps="nvdec CUVIDAV1PICPARAMS"
 av1_nvdec_hwaccel_select="av1_decoder"
 av1_vaapi_hwaccel_deps="vaapi VADecPictureParameterBufferAV1_bit_depth_idx"
 av1_vaapi_hwaccel_select="av1_decoder"
+av1_vdpau_hwaccel_deps="vdpau VdpPictureInfoAV1"
+av1_vdpau_hwaccel_select="av1_decoder"
 h263_vaapi_hwaccel_deps="vaapi"
 h263_vaapi_hwaccel_select="h263_decoder"
 h263_videotoolbox_hwaccel_deps="videotoolbox"
@@ -6391,6 +6393,7 @@ check_func_headers mfapi.h MFCreateAlignedMemoryBuffer 
-lmfplat
 
 check_type "vdpau/vdpau.h" "VdpPictureInfoHEVC"
 check_type "vdpau/vdpau.h" "VdpPictureInfoVP9"
+check_type "vdpau/vdpau.h" "VdpPictureInfoAV1"
 
 if [ -z "$nvccflags" ]; then
 nvccflags=$nvccflags_default
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 38425d2f22..813989cee9 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -954,6 +954,7 @@ OBJS-$(CONFIG_AV1_D3D11VA_HWACCEL)+= dxva2_av1.o
 OBJS-$(CONFIG_AV1_DXVA2_HWACCEL)  += dxva2_av1.o
 OBJS-$(CONFIG_AV1_NVDEC_HWACCEL)  += nvdec_av1.o
 OBJS-$(CONFIG_AV1_VAAPI_HWACCEL)  += vaapi_av1.o
+OBJS-$(CONFIG_AV1_VDPAU_HWACCEL)  += vdpau_av1.o
 OBJS-$(CONFIG_H263_VAAPI_HWACCEL) += vaapi_mpeg4.o
 OBJS-$(CONFIG_H263_VIDEOTOOLBOX_HWACCEL)  += videotoolbox.o
 OBJS-$(CONFIG_H264_D3D11VA_HWACCEL)   += dxva2_h264.o
diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 1c09b1d6d6..dd83373dd6 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -441,7 +441,8 @@ static int get_pixel_format(AVCodecContext *avctx)
 #define HWACCEL_MAX (CONFIG_AV1_DXVA2_HWACCEL + \
  CONFIG_AV1_D3D11VA_HWACCEL * 2 + \
  CONFIG_AV1_NVDEC_HWACCEL + \
- CONFIG_AV1_VAAPI_HWACCEL)
+ CONFIG_AV1_VAAPI_HWACCEL + \
+ CONFIG_AV1_VDPAU_HWACCEL)
 enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmtp = pix_fmts;
 
 if (seq->seq_profile == 2 && seq->color_config.high_bitdepth)
@@ -518,6 +519,9 @@ static int get_pixel_format(AVCodecContext *avctx)
 #endif
 #if CONFIG_AV1_VAAPI_HWACCEL
 *fmtp++ = AV_PIX_FMT_VAAPI;
+#endif
+#if CONFIG_AV1_VDPAU_HWACCEL
+*fmtp++ = AV_PIX_FMT_VDPAU;
 #endif
 break;
 case AV_PIX_FMT_YUV420P10:
@@ -533,6 +537,9 @@ static int get_pixel_format(AVCodecContext *avctx)
 #endif
 #if CONFIG_AV1_VAAPI_HWACCEL
 *fmtp++ = AV_PIX_FMT_VAAPI;
+#endif
+#if CONFIG_AV1_VDPAU_HWACCEL
+*fmtp++ = AV_PIX_FMT_VDPAU;
 #endif
 break;
 case AV_PIX_FMT_GRAY8:
@@ -1271,6 +1278,10 @@ const FFCodec ff_av1_decoder = {
 #if CONFIG_AV1_VAAPI_HWACCEL
 HWACCEL_VAAPI(av1),
 #endif
+#if CONFIG_AV1_VDPAU_HWACCEL
+HWACCEL_VDPAU(av1),
+#endif
+
 NULL
 },
 };
diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h
index ff4daca0e2..aca55831f3 100644
--- a/libavcodec/hwaccels.h
+++ b/libavcodec/hwaccels.h
@@ -26,6 +26,7 @@ extern const AVHWAccel ff_av1_d3d11va2_hwaccel;
 extern const AVHWAccel ff_av1_dxva2_hwaccel;
 extern const AVHWAccel ff_av1_nvdec_hwaccel;
 extern const AVHWAccel ff_av1_vaapi_hwaccel;
+extern const AVHWAccel ff_av1_vdpau_hwaccel;
 extern const AVHWAccel ff_h263_vaapi_hwaccel;
 extern const AVHWAccel ff_h263_videotoolbox_hwaccel;
 extern const AVHWAccel ff_h264_d3d11va_hwaccel;
diff --git a/libavcodec/vdpau_av1.c b/libavcodec/vdpau_av1.c
new file mode 100644
index 00..95c1e58cf7
--- /dev/null
+++ b/libavcodec/vdpau_av1.c
@@ -0,0 +1,370 @@
+/*
+ * AV1 HW decode acceleration through VDPAU
+ *
+ * Copyright (c) 2022 Manoj Gupta Bonda
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the ter

Re: [FFmpeg-devel] [PATCH] avutil/csp: create public API for colorspace structs

2022-05-16 Thread Leo Izen

On 5/15/22 12:32, Andreas Rheinhardt wrote:

Leo Izen:

+/* Returns AVCOL_PRI_UNSPECIFIED if no clear match can be identified */
+enum AVColorPrimaries av_detect_color_primaries(const struct ColorPrimaries 
*prm);
+
+const struct ColorPrimaries *av_get_color_primaries(enum AVColorPrimaries prm);
+const struct LumaCoefficients *av_get_luma_coefficients(enum AVColorSpace csp);
+
+#endif /* AVUTIL_CSP_H */


Is there any scenario in which these structs might need to be extended?
This is something that we could no longer easily do if these structs
were public.



I don't believe these will need to be extended since they're somewhat 
simple structs that are meant to contain a very specific set of data, 
not general data about a more abstract object.


- Leo Izen (thebombzen)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] avformat/jpegxl_probe: fix incorrect cw_mask probing

2022-05-16 Thread Leo Izen

On 5/1/22 15:39, Leo Izen wrote:

Fix incorrectly skipping over the upX_weights
if the cw_mask is present and it is not a multiple of 4.


Bumping for review.

- Leo Izen (thebombzen)


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

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


[FFmpeg-devel] [PATCH] avformat/mov: Only read the primary item for AVIF

2022-05-16 Thread Vignesh Venkatasubramanian
Update the still AVIF parser to only read the primary item. With this
patch, AVIF still images with exif/icc/alpha channel will no longer
fail to parse.

For example, this patch enables parsing of files in:
https://github.com/AOMediaCodec/av1-avif/tree/master/testFiles/Microsoft

Partially fixes trac ticket #7621

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

diff --git a/libavformat/isom.h b/libavformat/isom.h
index cf36f04d5b..f05c2d9c28 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -317,6 +317,7 @@ typedef struct MOVContext {
 uint32_t mfra_size;
 uint32_t max_stts_delta;
 int is_still_picture_avif;
+int primary_item_id;
 } MOVContext;
 
 int ff_mp4_read_descr_len(AVIOContext *pb);
diff --git a/libavformat/mov.c b/libavformat/mov.c
index d7be593a86..9310a393fe 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7445,6 +7445,13 @@ static int rb_size(AVIOContext *pb, uint64_t* value, int 
size)
 return size;
 }
 
+static int mov_read_pitm(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+{
+avio_rb32(pb);  // version & flags.
+c->primary_item_id = avio_rb16(pb);
+return atom.size;
+}
+
 static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
 int version, offset_size, length_size, base_offset_size, index_size;
@@ -7501,34 +7508,25 @@ static int mov_read_iloc(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 return AVERROR_PATCHWELCOME;
 }
 item_count = (version < 2) ? avio_rb16(pb) : avio_rb32(pb);
-if (item_count > 1) {
-// For still AVIF images, we only support one item. Second item will
-// generally be found for AVIF images with alpha channel. We don't
-// support them as of now.
-av_log(c->fc, AV_LOG_ERROR, "iloc: item_count > 1 not supported.\n");
-return AVERROR_PATCHWELCOME;
-}
 
 // Populate the necessary fields used by mov_build_index.
-sc->stsc_count = item_count;
-sc->stsc_data = av_malloc_array(item_count, sizeof(*sc->stsc_data));
+sc->stsc_count = 1;
+sc->stsc_data = av_malloc_array(1, sizeof(*sc->stsc_data));
 if (!sc->stsc_data)
 return AVERROR(ENOMEM);
 sc->stsc_data[0].first = 1;
 sc->stsc_data[0].count = 1;
 sc->stsc_data[0].id = 1;
-sc->chunk_count = item_count;
-sc->chunk_offsets =
-av_malloc_array(item_count, sizeof(*sc->chunk_offsets));
+sc->chunk_count = 1;
+sc->chunk_offsets = av_malloc_array(1, sizeof(*sc->chunk_offsets));
 if (!sc->chunk_offsets)
 return AVERROR(ENOMEM);
-sc->sample_count = item_count;
-sc->sample_sizes =
-av_malloc_array(item_count, sizeof(*sc->sample_sizes));
+sc->sample_count = 1;
+sc->sample_sizes = av_malloc_array(1, sizeof(*sc->sample_sizes));
 if (!sc->sample_sizes)
 return AVERROR(ENOMEM);
-sc->stts_count = item_count;
-sc->stts_data = av_malloc_array(item_count, sizeof(*sc->stts_data));
+sc->stts_count = 1;
+sc->stts_data = av_malloc_array(1, sizeof(*sc->stts_data));
 if (!sc->stts_data)
 return AVERROR(ENOMEM);
 sc->stts_data[0].count = 1;
@@ -7536,7 +7534,7 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 sc->stts_data[0].duration = 0;
 
 for (int i = 0; i < item_count; i++) {
-(version < 2) ? avio_rb16(pb) : avio_rb32(pb);  // item_id;
+int item_id = (version < 2) ? avio_rb16(pb) : avio_rb32(pb);
 if (version > 0)
 avio_rb16(pb);  // construction_method.
 avio_rb16(pb);  // data_reference_index.
@@ -7552,8 +7550,10 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 if (rb_size(pb, &extent_offset, offset_size) < 0 ||
 rb_size(pb, &extent_length, length_size) < 0)
 return AVERROR_INVALIDDATA;
-sc->sample_sizes[0] = extent_length;
-sc->chunk_offsets[0] = base_offset + extent_offset;
+if (item_id == c->primary_item_id) {
+sc->sample_sizes[0] = extent_length;
+sc->chunk_offsets[0] = base_offset + extent_offset;
+}
 }
 }
 
@@ -7670,6 +7670,7 @@ static const MOVParseTableEntry mov_default_parse_table[] 
= {
 { MKTAG('S','A','3','D'), mov_read_SA3D }, /* ambisonic audio box */
 { MKTAG('S','A','N','D'), mov_read_SAND }, /* non diegetic audio box */
 { MKTAG('i','l','o','c'), mov_read_iloc },
+{ MKTAG('p','i','t','m'), mov_read_pitm },
 { 0, NULL }
 };
 
-- 
2.36.0.550.gb090851708-goog

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

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


[FFmpeg-devel] [PATCH] avformat/img2: Add support for AVIF mux in image2

2022-05-16 Thread Vignesh Venkatasubramanian
Add support for AVIF muxing in the image2 muxer.

Tested with this example:
ffmpeg -lavfi testsrc=duration=1:size=320x320 -g 1 -flags global_header -c:v 
libaom-av1 -f image2 img-%2d.avif

Signed-off-by: Vignesh Venkatasubramanian 
---
 libavformat/img2enc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index 5ed97bb833..0015297ec2 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -58,6 +58,8 @@ static int write_header(AVFormatContext *s)
 img->muxer = "gif";
 } else if (st->codecpar->codec_id == AV_CODEC_ID_FITS) {
 img->muxer = "fits";
+} else if (st->codecpar->codec_id == AV_CODEC_ID_AV1) {
+img->muxer = "avif";
 } else if (st->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO) {
 const char *str = strrchr(s->url, '.');
 img->split_planes = str
@@ -265,7 +267,7 @@ const AVOutputFormat ff_image2_muxer = {
 .long_name  = NULL_IF_CONFIG_SMALL("image2 sequence"),
 .extensions = 
"bmp,dpx,exr,jls,jpeg,jpg,jxl,ljpg,pam,pbm,pcx,pfm,pgm,pgmyuv,"
   
"png,ppm,sgi,tga,tif,tiff,jp2,j2c,j2k,xwd,sun,ras,rs,im1,im8,"
-  "im24,sunras,vbn,xbm,xface,pix,y",
+  "im24,sunras,vbn,xbm,xface,pix,y,avif",
 .priv_data_size = sizeof(VideoMuxData),
 .video_codec= AV_CODEC_ID_MJPEG,
 .write_header   = write_header,
-- 
2.36.0.550.gb090851708-goog

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

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


[FFmpeg-devel] [PATCH 1/7] avcodec/error_resilience: Only keep what is needed from MECmpContext

2022-05-16 Thread Andreas Rheinhardt
ERContext currently has an embedded MECmpContext, despite only
needing exactly one function from it. This is wasteful because
MECmpContext is pretty large (135 pointers, 1080 B for eight byte
pointers). So keep only what is needed.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/error_resilience.c | 14 --
 libavcodec/error_resilience.h |  3 ++-
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
index e9764f8d96..f957c68d2c 100644
--- a/libavcodec/error_resilience.c
+++ b/libavcodec/error_resilience.c
@@ -766,12 +766,12 @@ static int is_intra_more_likely(ERContext *s)
 } else {
 ff_thread_await_progress(s->last_pic.tf, mb_y, 0);
 }
-is_intra_likely += s->mecc.sad[0](NULL, last_mb_ptr, mb_ptr,
-  linesize[0], 16);
+is_intra_likely += s->sad(NULL, last_mb_ptr, mb_ptr,
+  linesize[0], 16);
 // FIXME need await_progress() here
-is_intra_likely -= s->mecc.sad[0](NULL, last_mb_ptr,
-  last_mb_ptr + linesize[0] * 
16,
-  linesize[0], 16);
+is_intra_likely -= s->sad(NULL, last_mb_ptr,
+  last_mb_ptr + linesize[0] * 16,
+  linesize[0], 16);
 } else {
 if (IS_INTRA(s->cur_pic.mb_type[mb_xy]))
is_intra_likely++;
@@ -790,7 +790,9 @@ void ff_er_frame_start(ERContext *s)
 return;
 
 if (!s->mecc_inited) {
-ff_me_cmp_init(&s->mecc, s->avctx);
+MECmpContext mecc;
+ff_me_cmp_init(&mecc, s->avctx);
+s->sad = mecc.sad[0];
 s->mecc_inited = 1;
 }
 
diff --git a/libavcodec/error_resilience.h b/libavcodec/error_resilience.h
index 2187586618..53e5cf2621 100644
--- a/libavcodec/error_resilience.h
+++ b/libavcodec/error_resilience.h
@@ -52,7 +52,8 @@ typedef struct ERPicture {
 
 typedef struct ERContext {
 AVCodecContext *avctx;
-MECmpContext mecc;
+
+me_cmp_func sad;
 int mecc_inited;
 
 int *mb_index2xy;
-- 
2.32.0

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

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


[FFmpeg-devel] [PATCH 2/7] avcodec/mss2: Remove write-only QpelDSPContext

2022-05-16 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mss2.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c
index ab42d12217..228f66afc0 100644
--- a/libavcodec/mss2.c
+++ b/libavcodec/mss2.c
@@ -42,7 +42,6 @@ typedef struct MSS2Context {
 AVFrame   *last_pic;
 MSS12Context   c;
 MSS2DSPContext dsp;
-QpelDSPContext qdsp;
 SliceContext   sc[2];
 } MSS2Context;
 
@@ -837,7 +836,6 @@ static av_cold int mss2_decode_init(AVCodecContext *avctx)
 return ret;
 }
 ff_mss2dsp_init(&ctx->dsp);
-ff_qpeldsp_init(&ctx->qdsp);
 
 avctx->pix_fmt = c->free_colours == 127 ? AV_PIX_FMT_RGB555
 : AV_PIX_FMT_RGB24;
-- 
2.32.0

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

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


[FFmpeg-devel] [PATCH 3/7] avcodec/mpegvideo: Move float.h inclusion to mpegvideoenc.h

2022-05-16 Thread Andreas Rheinhardt
It is only needed for the options in mpegvideoenc.h.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpegvideo.h| 2 --
 libavcodec/mpegvideoenc.h | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 0f816e5807..a832369f7f 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -28,8 +28,6 @@
 #ifndef AVCODEC_MPEGVIDEO_H
 #define AVCODEC_MPEGVIDEO_H
 
-#include 
-
 #include "avcodec.h"
 #include "blockdsp.h"
 #include "error_resilience.h"
diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h
index fae41457bf..a0e8913ea6 100644
--- a/libavcodec/mpegvideoenc.h
+++ b/libavcodec/mpegvideoenc.h
@@ -28,6 +28,8 @@
 #ifndef AVCODEC_MPEGVIDEOENC_H
 #define AVCODEC_MPEGVIDEOENC_H
 
+#include 
+
 #include "libavutil/opt.h"
 #include "mpegvideo.h"
 
-- 
2.32.0

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

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


[FFmpeg-devel] [PATCH 4/7] avcodec/mpegvideoenc: Remove ineffective [pb]bias options

2022-05-16 Thread Andreas Rheinhardt
The user-provided value is overwritten in ff_mpv_encode_init()
without having ever been read.
(This has been broken when making these options mpegvideo-specific
in commits 910247f1720c6aae422723c05dac6d0b19f20bec and
cf7d2f2d2134c0854edf2db91e7436ac2bc9874f. No one has ever complained,
so this commit removes these fields.)

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpegvideoenc.h | 4 
 libavcodec/version.h  | 2 +-
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h
index a0e8913ea6..ecc389a6d3 100644
--- a/libavcodec/mpegvideoenc.h
+++ b/libavcodec/mpegvideoenc.h
@@ -43,8 +43,6 @@
 #define FF_MPV_FLAG_NAQ  0x0010
 #define FF_MPV_FLAG_MV0  0x0020
 
-#define FF_DEFAULT_QUANT_BIAS 99
-
 #define FF_MPV_OPT_CMP_FUNC \
 { "sad","Sum of absolute differences, fast", 0, AV_OPT_TYPE_CONST, {.i64 = 
FF_CMP_SAD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \
 { "sse","Sum of squared errors", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SSE 
}, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \
@@ -94,8 +92,6 @@ FF_MPV_OPT_CMP_FUNC, \
 {"border_mask", "increase the quantizer for macroblocks close to borders", 
FF_MPV_OFFSET(border_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, 
FLT_MAX, FF_MPV_OPT_FLAGS},\
 {"lmin", "minimum Lagrange factor (VBR)",   
FF_MPV_OFFSET(lmin), AV_OPT_TYPE_INT, {.i64 =  2*FF_QP2LAMBDA }, 0, INT_MAX, 
FF_MPV_OPT_FLAGS },\
 {"lmax", "maximum Lagrange factor (VBR)",   
FF_MPV_OFFSET(lmax), AV_OPT_TYPE_INT, {.i64 = 31*FF_QP2LAMBDA }, 0, INT_MAX, 
FF_MPV_OPT_FLAGS },\
-{"ibias", "intra quant bias",   
FF_MPV_OFFSET(intra_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS 
}, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },   \
-{"pbias", "inter quant bias",   
FF_MPV_OFFSET(inter_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS 
}, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },   \
 {"motion_est", "motion estimation algorithm",   
FF_MPV_OFFSET(motion_est), AV_OPT_TYPE_INT, {.i64 = FF_ME_EPZS }, FF_ME_ZERO, 
FF_ME_XONE, FF_MPV_OPT_FLAGS, "motion_est" },   \
 { "zero", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ZERO }, 0, 0, 
FF_MPV_OPT_FLAGS, "motion_est" }, \
 { "epzs", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_EPZS }, 0, 0, 
FF_MPV_OPT_FLAGS, "motion_est" }, \
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 87b7284a95..5183deb68b 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #include "version_major.h"
 
-#define LIBAVCODEC_VERSION_MINOR  28
+#define LIBAVCODEC_VERSION_MINOR  29
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
2.32.0

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

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


[FFmpeg-devel] [PATCH 5/7] avcodec/mjpegenc: Remove pointless motion-estimation options

2022-05-16 Thread Andreas Rheinhardt
(M)JPEG does not use motion estimation/motion vectors at all.
These options therefore don't affect the output at all.
So remove them.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ituh263enc.c|  2 ++
 libavcodec/mpeg12enc.c |  2 ++
 libavcodec/mpeg4videoenc.c |  1 +
 libavcodec/mpegvideo_enc.c |  1 +
 libavcodec/mpegvideoenc.h  | 16 +---
 libavcodec/version.h   |  2 +-
 6 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c
index e99ebfe076..ca44819639 100644
--- a/libavcodec/ituh263enc.c
+++ b/libavcodec/ituh263enc.c
@@ -885,6 +885,7 @@ static const AVOption h263_options[] = {
 { "obmc", "use overlapped block motion compensation.", 
OFFSET(obmc), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
 { "mb_info",  "emit macroblock info for RFC 2190 packetization, the 
parameter value is the maximum payload size", OFFSET(mb_info), AV_OPT_TYPE_INT, 
{ .i64 = 0 }, 0, INT_MAX, VE },
 FF_MPV_COMMON_OPTS
+FF_MPV_COMMON_MOTION_EST_OPTS
 #if FF_API_MPEGVIDEO_OPTS
 FF_MPV_DEPRECATED_MPEG_QUANT_OPT
 FF_MPV_DEPRECATED_A53_CC_OPT
@@ -921,6 +922,7 @@ static const AVOption h263p_options[] = {
 { "obmc",   "use overlapped block motion compensation.", OFFSET(obmc), 
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
 { "structured_slices", "Write slice start position at every GOB header 
instead of just GOB number.", OFFSET(h263_slice_structured), AV_OPT_TYPE_BOOL, 
{ .i64 = 0 }, 0, 1, VE},
 FF_MPV_COMMON_OPTS
+FF_MPV_COMMON_MOTION_EST_OPTS
 #if FF_API_MPEGVIDEO_OPTS
 FF_MPV_DEPRECATED_MPEG_QUANT_OPT
 FF_MPV_DEPRECATED_A53_CC_OPT
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 8d867cd7d0..e4980240c5 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -1172,6 +1172,7 @@ av_cold void ff_mpeg1_encode_init(MpegEncContext *s)
 static const AVOption mpeg1_options[] = {
 COMMON_OPTS
 FF_MPV_COMMON_OPTS
+FF_MPV_COMMON_MOTION_EST_OPTS
 #if FF_API_MPEGVIDEO_OPTS
 FF_MPV_DEPRECATED_MPEG_QUANT_OPT
 FF_MPV_DEPRECATED_A53_CC_OPT
@@ -1205,6 +1206,7 @@ static const AVOption mpeg2_options[] = {
 { LEVEL("low", 10) },
 #undef LEVEL
 FF_MPV_COMMON_OPTS
+FF_MPV_COMMON_MOTION_EST_OPTS
 #if FF_API_MPEGVIDEO_OPTS
 { "mpeg_quant",   "Deprecated, does nothing", 
FF_MPV_OFFSET(mpeg_quant),
   AV_OPT_TYPE_INT, {.i64 = 1 }, 0, 1, VE | AV_OPT_FLAG_DEPRECATED },
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index 69770dc153..45bba455bf 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -1379,6 +1379,7 @@ static const AVOption options[] = {
   OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, VE },
 FF_MPV_COMMON_BFRAME_OPTS
 FF_MPV_COMMON_OPTS
+FF_MPV_COMMON_MOTION_EST_OPTS
 #if FF_API_MPEGVIDEO_OPTS
 FF_MPV_DEPRECATED_A53_CC_OPT
 FF_MPV_DEPRECATED_MATRIX_OPT
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index c9d8c48026..1ef3e6f4a2 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -94,6 +94,7 @@ static uint8_t default_fcode_tab[MAX_MV * 2 + 1];
 
 static const AVOption mpv_generic_options[] = {
 FF_MPV_COMMON_OPTS
+FF_MPV_COMMON_MOTION_EST_OPTS
 #if FF_API_MPEGVIDEO_OPTS
 FF_MPV_DEPRECATED_MPEG_QUANT_OPT
 FF_MPV_DEPRECATED_A53_CC_OPT
diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h
index ecc389a6d3..a5f1014b50 100644
--- a/libavcodec/mpegvideoenc.h
+++ b/libavcodec/mpegvideoenc.h
@@ -92,10 +92,6 @@ FF_MPV_OPT_CMP_FUNC, \
 {"border_mask", "increase the quantizer for macroblocks close to borders", 
FF_MPV_OFFSET(border_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, 
FLT_MAX, FF_MPV_OPT_FLAGS},\
 {"lmin", "minimum Lagrange factor (VBR)",   
FF_MPV_OFFSET(lmin), AV_OPT_TYPE_INT, {.i64 =  2*FF_QP2LAMBDA }, 0, INT_MAX, 
FF_MPV_OPT_FLAGS },\
 {"lmax", "maximum Lagrange factor (VBR)",   
FF_MPV_OFFSET(lmax), AV_OPT_TYPE_INT, {.i64 = 31*FF_QP2LAMBDA }, 0, INT_MAX, 
FF_MPV_OPT_FLAGS },\
-{"motion_est", "motion estimation algorithm",   
FF_MPV_OFFSET(motion_est), AV_OPT_TYPE_INT, {.i64 = FF_ME_EPZS }, FF_ME_ZERO, 
FF_ME_XONE, FF_MPV_OPT_FLAGS, "motion_est" },   \
-{ "zero", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ZERO }, 0, 0, 
FF_MPV_OPT_FLAGS, "motion_est" }, \
-{ "epzs", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_EPZS }, 0, 0, 
FF_MPV_OPT_FLAGS, "motion_est" }, \
-{ "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, 
FF_MPV_OPT_FLAGS, "motion_est" }, \
 {"skip_threshold", "Frame skip threshold",  
FF_MPV_OFFSET(frame_skip_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, 
INT_MAX, FF_MPV_OPT_FLAGS }, \
 {"skip_factor", "Frame skip factor",
FF_MPV_OFFSET(frame_skip_factor), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, 

[FFmpeg-devel] [PATCH 6/7] avcodec/mpegvideoenc: Remove ineffective options

2022-05-16 Thread Andreas Rheinhardt
This commit removes the ineffective FF_MPV_DEPRECATED_ options,
namely mpeg_quant (this is only an option for MPEG-4), a53cc
(this is only an option for MPEG-2), force_duplicated_matrix
(applies only to MJPEG) and b_strategy, b_sensitivity and brd_scale
(these options only make sense for encoders supporting B-frames,
which currently means the MPEG-1/2 and MPEG-4 encoders).
Given that these options never changed the outcome of encoding,
they are removed at once.

Notice that the options for the encoders for which it made sense
are not affected by this.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ituh263enc.c| 12 
 libavcodec/mjpegenc.c  |  5 -
 libavcodec/mpeg12enc.c | 11 +--
 libavcodec/mpeg4videoenc.c |  4 
 libavcodec/mpegvideo.h |  2 +-
 libavcodec/mpegvideo_enc.c |  6 --
 libavcodec/mpegvideoenc.h  | 13 -
 libavcodec/version.h   |  2 +-
 libavcodec/version_major.h |  1 -
 9 files changed, 3 insertions(+), 53 deletions(-)

diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c
index ca44819639..2fcd001dba 100644
--- a/libavcodec/ituh263enc.c
+++ b/libavcodec/ituh263enc.c
@@ -886,12 +886,6 @@ static const AVOption h263_options[] = {
 { "mb_info",  "emit macroblock info for RFC 2190 packetization, the 
parameter value is the maximum payload size", OFFSET(mb_info), AV_OPT_TYPE_INT, 
{ .i64 = 0 }, 0, INT_MAX, VE },
 FF_MPV_COMMON_OPTS
 FF_MPV_COMMON_MOTION_EST_OPTS
-#if FF_API_MPEGVIDEO_OPTS
-FF_MPV_DEPRECATED_MPEG_QUANT_OPT
-FF_MPV_DEPRECATED_A53_CC_OPT
-FF_MPV_DEPRECATED_MATRIX_OPT
-FF_MPV_DEPRECATED_BFRAME_OPTS
-#endif
 { NULL },
 };
 
@@ -923,12 +917,6 @@ static const AVOption h263p_options[] = {
 { "structured_slices", "Write slice start position at every GOB header 
instead of just GOB number.", OFFSET(h263_slice_structured), AV_OPT_TYPE_BOOL, 
{ .i64 = 0 }, 0, 1, VE},
 FF_MPV_COMMON_OPTS
 FF_MPV_COMMON_MOTION_EST_OPTS
-#if FF_API_MPEGVIDEO_OPTS
-FF_MPV_DEPRECATED_MPEG_QUANT_OPT
-FF_MPV_DEPRECATED_A53_CC_OPT
-FF_MPV_DEPRECATED_MATRIX_OPT
-FF_MPV_DEPRECATED_BFRAME_OPTS
-#endif
 { NULL },
 };
 static const AVClass h263p_class = {
diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 8cada8366c..0ba166da5d 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -637,11 +637,6 @@ FF_MPV_COMMON_OPTS
 { "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = HUFFMAN_TABLE_DEFAULT }, 
INT_MIN, INT_MAX, VE, "huffman" },
 { "optimal", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = HUFFMAN_TABLE_OPTIMAL }, 
INT_MIN, INT_MAX, VE, "huffman" },
 { "force_duplicated_matrix", "Always write luma and chroma matrix for mjpeg, 
useful for rtp streaming.", OFFSET(force_duplicated_matrix), AV_OPT_TYPE_BOOL, 
{.i64 = 0 }, 0, 1, VE },
-#if FF_API_MPEGVIDEO_OPTS
-FF_MPV_DEPRECATED_MPEG_QUANT_OPT
-FF_MPV_DEPRECATED_A53_CC_OPT
-FF_MPV_DEPRECATED_BFRAME_OPTS
-#endif
 { NULL},
 };
 
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index e4980240c5..09d63ff7dc 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -1142,6 +1142,7 @@ av_cold void ff_mpeg1_encode_init(MpegEncContext *s)
 } else {
 s->min_qcoeff = -2047;
 s->max_qcoeff = 2047;
+s->mpeg_quant = 1;
 }
 if (s->intra_vlc_format) {
 s->intra_ac_vlc_length  =
@@ -1173,11 +1174,6 @@ static const AVOption mpeg1_options[] = {
 COMMON_OPTS
 FF_MPV_COMMON_OPTS
 FF_MPV_COMMON_MOTION_EST_OPTS
-#if FF_API_MPEGVIDEO_OPTS
-FF_MPV_DEPRECATED_MPEG_QUANT_OPT
-FF_MPV_DEPRECATED_A53_CC_OPT
-FF_MPV_DEPRECATED_MATRIX_OPT
-#endif
 { NULL },
 };
 
@@ -1207,11 +1203,6 @@ static const AVOption mpeg2_options[] = {
 #undef LEVEL
 FF_MPV_COMMON_OPTS
 FF_MPV_COMMON_MOTION_EST_OPTS
-#if FF_API_MPEGVIDEO_OPTS
-{ "mpeg_quant",   "Deprecated, does nothing", 
FF_MPV_OFFSET(mpeg_quant),
-  AV_OPT_TYPE_INT, {.i64 = 1 }, 0, 1, VE | AV_OPT_FLAG_DEPRECATED },
-FF_MPV_DEPRECATED_MATRIX_OPT
-#endif
 FF_MPEG2_PROFILE_OPTS
 { NULL },
 };
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index 45bba455bf..8f0452de3a 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -1380,10 +1380,6 @@ static const AVOption options[] = {
 FF_MPV_COMMON_BFRAME_OPTS
 FF_MPV_COMMON_OPTS
 FF_MPV_COMMON_MOTION_EST_OPTS
-#if FF_API_MPEGVIDEO_OPTS
-FF_MPV_DEPRECATED_A53_CC_OPT
-FF_MPV_DEPRECATED_MATRIX_OPT
-#endif
 FF_MPEG4_PROFILE_OPTS
 { NULL },
 };
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index a832369f7f..4b07c5bfb2 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -537,7 +537,7 @@ typedef struct MpegEncContext {
 
 int intra_penalty;
 
-#if FF_API_MPEGVIDEO_OPTS || FF_API_MJPEG_PRED
+#if FF_API_MJPEG_PRED
 int dummy;   ///< used as target for deprecated options
 #endif
 } MpegEncContext;
diff --git a/libavcodec/mpeg

[FFmpeg-devel] [PATCH 7/7] avcodec/mjpegenc: Remove ineffective pred option

2022-05-16 Thread Andreas Rheinhardt
Never did anything, so it is removed immediately.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mjpegenc.c  | 6 --
 libavcodec/mpegvideo.h | 4 
 libavcodec/version.h   | 2 +-
 libavcodec/version_major.h | 1 -
 4 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 0ba166da5d..27217441a3 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -627,12 +627,6 @@ static int amv_encode_picture(AVCodecContext *avctx, 
AVPacket *pkt,
 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
 FF_MPV_COMMON_OPTS
-#if FF_API_MJPEG_PRED
-{ "pred", "Deprecated, does nothing", FF_MPV_OFFSET(dummy), AV_OPT_TYPE_INT, { 
.i64 = 1 }, 1, 3, VE, "pred" },
-{ "left",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, 
VE, "pred" },
-{ "plane",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, INT_MIN, INT_MAX, 
VE, "pred" },
-{ "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 3 }, INT_MIN, INT_MAX, 
VE, "pred" },
-#endif
 { "huffman", "Huffman table strategy", OFFSET(huffman), AV_OPT_TYPE_INT, { 
.i64 = HUFFMAN_TABLE_OPTIMAL }, 0, NB_HUFFMAN_TABLE_OPTION - 1, VE, "huffman" },
 { "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = HUFFMAN_TABLE_DEFAULT }, 
INT_MIN, INT_MAX, VE, "huffman" },
 { "optimal", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = HUFFMAN_TABLE_OPTIMAL }, 
INT_MIN, INT_MAX, VE, "huffman" },
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 4b07c5bfb2..82889a0edd 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -536,10 +536,6 @@ typedef struct MpegEncContext {
 int noise_reduction;
 
 int intra_penalty;
-
-#if FF_API_MJPEG_PRED
-int dummy;   ///< used as target for deprecated options
-#endif
 } MpegEncContext;
 
 
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 497389d3f3..56dbb9238d 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #include "version_major.h"
 
-#define LIBAVCODEC_VERSION_MINOR  31
+#define LIBAVCODEC_VERSION_MINOR  32
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
diff --git a/libavcodec/version_major.h b/libavcodec/version_major.h
index 87609d5436..1e23ed5e03 100644
--- a/libavcodec/version_major.h
+++ b/libavcodec/version_major.h
@@ -48,7 +48,6 @@
 #define FF_API_AVCTX_TIMEBASE(LIBAVCODEC_VERSION_MAJOR < 60)
 #define FF_API_FLAG_TRUNCATED  (LIBAVCODEC_VERSION_MAJOR < 60)
 #define FF_API_SUB_TEXT_FORMAT (LIBAVCODEC_VERSION_MAJOR < 60)
-#define FF_API_MJPEG_PRED  (LIBAVCODEC_VERSION_MAJOR < 60)
 #define FF_API_IDCT_NONE   (LIBAVCODEC_VERSION_MAJOR < 60)
 #define FF_API_SVTAV1_OPTS (LIBAVCODEC_VERSION_MAJOR < 60)
 
-- 
2.32.0

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

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


Re: [FFmpeg-devel] [PATCH v2] avcodec/libaomenc: Add unmet target level warning

2022-05-16 Thread Bohan Li
Another ping :)

On Fri, Apr 29, 2022 at 2:46 PM Bohan Li  wrote:

> Gentle ping on this :)
>
> On Tue, Apr 19, 2022 at 11:20 AM Bohan Li  wrote:
>
>> When target levels are set, this patch checks whether they are
>> satisfied by libaom. If not, a warning is shown. Otherwise the output
>> levels are also logged.
>>
>> This patch applies basically the same approach used for libvpx.
>>
>> Signed-off-by: Bohan Li 
>> ---
>>  libavcodec/libaomenc.c | 64 ++
>>  1 file changed, 64 insertions(+)
>>
>> diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
>> index 054903e6e2..77be56fa51 100644
>> --- a/libavcodec/libaomenc.c
>> +++ b/libavcodec/libaomenc.c
>> @@ -198,6 +198,12 @@ static const char *const ctlidstr[] = {
>>  [AV1E_SET_ENABLE_SMOOTH_INTERINTRA] =
>> "AV1E_SET_ENABLE_SMOOTH_INTERINTRA",
>>  [AV1E_SET_ENABLE_REF_FRAME_MVS] =
>> "AV1E_SET_ENABLE_REF_FRAME_MVS",
>>  #endif
>> +#ifdef AOM_CTRL_AV1E_GET_SEQ_LEVEL_IDX
>> +[AV1E_GET_SEQ_LEVEL_IDX]= "AV1E_GET_SEQ_LEVEL_IDX",
>> +#endif
>> +#ifdef AOM_CTRL_AV1E_GET_TARGET_SEQ_LEVEL_IDX
>> +[AV1E_GET_TARGET_SEQ_LEVEL_IDX] =
>> "AV1E_GET_TARGET_SEQ_LEVEL_IDX",
>> +#endif
>>  };
>>
>>  static av_cold void log_encoder_error(AVCodecContext *avctx, const char
>> *desc)
>> @@ -323,10 +329,68 @@ static av_cold int codecctl_int(AVCodecContext
>> *avctx,
>>  return 0;
>>  }
>>
>> +#if defined(AOM_CTRL_AV1E_GET_SEQ_LEVEL_IDX) && \
>> +defined(AOM_CTRL_AV1E_GET_TARGET_SEQ_LEVEL_IDX)
>> +static av_cold int codecctl_intp(AVCodecContext *avctx,
>> +#ifdef UENUM1BYTE
>> + aome_enc_control_id id,
>> +#else
>> + enum aome_enc_control_id id,
>> +#endif
>> + int* ptr)
>> +{
>> +AOMContext *ctx = avctx->priv_data;
>> +char buf[80];
>> +int width = -30;
>> +int res;
>> +
>> +snprintf(buf, sizeof(buf), "%s:", ctlidstr[id]);
>> +av_log(avctx, AV_LOG_DEBUG, "  %*s%d\n", width, buf, *ptr);
>> +
>> +res = aom_codec_control(&ctx->encoder, id, ptr);
>> +if (res != AOM_CODEC_OK) {
>> +snprintf(buf, sizeof(buf), "Failed to set %s codec control",
>> + ctlidstr[id]);
>> +log_encoder_error(avctx, buf);
>> +return AVERROR(EINVAL);
>> +}
>> +
>> +return 0;
>> +}
>> +#endif
>> +
>>  static av_cold int aom_free(AVCodecContext *avctx)
>>  {
>>  AOMContext *ctx = avctx->priv_data;
>>
>> +#if defined(AOM_CTRL_AV1E_GET_SEQ_LEVEL_IDX) && \
>> +defined(AOM_CTRL_AV1E_GET_TARGET_SEQ_LEVEL_IDX)
>> +if (!(avctx->flags & AV_CODEC_FLAG_PASS1)) {
>> +int levels[32] = { 0 };
>> +int target_levels[32] = { 0 };
>> +
>> +if (!codecctl_intp(avctx, AV1E_GET_SEQ_LEVEL_IDX, levels) &&
>> +!codecctl_intp(avctx, AV1E_GET_TARGET_SEQ_LEVEL_IDX,
>> +   target_levels)) {
>> +for (int i = 0; i < 32; i++) {
>> +if (levels[i] > target_levels[i]) {
>> +// Warn when the target level was not met
>> +av_log(avctx, AV_LOG_WARNING,
>> +   "Could not encode to target level %d.%d for "
>> +   "operating point %d. The output level is
>> %d.%d.\n",
>> +   2 + (target_levels[i] >> 2), target_levels[i]
>> & 3,
>> +   i, 2 + (levels[i] >> 2), levels[i] & 3);
>> +} else if (target_levels[i] < 31) {
>> +// Log the encoded level if a target level was given
>> +av_log(avctx, AV_LOG_INFO,
>> +   "Output level for operating point %d is
>> %d.%d.\n",
>> +   i, 2 + (levels[i] >> 2), levels[i] & 3);
>> +}
>> +}
>> +}
>> +}
>> +#endif
>> +
>>  aom_codec_destroy(&ctx->encoder);
>>  av_freep(&ctx->twopass_stats.buf);
>>  av_freep(&avctx->stats_out);
>> --
>> 2.36.0.rc0.470.gd361397f0d-goog
>>
>>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH v2 1/2] avutil/wchar_filename, file_open: Support long file names on Windows

2022-05-16 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of nil-
> admir...@mailo.com
> Sent: Monday, May 16, 2022 10:12 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v2 1/2] avutil/wchar_filename,
> file_open: Support long file names on Windows
> 
> > +static inline int path_is_extended(const wchar_t *path)
> > +{
> > + size_t len = wcslen(path);
> > + if (len >= 4 && path[0] == L'\\' && (path[1] == L'\\' || path[1]
> == L'?') && path[2] == L'?' && path[3] == L'\\')
> 
> Length check is probably unnecessary: comparisons will reject '\0'
> and further comparisons won't run due to short-circuiting.

Yup, I think you're right, even though it would appear "unsafe" at
first sight. I've removed the length check.


> > + // The length of unc_prefix is 6 plus 1 for terminating zeros
> > + temp_w = (wchar_t *)av_calloc(len + 6 + 1, sizeof(wchar_t));
> 
> Not really true. The length of unc_prefix is 8.
> 2 is subtracted because UNC path already has \\ at the beginning.

Correct. It actually needs to be "len - 2 + 8 + 1".
I've updated the comment and the calculation.


> > + if (len >= 260 || (*ppath_w)[len - 1] == L' ' || (*ppath_w)[len -
> 1] == L'.') {
> 
> 1. Please change 260 to MAX_PATH.

Done.


> 2. GetFullPathName removes trailing spaces and dots, so the second
> part is always false.

Yea, when someone would want to handle such (weird) kind of path,
one would need to specify an extended path directly.
Removed the second part.


> > We already have win32_stat, but what's a bit tricky is that the
> > struct that this function takes as a parameter is named the same
> > as the function itself.
> 
> Sorry, I thought is was a definition of a function, not a struct.
> Since stat function is already defined as win32_stat,
> It's better to revert the changes.

stat wasn't already defined as win32_stat.
win32_stat was already defined but not mapped. That's what my change
does. 


> > The functions are needed in both. file_open.c cannot be included
> > in libavformat/os_support.h and neither the other way round,
> > so they need to be in a 3rd place. How about renaming
> > wchar_filename.h to windows_filename.h ?
> 
> Probably it's better to rename.

OK, but let's do this in subsequent patch shortly after.


> > I have skipped those checks because we won't have partially
> qualified
> > paths at this point (due to having called GetFullPathNameW) and
> > device paths are not allowed to be longer than 260, so this it might
> > happen that the UNC prefix gets added, but only when it's a long
> > path which doesn't work anyway (I've tested those cases).
> 
> I think it's better to test for \\.\ explicitly in path_is_extended:
> 1. It's not obvious that \\.\ aren't allowed to be long.
> 2. Probably FFmpeg is not going to have a longPathAware manifest,
>but it can be linked with an EXE with such a manifest.
>Would MAX_PATH restriction still apply?

That's a good question, but we need to be clear that device paths are
actually intended for accessing devices, e.g. like \\.\COM1
The fact that the prefix also works with a drive-letter path
is more due to some heritage and nobody would normally want to 
use such kind of paths to access files.

That being said, I've added a check (path_is_device_path()) for 
this now in the same way as .NET is doing it - which means
inside add_extended_prefix().


> You have the checks inside of get_extended_win32_path and none
> inside of add_extended_prefix. Yet add_extended_prefix can be called
> by anyone: it's not private. Thus add_extended_prefix either should be
> inlined,
> or it should have the necessary checks in place. Otherwise you end up
> with
> an API that's easy to use incorrectly and hard to use correctly, and
> it should be the other way around.

I have added checks there now for both device path and extended path
prefix. I have also clarified the function doc even further, so I 
hope it's sufficiently clear now. ;-)


> > And what's the point about this?
> 
> Point is obvious: extended paths are difficult to handle correctly.
> get_extended_win32_path cannot be used on its own, only as a final
> step before getting FILE* or a file descriptor.

Yes, that's how it's meant to be used, so the whole application can
be kept free from dealing with it.


Thanks again for the review, these were some good improvements.

Kind regards,
softworkz




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

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


[FFmpeg-devel] [PATCH v3 0/2] Support long file names on Windows

2022-05-16 Thread ffmpegagent
This patchset adds support for long file and directory paths on Windows. The
implementation follows the same logic that .NET is using internally, with
the only exception that it doesn't expand short path components in 8.3
format. .NET does this as the same function is also used for other purposes,
but in our case, that's not required. Short (8.3) paths are working as well
with the extended path prefix, even when longer than 260.

Successfully tested:

 * Regular paths wth drive letter
 * Regular UNC paths
 * Long paths wth drive letter
 * Long paths wth drive letter and forward slashes
 * Long UNC paths
 * Prefixed paths wth drive letter
 * Prefixed UNC paths

I have kept the individual functions separate on purpose, to make it easy to
compare with the .NET impl. (compilers should inlinie those anyway)

v2

 * wchar_filename: Improve comments and function documentation
 * os_support: adjust defines to use win32_stat

v3

 * removed length check in path_is_extended()
 * added path_is_device_path() check in add_extended_prefix()
 * add_extended_prefix(): clarified doc and add checks
 * clarified string allocation length calculation
 * replaced 260 with MAX_PATH
 * removed redundant checks after normalization

softworkz (2):
  avutil/wchar_filename,file_open: Support long file names on Windows
  avformat/os_support: Support long file names on Windows

 libavformat/os_support.h   |  26 --
 libavutil/file_open.c  |   2 +-
 libavutil/wchar_filename.h | 166 +
 3 files changed, 188 insertions(+), 6 deletions(-)


base-commit: e3580f60775c897c3b13b178c57ab191ecc4a031
Published-As: 
https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-28%2Fsoftworkz%2Fsubmit_long_filenames-v3
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg 
pr-ffstaging-28/softworkz/submit_long_filenames-v3
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/28

Range-diff vs v2:

 1:  b66dbdf40c ! 1:  ce70f7b021 avutil/wchar_filename,file_open: Support long 
file names on Windows
 @@ libavutil/wchar_filename.h: static inline int utf8towchar(const char 
*filename_u
  + */
  +static inline int path_is_extended(const wchar_t *path)
  +{
 -+size_t len = wcslen(path);
 -+if (len >= 4  && path[0] == L'\\' && (path[1] == L'\\' || path[1] == 
L'?') && path[2] == L'?' && path[3] == L'\\')
 ++if (path[0] == L'\\' && (path[1] == L'\\' || path[1] == L'?') && 
path[2] == L'?' && path[3] == L'\\')
 ++return 1;
 ++
 ++return 0;
 ++}
 ++
 ++/**
 ++ * Checks for a device path prefix.
 ++ * see .NET6: PathInternal.IsDevicePath()
 ++ */
 ++static inline int path_is_device_path(const wchar_t *path)
 ++{
 ++if (path[0] == L'\\' && path[1] == L'\\' && path[2] == L'.' && 
path[3] == L'\\')
  +return 1;
  +
  +return 0;
 @@ libavutil/wchar_filename.h: static inline int utf8towchar(const char 
*filename_u
  + * Adds an extended path or UNC prefix to longs paths or paths ending
  + * with a space or a dot. (' ' or '.').
  + * This function expects that the path has been normalized before by
 -+ * calling path_normalize().
 ++ * calling path_normalize() and it doesn't check whether the path is
 ++ * actually long (> MAX_PATH).
  + * see .NET6: PathInternal.EnsureExtendedPrefix() *
  + */
  +static inline int add_extended_prefix(wchar_t **ppath_w)
 @@ libavutil/wchar_filename.h: static inline int utf8towchar(const char 
*filename_u
  +const size_t len= wcslen(path_w);
  +wchar_t *temp_w;
  +
 -+if (len < 2)
 ++/* We're skipping the check IsPartiallyQualified() because
 ++ * we expect to have called GetFullPathNameW() already. */
 ++if (len < 2 || path_is_extended(*ppath_w) || 
path_is_device_path(*ppath_w)) {
  +return 0;
 ++}
  +
 -+/* We're skipping the check IsPartiallyQualified() because
 -+ * we know we have called GetFullPathNameW() already, also
 -+ * we don't check IsDevice() because device paths are not
 -+ * allowed to be long paths and we're calling this only
 -+ * for long paths.
 -+ */
  +if (path_w[0] == L'\\' && path_w[1] == L'\\') {
 -+// The length of unc_prefix is 6 plus 1 for terminating zeros
 -+temp_w = (wchar_t *)av_calloc(len + 6 + 1, sizeof(wchar_t));
 ++/* unc_prefix length is 8 plus 1 for terminating zeros,
 ++ * we subtract 2 for the leading '\\' of the original path */
 ++temp_w = (wchar_t *)av_calloc(len - 2 + 8 + 1, sizeof(wchar_t));
  +if (!temp_w) {
  +errno = ENOMEM;
  +return -1;
 @@ libavutil/wchar_filename.h: static inline int utf8towchar(const char 
*filename_u
  + * APIs. Paths with extended path prefix (either '\\?\' or \??\') are
  + * le

[FFmpeg-devel] [PATCH v3 1/2] avutil/wchar_filename, file_open: Support long file names on Windows

2022-05-16 Thread softworkz
From: softworkz 

Signed-off-by: softworkz 
---
 libavutil/file_open.c  |   2 +-
 libavutil/wchar_filename.h | 166 +
 2 files changed, 167 insertions(+), 1 deletion(-)

diff --git a/libavutil/file_open.c b/libavutil/file_open.c
index cc302f2f76..57c5e78d51 100644
--- a/libavutil/file_open.c
+++ b/libavutil/file_open.c
@@ -45,7 +45,7 @@ static int win32_open(const char *filename_utf8, int oflag, 
int pmode)
 wchar_t *filename_w;
 
 /* convert UTF-8 to wide chars */
-if (utf8towchar(filename_utf8, &filename_w))
+if (get_extended_win32_path(filename_utf8, &filename_w))
 return -1;
 if (!filename_w)
 goto fallback;
diff --git a/libavutil/wchar_filename.h b/libavutil/wchar_filename.h
index 90f082452c..94f8ce54b5 100644
--- a/libavutil/wchar_filename.h
+++ b/libavutil/wchar_filename.h
@@ -40,6 +40,172 @@ static inline int utf8towchar(const char *filename_utf8, 
wchar_t **filename_w)
 MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, *filename_w, num_chars);
 return 0;
 }
+
+/**
+ * Checks for extended path prefixes for which normalization needs to be 
skipped.
+ * see .NET6: PathInternal.IsExtended()
+ */
+static inline int path_is_extended(const wchar_t *path)
+{
+if (path[0] == L'\\' && (path[1] == L'\\' || path[1] == L'?') && path[2] 
== L'?' && path[3] == L'\\')
+return 1;
+
+return 0;
+}
+
+/**
+ * Checks for a device path prefix.
+ * see .NET6: PathInternal.IsDevicePath()
+ */
+static inline int path_is_device_path(const wchar_t *path)
+{
+if (path[0] == L'\\' && path[1] == L'\\' && path[2] == L'.' && path[3] == 
L'\\')
+return 1;
+
+return 0;
+}
+
+/**
+ * Performs path normalization by calling GetFullPathNameW().
+ * see .NET6: PathHelper.GetFullPathName()
+ */
+static inline int get_full_path_name(wchar_t **ppath_w)
+{
+int num_chars;
+wchar_t *temp_w;
+
+num_chars = GetFullPathNameW(*ppath_w, 0, NULL, NULL);
+if (num_chars <= 0) {
+errno = EINVAL;
+return -1;
+}
+
+temp_w = (wchar_t *)av_calloc(num_chars, sizeof(wchar_t));
+if (!temp_w) {
+errno = ENOMEM;
+return -1;
+}
+
+num_chars = GetFullPathNameW(*ppath_w, num_chars, temp_w, NULL);
+if (num_chars <= 0) {
+errno = EINVAL;
+return -1;
+}
+
+av_freep(ppath_w);
+*ppath_w = temp_w;
+
+return 0;
+}
+
+/**
+ * Normalizes a Windows file or folder path.
+ * Expansion of short paths (with 8.3 path components) is currently omitted
+ * as it is not required for accessing long paths.
+ * see .NET6: PathHelper.Normalize().
+ */
+static inline int path_normalize(wchar_t **ppath_w)
+{
+int ret;
+
+if ((ret = get_full_path_name(ppath_w)) < 0)
+return ret;
+
+/* What .NET does at this point is to call 
PathHelper.TryExpandShortFileName()
+ * in case the path contains a '~' character.
+ * We don't need to do this as we don't need to normalize the file name
+ * for presentation, and the extended path prefix works with 8.3 path
+ * components as well
+ */
+return 0;
+}
+
+/**
+ * Adds an extended path or UNC prefix to longs paths or paths ending
+ * with a space or a dot. (' ' or '.').
+ * This function expects that the path has been normalized before by
+ * calling path_normalize() and it doesn't check whether the path is
+ * actually long (> MAX_PATH).
+ * see .NET6: PathInternal.EnsureExtendedPrefix() *
+ */
+static inline int add_extended_prefix(wchar_t **ppath_w)
+{
+const wchar_t *unc_prefix   = L"?\\UNC\\";
+const wchar_t *extended_path_prefix = L"?\\";
+const wchar_t *path_w   = *ppath_w;
+const size_t len= wcslen(path_w);
+wchar_t *temp_w;
+
+/* We're skipping the check IsPartiallyQualified() because
+ * we expect to have called GetFullPathNameW() already. */
+if (len < 2 || path_is_extended(*ppath_w) || 
path_is_device_path(*ppath_w)) {
+return 0;
+}
+
+if (path_w[0] == L'\\' && path_w[1] == L'\\') {
+/* unc_prefix length is 8 plus 1 for terminating zeros,
+ * we subtract 2 for the leading '\\' of the original path */
+temp_w = (wchar_t *)av_calloc(len - 2 + 8 + 1, sizeof(wchar_t));
+if (!temp_w) {
+errno = ENOMEM;
+return -1;
+}
+wcscpy(temp_w, unc_prefix);
+wcscat(temp_w, path_w + 2);
+} else {
+// The length of extended_path_prefix is 4 plus 1 for terminating zeros
+temp_w = (wchar_t *)av_calloc(len + 4 + 1, sizeof(wchar_t));
+if (!temp_w) {
+errno = ENOMEM;
+return -1;
+}
+wcscpy(temp_w, extended_path_prefix);
+wcscat(temp_w, path_w);
+}
+
+av_freep(ppath_w);
+*ppath_w = temp_w;
+
+return 0;
+}
+
+/**
+ * Converts a file or folder path to wchar_t for use with Windows file
+ * APIs. Paths with extended path prefix (either '\\?\' or 

[FFmpeg-devel] [PATCH v3 2/2] avformat/os_support: Support long file names on Windows

2022-05-16 Thread softworkz
From: softworkz 

Signed-off-by: softworkz 
---
 libavformat/os_support.h | 26 +-
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/libavformat/os_support.h b/libavformat/os_support.h
index 5e6b32d2dc..bd8c89568f 100644
--- a/libavformat/os_support.h
+++ b/libavformat/os_support.h
@@ -49,7 +49,23 @@
 #  ifdef stat
 #   undef stat
 #  endif
-#  define stat _stati64
+#  define stat win32_stat
+
+struct win32_stat
+{
+_dev_t st_dev;
+_ino_t st_ino;
+unsigned short st_mode;
+short  st_nlink;
+short  st_uid;
+short  st_gid;
+_dev_t st_rdev;
+__int64st_size;
+__time64_t st_atime;
+__time64_t st_mtime;
+__time64_t st_ctime;
+};
+
 #  ifdef fstat
 #   undef fstat
 #  endif
@@ -153,7 +169,7 @@ static inline int win32_##name(const char *filename_utf8) \
 wchar_t *filename_w;  \
 int ret;  \
   \
-if (utf8towchar(filename_utf8, &filename_w))  \
+if (get_extended_win32_path(filename_utf8, &filename_w)) \
 return -1;\
 if (!filename_w)  \
 goto fallback;\
@@ -177,7 +193,7 @@ static inline int win32_##name(const char *filename_utf8, 
partype par) \
 wchar_t *filename_w;  \
 int ret;  \
   \
-if (utf8towchar(filename_utf8, &filename_w))  \
+if (get_extended_win32_path(filename_utf8, &filename_w)) \
 return -1;\
 if (!filename_w)  \
 goto fallback;\
@@ -199,9 +215,9 @@ static inline int win32_rename(const char *src_utf8, const 
char *dest_utf8)
 wchar_t *src_w, *dest_w;
 int ret;
 
-if (utf8towchar(src_utf8, &src_w))
+if (get_extended_win32_path(src_utf8, &src_w))
 return -1;
-if (utf8towchar(dest_utf8, &dest_w)) {
+if (get_extended_win32_path(dest_utf8, &dest_w)) {
 av_free(src_w);
 return -1;
 }
-- 
ffmpeg-codebot
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH v4 06/10] libavformat/asfdec: fix macro definition and use

2022-05-16 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Andreas Rheinhardt
> Sent: Monday, May 16, 2022 10:49 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v4 06/10] libavformat/asfdec: fix
> macro definition and use
> 
> Soft Works:
> >
> >
> >> -Original Message-
> >> From: ffmpeg-devel  On Behalf Of
> >> Andreas Rheinhardt
> >> Sent: Sunday, May 15, 2022 8:12 PM
> >> To: ffmpeg-devel@ffmpeg.org
> >> Subject: Re: [FFmpeg-devel] [PATCH v4 06/10] libavformat/asfdec:
> fix
> >> macro definition and use
> >>
> >> softworkz:
> >>> From: softworkz 
> >>>
> >>> Signed-off-by: softworkz 
> >>> ---
> >>>  libavformat/asfdec_f.c | 24 
> >>>  1 file changed, 12 insertions(+), 12 deletions(-)
> >>>
> >>> diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
> >>> index 81a29f99d5..91c3874ac7 100644
> >>> --- a/libavformat/asfdec_f.c
> >>> +++ b/libavformat/asfdec_f.c
> >>> @@ -906,21 +906,21 @@ static int asf_read_header(AVFormatContext
> *s)
> >>>  }
> >>>
> >>>  #define DO_2BITS(bits, var, defval) \
> >>> -switch (bits & 3) { \
> >>> +switch ((bits) & 3) {   \
> >>>  case 3: \
> >>> -var = avio_rl32(pb);\
> >>> +(var) = avio_rl32(pb);  \
> >>>  rsize += 4; \
> >>>  break;  \
> >>>  case 2: \
> >>> -var = avio_rl16(pb);\
> >>> +(var) = avio_rl16(pb);  \
> >>>  rsize += 2; \
> >>>  break;  \
> >>>  case 1: \
> >>> -var = avio_r8(pb);  \
> >>> +(var) = avio_r8(pb);\
> >>>  rsize++;\
> >>>  break;  \
> >>>  default:\
> >>> -var = defval;   \
> >>> +(var) = (defval);   \
> >>>  break;  \
> >>>  }
> >>>
> >>> @@ -1003,9 +1003,9 @@ static int asf_get_packet(AVFormatContext
> *s,
> >> AVIOContext *pb)
> >>>  asf->packet_flags= c;
> >>>  asf->packet_property = d;
> >>>
> >>> -DO_2BITS(asf->packet_flags >> 5, packet_length, s-
> >>> packet_size);
> >>> -DO_2BITS(asf->packet_flags >> 1, padsize, 0); // sequence
> >> ignored
> >>> -DO_2BITS(asf->packet_flags >> 3, padsize, 0); // padding
> length
> >>> +DO_2BITS(asf->packet_flags >> 5, packet_length, s-
> >packet_size)
> >>> +DO_2BITS(asf->packet_flags >> 1, padsize, 0) // sequence
> >> ignored
> >>> +DO_2BITS(asf->packet_flags >> 3, padsize, 0) // padding
> length
> >>>
> >>>  // the following checks prevent overflows and infinite loops
> >>>  if (!packet_length || packet_length >= (1U << 29)) {
> >>> @@ -1066,9 +1066,9 @@ static int
> >> asf_read_frame_header(AVFormatContext *s, AVIOContext *pb)
> >>>  asf->stream_index = asf->asfid2avid[num & 0x7f];
> >>>  asfst = &asf->streams[num & 0x7f];
> >>>  // sequence should be ignored!
> >>> -DO_2BITS(asf->packet_property >> 4, asf->packet_seq, 0);
> >>> -DO_2BITS(asf->packet_property >> 2, asf->packet_frag_offset,
> >> 0);
> >>> -DO_2BITS(asf->packet_property, asf->packet_replic_size, 0);
> >>> +DO_2BITS(asf->packet_property >> 4, asf->packet_seq, 0)
> >>> +DO_2BITS(asf->packet_property >> 2, asf->packet_frag_offset,
> 0)
> >>> +DO_2BITS(asf->packet_property, asf->packet_replic_size, 0)
> >>>  av_log(asf, AV_LOG_TRACE, "key:%d stream:%d seq:%d offset:%d
> >> replic_size:%d num:%X packet_property %X\n",
> >>>  asf->packet_key_frame, asf->stream_index, asf-
> >>> packet_seq,
> >>>  asf->packet_frag_offset, asf->packet_replic_size,
> num,
> >> asf->packet_property);
> >>> @@ -1144,7 +1144,7 @@ static int
> >> asf_read_frame_header(AVFormatContext *s, AVIOContext *pb)
> >>>  return AVERROR_INVALIDDATA;
> >>>  }
> >>>  if (asf->packet_flags & 0x01) {
> >>> -DO_2BITS(asf->packet_segsizetype >> 6, asf-
> >>> packet_frag_size, 0); // 0 is illegal
> >>> +DO_2BITS(asf->packet_segsizetype >> 6, asf-
> >>> packet_frag_size, 0) // 0 is illegal
> >>>  if (rsize > asf->packet_size_left) {
> >>>  av_log(s, AV_LOG_ERROR, "packet_replic_size is
> >> invalid\n");
> >>>  return AVERROR_INVALIDDATA;
> >>
> >> While protecting macro arguments is good, it is not really a "fix"
> >> unless current usage is buggy.
> >
> > Ok, I will rephrase the commit message.
> >
> >> Which it isn't here, because >> has higher precedence than &.
> >
> > Could you explain which change you are referrin

Re: [FFmpeg-devel] [PATCH] avformat/oggparsevorbis: Fix oggvorbis duration parsing for small files

2022-05-16 Thread Guangyu Sun
On Mon, May 9, 2022 at 11:19 AM Guangyu Sun  wrote:

> On Thu, May 5, 2022 at 4:05 PM Guangyu Sun  wrote:
>
>> The decoded Data is not returned from the first frame; it must be used
>> to 'prime' the decode engine. The duration of the first packet should
>> be ignored also by the container, to make sure the total duration is
>> trimmed correctly.
>>
>> If the file has multiple pages for the data packets. The duration of the
>> last packet can be correctly adjusted without being affected by the first
>> packet. But if the first packet and the last packet are located in the
>> same page, the duration of the last packet will have an unwanted offset.
>>
>> This commit fixes https://trac.ffmpeg.org/ticket/6367.
>>
>> dd if=/dev/zero of=./silence.raw count=1 bs=500
>> oggenc --raw silence.raw --output=silence.ogg
>> oggdec --raw --output silence.oggdec.raw silence.ogg
>> ffmpeg -codec:a libvorbis -i silence.ogg -f s16le -codec:a pcm_s16le
>> silence.libvorbis.ffmpeg.raw
>> ffmpeg -i silence.ogg -f s16le -codec:a pcm_s16le
>> silence.native.ffmpeg.raw
>> ls -l *.raw
>>
>> Signed-off-by: Guangyu Sun 
>> ---
>>  libavformat/oggparsevorbis.c | 11 ++-
>>  1 file changed, 10 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
>> index 289900f7cf..9a486c9fe8 100644
>> --- a/libavformat/oggparsevorbis.c
>> +++ b/libavformat/oggparsevorbis.c
>> @@ -412,6 +412,7 @@ static int vorbis_packet(AVFormatContext *s, int idx)
>>  struct ogg_stream *os = ogg->streams + idx;
>>  struct oggvorbis_private *priv = os->private;
>>  int duration, flags = 0;
>> +int first_page;
>>
>>  if (!priv->vp)
>>  return AVERROR_INVALIDDATA;
>> @@ -420,7 +421,8 @@ static int vorbis_packet(AVFormatContext *s, int idx)
>>   * here we parse the duration of each packet in the first page and
>> compare
>>   * the total duration to the page granule to find the encoder delay
>> and
>>   * set the first timestamp */
>> -if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) && !(os->flags &
>> OGG_FLAG_EOS) && (int64_t)os->granule>=0) {
>> +first_page = !os->lastpts || os->lastpts == AV_NOPTS_VALUE;
>> +if (first_page && !(os->flags & OGG_FLAG_EOS) &&
>> (int64_t)os->granule>=0) {
>>  int seg, d;
>>  uint8_t *last_pkt  = os->buf + os->pstart;
>>  uint8_t *next_pkt  = last_pkt;
>> @@ -479,6 +481,13 @@ static int vorbis_packet(AVFormatContext *s, int idx)
>>  flags = 0;
>>  }
>>  os->pduration = duration;
>> +/* Data is not returned from the first frame; it must be used to
>> 'prime'
>> + * the decode engine. The duration of the first packet should be
>> ignored
>> + * also by the container, to make sure the total duration is
>> trimmed
>> + * correctly.
>> + */
>> +if (first_page && os->segp == 1)
>> +os->pduration = 0;
>>  }
>>
>>  /* final packet handling
>> --
>> 2.30.1
>>
>>
> Ping.
>
Ping again. This patch fixes an oggvorbis transcode issue.
https://devforum.roblox.com/t/recent-changes-to-uploaded-audio-compressionprocessing-causing-timing-drift/1735440/10
___
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 0/2] Support long file names on Windows

2022-05-16 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of nil-
> admir...@mailo.com
> Sent: Monday, May 16, 2022 10:45 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH 0/2] Support long file names on
> Windows
> 
> > I have left those out by intention because they are pending removal
> > and are only for debugging.
> 
> Is dvdsubdec.c parse_ifo_palette pending removal?

Just the debug part. Seems I missed the other one.

> - vf_pnsr.c init()
> - vf_vidstabdetect.c config_input()
> - vf_vidstabtransform.c config_input()?

I don't have the latter two included due to missing
lib. No idea how I have missed the other two.

Thanks for pointing out. Update will follow.

Kind regards,
softworkz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH v3 0/2] use av_fopen_utf8() instead of plain fopen()

2022-05-16 Thread ffmpegagent
Unify file access operations by replacing usages of direct calls to posix
fopen()

v2: Remove changes to fftools for now
v3: Add some additional replacements

softworkz (2):
  avfilter: use av_fopen_utf8() instead of plain fopen()
  avfilter/dvdsubdec: use av_fopen_utf8() instead of plain fopen()

 libavcodec/dvdsubdec.c| 2 +-
 libavfilter/af_firequalizer.c | 2 +-
 libavfilter/vf_deshake.c  | 2 +-
 libavfilter/vf_psnr.c | 2 +-
 libavfilter/vf_signature.c| 4 ++--
 libavfilter/vf_ssim.c | 2 +-
 libavfilter/vf_vidstabdetect.c| 2 +-
 libavfilter/vf_vidstabtransform.c | 2 +-
 libavfilter/vf_vmafmotion.c   | 2 +-
 9 files changed, 10 insertions(+), 10 deletions(-)


base-commit: e3580f60775c897c3b13b178c57ab191ecc4a031
Published-As: 
https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-26%2Fsoftworkz%2Fsubmit_replace_fopen-v3
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg 
pr-ffstaging-26/softworkz/submit_replace_fopen-v3
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/26

Range-diff vs v2:

 1:  e47287be64 ! 1:  d81855ba42 avfilter: use av_fopen_utf8() instead of plain 
fopen()
 @@ libavfilter/vf_deshake.c: static av_cold int init(AVFilterContext *ctx)
   fwrite("Ori x, Avg x, Fin x, Ori y, Avg y, Fin y, Ori angle, Avg 
angle, Fin angle, Ori zoom, Avg zoom, Fin zoom\n", 1, 104, deshake->fp);
   
  
 + ## libavfilter/vf_psnr.c ##
 +@@ libavfilter/vf_psnr.c: static av_cold int init(AVFilterContext *ctx)
 + if (!strcmp(s->stats_file_str, "-")) {
 + s->stats_file = stdout;
 + } else {
 +-s->stats_file = fopen(s->stats_file_str, "w");
 ++s->stats_file = av_fopen_utf8(s->stats_file_str, "w");
 + if (!s->stats_file) {
 + int err = AVERROR(errno);
 + char buf[128];
 +
   ## libavfilter/vf_signature.c ##
  @@ libavfilter/vf_signature.c: static int xml_export(AVFilterContext 
*ctx, StreamContext *sc, const char* filen
   FILE* f;
 @@ libavfilter/vf_ssim.c: static av_cold int init(AVFilterContext *ctx)
   int err = AVERROR(errno);
   char buf[128];
  
 + ## libavfilter/vf_vidstabdetect.c ##
 +@@ libavfilter/vf_vidstabdetect.c: static int config_input(AVFilterLink 
*inlink)
 + av_log(ctx, AV_LOG_INFO, "  show = %d\n", s->conf.show);
 + av_log(ctx, AV_LOG_INFO, "result = %s\n", s->result);
 + 
 +-s->f = fopen(s->result, "w");
 ++s->f = av_fopen_utf8(s->result, "w");
 + if (s->f == NULL) {
 + av_log(ctx, AV_LOG_ERROR, "cannot open transform file %s\n", 
s->result);
 + return AVERROR(EINVAL);
 +
 + ## libavfilter/vf_vidstabtransform.c ##
 +@@ libavfilter/vf_vidstabtransform.c: static int 
config_input(AVFilterLink *inlink)
 + av_log(ctx, AV_LOG_INFO, "zoomspeed = %g\n", 
tc->conf.zoomSpeed);
 + av_log(ctx, AV_LOG_INFO, "interpol  = %s\n", 
getInterpolationTypeName(tc->conf.interpolType));
 + 
 +-f = fopen(tc->input, "r");
 ++f = av_fopen_utf8(tc->input, "r");
 + if (!f) {
 + int ret = AVERROR(errno);
 + av_log(ctx, AV_LOG_ERROR, "cannot open input file %s\n", 
tc->input);
 +
   ## libavfilter/vf_vmafmotion.c ##
  @@ libavfilter/vf_vmafmotion.c: static av_cold int init(AVFilterContext 
*ctx)
   if (!strcmp(s->stats_file_str, "-")) {
 -:  -- > 2:  1be02d9e04 avfilter/dvdsubdec: use av_fopen_utf8() 
instead of plain fopen()

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

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


[FFmpeg-devel] [PATCH v3 1/2] avfilter: use av_fopen_utf8() instead of plain fopen()

2022-05-16 Thread softworkz
From: softworkz 

Signed-off-by: softworkz 
---
 libavfilter/af_firequalizer.c | 2 +-
 libavfilter/vf_deshake.c  | 2 +-
 libavfilter/vf_psnr.c | 2 +-
 libavfilter/vf_signature.c| 4 ++--
 libavfilter/vf_ssim.c | 2 +-
 libavfilter/vf_vidstabdetect.c| 2 +-
 libavfilter/vf_vidstabtransform.c | 2 +-
 libavfilter/vf_vmafmotion.c   | 2 +-
 8 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavfilter/af_firequalizer.c b/libavfilter/af_firequalizer.c
index c19a2fe122..e1497dcef0 100644
--- a/libavfilter/af_firequalizer.c
+++ b/libavfilter/af_firequalizer.c
@@ -604,7 +604,7 @@ static int generate_kernel(AVFilterContext *ctx, const char 
*gain, const char *g
 if (ret < 0)
 return ret;
 
-if (s->dumpfile && (!s->dump_buf || !s->analysis_rdft || !(dump_fp = 
fopen(s->dumpfile, "w"
+if (s->dumpfile && (!s->dump_buf || !s->analysis_rdft || !(dump_fp = 
av_fopen_utf8(s->dumpfile, "w"
 av_log(ctx, AV_LOG_WARNING, "dumping failed.\n");
 
 vars[VAR_CHS] = inlink->ch_layout.nb_channels;
diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c
index 4f28467bb2..dea69e11cd 100644
--- a/libavfilter/vf_deshake.c
+++ b/libavfilter/vf_deshake.c
@@ -353,7 +353,7 @@ static av_cold int init(AVFilterContext *ctx)
 }
 
 if (deshake->filename)
-deshake->fp = fopen(deshake->filename, "w");
+deshake->fp = av_fopen_utf8(deshake->filename, "w");
 if (deshake->fp)
 fwrite("Ori x, Avg x, Fin x, Ori y, Avg y, Fin y, Ori angle, Avg 
angle, Fin angle, Ori zoom, Avg zoom, Fin zoom\n", 1, 104, deshake->fp);
 
diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
index 19852eaa69..09c2a5164a 100644
--- a/libavfilter/vf_psnr.c
+++ b/libavfilter/vf_psnr.c
@@ -280,7 +280,7 @@ static av_cold int init(AVFilterContext *ctx)
 if (!strcmp(s->stats_file_str, "-")) {
 s->stats_file = stdout;
 } else {
-s->stats_file = fopen(s->stats_file_str, "w");
+s->stats_file = av_fopen_utf8(s->stats_file_str, "w");
 if (!s->stats_file) {
 int err = AVERROR(errno);
 char buf[128];
diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c
index 4ca57ebf1d..904123fd4e 100644
--- a/libavfilter/vf_signature.c
+++ b/libavfilter/vf_signature.c
@@ -386,7 +386,7 @@ static int xml_export(AVFilterContext *ctx, StreamContext 
*sc, const char* filen
 FILE* f;
 unsigned int pot3[5] = { 3*3*3*3, 3*3*3, 3*3, 3, 1 };
 
-f = fopen(filename, "w");
+f = av_fopen_utf8(filename, "w");
 if (!f) {
 int err = AVERROR(EINVAL);
 char buf[128];
@@ -500,7 +500,7 @@ static int binary_export(AVFilterContext *ctx, 
StreamContext *sc, const char* fi
 if (!buffer)
 return AVERROR(ENOMEM);
 
-f = fopen(filename, "wb");
+f = av_fopen_utf8(filename, "wb");
 if (!f) {
 int err = AVERROR(EINVAL);
 char buf[128];
diff --git a/libavfilter/vf_ssim.c b/libavfilter/vf_ssim.c
index 32f313817d..4a82cbec06 100644
--- a/libavfilter/vf_ssim.c
+++ b/libavfilter/vf_ssim.c
@@ -404,7 +404,7 @@ static av_cold int init(AVFilterContext *ctx)
 if (!strcmp(s->stats_file_str, "-")) {
 s->stats_file = stdout;
 } else {
-s->stats_file = fopen(s->stats_file_str, "w");
+s->stats_file = av_fopen_utf8(s->stats_file_str, "w");
 if (!s->stats_file) {
 int err = AVERROR(errno);
 char buf[128];
diff --git a/libavfilter/vf_vidstabdetect.c b/libavfilter/vf_vidstabdetect.c
index 267a62ea9b..4acae5a3ea 100644
--- a/libavfilter/vf_vidstabdetect.c
+++ b/libavfilter/vf_vidstabdetect.c
@@ -126,7 +126,7 @@ static int config_input(AVFilterLink *inlink)
 av_log(ctx, AV_LOG_INFO, "  show = %d\n", s->conf.show);
 av_log(ctx, AV_LOG_INFO, "result = %s\n", s->result);
 
-s->f = fopen(s->result, "w");
+s->f = av_fopen_utf8(s->result, "w");
 if (s->f == NULL) {
 av_log(ctx, AV_LOG_ERROR, "cannot open transform file %s\n", 
s->result);
 return AVERROR(EINVAL);
diff --git a/libavfilter/vf_vidstabtransform.c 
b/libavfilter/vf_vidstabtransform.c
index 4619e9b256..17214f039f 100644
--- a/libavfilter/vf_vidstabtransform.c
+++ b/libavfilter/vf_vidstabtransform.c
@@ -191,7 +191,7 @@ static int config_input(AVFilterLink *inlink)
 av_log(ctx, AV_LOG_INFO, "zoomspeed = %g\n", tc->conf.zoomSpeed);
 av_log(ctx, AV_LOG_INFO, "interpol  = %s\n", 
getInterpolationTypeName(tc->conf.interpolType));
 
-f = fopen(tc->input, "r");
+f = av_fopen_utf8(tc->input, "r");
 if (!f) {
 int ret = AVERROR(errno);
 av_log(ctx, AV_LOG_ERROR, "cannot open input file %s\n", tc->input);
diff --git a/libavfilter/vf_vmafmotion.c b/libavfilter/vf_vmafmotion.c
index 8b7e9b17ef..2ac67e5935 100644
--- a/libavfilter/vf_vmafmotion.c
+++ b/libavfilter/vf_vmafmotion.c
@@ -312,

[FFmpeg-devel] [PATCH v3 2/2] avfilter/dvdsubdec: use av_fopen_utf8() instead of plain fopen()

2022-05-16 Thread softworkz
From: softworkz 

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

diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c
index 30fe4d41de..19b78b3eb1 100644
--- a/libavcodec/dvdsubdec.c
+++ b/libavcodec/dvdsubdec.c
@@ -617,7 +617,7 @@ static int parse_ifo_palette(DVDSubContext *ctx, char *p)
 const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
 
 ctx->has_palette = 0;
-if ((ifo = fopen(p, "r")) == NULL) {
+if ((ifo = av_fopen_utf8(p, "r")) == NULL) {
 av_log(ctx, AV_LOG_WARNING, "Unable to open IFO file \"%s\": %s\n", p, 
av_err2str(AVERROR(errno)));
 return AVERROR_EOF;
 }
-- 
ffmpeg-codebot
___
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".