Re: [FFmpeg-devel] [PATCH] ffmpeg: set user-set rotation for encoded streams too

2022-05-11 Thread Anton Khirnov
Quoting Gyan Doshi (2022-05-11 21:15:15)
> 
> 
> On 2022-05-12 12:19 am, Anton Khirnov wrote:
> > Quoting Gyan Doshi (2022-05-11 14:18:49)
> >>
> >> On 2022-05-11 05:26 pm, Anton Khirnov wrote:
> >>> Quoting Gyan Doshi (2022-05-10 13:40:54)
>  So far, -metadata:s:v rotate would only be applied to streamcopied
>  video streams.
> >>> Using -metadata for this functionality is a hack that should be removed,
> >>> not extended.
> >> When there's a replacement for CLI users, sure.
> >> Till then, there's no need for the disparity to be maintained.
> > I disagree. You are adding new behavior, which will need to be
> > maintained for backward compatibility and add extra burden on the person
> > who would want to implement this properly.
> >
> > If you want this functionality, just add a new option. It's not that
> > hard. There's plenty of hacks in ffmpeg already, we don't need any new
> > ones.
> 
> All the current state does is force the user to run a 2nd remux command 
> to set rotation.
> A new option for encoded streams creates a divergent syntax for no 
> visible benefit.

This new option would presumably apply to all streams, deprecating the
use of metadata for specifying rotations.

> If and when a display matrix can be user-specified, it will be easier to 
> retire the metadata hack than to change the arg syntax of a newly added 
> 'rotate' option.

I see no reason why the syntax should be changed.

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

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


Re: [FFmpeg-devel] [PATCH] configure: extend check to less than 3.0.0

2022-05-11 Thread Gyan Doshi




On 2022-05-12 01:41 am, Christopher Degawa wrote:

sdl2 recently changed their versioning, moving the patch level to minor level
https://github.com/libsdl-org/SDL/commit/cd7c2f1de7d9e418bb554047d714dd7cacc020ff
and have said that they will instead ship sdl3.pc for 3.0.0


Will apply.

Regards,
Gyan



trac: https://trac.ffmpeg.org/ticket/9768

Signed-off-by: Christopher Degawa 
---
  configure | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 4d2f4d9112..0faf2455b7 100755
--- a/configure
+++ b/configure
@@ -6742,7 +6742,7 @@ fi
  
  if enabled sdl2; then

  SDL2_CONFIG="${cross_prefix}sdl2-config"
-test_pkg_config sdl2 "sdl2 >= 2.0.1 sdl2 < 2.1.0" SDL_events.h 
SDL_PollEvent
+test_pkg_config sdl2 "sdl2 >= 2.0.1 sdl2 < 3.0.0" SDL_events.h 
SDL_PollEvent
  if disabled sdl2 && "${SDL2_CONFIG}" --version > /dev/null 2>&1; then
  sdl2_cflags=$("${SDL2_CONFIG}" --cflags)
  sdl2_extralibs=$("${SDL2_CONFIG}" --libs)


___
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] avfilter/vf_vpp_qsv: set outlink to EOF correctly

2022-05-11 Thread Fei Wang
1. Return error if filter frame fail before set outlink to EOF in none
pass through mode.
2. Set outlink to EOF before return success in pass through mode.

Fix endless cmd:

ffmpeg -hwaccel qsv -qsv_device /dev/dri/renderD128 -hwaccel_output_format \
qsv -v debug -c:v hevc_qsv -i 4k.h265  \
-filter_complex "vpp_qsv=w=3840:h=2160:async_depth=4[o1];[o1]split=2[s1][s2];
[s2]vpp_qsv=w=1920:h=1080:async_depth=4[o2];[o2]split=2[s3][s4];
[s4]vpp_qsv=w=1920:h=1080:async_depth=4[o3]" \
-map [s1] -c:v hevc_qsv -async 3 -async_depth 3 -b:v 9000k -preset 7 -g 33 -y 
-f null - \
-map [s3] -c:v hevc_qsv -async 3 -async_depth 3 -b:v 4000k -preset 7 -g 33 -y 
-f null - \
-map [o3] -c:v hevc_qsv -async 3 -async_depth 3 -b:v 3100k -preset 7 -g 33 -y 
-f null -
---
 libavfilter/vf_vpp_qsv.c | 35 +++
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index cfe343822b..3d9d3afbc8 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -556,15 +556,17 @@ static int activate(AVFilterContext *ctx)
 qsv->eof = s->eof;
 ret = ff_qsvvpp_filter_frame(qsv, inlink, in);
 av_frame_free();
+if (ret == AVERROR(EAGAIN))
+goto not_ready;
+else if (ret < 0)
+return ret;
 
-if (s->eof) {
-ff_outlink_set_status(outlink, status, pts);
-return 0;
-}
+if (s->eof)
+goto eof;
 
 if (qsv->got_frame) {
 qsv->got_frame = 0;
-return ret;
+return 0;
 }
 }
 } else {
@@ -573,18 +575,27 @@ static int activate(AVFilterContext *ctx)
 in->pts = av_rescale_q(in->pts, inlink->time_base, 
outlink->time_base);
 
 ret = ff_filter_frame(outlink, in);
-return ret;
+if (ret < 0)
+return ret;
+
+if (s->eof)
+goto eof;
+
+return 0;
 }
 }
 
-if (s->eof) {
-ff_outlink_set_status(outlink, status, pts);
-return 0;
-} else {
-FF_FILTER_FORWARD_WANTED(outlink, inlink);
-}
+not_ready:
+if (s->eof)
+goto eof;
+
+FF_FILTER_FORWARD_WANTED(outlink, inlink);
 
 return FFERROR_NOT_READY;
+
+eof:
+ff_outlink_set_status(outlink, status, pts);
+return 0;
 }
 
 static int query_formats(AVFilterContext *ctx)
-- 
2.25.1

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

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


Re: [FFmpeg-devel] [PATCH 2/4] avcodec/ccaption_dec: check the length of packet and return used length

2022-05-11 Thread lance . lmwang
On Wed, May 11, 2022 at 09:47:52PM +0200, Paul B Mahol wrote:
> why?

assuming the len is 1, the following code will access the next 3
array anymore, I think it's better to check the i with len -2.

for (i = 0; i < len; i += 3) {
to 
for (i = 0; i < len - 2; i += 3) {

for the return, I think it's correct to return the used length,
if it's error, have return already. right? 

-- 
Thanks,
Limin Wang
___
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 v11 1/6] libavutil/wchar_filename.h: Add whcartoutf8, wchartoansi and utf8toansi

2022-05-11 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Tobias Rapp
> Sent: Wednesday, May 11, 2022 3:33 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v11 1/6]
> libavutil/wchar_filename.h: Add whcartoutf8, wchartoansi and
> utf8toansi
> 
> On 11/05/2022 09:57, Soft Works wrote:
> >
> > [...]
> >
> > I'm not sure how much you had followed, so please excuse in case you
> > had already read it: the manifest approach does not work on a
> default
> > Windows installation.
> > To activate long path support, the users needs to opt-in to a
> behavior
> > that is probably deactivated by default for some reason. Also it
> > requires administrative privileges to make this change.
> > For me - and probably for others as well - that approach is useless,
> > as it would be the same as if there would be no long path support.
> > (when you cannot rely on that feature being always working, you
> > cannot use it)
> 
> For me an analogous case is the usage of the "--large-address-aware"
> linker flag. It enables FFmpeg to use more than 2GiB of memory on
> Win32.
> That feature is useless to users having <= 2GiB of total system memory
> available, and it makes no guarantee that an OOM error is avoided.
> Still
> it allows to exceed a limit for those that match the requirements --
> knowingly or by pure coincidence.

That's similar except for the fact that there wasn't an alternative
method that would always work.

I respect others opinions, but I don't agree to the "better than 
nothing approach". I'm following this mailing list for a long time
and suggesting a full working solution over a half-baked or half-
working solution has always been a valid argument, so I don't see
why it shouldn't be in this case.

My interest is to have a good solution, not to block anything, so
I'll try to prepare a patch implementing path prefixing shortly.

Thanks,
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] configure: extend check to less than 3.0.0

2022-05-11 Thread Christopher Degawa
sdl2 recently changed their versioning, moving the patch level to minor level
https://github.com/libsdl-org/SDL/commit/cd7c2f1de7d9e418bb554047d714dd7cacc020ff
and have said that they will instead ship sdl3.pc for 3.0.0

trac: https://trac.ffmpeg.org/ticket/9768

Signed-off-by: Christopher Degawa 
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 4d2f4d9112..0faf2455b7 100755
--- a/configure
+++ b/configure
@@ -6742,7 +6742,7 @@ fi
 
 if enabled sdl2; then
 SDL2_CONFIG="${cross_prefix}sdl2-config"
-test_pkg_config sdl2 "sdl2 >= 2.0.1 sdl2 < 2.1.0" SDL_events.h 
SDL_PollEvent
+test_pkg_config sdl2 "sdl2 >= 2.0.1 sdl2 < 3.0.0" SDL_events.h 
SDL_PollEvent
 if disabled sdl2 && "${SDL2_CONFIG}" --version > /dev/null 2>&1; then
 sdl2_cflags=$("${SDL2_CONFIG}" --cflags)
 sdl2_extralibs=$("${SDL2_CONFIG}" --libs)
-- 
2.35.1

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

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


Re: [FFmpeg-devel] [PATCH 2/4] avcodec/ccaption_dec: check the length of packet and return used length

2022-05-11 Thread Paul B Mahol
why?
___
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] ffmpeg: set user-set rotation for encoded streams too

2022-05-11 Thread Gyan Doshi




On 2022-05-12 12:19 am, Anton Khirnov wrote:

Quoting Gyan Doshi (2022-05-11 14:18:49)


On 2022-05-11 05:26 pm, Anton Khirnov wrote:

Quoting Gyan Doshi (2022-05-10 13:40:54)

So far, -metadata:s:v rotate would only be applied to streamcopied
video streams.

Using -metadata for this functionality is a hack that should be removed,
not extended.

When there's a replacement for CLI users, sure.
Till then, there's no need for the disparity to be maintained.

I disagree. You are adding new behavior, which will need to be
maintained for backward compatibility and add extra burden on the person
who would want to implement this properly.

If you want this functionality, just add a new option. It's not that
hard. There's plenty of hacks in ffmpeg already, we don't need any new
ones.


All the current state does is force the user to run a 2nd remux command 
to set rotation.
A new option for encoded streams creates a divergent syntax for no 
visible benefit.


If and when a display matrix can be user-specified, it will be easier to 
retire the metadata hack than to change the arg syntax of a newly added 
'rotate' option.


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

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


Re: [FFmpeg-devel] [PATCH 2/9] fftools/ffmpeg: reuse the encoding code for flushing encoders

2022-05-11 Thread Michael Niedermayer
On Wed, May 11, 2022 at 10:16:47AM +0200, Anton Khirnov wrote:
> ---
>  fftools/ffmpeg.c | 75 +++-
>  1 file changed, 16 insertions(+), 59 deletions(-)

breaks 2pass with ffv1

./ffmpeg -y  -i mm-short.mpg -an -vcodec ffv1 -strict -2 -slices 4 -t 1 -coder 
1 -level 2 -context 1 -bitexact -pass 1 /tmp/ffv1.2-p1.avi
./ffmpeg -y  -i mm-short.mpg -an -vcodec ffv1 -strict -2 -slices 4 -t 1 -coder 
1 -level 2 -context 1 -bitexact -pass 2 /tmp/ffv1.2-p1.avi

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is a danger to trust the dream we wish for rather than
the science we have, -- Dr. Kenneth Brown


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] ffmpeg: set user-set rotation for encoded streams too

2022-05-11 Thread Anton Khirnov
Quoting Gyan Doshi (2022-05-11 14:18:49)
> 
> 
> On 2022-05-11 05:26 pm, Anton Khirnov wrote:
> > Quoting Gyan Doshi (2022-05-10 13:40:54)
> >> So far, -metadata:s:v rotate would only be applied to streamcopied
> >> video streams.
> > Using -metadata for this functionality is a hack that should be removed,
> > not extended.
> 
> When there's a replacement for CLI users, sure.
> Till then, there's no need for the disparity to be maintained.

I disagree. You are adding new behavior, which will need to be
maintained for backward compatibility and add extra burden on the person
who would want to implement this properly.

If you want this functionality, just add a new option. It's not that
hard. There's plenty of hacks in ffmpeg already, we don't need any new
ones.

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

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


Re: [FFmpeg-devel] [PATCH] ffmpeg: set user-set rotation for encoded streams too

2022-05-11 Thread Anton Khirnov
Quoting Gyan Doshi (2022-05-11 18:30:41)
> 
> 
> On 2022-05-10 05:10 pm, Gyan Doshi wrote:
> > So far, -metadata:s:v rotate would only be applied to streamcopied
> > video streams.
> 
> Plan to push tomorrow.

WTF? This is not how development works.

I had an objection to your patch, it was not resolved yet. Threatening
to "push tomorrow" is very rude, at best.

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

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


Re: [FFmpeg-devel] [PATCH] avcodec/internal: Hide stuff only used by the core decode API

2022-05-11 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> The general decoding API uses bitstream filters and an AVFifo
> and therefore AVCodecInternal contains pointers to an AVBSFContext
> and to an AVFifo and lavc/internal.h includes lavc/bsf.h and
> lavu/fifo.h.
> Yet actually, only two files are supposed to use these, namely
> avcodec.c and (mainly) decode.c. For all the other files,
> it should be an opaque type that they should not touch and that
> they need not know anything about. This can be achieved by not
> including these headers and using the structs instead of the
> corresponding typedefs.
> This also forces translation units that really use the BSF
> and the FIFO APIs themselves to include the relevant headers
> directly instead of relying on indirect inclusions (up until now,
> even avcodec.c and decode.c relied on fifo.h to be included
> by internal.h).
> Of course, it also avoids unnecessary rebuilds when bsf.h or fifo.h
> change.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/avcodec.c   | 1 +
>  libavcodec/cuviddec.c  | 1 +
>  libavcodec/decode.c| 1 +
>  libavcodec/internal.h  | 6 ++
>  libavcodec/libvpxenc.c | 1 +
>  5 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
> index d11f035481..f4ce6b8459 100644
> --- a/libavcodec/avcodec.c
> +++ b/libavcodec/avcodec.c
> @@ -28,6 +28,7 @@
>  #include "libavutil/avstring.h"
>  #include "libavutil/bprint.h"
>  #include "libavutil/channel_layout.h"
> +#include "libavutil/fifo.h"
>  #include "libavutil/imgutils.h"
>  #include "libavutil/mem.h"
>  #include "libavutil/opt.h"
> diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
> index 81d4c89215..cb3cda7e24 100644
> --- a/libavcodec/cuviddec.c
> +++ b/libavcodec/cuviddec.c
> @@ -34,6 +34,7 @@
>  #include "libavutil/pixdesc.h"
>  
>  #include "avcodec.h"
> +#include "bsf.h"
>  #include "codec_internal.h"
>  #include "decode.h"
>  #include "hwconfig.h"
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index 69e68ab09d..209585c540 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -32,6 +32,7 @@
>  #include "libavutil/bprint.h"
>  #include "libavutil/channel_layout.h"
>  #include "libavutil/common.h"
> +#include "libavutil/fifo.h"
>  #include "libavutil/frame.h"
>  #include "libavutil/hwcontext.h"
>  #include "libavutil/imgutils.h"
> diff --git a/libavcodec/internal.h b/libavcodec/internal.h
> index 2fa56d3a59..17e1de8127 100644
> --- a/libavcodec/internal.h
> +++ b/libavcodec/internal.h
> @@ -28,11 +28,9 @@
>  
>  #include "libavutil/buffer.h"
>  #include "libavutil/channel_layout.h"
> -#include "libavutil/fifo.h"
>  #include "libavutil/mathematics.h"
>  #include "libavutil/pixfmt.h"
>  #include "avcodec.h"
> -#include "bsf.h"
>  #include "config.h"
>  
>  #define FF_SANE_NB_CHANNELS 512U
> @@ -73,14 +71,14 @@ typedef struct AVCodecInternal {
>   * avcodec_flush_buffers().
>   */
>  AVPacket *in_pkt;
> -AVBSFContext *bsf;
> +struct AVBSFContext *bsf;
>  
>  /**
>   * Properties (timestamps+side data) extracted from the last packet 
> passed
>   * for decoding.
>   */
>  AVPacket *last_pkt_props;
> -AVFifo *pkt_props;
> +struct AVFifo *pkt_props;
>  
>  /**
>   * temporary buffer used for encoders to store their bitstream
> diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
> index e35b47b87e..187a9e9a36 100644
> --- a/libavcodec/libvpxenc.c
> +++ b/libavcodec/libvpxenc.c
> @@ -42,6 +42,7 @@
>  #include "libavutil/base64.h"
>  #include "libavutil/common.h"
>  #include "libavutil/cpu.h"
> +#include "libavutil/fifo.h"
>  #include "libavutil/internal.h"
>  #include "libavutil/intreadwrite.h"
>  #include "libavutil/mathematics.h"

Will apply this patchset tomorrow unless there are objections.

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


Re: [FFmpeg-devel] [PATCH 3/3] avformat/movenc: Add support for AVIF muxing

2022-05-11 Thread Gyan Doshi




On 2022-05-11 10:24 pm, Vignesh Venkatasubramanian wrote:

On Wed, May 4, 2022 at 10:15 AM Vignesh Venkatasubramanian
 wrote:

Add an AVIF muxer by re-using the existing the mov/mp4 muxer.

AVIF Specification: https://aomediacodec.github.io/av1-avif

Sample usage for still image:
ffmpeg -i image.png -c:v libaom-av1 -avif-image 1 image.avif

Sample usage for animated AVIF image:
ffmpeg -i video.mp4 animated.avif

We can re-use any of the AV1 encoding options that will make
sense for image encoding (like bitrate, tiles, encoding speed,
etc).

The files generated by this muxer has been verified to be valid
AVIF files by the following:
1) Displays on Chrome (both still and animated images).
2) Displays on Firefox (only still images, firefox does not support
animated AVIF yet).
3) Verified to be valid by Compliance Warden:
https://github.com/gpac/ComplianceWarden

Fixes the encoder/muxer part of Trac Ticket #7621

Signed-off-by: Vignesh Venkatasubramanian 
---
  configure|   1 +
  libavformat/allformats.c |   1 +
  libavformat/movenc.c | 333 ---
  libavformat/movenc.h |   5 +
  4 files changed, 316 insertions(+), 24 deletions(-)

diff --git a/configure b/configure
index 196873c4aa..2992f9760e 100755
--- a/configure
+++ b/configure
@@ -3404,6 +3404,7 @@ asf_stream_muxer_select="asf_muxer"
  av1_demuxer_select="av1_frame_merge_bsf av1_parser"
  avi_demuxer_select="riffdec exif"
  avi_muxer_select="riffenc"
+avif_muxer_select="mov_muxer"
  caf_demuxer_select="iso_media"
  caf_muxer_select="iso_media"
  dash_muxer_select="mp4_muxer"
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 63876c468f..1802536633 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -81,6 +81,7 @@ extern const AVOutputFormat ff_au_muxer;
  extern const AVInputFormat  ff_av1_demuxer;
  extern const AVInputFormat  ff_avi_demuxer;
  extern const AVOutputFormat ff_avi_muxer;
+extern const AVOutputFormat ff_avif_muxer;
  extern const AVInputFormat  ff_avisynth_demuxer;
  extern const AVOutputFormat ff_avm2_muxer;
  extern const AVInputFormat  ff_avr_demuxer;
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 271db99b46..1a20fe17ca 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1335,7 +1335,7 @@ static int mov_write_av1c_tag(AVIOContext *pb, MOVTrack 
*track)

  avio_wb32(pb, 0);
  ffio_wfourcc(pb, "av1C");
-ff_isom_write_av1c(pb, track->vos_data, track->vos_len, 1);
+ff_isom_write_av1c(pb, track->vos_data, track->vos_len, track->mode != 
MODE_AVIF);
  return update_size(pb, pos);
  }

@@ -2037,12 +2037,13 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack 
*track, int prefer_icc)
  }
  }

-/* We should only ever be called by MOV or MP4. */
-av_assert0(track->mode == MODE_MOV || track->mode == MODE_MP4);
+/* We should only ever be called for MOV, MP4 and AVIF. */
+av_assert0(track->mode == MODE_MOV || track->mode == MODE_MP4 ||
+   track->mode == MODE_AVIF);

  avio_wb32(pb, 0); /* size */
  ffio_wfourcc(pb, "colr");
-if (track->mode == MODE_MP4)
+if (track->mode == MODE_MP4 || track->mode == MODE_AVIF)
  ffio_wfourcc(pb, "nclx");
  else
  ffio_wfourcc(pb, "nclc");
@@ -2052,7 +2053,7 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack 
*track, int prefer_icc)
  avio_wb16(pb, track->par->color_primaries);
  avio_wb16(pb, track->par->color_trc);
  avio_wb16(pb, track->par->color_space);
-if (track->mode == MODE_MP4) {
+if (track->mode == MODE_MP4 || track->mode == MODE_AVIF) {
  int full_range = track->par->color_range == AVCOL_RANGE_JPEG;
  avio_w8(pb, full_range << 7);
  }
@@ -2118,7 +2119,7 @@ static void find_compressor(char * compressor_name, int 
len, MOVTrack *track)
|| (track->par->width == 1440 && track->par->height == 1080)
|| (track->par->width == 1920 && track->par->height == 
1080);

-if (track->mode == MODE_MOV &&
+if ((track->mode == MODE_AVIF || track->mode == MODE_MOV) &&
  (encoder = av_dict_get(track->st->metadata, "encoder", NULL, 0))) {
  av_strlcpy(compressor_name, encoder->value, 32);
  } else if (track->par->codec_id == AV_CODEC_ID_MPEG2VIDEO && xdcam_res) {
@@ -2139,6 +2140,25 @@ static void find_compressor(char * compressor_name, int 
len, MOVTrack *track)
  }
  }

+static int mov_write_ccst_tag(AVIOContext *pb)
+{
+int64_t pos = avio_tell(pb);
+// Write sane defaults:
+// all_ref_pics_intra = 0 : all samples can use any type of reference.
+// intra_pred_used = 1 : intra prediction may or may not be used.
+// max_ref_per_pic = 15 : reserved value to indicate that any number of
+//reference images can be used.
+uint8_t ccstValue = (0 << 7) |  /* all_ref_pics_intra */
+(1 << 6) |  /* 

Re: [FFmpeg-devel] [PATCH 3/3] avformat/movenc: Add support for AVIF muxing

2022-05-11 Thread Vignesh Venkatasubramanian
On Wed, May 4, 2022 at 10:15 AM Vignesh Venkatasubramanian
 wrote:
>
> Add an AVIF muxer by re-using the existing the mov/mp4 muxer.
>
> AVIF Specification: https://aomediacodec.github.io/av1-avif
>
> Sample usage for still image:
> ffmpeg -i image.png -c:v libaom-av1 -avif-image 1 image.avif
>
> Sample usage for animated AVIF image:
> ffmpeg -i video.mp4 animated.avif
>
> We can re-use any of the AV1 encoding options that will make
> sense for image encoding (like bitrate, tiles, encoding speed,
> etc).
>
> The files generated by this muxer has been verified to be valid
> AVIF files by the following:
> 1) Displays on Chrome (both still and animated images).
> 2) Displays on Firefox (only still images, firefox does not support
>animated AVIF yet).
> 3) Verified to be valid by Compliance Warden:
>https://github.com/gpac/ComplianceWarden
>
> Fixes the encoder/muxer part of Trac Ticket #7621
>
> Signed-off-by: Vignesh Venkatasubramanian 
> ---
>  configure|   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/movenc.c | 333 ---
>  libavformat/movenc.h |   5 +
>  4 files changed, 316 insertions(+), 24 deletions(-)
>
> diff --git a/configure b/configure
> index 196873c4aa..2992f9760e 100755
> --- a/configure
> +++ b/configure
> @@ -3404,6 +3404,7 @@ asf_stream_muxer_select="asf_muxer"
>  av1_demuxer_select="av1_frame_merge_bsf av1_parser"
>  avi_demuxer_select="riffdec exif"
>  avi_muxer_select="riffenc"
> +avif_muxer_select="mov_muxer"
>  caf_demuxer_select="iso_media"
>  caf_muxer_select="iso_media"
>  dash_muxer_select="mp4_muxer"
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index 63876c468f..1802536633 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -81,6 +81,7 @@ extern const AVOutputFormat ff_au_muxer;
>  extern const AVInputFormat  ff_av1_demuxer;
>  extern const AVInputFormat  ff_avi_demuxer;
>  extern const AVOutputFormat ff_avi_muxer;
> +extern const AVOutputFormat ff_avif_muxer;
>  extern const AVInputFormat  ff_avisynth_demuxer;
>  extern const AVOutputFormat ff_avm2_muxer;
>  extern const AVInputFormat  ff_avr_demuxer;
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index 271db99b46..1a20fe17ca 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -1335,7 +1335,7 @@ static int mov_write_av1c_tag(AVIOContext *pb, MOVTrack 
> *track)
>
>  avio_wb32(pb, 0);
>  ffio_wfourcc(pb, "av1C");
> -ff_isom_write_av1c(pb, track->vos_data, track->vos_len, 1);
> +ff_isom_write_av1c(pb, track->vos_data, track->vos_len, track->mode != 
> MODE_AVIF);
>  return update_size(pb, pos);
>  }
>
> @@ -2037,12 +2037,13 @@ static int mov_write_colr_tag(AVIOContext *pb, 
> MOVTrack *track, int prefer_icc)
>  }
>  }
>
> -/* We should only ever be called by MOV or MP4. */
> -av_assert0(track->mode == MODE_MOV || track->mode == MODE_MP4);
> +/* We should only ever be called for MOV, MP4 and AVIF. */
> +av_assert0(track->mode == MODE_MOV || track->mode == MODE_MP4 ||
> +   track->mode == MODE_AVIF);
>
>  avio_wb32(pb, 0); /* size */
>  ffio_wfourcc(pb, "colr");
> -if (track->mode == MODE_MP4)
> +if (track->mode == MODE_MP4 || track->mode == MODE_AVIF)
>  ffio_wfourcc(pb, "nclx");
>  else
>  ffio_wfourcc(pb, "nclc");
> @@ -2052,7 +2053,7 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack 
> *track, int prefer_icc)
>  avio_wb16(pb, track->par->color_primaries);
>  avio_wb16(pb, track->par->color_trc);
>  avio_wb16(pb, track->par->color_space);
> -if (track->mode == MODE_MP4) {
> +if (track->mode == MODE_MP4 || track->mode == MODE_AVIF) {
>  int full_range = track->par->color_range == AVCOL_RANGE_JPEG;
>  avio_w8(pb, full_range << 7);
>  }
> @@ -2118,7 +2119,7 @@ static void find_compressor(char * compressor_name, int 
> len, MOVTrack *track)
>|| (track->par->width == 1440 && track->par->height == 
> 1080)
>|| (track->par->width == 1920 && track->par->height == 
> 1080);
>
> -if (track->mode == MODE_MOV &&
> +if ((track->mode == MODE_AVIF || track->mode == MODE_MOV) &&
>  (encoder = av_dict_get(track->st->metadata, "encoder", NULL, 0))) {
>  av_strlcpy(compressor_name, encoder->value, 32);
>  } else if (track->par->codec_id == AV_CODEC_ID_MPEG2VIDEO && xdcam_res) {
> @@ -2139,6 +2140,25 @@ static void find_compressor(char * compressor_name, 
> int len, MOVTrack *track)
>  }
>  }
>
> +static int mov_write_ccst_tag(AVIOContext *pb)
> +{
> +int64_t pos = avio_tell(pb);
> +// Write sane defaults:
> +// all_ref_pics_intra = 0 : all samples can use any type of reference.
> +// intra_pred_used = 1 : intra prediction may or may not be used.
> +// max_ref_per_pic = 15 : reserved value to indicate that any number of
> +//reference 

Re: [FFmpeg-devel] [PATCH] ffmpeg: set user-set rotation for encoded streams too

2022-05-11 Thread Gyan Doshi




On 2022-05-10 05:10 pm, Gyan Doshi wrote:

So far, -metadata:s:v rotate would only be applied to streamcopied
video streams.


Plan to push tomorrow.

Gyan


---
  fftools/ffmpeg.c | 7 +++
  1 file changed, 7 insertions(+)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index a85ed18b08..7c1db2162a 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3048,6 +3048,13 @@ static int init_output_stream_encode(OutputStream *ost, 
AVFrame *frame)
  av_reduce(>frame_rate.num, >frame_rate.den,
ost->frame_rate.num, ost->frame_rate.den, 65535);
  }
+
+if (ost->rotate_overridden) {
+uint8_t *sd = av_stream_new_side_data(ost->st, 
AV_PKT_DATA_DISPLAYMATRIX,
+  sizeof(int32_t) * 9);
+if (sd)
+av_display_rotation_set((int32_t *)sd, 
-ost->rotate_override_value);
+}
  }
  
  switch (enc_ctx->codec_type) {


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

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


[FFmpeg-devel] [PATCH 2/2] avcodec/decode: Don't allocate FrameDecodeData if it is unneeded

2022-05-11 Thread Andreas Rheinhardt
Currently, every call to ff_get_buffer() allocates FrameDecodeData,
although only very few decoders (those that might use nvdec or
videotoolbox hardware acceleration) actually need it.

This commit addresses this by adding an internal codec cap
to ensure that FrameDecodeData is only allocated for codecs
that might need it (i.e. for which there is a hardware acceleration
that might actually need it).

Signed-off-by: Andreas Rheinhardt 
---
1. It seems that this has even been allocated for some encoders
before c954cf1e1b766a0d1992d5be0a8be0055a8e1a6a.
2. Given that the videotoolbox hwaccels call ff_attach_decode_data()
themselves, they actually don't need the generic part of
ff_get_buffer() to allocate it for them; in particular, one could
avoid adding the flag to the prores decoder. I can modify the patch
in this way if desired (it would also necessitate modifying the assert
in decode_receive_frame_internal()).
3. Unfortunately, I don't have hardware to actually test nvdec or
videotoolbox, so only the "it works if allocating it is certainly
unnecessary" has been tested. It would be nice if someone could 
also test the other part.
4. One could of course set these flags only if the relevant hwaccels
are enabled at compile-time.
5. Unfortunately, it seems to be too late to call
ff_attach_decode_data() from ff_nvdec_start_frame(), as it is called
after ff_thread_finish_setup() might have been called, so modifying
the frame would be a race.
6. Maybe the following would also work: Add a caps_internal to AVHWAccel
and only allocate FrameDecodeData if the hardware acceleration currently
in use needs it (as given by this new cap). It should work (hopefully)
and would be cleaner.

 libavcodec/av1dec.c |  3 ++-
 libavcodec/codec_internal.h |  5 +
 libavcodec/decode.c | 16 +---
 libavcodec/h263dec.c|  6 --
 libavcodec/h264dec.c|  3 ++-
 libavcodec/hevcdec.c|  3 ++-
 libavcodec/mjpegdec.c   |  3 ++-
 libavcodec/mpeg12dec.c  |  6 --
 libavcodec/mpeg4videodec.c  |  3 ++-
 libavcodec/proresdec2.c |  3 ++-
 libavcodec/tests/avcodec.c  | 15 ++-
 libavcodec/vc1dec.c |  6 --
 libavcodec/vp8.c|  3 ++-
 libavcodec/vp9.c|  3 ++-
 14 files changed, 56 insertions(+), 22 deletions(-)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 1c09b1d6d6..291ba94a36 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -1250,7 +1250,8 @@ const FFCodec ff_av1_decoder = {
 .p.capabilities= AV_CODEC_CAP_DR1 | AV_CODEC_CAP_AVOID_PROBING,
 .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
  FF_CODEC_CAP_INIT_CLEANUP |
- FF_CODEC_CAP_SETS_PKT_DTS,
+ FF_CODEC_CAP_SETS_PKT_DTS |
+ FF_CODEC_CAP_FRAME_DECODE_DATA,
 .flush = av1_decode_flush,
 .p.profiles= NULL_IF_CONFIG_SMALL(ff_av1_profiles),
 .p.priv_class  = _class,
diff --git a/libavcodec/codec_internal.h b/libavcodec/codec_internal.h
index 5df286ce52..cefe3fdd1a 100644
--- a/libavcodec/codec_internal.h
+++ b/libavcodec/codec_internal.h
@@ -73,6 +73,11 @@
  * internal logic derive them from AVCodecInternal.last_pkt_props.
  */
 #define FF_CODEC_CAP_SETS_FRAME_PROPS   (1 << 8)
+/**
+ * This decoder might use FrameDecodeData. In particular, ff_get_buffer()
+ * shall allocate it.
+ */
+#define FF_CODEC_CAP_FRAME_DECODE_DATA  (1 << 9)
 
 /**
  * FFCodec.codec_tags termination value
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 264fc66a81..33c97c41a6 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -548,10 +548,10 @@ static int decode_receive_frame_internal(AVCodecContext 
*avctx, AVFrame *frame)
  frame->pts,
  frame->pkt_dts);
 
-/* the only case where decode data is not set should be decoders
- * that do not call ff_get_buffer() */
-av_assert0((frame->private_ref && frame->private_ref->size == 
sizeof(FrameDecodeData)) ||
-   !(avctx->codec->capabilities & AV_CODEC_CAP_DR1));
+/* the only case where decode data may be set should be decoders
+ * with the FF_CODEC_CAP_FRAME_DECODE_DATA cap */
+av_assert0(!frame->private_ref ||
+   codec->caps_internal & FF_CODEC_CAP_FRAME_DECODE_DATA);
 
 if (frame->private_ref) {
 FrameDecodeData *fdd = (FrameDecodeData*)frame->private_ref->data;
@@ -1460,9 +1460,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 validate_avframe_allocation(avctx, frame);
 
-ret = ff_attach_decode_data(frame);
-if (ret < 0)
-goto fail;
+if (ffcodec(avctx->codec)->caps_internal & FF_CODEC_CAP_FRAME_DECODE_DATA) 
{
+ret = ff_attach_decode_data(frame);
+if (ret < 0)
+goto fail;
+}

[FFmpeg-devel] [PATCH 1/2] avcodec/wrapped_avframe: Don't attach FrameDecodeData unnecessarily

2022-05-11 Thread Andreas Rheinhardt
It is unneeded, as this decoder does not call ff_get_buffer().

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/wrapped_avframe.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/libavcodec/wrapped_avframe.c b/libavcodec/wrapped_avframe.c
index 3af007d478..06c274eed0 100644
--- a/libavcodec/wrapped_avframe.c
+++ b/libavcodec/wrapped_avframe.c
@@ -98,12 +98,6 @@ static int wrapped_avframe_decode(AVCodecContext *avctx, 
AVFrame *out,
 
 av_frame_move_ref(out, in);
 
-err = ff_attach_decode_data(out);
-if (err < 0) {
-av_frame_unref(out);
-return err;
-}
-
 *got_frame = 1;
 return 0;
 }
-- 
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 1/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122

2022-05-11 Thread Zane van Iperen




On 11/5/22 21:53, Anton Khirnov wrote:

Quoting Zane van Iperen (2022-04-24 12:14:03)

+void av_uuid_nil_set(AVUUID uu)

 ^^^
sounds weird

av_uuid_zero()?
av_uuid_reset()?



Good point, `av_uuid_zero()` has a nice ring to it.
___
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/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122

2022-05-11 Thread Zane van Iperen




On 10/5/22 23:18, Andreas Rheinhardt wrote:


+int av_uuid_parse_range(const char *in_start, const char *in_end, AVUUID uu)
+{
+int i;
+const char *cp;
+char buf[3];
+
+if ((in_end - in_start) != 36)
+return -1;
+
+for (i = 0, cp = in_start; i < 36; i++, cp++) {
+if (i == 8 || i == 13 || i == 18 || i == 23) {
+if (*cp == '-')
+continue;
+return AVERROR(EINVAL);
+}
+
+if (!av_isxdigit(*cp))
+return AVERROR(EINVAL);
+}
+
+buf[2] = '\0';
+for (i = 0, cp = in_start; i < 16; i++) {
+if (i == 4 || i == 6 || i == 8 || i == 10)
+cp++;
+
+buf[0] = *cp++;
+buf[1] = *cp++;
+
+errno = 0;
+uu[i] = strtoul(buf, NULL, 16);
+if (errno)
+return AVERROR(errno);


How could this ever happen given that you have already checked that the
buffer only contains hex digits? And isn't using strtoul a bit overkill
anyway? I'd just check and parse this stuff in one loop.



Yeah, good point. It's based off libuuid's, which has some time/clock uuid 
handling
between the two loops. I'll tidy it up in the next few days... hopefully...


+/**
+ * @file
+ * UUID parsing and serialization utilities.
+ * The library treat the UUID as an opaque sequence of 16 unsigned bytes,

^
s


Fixed.


+/**
+ * Parses a string representation of a UUID formatted according to IETF RFC 
4122
+ * into an AVUUID. The parsing is case-insensitive. The string must be 37
+ * characters long, including the terminating NULL character.


NUL, NULL is for pointers.



Changed.


+/**
+ * Parses a string representation of a UUID formatted according to IETF RFC 
4122
+ * into an AVUUID. The parsing is case-insensitive. The string must consist of
+ * 36 characters, i.e. `in_end - in_start == 36`
+ *
+ * @param[in]  in_start Pointer to the first character of the string 
representation
+ * @param[in]  in_end   Pointer to the character after the last character of 
the
+ *  string representation. That memory location is never
+ *  accessed
+ * @param[out] uu   AVUUID
+ * @return  A non-zero value in case of an error.
+ */
+int av_uuid_parse_range(const char *in_start, const char *in_end, AVUUID uu);


This sounds like in_end is actually redundant. Does retaining it improve
extensibility?



I believe so. The main difference is av_uuid_parse_range() can handle non 
NUL-termiated
strings. I can just remove the entire last sentence (or change "must" to 
"should").


+
+/**
+ * Serializes a AVUUID into a string representation according to IETF RFC 4122.
+ * The string is lowercase and always 37 characters long, including the
+ * terminating NULL character.
+ *
+ * @param[in]  uu  AVUUID
+ * @param[out] out Pointer to a array of no less than 37 characters.

   ^
   n



Fixed.



+/**
+ * Sets a UUID to nil
+ *
+ * @param[in,out]  uu  UUID to be set to nil
+ */
+void av_uuid_nil_set(AVUUID uu);


Why are these three functions not static inline? Exporting them seems
like a waste.



No particular reason, it's easy enough to change.

___
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/4] avcodec/dvdsubenc: return error if canvas_size is too small for subtitle render

2022-05-11 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/dvdsubenc.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/dvdsubenc.c b/libavcodec/dvdsubenc.c
index fc3b7d1816..d29db7d49c 100644
--- a/libavcodec/dvdsubenc.c
+++ b/libavcodec/dvdsubenc.c
@@ -376,6 +376,12 @@ static int encode_dvd_subtitles(AVCodecContext *avctx,
 x2 = vrect.x + vrect.w - 1;
 y2 = vrect.y + vrect.h - 1;
 
+if (x2 > avctx->width || y2 > avctx->height) {
+av_log(avctx, AV_LOG_ERROR, "canvas_size(%d:%d) is too small(%d:%d) 
for render\n",
+   avctx->width, avctx->height, x2, y2);
+ret = AVERROR(EINVAL);;
+goto fail;
+}
 *q++ = 0x05;
 // x1 x2 -> 6 nibbles
 *q++ = vrect.x >> 4;
-- 
2.35.1

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

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


[FFmpeg-devel] [PATCH 3/4] avformat/sccenc: avoid potential invalid access

2022-05-11 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/sccenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/sccenc.c b/libavformat/sccenc.c
index c8c4d097e4..2b924ba6e7 100644
--- a/libavformat/sccenc.c
+++ b/libavformat/sccenc.c
@@ -72,11 +72,11 @@ static int scc_write_packet(AVFormatContext *avf, AVPacket 
*pkt)
 s = (int)(pts /  1000) % 60;
 f = (int)(pts %  1000) / 33;
 
-for (i = 0; i < pkt->size; i+=3) {
+for (i = 0; i < pkt->size - 2; i+=3) {
 if (pkt->data[i] == 0xfc && ((pkt->data[i + 1] != 0x80 || pkt->data[i 
+ 2] != 0x80)))
 break;
 }
-if (i >= pkt->size)
+if (i >= pkt->size - 2)
 return 0;
 
 if (!scc->inside && (scc->prev_h != h || scc->prev_m != m || scc->prev_s 
!= s || scc->prev_f != f)) {
-- 
2.35.1

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

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


[FFmpeg-devel] [PATCH 2/4] avcodec/ccaption_dec: check the length of packet and return used length

2022-05-11 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavcodec/ccaption_dec.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
index 34f0513b1a..8f61e8aa03 100644
--- a/libavcodec/ccaption_dec.c
+++ b/libavcodec/ccaption_dec.c
@@ -852,6 +852,11 @@ static int decode(AVCodecContext *avctx, AVSubtitle *sub,
 int i;
 unsigned nb_rect_allocated = 0;
 
+if (len < 3) {
+ff_dlog(avctx, "incomplete or broken packet");
+return len;
+}
+
 for (i = 0; i < len; i += 3) {
 uint8_t hi, cc_type = bptr[i] & 1;
 
@@ -922,7 +927,7 @@ static int decode(AVCodecContext *avctx, AVSubtitle *sub,
 }
 
 *got_sub = sub->num_rects > 0;
-return ret;
+return len;
 }
 
 #define OFFSET(x) offsetof(CCaptionSubContext, x)
-- 
2.35.1

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

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


[FFmpeg-devel] [PATCH 1/4] remove sccenc dependency on subtitles

2022-05-11 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 3b9995a9d3..8e612b6cc7 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -514,7 +514,7 @@ OBJS-$(CONFIG_SBC_DEMUXER)   += sbcdec.o 
rawdec.o
 OBJS-$(CONFIG_SBC_MUXER) += rawenc.o
 OBJS-$(CONFIG_SBG_DEMUXER)   += sbgdec.o
 OBJS-$(CONFIG_SCC_DEMUXER)   += sccdec.o subtitles.o
-OBJS-$(CONFIG_SCC_MUXER) += sccenc.o subtitles.o
+OBJS-$(CONFIG_SCC_MUXER) += sccenc.o
 OBJS-$(CONFIG_SCD_DEMUXER)   += scd.o
 OBJS-$(CONFIG_SDP_DEMUXER)   += rtsp.o
 OBJS-$(CONFIG_SDR2_DEMUXER)  += sdr2.o
-- 
2.35.1

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

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


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

2022-05-11 Thread Tobias Rapp

On 11/05/2022 09:57, Soft Works wrote:


[...]

I'm not sure how much you had followed, so please excuse in case you
had already read it: the manifest approach does not work on a default
Windows installation.
To activate long path support, the users needs to opt-in to a behavior
that is probably deactivated by default for some reason. Also it
requires administrative privileges to make this change.
For me - and probably for others as well - that approach is useless,
as it would be the same as if there would be no long path support.
(when you cannot rely on that feature being always working, you
cannot use it)


For me an analogous case is the usage of the "--large-address-aware" 
linker flag. It enables FFmpeg to use more than 2GiB of memory on Win32. 
That feature is useless to users having <= 2GiB of total system memory 
available, and it makes no guarantee that an OOM error is avoided. Still 
it allows to exceed a limit for those that match the requirements -- 
knowingly or by pure coincidence.


Regards,
Tobias

___
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] avcodec: add an AVCodecContext flag to export A53/SCTE20/DVD CC side data on demand

2022-05-11 Thread lance . lmwang
On Wed, May 11, 2022 at 02:00:10PM +0200, Anton Khirnov wrote:
> Quoting lance.lmw...@gmail.com (2022-05-08 09:17:01)
> > From: Limin Wang 
> > 
> > some samples include both A53 and SCTE20 data. Before the commit, both
> > of the will be exported, so the CC data will be repeated or garbarge
> 
> Why would it be garbage? That sounds like a bug.
> Why can't we just export both?
for A53/SCTE20/DVDCC are exprted by A53_CC side data and they're sharing
the same a53_buf_ref to store the data, so if stream contains CC wrapped
as ATSC A53 packets + the same data wrapped as SCTE-20 packets, the CC
data will repeated. We can consider to add a new side data type if necessary,
but it's preferable to export A53_CC even it's SCTE20, so we can't export
both by A53_CC still.

related topic for it:
https://trac.ffmpeg.org/ticket/9724
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20220427084949.73931-1-4ru...@gmail.com/
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20180306222512.20124-1-ffm...@tmm1.net/


> 
> -- 
> Anton Khirnov

-- 
Thanks,
Limin Wang
___
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] ffmpeg: set user-set rotation for encoded streams too

2022-05-11 Thread Gyan Doshi




On 2022-05-11 05:26 pm, Anton Khirnov wrote:

Quoting Gyan Doshi (2022-05-10 13:40:54)

So far, -metadata:s:v rotate would only be applied to streamcopied
video streams.

Using -metadata for this functionality is a hack that should be removed,
not extended.


When there's a replacement for CLI users, sure.
Till then, there's no need for the disparity to be maintained.

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

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


Re: [FFmpeg-devel] [PATCH 2/2] avcodec: add an AVCodecContext flag to export A53/SCTE20/DVD CC side data on demand

2022-05-11 Thread Anton Khirnov
Quoting lance.lmw...@gmail.com (2022-05-08 09:17:01)
> From: Limin Wang 
> 
> some samples include both A53 and SCTE20 data. Before the commit, both
> of the will be exported, so the CC data will be repeated or garbarge

Why would it be garbage? That sounds like a bug.
Why can't we just export both?

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

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


Re: [FFmpeg-devel] [PATCH] ffmpeg: set user-set rotation for encoded streams too

2022-05-11 Thread Anton Khirnov
Quoting Gyan Doshi (2022-05-10 13:40:54)
> So far, -metadata:s:v rotate would only be applied to streamcopied
> video streams.

Using -metadata for this functionality is a hack that should be removed,
not extended.

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

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


Re: [FFmpeg-devel] [PATCH v2 1/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122

2022-05-11 Thread Anton Khirnov
Quoting Zane van Iperen (2022-04-24 12:14:03)
> +void av_uuid_nil_set(AVUUID uu)
^^^
sounds weird

av_uuid_zero()?
av_uuid_reset()?

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

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


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

2022-05-11 Thread nil-admirari
> I'm not sure how much you had followed, so please excuse in case you
> had already read it: the manifest approach does not work on a default
> Windows installation.
> To activate long path support, the users needs to opt-in to a behavior
> that is probably deactivated by default for some reason. Also it
> requires administrative privileges to make this change.
> For me - and probably for others as well - that approach is useless,
> as it would be the same as if there would be no long path support.
> (when you cannot rely on that feature being always working, you
> cannot use it)

For yt-dlp and StaxRip users manifest change is not the same as
the complete absence of a feature. If it's that way for you, well it doesn't 
take
much effort to pretend that the manifest is just not there.



___
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 v11 1/6] libavutil/wchar_filename.h: Add whcartoutf8, wchartoansi and utf8toansi

2022-05-11 Thread nil-admirari
> I think that can be changed easily.

How about writing the necessary patches yourself?

> A path using forward slashes can still be prefixed with '\\?\'

It cannot. Only backslashes are valid in \\?\ paths.

> The prefixing can be implemented as a function and then be used 
> in file_open.c.
> Other file system related functions like mkdir, rename, rmdir, etc.
> are already intercepted in os_support.h, and the prefixing can be 
> applied there.

I haven't found path concat in these headers. What I did find, however,
is the use of snprintf with forward slash separators right inside the #ifdef 
_WIN32:

#if defined(_WIN32) || defined (__ANDROID__) || defined(__DJGPP__)
if (fd < 0) {
snprintf(*filename, len, "./%sXX", prefix);
fd = mkstemp(*filename);
}
#endif

> I have not fully analyzed the situation,
> but surely there are just a small number of places that need to 
> be changed and not 587.

587 was obtained with fgrep snprintf **/*.c | wc -l (became 588 after a recent 
pull).
At least two of these uses of snprintf correspond to path concatenation,
and have been already presented here. Not all of them do, but I have no interest
in examining the other 586 cases. But if you think that it's easy, well go 
ahead.



___
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/9] fftools/ffmpeg: share the code encoding a single frame between video and audio

2022-05-11 Thread Anton Khirnov
In case anyone cares about the context - these patches were previously a
part of the muxer-threading set, but I've decided to factor them out and
reshuffle them. do_video_stats() is now kept close to the encoder rather
than being moved to the muxing code.

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

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


[FFmpeg-devel] [PATCH 9/9] fftools/ffmpeg: move processing AV_PKT_DATA_QUALITY_STATS to do_video_stats()

2022-05-11 Thread Anton Khirnov
This is a more appropriate place for this code, since the values we read
from AV_PKT_DATA_QUALITY_STATS side data are primarily written into
video stats. This ensures that the values written into stats actually
apply to the right packet.

Rename the function to update_video_stats() to better reflect its new
purpose.
---
 fftools/ffmpeg.c | 23 +++
 fftools/ffmpeg_mux.c | 13 -
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index fe7c37db62..2706719206 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -835,13 +835,28 @@ static double psnr(double d)
 return -10.0 * log10(d);
 }
 
-static void do_video_stats(OutputStream *ost, const AVPacket *pkt)
+static void update_video_stats(OutputStream *ost, const AVPacket *pkt, int 
write_vstats)
 {
+const uint8_t *sd = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS,
+NULL);
 AVCodecContext *enc = ost->enc_ctx;
 int frame_number;
 double ti1, bitrate, avg_bitrate;
 
-/* this is executed just the first time do_video_stats is called */
+ost->quality   = sd ? AV_RL32(sd) : -1;
+ost->pict_type = sd ? sd[4] : AV_PICTURE_TYPE_NONE;
+
+for (int i = 0; ierror); i++) {
+if (sd && i < sd[5])
+ost->error[i] = AV_RL64(sd + 8 + 8*i);
+else
+ost->error[i] = -1;
+}
+
+if (!write_vstats)
+return;
+
+/* this is executed just the first time update_video_stats is called */
 if (!vstats_file) {
 vstats_file = fopen(vstats_filename, "w");
 if (!vstats_file) {
@@ -941,8 +956,8 @@ static int encode_frame(OutputFile *of, OutputStream *ost, 
AVFrame *frame)
av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, 
>time_base));
 }
 
-if (enc->codec_type == AVMEDIA_TYPE_VIDEO && vstats_filename)
-do_video_stats(ost, pkt);
+if (enc->codec_type == AVMEDIA_TYPE_VIDEO)
+update_video_stats(ost, pkt, !!vstats_filename);
 
 ost->packets_encoded++;
 
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 3cdaa494d7..794d580635 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -101,19 +101,6 @@ void of_write_packet(OutputFile *of, AVPacket *pkt, 
OutputStream *ost,
 pkt->pts = pkt->dts = AV_NOPTS_VALUE;
 
 if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
-int i;
-uint8_t *sd = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS,
-  NULL);
-ost->quality = sd ? AV_RL32(sd) : -1;
-ost->pict_type = sd ? sd[4] : AV_PICTURE_TYPE_NONE;
-
-for (i = 0; ierror); i++) {
-if (sd && i < sd[5])
-ost->error[i] = AV_RL64(sd + 8 + 8*i);
-else
-ost->error[i] = -1;
-}
-
 if (ost->frame_rate.num && ost->is_cfr) {
 if (pkt->duration > 0)
 av_log(NULL, AV_LOG_WARNING, "Overriding packet duration by 
frame rate, this should not happen\n");
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 6/9] fftools/ffmpeg: stop using AVStream.nb_frames in do_video_stats()

2022-05-11 Thread Anton Khirnov
Its use for muxing is not documented, in practice it is incremented per
each packet successfully passed to the muxer's write_packet(). Since
there is a lot of indirection between ffmpeg receiving a packet from the
encoder and it actually being written (e.g. bitstream filters, the
interleaving queue), using nb_frames here is incorrect.

Add a new counter for packets received from encoder instead.
---
 fftools/ffmpeg.c | 4 +++-
 fftools/ffmpeg.h | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index ae3cc57bef..c15d1486dd 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -851,7 +851,7 @@ static void do_video_stats(OutputStream *ost, int 
frame_size)
 }
 
 enc = ost->enc_ctx;
-frame_number = ost->st->nb_frames;
+frame_number = ost->packets_encoded;
 if (vstats_version <= 1) {
 fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number,
 ost->quality / (float)FF_QP2LAMBDA);
@@ -945,6 +945,8 @@ static int encode_frame(OutputFile *of, OutputStream *ost, 
AVFrame *frame)
 if (enc->codec_type == AVMEDIA_TYPE_VIDEO && vstats_filename)
 do_video_stats(ost, pkt->size);
 
+ost->packets_encoded++;
+
 output_packet(of, pkt, ost, 0);
 
 /* if two pass, output log */
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 9f0c093e34..7326193caf 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -551,6 +551,8 @@ typedef struct OutputStream {
 // number of frames/samples sent to the encoder
 uint64_t frames_encoded;
 uint64_t samples_encoded;
+// number of packets received from the encoder
+uint64_t packets_encoded;
 
 /* packet quality factor */
 int quality;
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 8/9] fftools/ffmpeg: merge variable declaration and initialization

2022-05-11 Thread Anton Khirnov
---
 fftools/ffmpeg.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 5983c57410..fe7c37db62 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -837,7 +837,7 @@ static double psnr(double d)
 
 static void do_video_stats(OutputStream *ost, const AVPacket *pkt)
 {
-AVCodecContext *enc;
+AVCodecContext *enc = ost->enc_ctx;
 int frame_number;
 double ti1, bitrate, avg_bitrate;
 
@@ -850,7 +850,6 @@ static void do_video_stats(OutputStream *ost, const 
AVPacket *pkt)
 }
 }
 
-enc = ost->enc_ctx;
 frame_number = ost->packets_encoded;
 if (vstats_version <= 1) {
 fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number,
-- 
2.34.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 5/9] fftools/ffmpeg: move do_video_stats() to avoid a forward declaration

2022-05-11 Thread Anton Khirnov
---
 fftools/ffmpeg.c | 93 
 1 file changed, 46 insertions(+), 47 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 2bc612f448..ae3cc57bef 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -127,7 +127,6 @@ typedef struct BenchmarkTimeStamps {
 int64_t sys_usec;
 } BenchmarkTimeStamps;
 
-static void do_video_stats(OutputStream *ost, int frame_size);
 static BenchmarkTimeStamps get_benchmark_time_stamps(void);
 static int64_t getmaxrss(void);
 static int ifilter_has_all_input_formats(FilterGraph *fg);
@@ -831,6 +830,52 @@ static int init_output_stream_wrapper(OutputStream *ost, 
AVFrame *frame,
 return ret;
 }
 
+static double psnr(double d)
+{
+return -10.0 * log10(d);
+}
+
+static void do_video_stats(OutputStream *ost, int frame_size)
+{
+AVCodecContext *enc;
+int frame_number;
+double ti1, bitrate, avg_bitrate;
+
+/* this is executed just the first time do_video_stats is called */
+if (!vstats_file) {
+vstats_file = fopen(vstats_filename, "w");
+if (!vstats_file) {
+perror("fopen");
+exit_program(1);
+}
+}
+
+enc = ost->enc_ctx;
+frame_number = ost->st->nb_frames;
+if (vstats_version <= 1) {
+fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number,
+ost->quality / (float)FF_QP2LAMBDA);
+} else  {
+fprintf(vstats_file, "out= %2d st= %2d frame= %5d q= %2.1f ", 
ost->file_index, ost->index, frame_number,
+ost->quality / (float)FF_QP2LAMBDA);
+}
+
+if (ost->error[0]>=0 && (enc->flags & AV_CODEC_FLAG_PSNR))
+fprintf(vstats_file, "PSNR= %6.2f ", psnr(ost->error[0] / (enc->width 
* enc->height * 255.0 * 255.0)));
+
+fprintf(vstats_file,"f_size= %6d ", frame_size);
+/* compute pts value */
+ti1 = av_stream_get_end_pts(ost->st) * av_q2d(ost->st->time_base);
+if (ti1 < 0.01)
+ti1 = 0.01;
+
+bitrate = (frame_size * 8) / av_q2d(enc->time_base) / 1000.0;
+avg_bitrate = (double)(ost->data_size * 8) / ti1 / 1000.0;
+fprintf(vstats_file, "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= 
%7.1fkbits/s ",
+   (double)ost->data_size / 1024, ti1, bitrate, avg_bitrate);
+fprintf(vstats_file, "type= %c\n", 
av_get_picture_type_char(ost->pict_type));
+}
+
 static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame)
 {
 AVCodecContext   *enc = ost->enc_ctx;
@@ -1230,52 +1275,6 @@ static void do_video_out(OutputFile *of,
 av_frame_move_ref(ost->last_frame, next_picture);
 }
 
-static double psnr(double d)
-{
-return -10.0 * log10(d);
-}
-
-static void do_video_stats(OutputStream *ost, int frame_size)
-{
-AVCodecContext *enc;
-int frame_number;
-double ti1, bitrate, avg_bitrate;
-
-/* this is executed just the first time do_video_stats is called */
-if (!vstats_file) {
-vstats_file = fopen(vstats_filename, "w");
-if (!vstats_file) {
-perror("fopen");
-exit_program(1);
-}
-}
-
-enc = ost->enc_ctx;
-frame_number = ost->st->nb_frames;
-if (vstats_version <= 1) {
-fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number,
-ost->quality / (float)FF_QP2LAMBDA);
-} else  {
-fprintf(vstats_file, "out= %2d st= %2d frame= %5d q= %2.1f ", 
ost->file_index, ost->index, frame_number,
-ost->quality / (float)FF_QP2LAMBDA);
-}
-
-if (ost->error[0]>=0 && (enc->flags & AV_CODEC_FLAG_PSNR))
-fprintf(vstats_file, "PSNR= %6.2f ", psnr(ost->error[0] / (enc->width 
* enc->height * 255.0 * 255.0)));
-
-fprintf(vstats_file,"f_size= %6d ", frame_size);
-/* compute pts value */
-ti1 = av_stream_get_end_pts(ost->st) * av_q2d(ost->st->time_base);
-if (ti1 < 0.01)
-ti1 = 0.01;
-
-bitrate = (frame_size * 8) / av_q2d(enc->time_base) / 1000.0;
-avg_bitrate = (double)(ost->data_size * 8) / ti1 / 1000.0;
-fprintf(vstats_file, "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= 
%7.1fkbits/s ",
-   (double)ost->data_size / 1024, ti1, bitrate, avg_bitrate);
-fprintf(vstats_file, "type= %c\n", 
av_get_picture_type_char(ost->pict_type));
-}
-
 static void finish_output_stream(OutputStream *ost)
 {
 OutputFile *of = output_files[ost->file_index];
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 7/9] fftools/ffmpeg: stop using av_stream_get_end_pts() in do_video_stats()

2022-05-11 Thread Anton Khirnov
It retrieves libavformat's internal dts value (contrary to the
function's name), which is not only incorrect in general, but also
unnecessary because we can access the packet directly.
---
 fftools/ffmpeg.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index c15d1486dd..5983c57410 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -835,7 +835,7 @@ static double psnr(double d)
 return -10.0 * log10(d);
 }
 
-static void do_video_stats(OutputStream *ost, int frame_size)
+static void do_video_stats(OutputStream *ost, const AVPacket *pkt)
 {
 AVCodecContext *enc;
 int frame_number;
@@ -863,13 +863,13 @@ static void do_video_stats(OutputStream *ost, int 
frame_size)
 if (ost->error[0]>=0 && (enc->flags & AV_CODEC_FLAG_PSNR))
 fprintf(vstats_file, "PSNR= %6.2f ", psnr(ost->error[0] / (enc->width 
* enc->height * 255.0 * 255.0)));
 
-fprintf(vstats_file,"f_size= %6d ", frame_size);
+fprintf(vstats_file,"f_size= %6d ", pkt->size);
 /* compute pts value */
-ti1 = av_stream_get_end_pts(ost->st) * av_q2d(ost->st->time_base);
+ti1 = pkt->dts * av_q2d(ost->mux_timebase);
 if (ti1 < 0.01)
 ti1 = 0.01;
 
-bitrate = (frame_size * 8) / av_q2d(enc->time_base) / 1000.0;
+bitrate = (pkt->size * 8) / av_q2d(enc->time_base) / 1000.0;
 avg_bitrate = (double)(ost->data_size * 8) / ti1 / 1000.0;
 fprintf(vstats_file, "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= 
%7.1fkbits/s ",
(double)ost->data_size / 1024, ti1, bitrate, avg_bitrate);
@@ -943,7 +943,7 @@ static int encode_frame(OutputFile *of, OutputStream *ost, 
AVFrame *frame)
 }
 
 if (enc->codec_type == AVMEDIA_TYPE_VIDEO && vstats_filename)
-do_video_stats(ost, pkt->size);
+do_video_stats(ost, pkt);
 
 ost->packets_encoded++;
 
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 1/9] fftools/ffmpeg: share the code encoding a single frame between video and audio

2022-05-11 Thread Anton Khirnov
Call do_video_stats() for every video packets produced by the encoder,
rather than for every frame sent to the encoder.
---
 fftools/ffmpeg.c | 145 ---
 1 file changed, 60 insertions(+), 85 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index a85ed18b08..0e62c39522 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -831,63 +831,96 @@ static int init_output_stream_wrapper(OutputStream *ost, 
AVFrame *frame,
 return ret;
 }
 
-static void do_audio_out(OutputFile *of, OutputStream *ost,
- AVFrame *frame)
+static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame)
 {
-AVCodecContext *enc = ost->enc_ctx;
-AVPacket *pkt = ost->pkt;
+AVCodecContext   *enc = ost->enc_ctx;
+AVPacket *pkt = ost->pkt;
+const char *type_desc = av_get_media_type_string(enc->codec_type);
 int ret;
 
-adjust_frame_pts_to_encoder_tb(of, ost, frame);
-
-if (!check_recording_time(ost))
-return;
-
-if (frame->pts == AV_NOPTS_VALUE || audio_sync_method < 0)
-frame->pts = ost->sync_opts;
-ost->sync_opts = frame->pts + frame->nb_samples;
-ost->samples_encoded += frame->nb_samples;
 ost->frames_encoded++;
 
 update_benchmark(NULL);
+
 if (debug_ts) {
-av_log(NULL, AV_LOG_INFO, "encoder <- type:audio "
+av_log(NULL, AV_LOG_INFO, "encoder <- type:%s "
"frame_pts:%s frame_pts_time:%s time_base:%d/%d\n",
+   type_desc,
av_ts2str(frame->pts), av_ts2timestr(frame->pts, 
>time_base),
enc->time_base.num, enc->time_base.den);
 }
 
 ret = avcodec_send_frame(enc, frame);
-if (ret < 0)
-goto error;
+if (ret < 0) {
+av_log(NULL, AV_LOG_ERROR, "Error submitting %s frame to the 
encoder\n",
+   type_desc);
+return ret;
+}
 
 while (1) {
 ret = avcodec_receive_packet(enc, pkt);
+update_benchmark("encode_%s %d.%d", type_desc,
+ ost->file_index, ost->index);
 if (ret == AVERROR(EAGAIN))
-break;
-if (ret < 0)
-goto error;
+return 0;
+else if (ret < 0) {
+av_log(NULL, AV_LOG_ERROR, "%s encoding failed\n", type_desc);
+return ret;
+}
 
-update_benchmark("encode_audio %d.%d", ost->file_index, ost->index);
+if (debug_ts) {
+av_log(NULL, AV_LOG_INFO, "encoder -> type:%s "
+   "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s "
+   "duration:%s duration_time:%s\n",
+   type_desc,
+   av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, 
>time_base),
+   av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, 
>time_base),
+   av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, 
>time_base));
+}
 
 av_packet_rescale_ts(pkt, enc->time_base, ost->mux_timebase);
 
 if (debug_ts) {
-av_log(NULL, AV_LOG_INFO, "encoder -> type:audio "
+av_log(NULL, AV_LOG_INFO, "encoder -> type:%s "
"pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s "
"duration:%s duration_time:%s\n",
+   type_desc,
av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, 
>time_base),
av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, 
>time_base),
av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, 
>time_base));
 }
 
+if (enc->codec_type == AVMEDIA_TYPE_VIDEO && vstats_filename)
+do_video_stats(ost, pkt->size);
+
 output_packet(of, pkt, ost, 0);
+
+/* if two pass, output log */
+if (ost->logfile && enc->stats_out)
+fprintf(ost->logfile, "%s", enc->stats_out);
 }
 
-return;
-error:
-av_log(NULL, AV_LOG_FATAL, "Audio encoding failed\n");
-exit_program(1);
+av_assert0(0);
+}
+
+static void do_audio_out(OutputFile *of, OutputStream *ost,
+ AVFrame *frame)
+{
+int ret;
+
+adjust_frame_pts_to_encoder_tb(of, ost, frame);
+
+if (!check_recording_time(ost))
+return;
+
+if (frame->pts == AV_NOPTS_VALUE || audio_sync_method < 0)
+frame->pts = ost->sync_opts;
+ost->sync_opts = frame->pts + frame->nb_samples;
+ost->samples_encoded += frame->nb_samples;
+
+ret = encode_frame(of, ost, frame);
+if (ret < 0)
+exit_program(1);
 }
 
 static void do_subtitle_out(OutputFile *of,
@@ -979,14 +1012,12 @@ static void do_video_out(OutputFile *of,
  AVFrame *next_picture)
 {
 int ret;
-AVPacket *pkt = ost->pkt;
 AVCodecContext *enc = ost->enc_ctx;
 AVRational frame_rate;
 int nb_frames, nb0_frames, i;
 double delta, delta0;
 double duration = 0;
 double sync_ipts = AV_NOPTS_VALUE;
-int frame_size = 0;
   

[FFmpeg-devel] [PATCH 4/9] fftools/ffmpeg: drop a useless check and reduce indentation

2022-05-11 Thread Anton Khirnov
do_video_stats() is only ever called for video.
---
 fftools/ffmpeg.c | 48 +++-
 1 file changed, 23 insertions(+), 25 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 69b9c42822..2bc612f448 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1251,31 +1251,29 @@ static void do_video_stats(OutputStream *ost, int 
frame_size)
 }
 
 enc = ost->enc_ctx;
-if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
-frame_number = ost->st->nb_frames;
-if (vstats_version <= 1) {
-fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number,
-ost->quality / (float)FF_QP2LAMBDA);
-} else  {
-fprintf(vstats_file, "out= %2d st= %2d frame= %5d q= %2.1f ", 
ost->file_index, ost->index, frame_number,
-ost->quality / (float)FF_QP2LAMBDA);
-}
-
-if (ost->error[0]>=0 && (enc->flags & AV_CODEC_FLAG_PSNR))
-fprintf(vstats_file, "PSNR= %6.2f ", psnr(ost->error[0] / 
(enc->width * enc->height * 255.0 * 255.0)));
-
-fprintf(vstats_file,"f_size= %6d ", frame_size);
-/* compute pts value */
-ti1 = av_stream_get_end_pts(ost->st) * av_q2d(ost->st->time_base);
-if (ti1 < 0.01)
-ti1 = 0.01;
-
-bitrate = (frame_size * 8) / av_q2d(enc->time_base) / 1000.0;
-avg_bitrate = (double)(ost->data_size * 8) / ti1 / 1000.0;
-fprintf(vstats_file, "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s 
avg_br= %7.1fkbits/s ",
-   (double)ost->data_size / 1024, ti1, bitrate, avg_bitrate);
-fprintf(vstats_file, "type= %c\n", 
av_get_picture_type_char(ost->pict_type));
-}
+frame_number = ost->st->nb_frames;
+if (vstats_version <= 1) {
+fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number,
+ost->quality / (float)FF_QP2LAMBDA);
+} else  {
+fprintf(vstats_file, "out= %2d st= %2d frame= %5d q= %2.1f ", 
ost->file_index, ost->index, frame_number,
+ost->quality / (float)FF_QP2LAMBDA);
+}
+
+if (ost->error[0]>=0 && (enc->flags & AV_CODEC_FLAG_PSNR))
+fprintf(vstats_file, "PSNR= %6.2f ", psnr(ost->error[0] / (enc->width 
* enc->height * 255.0 * 255.0)));
+
+fprintf(vstats_file,"f_size= %6d ", frame_size);
+/* compute pts value */
+ti1 = av_stream_get_end_pts(ost->st) * av_q2d(ost->st->time_base);
+if (ti1 < 0.01)
+ti1 = 0.01;
+
+bitrate = (frame_size * 8) / av_q2d(enc->time_base) / 1000.0;
+avg_bitrate = (double)(ost->data_size * 8) / ti1 / 1000.0;
+fprintf(vstats_file, "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= 
%7.1fkbits/s ",
+   (double)ost->data_size / 1024, ti1, bitrate, avg_bitrate);
+fprintf(vstats_file, "type= %c\n", 
av_get_picture_type_char(ost->pict_type));
 }
 
 static void finish_output_stream(OutputStream *ost)
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 2/9] fftools/ffmpeg: reuse the encoding code for flushing encoders

2022-05-11 Thread Anton Khirnov
---
 fftools/ffmpeg.c | 75 +++-
 1 file changed, 16 insertions(+), 59 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 0e62c39522..9fa0719cf6 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -836,12 +836,12 @@ static int encode_frame(OutputFile *of, OutputStream 
*ost, AVFrame *frame)
 AVCodecContext   *enc = ost->enc_ctx;
 AVPacket *pkt = ost->pkt;
 const char *type_desc = av_get_media_type_string(enc->codec_type);
+const char*action = frame ? "encode" : "flush";
 int ret;
 
+if (frame) {
 ost->frames_encoded++;
 
-update_benchmark(NULL);
-
 if (debug_ts) {
 av_log(NULL, AV_LOG_INFO, "encoder <- type:%s "
"frame_pts:%s frame_pts_time:%s time_base:%d/%d\n",
@@ -849,9 +849,12 @@ static int encode_frame(OutputFile *of, OutputStream *ost, 
AVFrame *frame)
av_ts2str(frame->pts), av_ts2timestr(frame->pts, 
>time_base),
enc->time_base.num, enc->time_base.den);
 }
+}
+
+update_benchmark(NULL);
 
 ret = avcodec_send_frame(enc, frame);
-if (ret < 0) {
+if (ret < 0 && !(ret == AVERROR_EOF && !frame)) {
 av_log(NULL, AV_LOG_ERROR, "Error submitting %s frame to the 
encoder\n",
type_desc);
 return ret;
@@ -859,11 +862,15 @@ static int encode_frame(OutputFile *of, OutputStream 
*ost, AVFrame *frame)
 
 while (1) {
 ret = avcodec_receive_packet(enc, pkt);
-update_benchmark("encode_%s %d.%d", type_desc,
+update_benchmark("%s_%s %d.%d", action, type_desc,
  ost->file_index, ost->index);
-if (ret == AVERROR(EAGAIN))
+if (ret == AVERROR(EAGAIN)) {
+av_assert0(frame); // should never happen during flushing
 return 0;
-else if (ret < 0) {
+} else if (ret == AVERROR_EOF) {
+output_packet(of, pkt, ost, 1);
+return ret;
+} else if (ret < 0) {
 av_log(NULL, AV_LOG_ERROR, "%s encoding failed\n", type_desc);
 return ret;
 }
@@ -1762,59 +1769,9 @@ static void flush_encoders(void)
 if (enc->codec_type != AVMEDIA_TYPE_VIDEO && enc->codec_type != 
AVMEDIA_TYPE_AUDIO)
 continue;
 
-for (;;) {
-const char *desc = NULL;
-AVPacket *pkt = ost->pkt;
-int pkt_size;
-
-switch (enc->codec_type) {
-case AVMEDIA_TYPE_AUDIO:
-desc   = "audio";
-break;
-case AVMEDIA_TYPE_VIDEO:
-desc   = "video";
-break;
-default:
-av_assert0(0);
-}
-
-update_benchmark(NULL);
-
-while ((ret = avcodec_receive_packet(enc, pkt)) == 
AVERROR(EAGAIN)) {
-ret = avcodec_send_frame(enc, NULL);
-if (ret < 0) {
-av_log(NULL, AV_LOG_FATAL, "%s encoding failed: %s\n",
-   desc,
-   av_err2str(ret));
-exit_program(1);
-}
-}
-
-update_benchmark("flush_%s %d.%d", desc, ost->file_index, 
ost->index);
-if (ret < 0 && ret != AVERROR_EOF) {
-av_log(NULL, AV_LOG_FATAL, "%s encoding failed: %s\n",
-   desc,
-   av_err2str(ret));
-exit_program(1);
-}
-if (ost->logfile && enc->stats_out) {
-fprintf(ost->logfile, "%s", enc->stats_out);
-}
-if (ret == AVERROR_EOF) {
-output_packet(of, pkt, ost, 1);
-break;
-}
-if (ost->finished & MUXER_FINISHED) {
-av_packet_unref(pkt);
-continue;
-}
-av_packet_rescale_ts(pkt, enc->time_base, ost->mux_timebase);
-pkt_size = pkt->size;
-output_packet(of, pkt, ost, 0);
-if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO && 
vstats_filename) {
-do_video_stats(ost, pkt_size);
-}
-}
+ret = encode_frame(of, ost, NULL);
+if (ret != AVERROR_EOF)
+exit_program(1);
 }
 }
 
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 3/9] fftools/ffmpeg: reindent after previous commit

2022-05-11 Thread Anton Khirnov
---
 fftools/ffmpeg.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 9fa0719cf6..69b9c42822 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -840,15 +840,15 @@ static int encode_frame(OutputFile *of, OutputStream 
*ost, AVFrame *frame)
 int ret;
 
 if (frame) {
-ost->frames_encoded++;
+ost->frames_encoded++;
 
-if (debug_ts) {
-av_log(NULL, AV_LOG_INFO, "encoder <- type:%s "
-   "frame_pts:%s frame_pts_time:%s time_base:%d/%d\n",
-   type_desc,
-   av_ts2str(frame->pts), av_ts2timestr(frame->pts, 
>time_base),
-   enc->time_base.num, enc->time_base.den);
-}
+if (debug_ts) {
+av_log(NULL, AV_LOG_INFO, "encoder <- type:%s "
+   "frame_pts:%s frame_pts_time:%s time_base:%d/%d\n",
+   type_desc,
+   av_ts2str(frame->pts), av_ts2timestr(frame->pts, 
>time_base),
+   enc->time_base.num, enc->time_base.den);
+}
 }
 
 update_benchmark(NULL);
-- 
2.34.1

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

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


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

2022-05-11 Thread Hendrik Leppkes
On Wed, May 11, 2022 at 9:58 AM Soft Works  wrote:
>
>
>
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > Tobias Rapp
> > Sent: Wednesday, May 11, 2022 9:46 AM
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: Re: [FFmpeg-devel] [PATCH v11 1/6]
> > libavutil/wchar_filename.h: Add whcartoutf8, wchartoansi and
> > utf8toansi
> >
> > On 11/05/2022 01:32, Soft Works wrote:
> > >>
> > >> [...]
> > >>
> > >> The prefixing can be implemented as a function and then be used
> > >> in file_open.c.
> > >>
> > >> Other file system related functions like mkdir, rename, rmdir, etc.
> > >> are already intercepted in os_support.h, and the prefixing can be
> > >> applied there.
> > >>
> > >> Maybe I missed some cases, I have not fully analyzed the situation,
> > >> but surely there are just a small number of places that need to
> > >> be changed and not 587.
> > >>
> > >>
> > >> For the procedure of prefixing I would take a look at how it's done
> > >> in .NET. This is probably the most mature code for handling this
> > >> and might save us from dealing with issues and regressions until we
> > >> got it right.
> > >
> > > The logic they use is here:
> > >
> > >
> > https://github.com/dotnet/runtime/blob/main/src/libraries/System.Priva
> > te.CoreLib/src/System/IO/PathHelper.Windows.cs
> > >
> > > Probably it can be simplified a bit.
> >
> > Out of curiosity I searched for some automatic path prefixing code and
> > the author of this file claims that it should be handling most corner
> > cases:
> >
> > https://github.com/JFLarvoire/SysToolsLib/blob/master/C/MsvcLibX/src/m
> > b2wpath.c
> >
> > That amount of logic inside CorrectWidePath() does not look appealing
> > to
> > me. And even if we simplify that now I guess it will grow once the
> > corner cases drop in via bug reports.
>
> I would follow the MS code, that will be the safest way.
>
> > So I'm in favor of removing the MAX_PATH limit, converting needed
> > Win32
> > function calls from ANSI to WideChar, and adding the longPathAware
> > manifest flag.
>
> I'm not sure how much you had followed, so please excuse in case you
> had already read it: the manifest approach does not work on a default
> Windows installation.
> To activate long path support, the users needs to opt-in to a behavior
> that is probably deactivated by default for some reason. Also it
> requires administrative privileges to make this change.
> For me - and probably for others as well - that approach is useless,
> as it would be the same as if there would be no long path support.
> (when you cannot rely on that feature being always working, you
> cannot use it)
>

We've been over this - not every feature needs to be useful to
everyone. The addition of the manifest does not make existing behavior
worse, nor does it prevent working on an alternate solution in the
future.
These are not reasons to block it. If you want to contribute an
alternate solution, you are welcome to do so, this does not block that
or impede that in any way - if anything, it lays the groundwork to do
that, because it already removes the MAX_PATH limitations from the
code in various places.

If you can provide an argument why this patch should not be applied
that isn't "its not a 100% solution for everything", then you are
welcome to do so, otherwise you are beating a dead horse at this
point.
If you want a better solution - provide one.

- Hendrik
___
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 v11 1/6] libavutil/wchar_filename.h: Add whcartoutf8, wchartoansi and utf8toansi

2022-05-11 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Tobias Rapp
> Sent: Wednesday, May 11, 2022 9:46 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v11 1/6]
> libavutil/wchar_filename.h: Add whcartoutf8, wchartoansi and
> utf8toansi
> 
> On 11/05/2022 01:32, Soft Works wrote:
> >>
> >> [...]
> >>
> >> The prefixing can be implemented as a function and then be used
> >> in file_open.c.
> >>
> >> Other file system related functions like mkdir, rename, rmdir, etc.
> >> are already intercepted in os_support.h, and the prefixing can be
> >> applied there.
> >>
> >> Maybe I missed some cases, I have not fully analyzed the situation,
> >> but surely there are just a small number of places that need to
> >> be changed and not 587.
> >>
> >>
> >> For the procedure of prefixing I would take a look at how it's done
> >> in .NET. This is probably the most mature code for handling this
> >> and might save us from dealing with issues and regressions until we
> >> got it right.
> >
> > The logic they use is here:
> >
> >
> https://github.com/dotnet/runtime/blob/main/src/libraries/System.Priva
> te.CoreLib/src/System/IO/PathHelper.Windows.cs
> >
> > Probably it can be simplified a bit.
> 
> Out of curiosity I searched for some automatic path prefixing code and
> the author of this file claims that it should be handling most corner
> cases:
> 
> https://github.com/JFLarvoire/SysToolsLib/blob/master/C/MsvcLibX/src/m
> b2wpath.c
> 
> That amount of logic inside CorrectWidePath() does not look appealing
> to
> me. And even if we simplify that now I guess it will grow once the
> corner cases drop in via bug reports.

I would follow the MS code, that will be the safest way.

> So I'm in favor of removing the MAX_PATH limit, converting needed
> Win32
> function calls from ANSI to WideChar, and adding the longPathAware
> manifest flag.

I'm not sure how much you had followed, so please excuse in case you
had already read it: the manifest approach does not work on a default
Windows installation.
To activate long path support, the users needs to opt-in to a behavior
that is probably deactivated by default for some reason. Also it
requires administrative privileges to make this change.
For me - and probably for others as well - that approach is useless,
as it would be the same as if there would be no long path support.
(when you cannot rely on that feature being always working, you
cannot use it)

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


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

2022-05-11 Thread Tobias Rapp

On 11/05/2022 01:32, Soft Works wrote:


[...]

The prefixing can be implemented as a function and then be used
in file_open.c.

Other file system related functions like mkdir, rename, rmdir, etc.
are already intercepted in os_support.h, and the prefixing can be
applied there.

Maybe I missed some cases, I have not fully analyzed the situation,
but surely there are just a small number of places that need to
be changed and not 587.


For the procedure of prefixing I would take a look at how it's done
in .NET. This is probably the most mature code for handling this
and might save us from dealing with issues and regressions until we
got it right.


The logic they use is here:

https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/IO/PathHelper.Windows.cs

Probably it can be simplified a bit.


Out of curiosity I searched for some automatic path prefixing code and 
the author of this file claims that it should be handling most corner cases:


https://github.com/JFLarvoire/SysToolsLib/blob/master/C/MsvcLibX/src/mb2wpath.c

That amount of logic inside CorrectWidePath() does not look appealing to 
me. And even if we simplify that now I guess it will grow once the 
corner cases drop in via bug reports.


So I'm in favor of removing the MAX_PATH limit, converting needed Win32 
function calls from ANSI to WideChar, and adding the longPathAware 
manifest flag. I think the activeCodePage=UTF-8 patch could break 
Windows applications that expect the system-wide ANSI codepage to be 
used for FFmpeg text output, though.


Regards,
Tobias

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