Re: [FFmpeg-devel] [PATCH v2] avcodec/startcode: Avoid unaligned accesses

2022-10-13 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2022-10-12 00:20:23)
> Up until now, ff_startcode_find_candidate_c() simply casts
> an uint8_t* to uint64_t*/uint32_t* to read 64/32 bits at a time
> in case HAVE_FAST_UNALIGNED is true. Yet this ignores the
> alignment requirement of these types as well as effective type
> rules of the C standard. This commit therefore replaces these
> direct accesses with AV_RN64/32; this also improves
> readability.
> 
> UBSan reported these unaligned accesses which happened in 233
> FATE-tests involving H.264 and VC-1 (this has also been reported
> in tickets #8138 and #8485); these tests are fixed by this commit.
> 
> The output of GCC with -O3 is unchanged for aarch64, alpha, arm,
> loongarch, ppc and x64. There was only a slight difference for mips.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
> This is v2 of 
> https://patchwork.ffmpeg.org/project/ffmpeg/patch/20200122145210.6898-1-andreas.rheinha...@gmail.com/
> 
> Here is the mips code before this change:
> 
> startcode_old_O3.o: file format elf64-tradlittlemips
> 
> 
> Disassembly of section .text:
> 
>  :
>0: 18a00029bleza1,a8 
>4: 3c08ff7flui a4,0xff7f
>8: 3c07ff01lui a3,0xff01
>c: 65087f7fdaddiu  a4,a4,32639
>   10: 64e70101daddiu  a3,a3,257
>   14: 00084438dslla4,a4,0x10
>   18: 00073c38dslla3,a3,0x10
>   1c: 65087f7fdaddiu  a4,a4,32639
>   20: 64e70101daddiu  a3,a3,257
>   24: 00084478dslla4,a4,0x11
>   28: 00073df8dslla3,a3,0x17
>   2c: 00803025movea2,a0
>   30: 1025movev0,zero
>   34: 3508feffori a4,a4,0xfeff
>   38: 1005b   50 
>   3c: 34e78080ori a3,a3,0x8080
>   40: 24420008addiu   v0,v0,8
>   44: 0045182aslt v1,v0,a1
>   48: 10600015beqzv1,a0 
>   4c: nop
>   50: dcc3ld  v1,0(a2)
>   54: 0068482ddaddu   a5,v1,a4
>   58: 44a3dmtc1   v1,$f0
>   5c: 44a90800dmtc1   a5,$f1
>   60: 4be10002pandn   $f0,$f0,$f1
>   64: 4423dmfc1   v1,$f0
>   68: 00671824and v1,v1,a3
>   6c: 1060fff4beqzv1,40 
>   70: 64c60008daddiu  a2,a2,8
>   74: 0045182aslt v1,v0,a1
>   78: 1069beqzv1,a0 
>   7c: 0082182ddaddu   v1,a0,v0
>   80: 1005b   98 
>   84: 9064lbu a0,0(v1)
>   88: 24420001addiu   v0,v0,1
>   8c: 10a20008beq a1,v0,b0 
>   90: nop
>   94: 9064lbu a0,0(v1)
>   98: 1480fffbbneza0,88 
>   9c: 64630001daddiu  v1,v1,1
>   a0: 03e8jr  ra
>   a4: nop
>   a8: 03e8jr  ra
>   ac: 1025movev0,zero
>   b0: 03e8jr  ra
>   b4: 00a01025movev0,a1
>   ...
> 
> And here after this change:
> 
> startcode_new_O3.o: file format elf64-tradlittlemips
> 
> 
> Disassembly of section .text:
> 
>  :
>0: 18a0002bbleza1,b0 
>4: 3c08ff7flui a4,0xff7f
>8: 3c07ff01lui a3,0xff01
>c: 65087f7fdaddiu  a4,a4,32639
>   10: 64e70101daddiu  a3,a3,257
>   14: 00084438dslla4,a4,0x10
>   18: 00073c38dslla3,a3,0x10
>   1c: 65087f7fdaddiu  a4,a4,32639
>   20: 64e70101daddiu  a3,a3,257
>   24: 00084478dslla4,a4,0x11
>   28: 00073df8dslla3,a3,0x17
>   2c: 00803025movea2,a0
>   30: 1025movev0,zero
>   34: 3508feffori a4,a4,0xfeff
>   38: 1005b   50 
>   3c: 34e78080ori a3,a3,0x8080
>   40: 24420008addiu   v0,v0,8
>   44: 0045182aslt v1,v0,a1
>   48: 10600017beqzv1,a8 
>   4c: nop
>   50: 68c30007ldl v1,7(a2)
>   54: 6cc3ldr v1,0(a2)
>   58: 0068482ddaddu   a5,v1,a4
>   5c: 44a3dmtc1   v1,$f0
>   60: 44a90800dmtc1   a5,$f1
>   64: 4be10002pandn   $f0,$f0,$f1
>   68: 4423dmfc1   v1,$f0
>   6c: 00671824and v1,v1,a3
>   70: 1060fff3beqzv1,40 
>   74: 64c60008daddiu  a2,a2,8
>   78: 0045182aslt v1,v0,a1
>   7c: 106abeqzv1,a8 
>   80: 0082182ddaddu   v1,a0,v0
>   84: 1006b   a0 
>   88: 9064lbu a0,0(v1)
>   8c: nop
>   90: 24420001addiu   v0,v0,1
>   94: 10a20008beq a1,v0,b8 
>   98: nop
>   9c: 9064lbu a0,0(v1)
>   a0: 1480fffbbneza0,90 
>   a4: 64630001daddiu  v1,v1,1
>   a8: 03e8jr  ra
>   ac: nop
>   b0: 03e8jr  ra
>   b4: 1025movev0,zero
>   b8: 03e8jr  ra
>   bc: 00a01025movev0,a1
> 

[FFmpeg-devel] [PATCH 2/2] avcodec/vp3data: rectify comment

2022-10-13 Thread Peter Ross
---

they're actually one byte different.

 libavcodec/vp3data.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/vp3data.h b/libavcodec/vp3data.h
index 317797a697..a347f492ad 100644
--- a/libavcodec/vp3data.h
+++ b/libavcodec/vp3data.h
@@ -25,7 +25,7 @@
 #include 
 
 /* these coefficients dequantize intraframe Y plane coefficients
- * (note: same as JPEG) */
+ * (note: almost the same as JPEG) */
 static const uint8_t vp31_intra_y_dequant[64] = {
 16, 11, 10, 16,  24,  40,  51,  61,
 12, 12, 14, 19,  26,  58,  60,  55,
-- 
2.35.1

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


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

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


[FFmpeg-devel] [PATCH 1/2] avcodec/jpegtables: remove duplicate luma and chroma quantization tables

2022-10-13 Thread Peter Ross
Duplicates of the standard JPEG quantization tables were found in the
AGM, MSS34(dsp), NUV and VP31 codecs. This patch elimates those duplicates,
placing a single copy in jpegtables.
---
 configure   |  6 --
 libavcodec/agm.c| 27 +--
 libavcodec/jpegtables.c |  6 ++
 libavcodec/jpegtables.h |  3 +++
 libavcodec/mss34dsp.c   | 25 ++---
 libavcodec/nuv.c| 27 +++
 libavcodec/vp3.c|  3 ++-
 libavcodec/vp3data.h| 13 -
 8 files changed, 21 insertions(+), 89 deletions(-)

diff --git a/configure b/configure
index f3fd91f592..2271e9b485 100755
--- a/configure
+++ b/configure
@@ -2758,6 +2758,7 @@ mpegvideodec_select="mpegvideo mpeg_er"
 mpegvideoenc_select="aandcttables fdctdsp me_cmp mpegvideo pixblockdsp qpeldsp"
 msmpeg4dec_select="h263_decoder"
 msmpeg4enc_select="h263_encoder"
+mss34dsp_select="jpegtables"
 vc1dsp_select="h264chroma qpeldsp startcode"
 rdft_select="fft"
 
@@ -2773,6 +2774,7 @@ ac3_fixed_encoder_select="ac3dsp audiodsp mdct me_cmp"
 acelp_kelvin_decoder_select="audiodsp"
 adpcm_g722_decoder_select="g722dsp"
 adpcm_g722_encoder_select="g722dsp"
+agm_decoder_select="jpegtables"
 aic_decoder_select="golomb idctdsp"
 alac_encoder_select="lpc"
 als_decoder_select="bswapdsp mpeg4audio"
@@ -2918,7 +2920,7 @@ mxpeg_decoder_select="mjpeg_decoder"
 nellymoser_decoder_select="mdct sinewin"
 nellymoser_encoder_select="audio_frame_queue mdct sinewin"
 notchlc_decoder_select="lzf"
-nuv_decoder_select="idctdsp"
+nuv_decoder_select="idctdsp jpegtables"
 on2avc_decoder_select="mdct"
 opus_decoder_deps="swresample"
 opus_encoder_select="audio_frame_queue"
@@ -2983,7 +2985,7 @@ vc1_decoder_select="blockdsp h264qpel intrax8 
mpegvideodec msmpeg4dec vc1dsp"
 vc1image_decoder_select="vc1_decoder"
 vorbis_decoder_select="mdct"
 vorbis_encoder_select="audio_frame_queue mdct"
-vp3_decoder_select="hpeldsp vp3dsp videodsp"
+vp3_decoder_select="hpeldsp jpegtables vp3dsp videodsp"
 vp4_decoder_select="vp3_decoder"
 vp5_decoder_select="h264chroma hpeldsp videodsp vp3dsp vp56dsp"
 vp6_decoder_select="h264chroma hpeldsp huffman videodsp vp3dsp vp56dsp"
diff --git a/libavcodec/agm.c b/libavcodec/agm.c
index 017aa0e1fa..614bf92d97 100644
--- a/libavcodec/agm.c
+++ b/libavcodec/agm.c
@@ -33,24 +33,7 @@
 #include "decode.h"
 #include "get_bits.h"
 #include "idctdsp.h"
-
-static const uint8_t unscaled_luma[64] = {
-16, 11, 10, 16, 24, 40, 51, 61, 12, 12, 14, 19,
-26, 58, 60, 55, 14, 13, 16, 24, 40, 57, 69, 56,
-14, 17, 22, 29, 51, 87, 80, 62, 18, 22, 37, 56,
-68,109,103, 77, 24, 35, 55, 64, 81,104,113, 92,
-49, 64, 78, 87,103,121,120,101, 72, 92, 95, 98,
-112,100,103,99
-};
-
-static const uint8_t unscaled_chroma[64] = {
-17, 18, 24, 47, 99, 99, 99, 99, 18, 21, 26, 66,
-99, 99, 99, 99, 24, 26, 56, 99, 99, 99, 99, 99,
-47, 66, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
-99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
-99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
-99, 99, 99, 99
-};
+#include "jpegtables.h"
 
 typedef struct MotionVector {
 int16_t x, y;
@@ -550,13 +533,13 @@ static void compute_quant_matrix(AGMContext *s, double 
qscale)
 } else {
 if (qscale >= 0.0) {
 for (int i = 0; i < 64; i++) {
-luma[i]   = FFMAX(1, unscaled_luma  [(i & 7) * 8 + (i >> 3)] * 
f);
-chroma[i] = FFMAX(1, unscaled_chroma[(i & 7) * 8 + (i >> 3)] * 
f);
+luma[i]   = FFMAX(1, ff_mjpeg_std_luminance_quant_tbl  [(i & 
7) * 8 + (i >> 3)] * f);
+chroma[i] = FFMAX(1, ff_mjpeg_std_chrominance_quant_tbl[(i & 
7) * 8 + (i >> 3)] * f);
 }
 } else {
 for (int i = 0; i < 64; i++) {
-luma[i]   = FFMAX(1, 255.0 - (255 - unscaled_luma  [(i & 7) * 
8 + (i >> 3)]) * f);
-chroma[i] = FFMAX(1, 255.0 - (255 - unscaled_chroma[(i & 7) * 
8 + (i >> 3)]) * f);
+luma[i]   = FFMAX(1, 255.0 - (255 - 
ff_mjpeg_std_luminance_quant_tbl  [(i & 7) * 8 + (i >> 3)]) * f);
+chroma[i] = FFMAX(1, 255.0 - (255 - 
ff_mjpeg_std_chrominance_quant_tbl[(i & 7) * 8 + (i >> 3)]) * f);
 }
 }
 }
diff --git a/libavcodec/jpegtables.c b/libavcodec/jpegtables.c
index e453fcf90d..fadb40527e 100644
--- a/libavcodec/jpegtables.c
+++ b/libavcodec/jpegtables.c
@@ -32,12 +32,11 @@
 
 #include "jpegtabs.h"
 
-#if 0
 /* These are the sample quantization tables given in JPEG spec section K.1.
  * The spec says that the values given produce "good" quality, and
  * when divided by 2, "very good" quality.
  */
-static const unsigned char std_luminance_quant_tbl[64] = {
+const uint8_t ff_mjpeg_std_luminance_quant_tbl[64] = {
 16,  11,  10,  16,  24,  40,  51,  61,
 12,  12,  14,  19,  26,  58,  60,  55,
 14,  13,  16,  24,  40,  57,  69,  56,
@@ -47,7 +46,7 @@ static const unsigned char std_luminance_quant_tbl[64] = {
 

Re: [FFmpeg-devel] [PATCH] ffmpeg: fix implementation of updated input start time

2022-10-13 Thread Gyan Doshi




On 2022-10-12 09:50 pm, Anton Khirnov wrote:

Quoting Gyan Doshi (2022-09-27 06:40:56)

The current adjustment of input start times just adjusts the tsoffset.
And it does so, by resetting the tsoffset to nullify the new start time.
This leads to breakage of -copyts, ignoring of user_ts_offset, breaking

  ^^
  no such variable


Will correct.

of -isync as well as breaking wrap correction.

Given all these options that are supposed to interact with each other in
highly nonobvious ways, it would be great to have tests for the use
cases you're fixing here.


These options don't really interact with each other. They all derive 
from or reference the start time.
Since ctx->start_time can't be changed outside lavf, we need to point to 
an fftools field. Basically, that's it.



Fixed by taking cognizance of these parameters, and by correcting start
times just before sync offsets are applied.
---
  fftools/ffmpeg.c   | 24 +---
  fftools/ffmpeg.h   |  5 -
  fftools/ffmpeg_demux.c |  4 ++--
  fftools/ffmpeg_opt.c   | 50 +-
  4 files changed, 52 insertions(+), 31 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 0e1477299d..fabb0fb952 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1898,7 +1898,7 @@ static void do_streamcopy(InputStream *ist, OutputStream 
*ost, const AVPacket *p
  start_time = 0;
  if (copy_ts) {
  start_time += f->start_time != AV_NOPTS_VALUE ? f->start_time : 0;
-start_time += start_at_zero ? 0 : f->ctx->start_time;
+start_time += start_at_zero ? 0 : f->enabled_start_time;
  }
  if (ist->pts >= f->recording_time + start_time) {
  close_output_stream(ost);
@@ -3323,28 +3323,6 @@ static int transcode_init(void)
  input_streams[j + ifile->ist_index]->start = 
av_gettime_relative();
  }
  
-// Correct starttime based on the enabled streams

-for (i = 0; i < nb_input_files; i++) {
-InputFile   *ifile = input_files[i];
-AVFormatContext*is = ifile->ctx;
-int64_t new_start_time = INT64_MAX;
-
-if (is->start_time == AV_NOPTS_VALUE ||
-!(is->iformat->flags & AVFMT_TS_DISCONT))
-continue;
-
-for (int j = 0; j < is->nb_streams; j++) {
-AVStream *st = is->streams[j];
-if(st->discard == AVDISCARD_ALL || st->start_time == 
AV_NOPTS_VALUE)
-continue;
-new_start_time = FFMIN(new_start_time, av_rescale_q(st->start_time, 
st->time_base, AV_TIME_BASE_Q));
-}
-if (new_start_time > is->start_time) {
-av_log(is, AV_LOG_VERBOSE, "Correcting start time by %"PRId64"\n", 
new_start_time - is->start_time);
-ifile->ts_offset = -new_start_time;
-}
-}
-

The change would be more readable if you first moved this block into a
separate function in a separate patch.

Will do.



Also, apply_sync_offsets() and correct_input_start_times() both modify
ts_offset in complicated ways. IMO it makes more sense to have both
loops in one function.


I'd prefer a parent container with these two as child functions. I like 
the one purpose per function - cleaner for any future changes.



  /* init input streams */
  for (i = 0; i < nb_input_streams; i++)
  if ((ret = init_input_stream(i, error, sizeof(error))) < 0)
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index ede0b2bd96..b93c2427b6 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -439,7 +439,10 @@ typedef struct InputFile {
  AVRational time_base; /* time base of the duration */
  int64_t input_ts_offset;
  int input_sync_ref;
-
+/**
+ * Effective format start time based on enabled streams.
+ */
+int64_t enabled_start_time;

Not a big fan of the name. Maybe start_time_effective would be better.
Or maybe even rename InputFile.start_time into start_time_user and reuse
the start_time name for the new variable.


I like start_time_effective . Will do.

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] avcodec: add D3D12VA hardware accelerated H264, HEVC, VP9, and AV1 decoding

2022-10-13 Thread Lynne
Oct 13, 2022, 17:48 by toq...@outlook.com:

>> Lynne wrote:
>>
>> Oct 12, 2022, 13:09 by toq...@outlook.com:
>>
>>> [PATCH] avcodec: add D3D12VA hardware accelerated H264, HEVC, VP9, and AV1 
>>> decoding
>>>
>>> Patch attached.
>>>
>> The Sync locking functions and the queue locking functions should
>> be a function pointer in the device/frame context. Vulkan has
>> the same issue, and that's how I did it there. This allows for
>> API users to plug their own locking primitives in, which they need
>> to in case they initialize their own contexts.
>>
>
> I don’t need to follow your design.
>

Yes, you do, because it's not my design, it's the design of the entire
hwcontext system. If API users cannot initialize a hwcontext with
their own, it's breakage. It's not optional.
Locking primitives are a part of this.
Either fix this or this is simply not getting merged.


>> You should also document which fields API users have to set
>> themselves if they plan to use their own context.
>>
>
> Where should I document them? Doesn’t the comments enough?
>

In the comments. Look at how it's done elsewhere.


>> Also, struct names in the public context lack an AV prefix.
>>
> Will fix. And which struct? Could you add the reference?
>

In the main public context.


>> D3D12VA_MAX_SURFACES is a terrible hack. Vendors should
>> fix their own drivers rather than users running out of memory.
>>
>
> Not my responsibility as a personal developer. I know nothing
> about the drivers. You can ask those vendors to fix them. I don’t
> think it’s a `terrible hack`. On my test, The MAX_SURFACES is
> enough for the decoder. If there are any docs or the drivers fixed
> it, just simply remove it. Why user will run out of memory?
>

The whole way the hwcontext is designed is sketchy. Why are
you keeping all texture information in an array (texture_infos)?Frames are 
already pooled (it's called AVFramePool), so you're
not doing anything by adding a second layer on top of this other
than complexity.
The initial_pool_size parameter was a hack added to support
hwcontexts which cannot allocate surfaces dynamically, you don't
need to support this at all, you can just let users allocate
frames as they need to rather than preinitializing.


>> Also, you have code style issues, don't wrap one-line if statements
>> or loops in brackets.
>>
> Will fix. And which loop? Could you add the reference?
>
>> ff_d3d12dec_get_suitable_max_bitstream_size is an awful function.
>> It does float math for sizes and has a magic mult factor of 1.5.
>> You have to calculate this properly.
>>
> It simply calculate the size of NV12 and P010. Will add comment.
>

Do it _properly_. We have utilities for it. If not, multiplication by 1.5
is val + (val >> 1).


>> On a first look, this is what stands out. Really must be split apart
>> in patches.
>>
>
> Already claim that I will split 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 5/6] avcodec/mpeg4videodec: Remove always-true checks

2022-10-13 Thread Michael Niedermayer
On Thu, Oct 13, 2022 at 11:23:33PM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Hi
> > 
> > On Wed, Oct 12, 2022 at 08:06:22PM +0200, Andreas Rheinhardt wrote:
> >> codec_id is always AV_CODEC_ID_MPEG4 in this file.
> >>
> >> Signed-off-by: Andreas Rheinhardt 
> >> ---
> >>  libavcodec/mpeg4videodec.c | 6 ++
> >>  1 file changed, 2 insertions(+), 4 deletions(-)
> > [...]
> >> @@ -3084,7 +3083,6 @@ int ff_mpeg4_workaround_bugs(AVCodecContext *avctx)
> >> ctx->divx_version, ctx->divx_build, s->divx_packed ? "p" : 
> >> "");
> >>  
> >>  if (CONFIG_MPEG4_DECODER && ctx->xvid_build >= 0 &&
> >> -s->codec_id == AV_CODEC_ID_MPEG4 &&
> > 
> > should the CONFIG_MPEG4_DECODER check be removed too ?
> > 
> 
> This file is also compiled if the MPEG-4 parser or the H.263 decoder is
> enabled (hence if any of the H.263 decoder family is enabled); the
> former is probably done because of ff_mpeg4_pred_ac() which is used by
> msmpeg4dec.c (this is the only exception to what I wrote in the commit
> message; will amend it). The latter could be solved by moving the code
> common to mpeg4-decoder and parser out into a file of its own, say
> mpeg4_parse.c. I pondered doing that; would you have any objections to
> it? It would allow to cut down on the crazy list of requirements of the
> mpeg4 parser.

really, you are doing this factorization, you decide which way it makes
most sense.
Id just say something if i see something that "feels" wrong
here it was just me seeing te compile time check and you saying its always
AV_CODEC_ID_MPEG4.
Maybe you could word the commit messsage more verbosely 

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin


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 5/6] avcodec/mpeg4videodec: Remove always-true checks

2022-10-13 Thread Andreas Rheinhardt
Michael Niedermayer:
> Hi
> 
> On Wed, Oct 12, 2022 at 08:06:22PM +0200, Andreas Rheinhardt wrote:
>> codec_id is always AV_CODEC_ID_MPEG4 in this file.
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>>  libavcodec/mpeg4videodec.c | 6 ++
>>  1 file changed, 2 insertions(+), 4 deletions(-)
> [...]
>> @@ -3084,7 +3083,6 @@ int ff_mpeg4_workaround_bugs(AVCodecContext *avctx)
>> ctx->divx_version, ctx->divx_build, s->divx_packed ? "p" : 
>> "");
>>  
>>  if (CONFIG_MPEG4_DECODER && ctx->xvid_build >= 0 &&
>> -s->codec_id == AV_CODEC_ID_MPEG4 &&
> 
> should the CONFIG_MPEG4_DECODER check be removed too ?
> 

This file is also compiled if the MPEG-4 parser or the H.263 decoder is
enabled (hence if any of the H.263 decoder family is enabled); the
former is probably done because of ff_mpeg4_pred_ac() which is used by
msmpeg4dec.c (this is the only exception to what I wrote in the commit
message; will amend it). The latter could be solved by moving the code
common to mpeg4-decoder and parser out into a file of its own, say
mpeg4_parse.c. I pondered doing that; would you have any objections to
it? It would allow to cut down on the crazy list of requirements of the
mpeg4 parser.
Anyway, given that both the MPEG-4 parser as well as the H.263 decoder
already require mpegvideodec, one could remove this CONFIG_MPEG4_DECODER
without causing linking failures, but doing so would cause a tiny bit
more code to be included in case the MPEG-4 decoder is disabled (in
fact, ff_mpeg4_workaround_bugs() is completely unnecessary in this
case). So removing it has a tiny disadvantage now and I intend to deal
with this whole issue later anyway, so I don't intend to do it now
(unless you insist).

- 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 5/6] avcodec/mpeg4videodec: Remove always-true checks

2022-10-13 Thread Michael Niedermayer
Hi

On Wed, Oct 12, 2022 at 08:06:22PM +0200, Andreas Rheinhardt wrote:
> codec_id is always AV_CODEC_ID_MPEG4 in this file.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/mpeg4videodec.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)
[...]
> @@ -3084,7 +3083,6 @@ int ff_mpeg4_workaround_bugs(AVCodecContext *avctx)
> ctx->divx_version, ctx->divx_build, s->divx_packed ? "p" : 
> "");
>  
>  if (CONFIG_MPEG4_DECODER && ctx->xvid_build >= 0 &&
> -s->codec_id == AV_CODEC_ID_MPEG4 &&

should the CONFIG_MPEG4_DECODER check be removed too ?

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Never trust a computer, one day, it may think you are the virus. -- Compn


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

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


Re: [FFmpeg-devel] [PATCH 1/4] avcodec/svq1enc: Inline constants

2022-10-13 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/svq1.h|  7 +++
>  libavcodec/svq1enc.c | 13 +
>  2 files changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/libavcodec/svq1.h b/libavcodec/svq1.h
> index 0ebc73a933..af8a7dfa04 100644
> --- a/libavcodec/svq1.h
> +++ b/libavcodec/svq1.h
> @@ -42,6 +42,13 @@
>  #define SVQ1_BLOCK_INTER_4V 2
>  #define SVQ1_BLOCK_INTRA3
>  
> +#define SVQ1_BLOCK_SKIP_CODE1
> +#define SVQ1_BLOCK_SKIP_LEN 1
> +#define SVQ1_BLOCK_INTER_CODE   1
> +#define SVQ1_BLOCK_INTER_LEN2
> +#define SVQ1_BLOCK_INTRA_CODE   0
> +#define SVQ1_BLOCK_INTRA_LEN3
> +
>  extern const int8_t *const ff_svq1_inter_codebooks[6];
>  extern const int8_t *const ff_svq1_intra_codebooks[6];
>  
> diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
> index ef6655c2f7..79e9e578ac 100644
> --- a/libavcodec/svq1enc.c
> +++ b/libavcodec/svq1enc.c
> @@ -390,9 +390,8 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
>  init_put_bits(&s->reorder_pb[i], reorder_buffer[0][i],
>7 * 32);
>  if (s->pict_type == AV_PICTURE_TYPE_P) {
> -const uint8_t *vlc = 
> ff_svq1_block_type_vlc[SVQ1_BLOCK_INTRA];
> -put_bits(&s->reorder_pb[5], vlc[1], vlc[0]);
> -score[0] = vlc[1] * lambda;
> +put_bits(&s->reorder_pb[5], SVQ1_BLOCK_INTRA_LEN, 
> SVQ1_BLOCK_INTRA_CODE);
> +score[0] = SVQ1_BLOCK_INTRA_LEN * lambda;
>  }
>  score[0] += encode_block(s, src + 16 * x, NULL, temp, stride,
>   5, 64, lambda, 1);
> @@ -406,7 +405,6 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
>  best = 0;
>  
>  if (s->pict_type == AV_PICTURE_TYPE_P) {
> -const uint8_t *vlc = 
> ff_svq1_block_type_vlc[SVQ1_BLOCK_INTER];
>  int mx, my, pred_x, pred_y, dxy;
>  int16_t *motion_ptr;
>  
> @@ -417,7 +415,7 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
>  init_put_bits(&s->reorder_pb[i], 
> reorder_buffer[1][i],
>7 * 32);
>  
> -put_bits(&s->reorder_pb[5], vlc[1], vlc[0]);
> +put_bits(&s->reorder_pb[5], SVQ1_BLOCK_INTER_LEN, 
> SVQ1_BLOCK_INTER_CODE);
>  
>  s->m.pb = s->reorder_pb[5];
>  mx  = motion_ptr[0];
> @@ -442,14 +440,13 @@ static int svq1_encode_plane(SVQ1EncContext *s, int 
> plane,
>   decoded, stride, 5, 64, lambda, 
> 0);
>  best  = score[1] <= score[0];
>  
> -vlc   = ff_svq1_block_type_vlc[SVQ1_BLOCK_SKIP];
>  score[2]  = s->mecc.sse[0](NULL, src + 16 * x, ref,
> stride, 16);
> -score[2] += vlc[1] * lambda;
> +score[2] += SVQ1_BLOCK_SKIP_LEN * lambda;
>  if (score[2] < score[best] && mx == 0 && my == 0) {
>  best = 2;
>  s->hdsp.put_pixels_tab[0][0](decoded, ref, stride, 
> 16);
> -put_bits(&s->pb, vlc[1], vlc[0]);
> +put_bits(&s->pb, SVQ1_BLOCK_SKIP_LEN, 
> SVQ1_BLOCK_SKIP_CODE);
>  }
>  }
>  

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] avcodec: add D3D12VA hardware accelerated H264, HEVC, VP9, and AV1 decoding

2022-10-13 Thread Wu Jianhua
James Almer wrote:
> On 10/13/2022 12:48 PM, Wu Jianhua wrote:
>>> Lynne wrote:
>>
>>> Oct 12, 2022, 13:09 by toq...@outlook.com:
>>
 [PATCH] avcodec: add D3D12VA hardware accelerated H264, HEVC, VP9, and AV1 
 decoding

 Patch attached.

>>
>>> The Sync locking functions and the queue locking functions should
>>> be a function pointer in the device/frame context. Vulkan has
>>> the same issue, and that's how I did it there. This allows for
>>> API users to plug their own locking primitives in, which they need
>>> to in case they initialize their own contexts.
>>
>> I don’t need to follow your design.
>>
>>> You should also document which fields API users have to set
>>> themselves if they plan to use their own context.
>>
>> Where should I document them? Doesn’t the comments enough?
>>
>>> Also, struct names in the public context lack an AV prefix.
>> Will fix. And which struct? Could you add the reference?
>>
>>> D3D12VA_MAX_SURFACES is a terrible hack. Vendors should
>>> fix their own drivers rather than users running out of memory.
>>
>> Not my responsibility as a personal developer. I know nothing
>> about the drivers. You can ask those vendors to fix them. I don’t
>> think it’s a `terrible hack`. On my test, The MAX_SURFACES is
>> enough for the decoder. If there are any docs or the drivers fixed
>> it, just simply remove it. Why user will run out of memory?
>>
>>> Also, you have code style issues, don't wrap one-line if statements
>>> or loops in brackets.
>> Will fix. And which loop? Could you add the reference?
>>
>>> ff_d3d12dec_get_suitable_max_bitstream_size is an awful function.
>>> It does float math for sizes and has a magic mult factor of 1.5.
>>> You have to calculate this properly.
>> It simply calculate the size of NV12 and P010. Will add comment.
>
> Then you should probably use imgutils.h functions for that, and/or
> AVPixFmtDescriptor from pixdesc.h.

Great! Really thanks for the details. I will try to take a look at how to do 
that better.


___
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: add D3D12VA hardware accelerated H264, HEVC, VP9, and AV1 decoding

2022-10-13 Thread James Almer

On 10/13/2022 12:48 PM, Wu Jianhua wrote:

Lynne wrote:



Oct 12, 2022, 13:09 by toq...@outlook.com:



[PATCH] avcodec: add D3D12VA hardware accelerated H264, HEVC, VP9, and AV1 
decoding

Patch attached.




The Sync locking functions and the queue locking functions should
be a function pointer in the device/frame context. Vulkan has
the same issue, and that's how I did it there. This allows for
API users to plug their own locking primitives in, which they need
to in case they initialize their own contexts.


I don’t need to follow your design.


You should also document which fields API users have to set
themselves if they plan to use their own context.


Where should I document them? Doesn’t the comments enough?


Also, struct names in the public context lack an AV prefix.

Will fix. And which struct? Could you add the reference?


D3D12VA_MAX_SURFACES is a terrible hack. Vendors should
fix their own drivers rather than users running out of memory.


Not my responsibility as a personal developer. I know nothing
about the drivers. You can ask those vendors to fix them. I don’t
think it’s a `terrible hack`. On my test, The MAX_SURFACES is
enough for the decoder. If there are any docs or the drivers fixed
it, just simply remove it. Why user will run out of memory?


Also, you have code style issues, don't wrap one-line if statements
or loops in brackets.

Will fix. And which loop? Could you add the reference?


ff_d3d12dec_get_suitable_max_bitstream_size is an awful function.
It does float math for sizes and has a magic mult factor of 1.5.
You have to calculate this properly.

It simply calculate the size of NV12 and P010. Will add comment.


Then you should probably use imgutils.h functions for that, and/or 
AVPixFmtDescriptor from pixdesc.h.





On a first look, this is what stands out. Really must be split apart
in patches.


Already claim that I will split 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".

___
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: add D3D12VA hardware accelerated H264, HEVC, VP9, and AV1 decoding

2022-10-13 Thread Wu Jianhua
> Lynne wrote:

> Oct 12, 2022, 13:09 by toq...@outlook.com:

>> [PATCH] avcodec: add D3D12VA hardware accelerated H264, HEVC, VP9, and AV1 
>> decoding
>>
>> Patch attached.
>>

> The Sync locking functions and the queue locking functions should
> be a function pointer in the device/frame context. Vulkan has
> the same issue, and that's how I did it there. This allows for
> API users to plug their own locking primitives in, which they need
> to in case they initialize their own contexts.

I don’t need to follow your design.

> You should also document which fields API users have to set
> themselves if they plan to use their own context.

Where should I document them? Doesn’t the comments enough?

> Also, struct names in the public context lack an AV prefix.
Will fix. And which struct? Could you add the reference?

> D3D12VA_MAX_SURFACES is a terrible hack. Vendors should
> fix their own drivers rather than users running out of memory.

Not my responsibility as a personal developer. I know nothing
about the drivers. You can ask those vendors to fix them. I don’t
think it’s a `terrible hack`. On my test, The MAX_SURFACES is
enough for the decoder. If there are any docs or the drivers fixed
it, just simply remove it. Why user will run out of memory?

> Also, you have code style issues, don't wrap one-line if statements
> or loops in brackets.
Will fix. And which loop? Could you add the reference?

> ff_d3d12dec_get_suitable_max_bitstream_size is an awful function.
> It does float math for sizes and has a magic mult factor of 1.5.
> You have to calculate this properly.
It simply calculate the size of NV12 and P010. Will add comment.

> On a first look, this is what stands out. Really must be split apart
> in patches.

Already claim that I will split 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 1/1] libswscale: force a minimum size of the slide for bayer sources

2022-10-13 Thread Anton Khirnov
Will push.

-- 
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] lavf/async: Fix ring_write return value

2022-10-13 Thread Anton Khirnov
Quoting Guangyu Sun (2022-09-29 20:11:34)
> his fixes a regression from commit 36117968ad.
> 
> wrapped_url_read() used to be able to return positive number from
> ffurl_read(). It relies on the result to check if EOF is reached in
> async_buffer_task().
> 
> But FIFO callbacks must return 0 on success. This should be handled
> in ring_write() instead.
> 
> Test case:
>   ffmpeg -f lavfi -i testsrc -t 1 test.mp4
>   ffmpeg -i async:test.mp4
> 
> Signed-off-by: Guangyu Sun 
> ---
>  libavformat/async.c | 8 +++-
>  1 file changed, 7 insertions(+), 1 deletion(-)

Thank you, will push.

-- 
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 1/3] fftools/cmdutils: Use av_err2str

2022-10-13 Thread Anton Khirnov
Patchset looks good, will push.

-- 
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 13/13] fftools/ffmpeg: move init_output_bsfs() to ffmpeg_mux

2022-10-13 Thread Anton Khirnov
Bitstream filtering is done as a part of muxing, so this is the more
proper place for this.
---
 fftools/ffmpeg.c | 36 
 fftools/ffmpeg_mux.c | 38 ++
 2 files changed, 38 insertions(+), 36 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 9bb877fb34..46d2912d07 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2651,35 +2651,6 @@ static int compare_int64(const void *a, const void *b)
 return FFDIFFSIGN(*(const int64_t *)a, *(const int64_t *)b);
 }
 
-static int init_output_bsfs(OutputStream *ost)
-{
-AVBSFContext *ctx = ost->bsf_ctx;
-int ret;
-
-if (!ctx)
-return 0;
-
-ret = avcodec_parameters_copy(ctx->par_in, ost->st->codecpar);
-if (ret < 0)
-return ret;
-
-ctx->time_base_in = ost->st->time_base;
-
-ret = av_bsf_init(ctx);
-if (ret < 0) {
-av_log(NULL, AV_LOG_ERROR, "Error initializing bitstream filter: %s\n",
-   ctx->filter->name);
-return ret;
-}
-
-ret = avcodec_parameters_copy(ost->st->codecpar, ctx->par_out);
-if (ret < 0)
-return ret;
-ost->st->time_base = ctx->time_base_out;
-
-return 0;
-}
-
 static int init_output_stream_streamcopy(OutputStream *ost)
 {
 OutputFile *of = output_files[ost->file_index];
@@ -3212,13 +3183,6 @@ static int init_output_stream(OutputStream *ost, AVFrame 
*frame,
 return ret;
 }
 
-/* initialize bitstream filters for the output stream
- * needs to be done here, because the codec id for streamcopy is not
- * known until now */
-ret = init_output_bsfs(ost);
-if (ret < 0)
-return ret;
-
 ret = of_stream_init(output_files[ost->file_index], ost);
 if (ret < 0)
 return ret;
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 652628185e..5418cd3000 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -536,12 +536,50 @@ int mux_check_init(Muxer *mux)
 return 0;
 }
 
+static int bsf_init(OutputStream *ost)
+{
+AVBSFContext *ctx = ost->bsf_ctx;
+int ret;
+
+if (!ctx)
+return 0;
+
+ret = avcodec_parameters_copy(ctx->par_in, ost->st->codecpar);
+if (ret < 0)
+return ret;
+
+ctx->time_base_in = ost->st->time_base;
+
+ret = av_bsf_init(ctx);
+if (ret < 0) {
+av_log(NULL, AV_LOG_ERROR, "Error initializing bitstream filter: %s\n",
+   ctx->filter->name);
+return ret;
+}
+
+ret = avcodec_parameters_copy(ost->st->codecpar, ctx->par_out);
+if (ret < 0)
+return ret;
+ost->st->time_base = ctx->time_base_out;
+
+return 0;
+}
+
 int of_stream_init(OutputFile *of, OutputStream *ost)
 {
 Muxer *mux = mux_from_of(of);
+int ret;
+
 if (ost->sq_idx_mux >= 0)
 sq_set_tb(mux->sq_mux, ost->sq_idx_mux, ost->mux_timebase);
 
+/* initialize bitstream filters for the output stream
+ * needs to be done here, because the codec id for streamcopy is not
+ * known until now */
+ret = bsf_init(ost);
+if (ret < 0)
+return ret;
+
 ost->initialized = 1;
 
 return mux_check_init(mux);
-- 
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 11/13] fftools/ffmpeg_mux: inline mux_free() into of_close()

2022-10-13 Thread Anton Khirnov
mux_free() is no longer called from anywhere else.
---
 fftools/ffmpeg_mux.c | 31 +--
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 2f71e03144..f830e5854b 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -599,8 +599,20 @@ static void fc_close(AVFormatContext **pfc)
 *pfc = NULL;
 }
 
-static void mux_free(Muxer *mux)
+void of_close(OutputFile **pof)
 {
+OutputFile *of = *pof;
+Muxer *mux;
+
+if (!of)
+return;
+mux = mux_from_of(of);
+
+thread_stop(mux);
+
+sq_free(&of->sq_encode);
+sq_free(&of->sq_mux);
+
 for (int i = 0; i < mux->of.nb_streams; i++) {
 MuxStream *ms = &mux->streams[i];
 AVPacket *pkt;
@@ -618,23 +630,6 @@ static void mux_free(Muxer *mux)
 av_packet_free(&mux->sq_pkt);
 
 fc_close(&mux->fc);
-}
-
-void of_close(OutputFile **pof)
-{
-OutputFile *of = *pof;
-Muxer *mux;
-
-if (!of)
-return;
-mux = mux_from_of(of);
-
-thread_stop(mux);
-
-sq_free(&of->sq_encode);
-sq_free(&of->sq_mux);
-
-mux_free(mux_from_of(of));
 
 av_freep(pof);
 }
-- 
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 12/13] fftools/ffmpeg_mux: move sq_mux from OutputFile to Muxer

2022-10-13 Thread Anton Khirnov
It is internal to ffmpeg_mux* and does not need to be visible to other
code.
---
 fftools/ffmpeg.h  | 1 -
 fftools/ffmpeg_mux.c  | 8 
 fftools/ffmpeg_mux.h  | 1 +
 fftools/ffmpeg_mux_init.c | 8 
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 9ccd158e4b..20eb6e2aa9 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -620,7 +620,6 @@ typedef struct OutputFile {
 const char   *url;
 
 SyncQueue *sq_encode;
-SyncQueue *sq_mux;
 
 int nb_streams;
 int ost_index;   /* index of the first stream in output_streams */
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index f830e5854b..652628185e 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -159,12 +159,12 @@ static int sync_queue_process(Muxer *mux, OutputStream 
*ost, AVPacket *pkt)
 OutputFile *of = &mux->of;
 
 if (ost->sq_idx_mux >= 0) {
-int ret = sq_send(of->sq_mux, ost->sq_idx_mux, SQPKT(pkt));
+int ret = sq_send(mux->sq_mux, ost->sq_idx_mux, SQPKT(pkt));
 if (ret < 0)
 return ret;
 
 while (1) {
-ret = sq_receive(of->sq_mux, -1, SQPKT(mux->sq_pkt));
+ret = sq_receive(mux->sq_mux, -1, SQPKT(mux->sq_pkt));
 if (ret < 0)
 return (ret == AVERROR_EOF || ret == AVERROR(EAGAIN)) ? 0 : 
ret;
 
@@ -540,7 +540,7 @@ int of_stream_init(OutputFile *of, OutputStream *ost)
 {
 Muxer *mux = mux_from_of(of);
 if (ost->sq_idx_mux >= 0)
-sq_set_tb(of->sq_mux, ost->sq_idx_mux, ost->mux_timebase);
+sq_set_tb(mux->sq_mux, ost->sq_idx_mux, ost->mux_timebase);
 
 ost->initialized = 1;
 
@@ -611,7 +611,7 @@ void of_close(OutputFile **pof)
 thread_stop(mux);
 
 sq_free(&of->sq_encode);
-sq_free(&of->sq_mux);
+sq_free(&mux->sq_mux);
 
 for (int i = 0; i < mux->of.nb_streams; i++) {
 MuxStream *ms = &mux->streams[i];
diff --git a/fftools/ffmpeg_mux.h b/fftools/ffmpeg_mux.h
index d9c4dce750..7cb1337b49 100644
--- a/fftools/ffmpeg_mux.h
+++ b/fftools/ffmpeg_mux.h
@@ -68,6 +68,7 @@ typedef struct Muxer {
 atomic_int_least64_t last_filesize;
 int header_written;
 
+SyncQueue *sq_mux;
 AVPacket *sq_pkt;
 } Muxer;
 
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index be7286c26d..3945bbed3a 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1100,8 +1100,8 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext 
*oc, int64_t buf_size_u
 /* if there are any additional interleaved streams, then ALL the streams
  * are also synchronized before sending them to the muxer */
 if (nb_interleaved > nb_av_enc) {
-of->sq_mux = sq_alloc(SYNC_QUEUE_PACKETS, buf_size_us);
-if (!of->sq_mux)
+mux->sq_mux = sq_alloc(SYNC_QUEUE_PACKETS, buf_size_us);
+if (!mux->sq_mux)
 return AVERROR(ENOMEM);
 
 mux->sq_pkt = av_packet_alloc();
@@ -1115,13 +1115,13 @@ static int setup_sync_queues(Muxer *mux, 
AVFormatContext *oc, int64_t buf_size_u
 if (!IS_INTERLEAVED(type))
 continue;
 
-ost->sq_idx_mux = sq_add_stream(of->sq_mux,
+ost->sq_idx_mux = sq_add_stream(mux->sq_mux,
 of->shortest || ost->max_frames < 
INT64_MAX);
 if (ost->sq_idx_mux < 0)
 return ost->sq_idx_mux;
 
 if (ost->max_frames != INT64_MAX)
-sq_limit_frames(of->sq_mux, ost->sq_idx_mux, ost->max_frames);
+sq_limit_frames(mux->sq_mux, ost->sq_idx_mux, ost->max_frames);
 }
 }
 
-- 
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 09/13] fftools/ffmpeg_mux: allocate sq_pkt in setup_sync_queues()

2022-10-13 Thread Anton Khirnov
This is now possible since setup_sync_queues() can interact with Muxer.
---
 fftools/ffmpeg_mux.c  |  8 
 fftools/ffmpeg_mux_init.c | 13 ++---
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 4cb5a71659..4c56f4ba96 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -671,14 +671,6 @@ int of_muxer_init(OutputFile *of, AVFormatContext *fc,
 if (strcmp(of->format->name, "rtp"))
 want_sdp = 0;
 
-if (of->sq_mux) {
-mux->sq_pkt = av_packet_alloc();
-if (!mux->sq_pkt) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
-}
-
 /* write the header for files with no streams */
 if (of->format->flags & AVFMT_NOSTREAMS && fc->nb_streams == 0) {
 ret = mux_check_init(of);
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 5b515ed034..6c4d9bad1e 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1040,8 +1040,9 @@ loop_end:
 }
 }
 
-static int setup_sync_queues(OutputFile *of, AVFormatContext *oc, int64_t 
buf_size_us)
+static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t 
buf_size_us)
 {
+OutputFile *of = &mux->of;
 int nb_av_enc = 0, nb_interleaved = 0;
 int limit_frames = 0, limit_frames_av_enc = 0;
 
@@ -1103,6 +1104,10 @@ static int setup_sync_queues(OutputFile *of, 
AVFormatContext *oc, int64_t buf_si
 if (!of->sq_mux)
 return AVERROR(ENOMEM);
 
+mux->sq_pkt = av_packet_alloc();
+if (!mux->sq_pkt)
+return AVERROR(ENOMEM);
+
 for (int i = 0; i < oc->nb_streams; i++) {
 OutputStream *ost = output_streams[of->ost_index + i];
 enum AVMediaType type = ost->st->codecpar->codec_type;
@@ -1573,6 +1578,7 @@ static int set_dispositions(OutputFile *of, 
AVFormatContext *ctx)
 
 int of_open(OptionsContext *o, const char *filename)
 {
+Muxer *mux;
 AVFormatContext *oc;
 int i, j, err;
 OutputFile *of;
@@ -1594,7 +1600,8 @@ int of_open(OptionsContext *o, const char *filename)
 }
 }
 
-of = allocate_array_elem(&output_files, sizeof(Muxer), &nb_output_files);
+mux = allocate_array_elem(&output_files, sizeof(Muxer), &nb_output_files);
+of  = &mux->of;
 
 of->index  = nb_output_files - 1;
 of->ost_index  = nb_output_streams;
@@ -1869,7 +1876,7 @@ int of_open(OptionsContext *o, const char *filename)
 exit_program(1);
 }
 
-err = setup_sync_queues(of, oc, o->shortest_buf_duration * AV_TIME_BASE);
+err = setup_sync_queues(mux, oc, o->shortest_buf_duration * AV_TIME_BASE);
 if (err < 0) {
 av_log(NULL, AV_LOG_FATAL, "Error setting up output sync queues\n");
 exit_program(1);
-- 
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 07/13] fftools/ffmpeg_mux: move Muxer and MuxStream to a new header

2022-10-13 Thread Anton Khirnov
This will allow ffmpeg_mux_init.c to see work with these structs.
---
 fftools/ffmpeg_mux.c | 36 +-
 fftools/ffmpeg_mux.h | 72 
 2 files changed, 73 insertions(+), 35 deletions(-)
 create mode 100644 fftools/ffmpeg_mux.h

diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 7bc25c6175..09213472a6 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -21,6 +21,7 @@
 #include 
 
 #include "ffmpeg.h"
+#include "ffmpeg_mux.h"
 #include "objpool.h"
 #include "sync_queue.h"
 #include "thread_queue.h"
@@ -37,41 +38,6 @@
 #include "libavformat/avformat.h"
 #include "libavformat/avio.h"
 
-typedef struct MuxStream {
-/* the packets are buffered here until the muxer is ready to be 
initialized */
-AVFifo *muxing_queue;
-
-/*
- * The size of the AVPackets' buffers in queue.
- * Updated when a packet is either pushed or pulled from the queue.
- */
-size_t muxing_queue_data_size;
-
-/* dts of the last packet sent to the muxer, in the stream timebase
- * used for making up missing dts values */
-int64_t last_mux_dts;
-} MuxStream;
-
-struct Muxer {
-AVFormatContext *fc;
-
-pthread_tthread;
-ThreadQueue *tq;
-
-MuxStream *streams;
-
-AVDictionary *opts;
-
-int thread_queue_size;
-
-/* filesize limit expressed in bytes */
-int64_t limit_filesize;
-atomic_int_least64_t last_filesize;
-int header_written;
-
-AVPacket *sq_pkt;
-};
-
 static int want_sdp = 1;
 
 static int64_t filesize(AVIOContext *pb)
diff --git a/fftools/ffmpeg_mux.h b/fftools/ffmpeg_mux.h
new file mode 100644
index 00..920e4ff7ab
--- /dev/null
+++ b/fftools/ffmpeg_mux.h
@@ -0,0 +1,72 @@
+/*
+ * Muxer internal APIs - should not be included outside of ffmpeg_mux*
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef FFTOOLS_FFMPEG_MUX_H
+#define FFTOOLS_FFMPEG_MUX_H
+
+#include 
+#include 
+
+#include "thread_queue.h"
+
+#include "libavformat/avformat.h"
+
+#include "libavcodec/packet.h"
+
+#include "libavutil/dict.h"
+#include "libavutil/fifo.h"
+#include "libavutil/thread.h"
+
+typedef struct MuxStream {
+/* the packets are buffered here until the muxer is ready to be 
initialized */
+AVFifo *muxing_queue;
+
+/*
+ * The size of the AVPackets' buffers in queue.
+ * Updated when a packet is either pushed or pulled from the queue.
+ */
+size_t muxing_queue_data_size;
+
+/* dts of the last packet sent to the muxer, in the stream timebase
+ * used for making up missing dts values */
+int64_t last_mux_dts;
+} MuxStream;
+
+struct Muxer {
+AVFormatContext *fc;
+
+pthread_tthread;
+ThreadQueue *tq;
+
+MuxStream *streams;
+
+AVDictionary *opts;
+
+int thread_queue_size;
+
+/* filesize limit expressed in bytes */
+int64_t limit_filesize;
+atomic_int_least64_t last_filesize;
+int header_written;
+
+AVPacket *sq_pkt;
+};
+
+#endif /* FFTOOLS_FFMPEG_MUX_H */
-- 
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 03/13] fftools/ffmpeg_mux: rename submit_packet() to thread_submit_packet()

2022-10-13 Thread Anton Khirnov
This is more descriptive, and the submit_packet() name will be reused in
following commits.
---
 fftools/ffmpeg_mux.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 6e9cbb4bab..7762038b1d 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -254,7 +254,7 @@ finish:
 return (void*)(intptr_t)ret;
 }
 
-static int submit_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
+static int thread_submit_packet(OutputFile *of, OutputStream *ost, AVPacket 
*pkt)
 {
 Muxer *mux = of->mux;
 int ret = 0;
@@ -324,7 +324,7 @@ static int of_submit_packet(OutputFile *of, AVPacket *pkt, 
OutputStream *ost)
 int ret;
 
 if (of->mux->tq) {
-return submit_packet(of, ost, pkt);
+return thread_submit_packet(of, ost, pkt);
 } else {
 /* the muxer is not initialized yet, buffer the packet */
 ret = queue_packet(of, ost, pkt);
@@ -447,7 +447,7 @@ static int thread_start(OutputFile *of)
 ost->mux_timebase = ost->st->time_base;
 
 while (av_fifo_read(ms->muxing_queue, &pkt, 1) >= 0) {
-ret = submit_packet(of, ost, pkt);
+ret = thread_submit_packet(of, ost, pkt);
 if (pkt) {
 ms->muxing_queue_data_size -= pkt->size;
 av_packet_free(&pkt);
-- 
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 05/13] fftools/ffmpeg: move some stream initialization code to ffmpeg_mux

2022-10-13 Thread Anton Khirnov
The code in question is muxing-specific and so belongs there. This will
allow make some objects private to the muxer in future commits.
---
 fftools/ffmpeg.c |  8 +---
 fftools/ffmpeg.h | 10 --
 fftools/ffmpeg_mux.c | 15 ---
 3 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 015ff762c9..9bb877fb34 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3115,7 +3115,6 @@ static int init_output_stream_encode(OutputStream *ost, 
AVFrame *frame)
 static int init_output_stream(OutputStream *ost, AVFrame *frame,
   char *error, int error_len)
 {
-OutputFile *of = output_files[ost->file_index];
 int ret = 0;
 
 if (ost->enc_ctx) {
@@ -3220,12 +3219,7 @@ static int init_output_stream(OutputStream *ost, AVFrame 
*frame,
 if (ret < 0)
 return ret;
 
-if (ost->sq_idx_mux >= 0)
-sq_set_tb(of->sq_mux, ost->sq_idx_mux, ost->mux_timebase);
-
-ost->initialized = 1;
-
-ret = of_check_init(output_files[ost->file_index]);
+ret = of_stream_init(output_files[ost->file_index], ost);
 if (ret < 0)
 return ret;
 
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 632b7c0e86..5030f72fe5 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -720,8 +720,14 @@ int hwaccel_decode_init(AVCodecContext *avctx);
 int of_muxer_init(OutputFile *of, AVFormatContext *fc,
   AVDictionary *opts, int64_t limit_filesize,
   int thread_queue_size);
-/* open the muxer when all the streams are initialized */
-int of_check_init(OutputFile *of);
+
+/*
+ * Initialize muxing state for the given stream, should be called
+ * after the codec/streamcopy setup has been done.
+ *
+ * Open the muxer once all the streams have been initialized.
+ */
+int of_stream_init(OutputFile *of, OutputStream *ost);
 int of_write_trailer(OutputFile *of);
 void of_close(OutputFile **pof);
 
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 63f63c0852..7bc25c6175 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -516,8 +516,7 @@ fail:
 return ret;
 }
 
-/* open the muxer when all the streams are initialized */
-int of_check_init(OutputFile *of)
+static int mux_check_init(OutputFile *of)
 {
 AVFormatContext *fc = of->mux->fc;
 int ret, i;
@@ -565,6 +564,16 @@ int of_check_init(OutputFile *of)
 return 0;
 }
 
+int of_stream_init(OutputFile *of, OutputStream *ost)
+{
+if (ost->sq_idx_mux >= 0)
+sq_set_tb(of->sq_mux, ost->sq_idx_mux, ost->mux_timebase);
+
+ost->initialized = 1;
+
+return mux_check_init(of);
+}
+
 int of_write_trailer(OutputFile *of)
 {
 AVFormatContext *fc = of->mux->fc;
@@ -710,7 +719,7 @@ int of_muxer_init(OutputFile *of, AVFormatContext *fc,
 
 /* write the header for files with no streams */
 if (of->format->flags & AVFMT_NOSTREAMS && fc->nb_streams == 0) {
-ret = of_check_init(of);
+ret = mux_check_init(of);
 if (ret < 0)
 goto fail;
 }
-- 
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 10/13] fftools/ffmpeg_mux: inline of_muxer_init() into of_open()

2022-10-13 Thread Anton Khirnov
A separate muxer init is no longer necessary, now that of_open() has
access to Muxer.
---
 fftools/ffmpeg.h  |  4 ---
 fftools/ffmpeg_mux.c  | 56 ---
 fftools/ffmpeg_mux.h  |  5 
 fftools/ffmpeg_mux_init.c | 39 ---
 4 files changed, 40 insertions(+), 64 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index fb409c22ad..9ccd158e4b 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -727,10 +727,6 @@ int hw_device_setup_for_filter(FilterGraph *fg);
 
 int hwaccel_decode_init(AVCodecContext *avctx);
 
-int of_muxer_init(OutputFile *of, AVFormatContext *fc,
-  AVDictionary *opts, int64_t limit_filesize,
-  int thread_queue_size);
-
 /*
  * Initialize muxing state for the given stream, should be called
  * after the codec/streamcopy setup has been done.
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 4c56f4ba96..2f71e03144 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -38,7 +38,7 @@
 #include "libavformat/avformat.h"
 #include "libavformat/avio.h"
 
-static int want_sdp = 1;
+int want_sdp = 1;
 
 static Muxer *mux_from_of(OutputFile *of)
 {
@@ -487,9 +487,9 @@ fail:
 return ret;
 }
 
-static int mux_check_init(OutputFile *of)
+int mux_check_init(Muxer *mux)
 {
-Muxer *mux = mux_from_of(of);
+OutputFile *of = &mux->of;
 AVFormatContext *fc = mux->fc;
 int ret, i;
 
@@ -538,12 +538,13 @@ static int mux_check_init(OutputFile *of)
 
 int of_stream_init(OutputFile *of, OutputStream *ost)
 {
+Muxer *mux = mux_from_of(of);
 if (ost->sq_idx_mux >= 0)
 sq_set_tb(of->sq_mux, ost->sq_idx_mux, ost->mux_timebase);
 
 ost->initialized = 1;
 
-return mux_check_init(of);
+return mux_check_init(mux);
 }
 
 int of_write_trailer(OutputFile *of)
@@ -638,53 +639,6 @@ void of_close(OutputFile **pof)
 av_freep(pof);
 }
 
-int of_muxer_init(OutputFile *of, AVFormatContext *fc,
-  AVDictionary *opts, int64_t limit_filesize,
-  int thread_queue_size)
-{
-Muxer *mux = mux_from_of(of);
-int ret = 0;
-
-mux->streams = av_calloc(fc->nb_streams, sizeof(*mux->streams));
-if (!mux->streams) {
-fc_close(&fc);
-return AVERROR(ENOMEM);
-}
-of->nb_streams = fc->nb_streams;
-
-mux->fc  = fc;
-
-for (int i = 0; i < fc->nb_streams; i++) {
-MuxStream *ms = &mux->streams[i];
-ms->muxing_queue = av_fifo_alloc2(8, sizeof(AVPacket*), 0);
-if (!ms->muxing_queue) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
-ms->last_mux_dts = AV_NOPTS_VALUE;
-}
-
-mux->thread_queue_size = thread_queue_size > 0 ? thread_queue_size : 8;
-mux->limit_filesize = limit_filesize;
-mux->opts   = opts;
-
-if (strcmp(of->format->name, "rtp"))
-want_sdp = 0;
-
-/* write the header for files with no streams */
-if (of->format->flags & AVFMT_NOSTREAMS && fc->nb_streams == 0) {
-ret = mux_check_init(of);
-if (ret < 0)
-goto fail;
-}
-
-fail:
-if (ret < 0)
-mux_free(mux);
-
-return ret;
-}
-
 int64_t of_filesize(OutputFile *of)
 {
 Muxer *mux = mux_from_of(of);
diff --git a/fftools/ffmpeg_mux.h b/fftools/ffmpeg_mux.h
index 90ff979ec1..d9c4dce750 100644
--- a/fftools/ffmpeg_mux.h
+++ b/fftools/ffmpeg_mux.h
@@ -71,4 +71,9 @@ typedef struct Muxer {
 AVPacket *sq_pkt;
 } Muxer;
 
+/* whether we want to print an SDP, set in of_open() */
+extern int want_sdp;
+
+int mux_check_init(Muxer *mux);
+
 #endif /* FFTOOLS_FFMPEG_MUX_H */
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 6c4d9bad1e..be7286c26d 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1582,7 +1582,7 @@ int of_open(OptionsContext *o, const char *filename)
 AVFormatContext *oc;
 int i, j, err;
 OutputFile *of;
-AVDictionary *unused_opts = NULL, *format_opts = NULL;
+AVDictionary *unused_opts = NULL;
 const AVDictionaryEntry *e = NULL;
 
 if (o->stop_time != INT64_MAX && o->recording_time != INT64_MAX) {
@@ -1608,7 +1608,10 @@ int of_open(OptionsContext *o, const char *filename)
 of->recording_time = o->recording_time;
 of->start_time = o->start_time;
 of->shortest   = o->shortest;
-av_dict_copy(&format_opts, o->g->format_opts, 0);
+
+mux->thread_queue_size = o->thread_queue_size > 0 ? o->thread_queue_size : 
8;
+mux->limit_filesize= o->limit_filesize;
+av_dict_copy(&mux->opts, o->g->format_opts, 0);
 
 if (!strcmp(filename, "-"))
 filename = "pipe:";
@@ -1618,6 +1621,10 @@ int of_open(OptionsContext *o, const char *filename)
 print_error(filename, err);
 exit_program(1);
 }
+mux->fc = oc;
+
+if (strcmp(oc->oformat->name, "rtp"))
+want_sdp = 0;
 
 of->format = oc->oformat;
 if (o->recording_time != INT64_MAX)
@@ -16

[FFmpeg-devel] [PATCH 04/13] fftools/ffmpeg_mux: drop the of_ prefix from of_submit_packet()

2022-10-13 Thread Anton Khirnov
This function is now static.
---
 fftools/ffmpeg_mux.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 7762038b1d..63f63c0852 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -319,7 +319,7 @@ static int queue_packet(OutputFile *of, OutputStream *ost, 
AVPacket *pkt)
 return 0;
 }
 
-static int of_submit_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost)
+static int submit_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost)
 {
 int ret;
 
@@ -367,12 +367,12 @@ void of_output_packet(OutputFile *of, AVPacket *pkt, 
OutputStream *ost, int eof)
 goto fail;
 }
 
-ret = of_submit_packet(of, bsf_eof ? NULL : pkt, ost);
+ret = submit_packet(of, bsf_eof ? NULL : pkt, ost);
 if (ret < 0)
 goto mux_fail;
 }
 } else {
-ret = of_submit_packet(of, eof ? NULL : pkt, ost);
+ret = submit_packet(of, eof ? NULL : pkt, ost);
 if (ret < 0)
 goto mux_fail;
 }
-- 
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 08/13] fftools/ffmpeg_mux: embed OutputFile in a Muxer

2022-10-13 Thread Anton Khirnov
This is now possible since the code allocating OutputFile can see
sizeof(Muxer). Avoids the overhead and extra complexity of allocating
two objects instead of one.

Similar to what is done e.g. for AVStream/FFStream in lavf.
---
 fftools/ffmpeg.h  |   3 -
 fftools/ffmpeg_mux.c  | 128 +++---
 fftools/ffmpeg_mux.h  |   6 +-
 fftools/ffmpeg_mux_init.c |   4 +-
 4 files changed, 69 insertions(+), 72 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index f45b352bb0..fb409c22ad 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -613,12 +613,9 @@ typedef struct OutputStream {
 int sq_idx_mux;
 } OutputStream;
 
-typedef struct Muxer Muxer;
-
 typedef struct OutputFile {
 int index;
 
-Muxer*mux;
 const AVOutputFormat *format;
 const char   *url;
 
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 09213472a6..4cb5a71659 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -40,6 +40,11 @@
 
 static int want_sdp = 1;
 
+static Muxer *mux_from_of(OutputFile *of)
+{
+return (Muxer*)of;
+}
+
 static int64_t filesize(AVIOContext *pb)
 {
 int64_t ret = -1;
@@ -53,17 +58,17 @@ static int64_t filesize(AVIOContext *pb)
 return ret;
 }
 
-static int write_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
+static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt)
 {
-MuxStream *ms = &of->mux->streams[ost->index];
-AVFormatContext *s = of->mux->fc;
+MuxStream *ms = &mux->streams[ost->index];
+AVFormatContext *s = mux->fc;
 AVStream *st = ost->st;
 int64_t fs;
 int ret;
 
 fs = filesize(s->pb);
-atomic_store(&of->mux->last_filesize, fs);
-if (fs >= of->mux->limit_filesize) {
+atomic_store(&mux->last_filesize, fs);
+if (fs >= mux->limit_filesize) {
 ret = AVERROR_EOF;
 goto fail;
 }
@@ -149,33 +154,35 @@ fail:
 return ret;
 }
 
-static int sync_queue_process(OutputFile *of, OutputStream *ost, AVPacket *pkt)
+static int sync_queue_process(Muxer *mux, OutputStream *ost, AVPacket *pkt)
 {
+OutputFile *of = &mux->of;
+
 if (ost->sq_idx_mux >= 0) {
 int ret = sq_send(of->sq_mux, ost->sq_idx_mux, SQPKT(pkt));
 if (ret < 0)
 return ret;
 
 while (1) {
-ret = sq_receive(of->sq_mux, -1, SQPKT(of->mux->sq_pkt));
+ret = sq_receive(of->sq_mux, -1, SQPKT(mux->sq_pkt));
 if (ret < 0)
 return (ret == AVERROR_EOF || ret == AVERROR(EAGAIN)) ? 0 : 
ret;
 
-ret = write_packet(of, output_streams[of->ost_index + ret],
-   of->mux->sq_pkt);
+ret = write_packet(mux, output_streams[of->ost_index + ret],
+   mux->sq_pkt);
 if (ret < 0)
 return ret;
 }
 } else if (pkt)
-return write_packet(of, ost, pkt);
+return write_packet(mux, ost, pkt);
 
 return 0;
 }
 
 static void *muxer_thread(void *arg)
 {
-OutputFile *of = arg;
-Muxer *mux = of->mux;
+Muxer *mux = arg;
+OutputFile *of = &mux->of;
 AVPacket  *pkt = NULL;
 intret = 0;
 
@@ -198,7 +205,7 @@ static void *muxer_thread(void *arg)
 }
 
 ost = output_streams[of->ost_index + stream_idx];
-ret = sync_queue_process(of, ost, ret < 0 ? NULL : pkt);
+ret = sync_queue_process(mux, ost, ret < 0 ? NULL : pkt);
 av_packet_unref(pkt);
 if (ret == AVERROR_EOF)
 tq_receive_finish(mux->tq, stream_idx);
@@ -220,9 +227,8 @@ finish:
 return (void*)(intptr_t)ret;
 }
 
-static int thread_submit_packet(OutputFile *of, OutputStream *ost, AVPacket 
*pkt)
+static int thread_submit_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt)
 {
-Muxer *mux = of->mux;
 int ret = 0;
 
 if (!pkt || ost->finished & MUXER_FINISHED)
@@ -243,9 +249,9 @@ finish:
 return ret == AVERROR_EOF ? 0 : ret;
 }
 
-static int queue_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
+static int queue_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt)
 {
-MuxStream *ms = &of->mux->streams[ost->index];
+MuxStream *ms = &mux->streams[ost->index];
 AVPacket *tmp_pkt = NULL;
 int ret;
 
@@ -285,15 +291,15 @@ static int queue_packet(OutputFile *of, OutputStream 
*ost, AVPacket *pkt)
 return 0;
 }
 
-static int submit_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost)
+static int submit_packet(Muxer *mux, AVPacket *pkt, OutputStream *ost)
 {
 int ret;
 
-if (of->mux->tq) {
-return thread_submit_packet(of, ost, pkt);
+if (mux->tq) {
+return thread_submit_packet(mux, ost, pkt);
 } else {
 /* the muxer is not initialized yet, buffer the packet */
-ret = queue_packet(of, ost, pkt);
+ret = queue_packet(mux, ost, pkt);
 if (ret < 0) {
 if (pkt)
 av_packet_unr

[FFmpeg-devel] [PATCH 02/13] fftools/ffmpeg: move output_packet() to ffmpeg_mux

2022-10-13 Thread Anton Khirnov
This function is common to both transcoding and streamcopy, so it
properly belongs into the muxing code.
---
 fftools/ffmpeg.c | 78 
 fftools/ffmpeg.h | 13 +++-
 fftools/ffmpeg_mux.c | 54 +-
 3 files changed, 72 insertions(+), 73 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 754172e568..015ff762c9 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -694,70 +694,6 @@ static void close_output_stream(OutputStream *ost)
 sq_send(of->sq_encode, ost->sq_idx_encode, SQFRAME(NULL));
 }
 
-/*
- * Send a single packet to the output, applying any bitstream filters
- * associated with the output stream.  This may result in any number
- * of packets actually being written, depending on what bitstream
- * filters are applied.  The supplied packet is consumed and will be
- * blank (as if newly-allocated) when this function returns.
- *
- * If eof is set, instead indicate EOF to all bitstream filters and
- * therefore flush any delayed packets to the output.  A blank packet
- * must be supplied in this case.
- */
-static void output_packet(OutputFile *of, AVPacket *pkt,
-  OutputStream *ost, int eof)
-{
-const char *err_msg;
-int ret = 0;
-
-if (!eof && pkt->dts != AV_NOPTS_VALUE)
-ost->last_mux_dts = av_rescale_q(pkt->dts, ost->mux_timebase, 
AV_TIME_BASE_Q);
-
-/* apply the output bitstream filters */
-if (ost->bsf_ctx) {
-int bsf_eof = 0;
-
-ret = av_bsf_send_packet(ost->bsf_ctx, eof ? NULL : pkt);
-if (ret < 0) {
-err_msg = "submitting a packet for bitstream filtering";
-goto fail;
-}
-
-while (!bsf_eof) {
-ret = av_bsf_receive_packet(ost->bsf_ctx, pkt);
-if (ret == AVERROR(EAGAIN))
-return;
-else if (ret == AVERROR_EOF)
-bsf_eof = 1;
-else if (ret < 0) {
-err_msg = "applying bitstream filters to a packet";
-goto fail;
-}
-
-ret = of_submit_packet(of, bsf_eof ? NULL : pkt, ost);
-if (ret < 0)
-goto mux_fail;
-}
-} else {
-ret = of_submit_packet(of, eof ? NULL : pkt, ost);
-if (ret < 0)
-goto mux_fail;
-}
-
-return;
-
-mux_fail:
-err_msg = "submitting a packet to the muxer";
-
-fail:
-av_log(NULL, AV_LOG_ERROR, "Error %s for output stream #%d:%d.\n",
-   err_msg, ost->file_index, ost->index);
-if (exit_on_error)
-exit_program(1);
-
-}
-
 static int check_recording_time(OutputStream *ost, int64_t ts, AVRational tb)
 {
 OutputFile *of = output_files[ost->file_index];
@@ -949,7 +885,7 @@ static int encode_frame(OutputFile *of, OutputStream *ost, 
AVFrame *frame)
 av_assert0(frame); // should never happen during flushing
 return 0;
 } else if (ret == AVERROR_EOF) {
-output_packet(of, pkt, ost, 1);
+of_output_packet(of, pkt, ost, 1);
 return ret;
 } else if (ret < 0) {
 av_log(NULL, AV_LOG_ERROR, "%s encoding failed\n", type_desc);
@@ -985,7 +921,7 @@ static int encode_frame(OutputFile *of, OutputStream *ost, 
AVFrame *frame)
 
 ost->packets_encoded++;
 
-output_packet(of, pkt, ost, 0);
+of_output_packet(of, pkt, ost, 0);
 }
 
 av_assert0(0);
@@ -1127,7 +1063,7 @@ static void do_subtitle_out(OutputFile *of,
 pkt->pts += av_rescale_q(sub->end_display_time, (AVRational){ 
1, 1000 }, ost->mux_timebase);
 }
 pkt->dts = pkt->pts;
-output_packet(of, pkt, ost, 0);
+of_output_packet(of, pkt, ost, 0);
 }
 }
 
@@ -1832,7 +1768,7 @@ static void flush_encoders(void)
 exit_program(1);
 }
 
-output_packet(of, ost->pkt, ost, 1);
+of_output_packet(of, ost->pkt, ost, 1);
 }
 
 init_output_stream_wrapper(ost, NULL, 1);
@@ -1878,7 +1814,7 @@ static void do_streamcopy(InputStream *ist, OutputStream 
*ost, const AVPacket *p
 av_packet_unref(opkt);
 // EOF: flush output bitstream filters.
 if (!pkt) {
-output_packet(of, opkt, ost, 1);
+of_output_packet(of, opkt, ost, 1);
 return;
 }
 
@@ -1934,7 +1870,7 @@ static void do_streamcopy(InputStream *ist, OutputStream 
*ost, const AVPacket *p
 
 opkt->duration = av_rescale_q(pkt->duration, ist->st->time_base, 
ost->mux_timebase);
 
-output_packet(of, opkt, ost, 0);
+of_output_packet(of, opkt, ost, 0);
 
 ost->streamcopy_started = 1;
 }
@@ -3833,7 +3769,7 @@ static int process_input(int file_index)
 if (ost->source_index == ifile->ist_index + i &&
 (!ost->enc_ctx || ost->enc_ctx->codec_type == 
AVMEDIA_TYPE_SUBTITLE)) {
 OutputFile *of = output_files[ost->file_ind

[FFmpeg-devel] [PATCH 01/13] fftools/ffmpeg_mux: do not unref a NULL packet

2022-10-13 Thread Anton Khirnov
The packet submitted to of_submit_packet() may be NULL to signal EOF.
---
 fftools/ffmpeg_mux.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 395f7cc89f..a6877ae5ec 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -329,7 +329,8 @@ int of_submit_packet(OutputFile *of, AVPacket *pkt, 
OutputStream *ost)
 /* the muxer is not initialized yet, buffer the packet */
 ret = queue_packet(of, ost, pkt);
 if (ret < 0) {
-av_packet_unref(pkt);
+if (pkt)
+av_packet_unref(pkt);
 return ret;
 }
 }
-- 
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] avcodec: add D3D12VA hardware accelerated H264, HEVC, VP9, and AV1 decoding

2022-10-13 Thread Lynne
Oct 12, 2022, 13:09 by toq...@outlook.com:

> [PATCH] avcodec: add D3D12VA hardware accelerated H264, HEVC, VP9, and AV1 
> decoding
>
> Patch attached.
>

The Sync locking functions and the queue locking functions should
be a function pointer in the device/frame context. Vulkan has
the same issue, and that's how I did it there. This allows for
API users to plug their own locking primitives in, which they need
to in case they initialize their own contexts.

You should also document which fields API users have to set
themselves if they plan to use their own context.

Also, struct names in the public context lack an AV prefix.

D3D12VA_MAX_SURFACES is a terrible hack. Vendors should
fix their own drivers rather than users running out of memory.

Also, you have code style issues, don't wrap one-line if statements
or loops in brackets.

ff_d3d12dec_get_suitable_max_bitstream_size is an awful function.
It does float math for sizes and has a magic mult factor of 1.5.
You have to calculate this properly.

On a first look, this is what stands out. Really must be split apart
in patches.
___
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] doc/encoders: Add doc for av1_qsv

2022-10-13 Thread wenbin . chen-at-intel . com
From: Wenbin Chen 

Add doc for av1_qsv.

Signed-off-by: Wenbin Chen 
---
 doc/encoders.texi | 32 
 1 file changed, 32 insertions(+)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 1a5216f8eb..53dd02fd28 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -3775,6 +3775,38 @@ Number of columns for tiled encoding (requires libmfx >= 
1.29).
 Number of rows for tiled encoding (requires libmfx  >= 1.29).
 @end table
 
+@subsection AV1 Options
+These options are used by av1_qsv (requires libvpl).
+@table @option
+@item @var{profile}
+@table @samp
+@item unknown
+@item main
+@end table
+
+@item @var{tile_cols}
+Number of columns for tiled encoding.
+
+@item @var{tile_rows}
+Number of rows for tiled encoding.
+
+@item @var{adaptive_i}
+This flag controls insertion of I frames by the QSV encoder. Turn ON this flag
+to allow changing of frame type from P and B to I.
+
+@item @var{adaptive_b}
+This flag controls changing of frame type from B to P.
+
+@item @var{b_strategy}
+This option controls usage of B frames as reference.
+
+@item @var{extbrc}
+Extended bitrate control.
+
+@item @var{look_ahead_depth}
+Depth of look ahead in number frames, available when extbrc option is enabled.
+@end table
+
 @section snow
 
 @subsection Options
-- 
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/2] libavcodec/qsvenc_av1: add av1_qsv encoder

2022-10-13 Thread wenbin . chen-at-intel . com
From: Wenbin Chen 

It is available only when libvpl is enabled. MSDK doesn't support av1
encoding.

sample command:
ffmpeg -f rawvideo -pix_fmt nv12 -s 1920x1080 -i input.yuv \
-c:v av1_qsv output.ivf

Signed-off-by: Wenbin Chen 
Signed-off-by: Haihao Xiang 
---
 configure   |   2 +
 libavcodec/Makefile |   1 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/qsvenc.c | 196 +++-
 libavcodec/qsvenc.h |   7 +-
 libavcodec/qsvenc_av1.c | 156 
 6 files changed, 358 insertions(+), 5 deletions(-)
 create mode 100644 libavcodec/qsvenc_av1.c

diff --git a/configure b/configure
index f3fd91f592..7c4fef6cb0 100755
--- a/configure
+++ b/configure
@@ -3269,6 +3269,8 @@ vp9_qsv_encoder_select="qsvenc"
 vp9_v4l2m2m_decoder_deps="v4l2_m2m vp9_v4l2_m2m"
 wmv3_crystalhd_decoder_select="crystalhd"
 av1_qsv_decoder_select="qsvdec"
+av1_qsv_encoder_select="qsvenc"
+av1_qsv_encoder_deps="libvpl"
 
 # parsers
 aac_parser_select="adts_header mpeg4audio"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 37b63cadc2..77deaafe98 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -244,6 +244,7 @@ OBJS-$(CONFIG_AURA_DECODER)+= cyuv.o
 OBJS-$(CONFIG_AURA2_DECODER)   += aura.o
 OBJS-$(CONFIG_AV1_DECODER) += av1dec.o
 OBJS-$(CONFIG_AV1_CUVID_DECODER)   += cuviddec.o
+OBJS-$(CONFIG_AV1_QSV_ENCODER) += qsvenc_av1.o
 OBJS-$(CONFIG_AVRN_DECODER)+= avrndec.o
 OBJS-$(CONFIG_AVRP_DECODER)+= r210dec.o
 OBJS-$(CONFIG_AVRP_ENCODER)+= r210enc.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index cfeb01ac1c..57e53437dc 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -827,6 +827,7 @@ extern const FFCodec ff_libaom_av1_decoder;
 extern const FFCodec ff_av1_decoder;
 extern const FFCodec ff_av1_cuvid_decoder;
 extern const FFCodec ff_av1_qsv_decoder;
+extern const FFCodec ff_av1_qsv_encoder;
 extern const FFCodec ff_libopenh264_encoder;
 extern const FFCodec ff_libopenh264_decoder;
 extern const FFCodec ff_h264_amf_encoder;
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index dc5479d0f3..fd3b9d5cbe 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -82,6 +82,14 @@ static const struct profile_names vp9_profiles[] = {
 { MFX_PROFILE_VP9_3,"vp9 3" },
 };
 
+static const struct profile_names av1_profiles[] = {
+#if QSV_VERSION_ATLEAST(1, 34)
+{ MFX_PROFILE_AV1_MAIN, "av1 main"  },
+{ MFX_PROFILE_AV1_HIGH, "av1 high"  },
+{ MFX_PROFILE_AV1_PRO,  "av1 professional"  },
+#endif
+};
+
 typedef struct QSVPacket {
 AVPacketpkt;
 mfxSyncPoint   *sync;
@@ -114,6 +122,11 @@ static const char *print_profile(enum AVCodecID codec_id, 
mfxU16 profile)
 num_profiles = FF_ARRAY_ELEMS(vp9_profiles);
 break;
 
+case AV_CODEC_ID_AV1:
+profiles = av1_profiles;
+num_profiles = FF_ARRAY_ELEMS(av1_profiles);
+break;
+
 default:
 return "unknown";
 }
@@ -429,6 +442,88 @@ static void dump_video_mjpeg_param(AVCodecContext *avctx, 
QSVEncContext *q)
info->FrameInfo.FrameRateExtD, info->FrameInfo.FrameRateExtN);
 }
 
+#if QSV_HAVE_EXT_AV1_PARAM
+static void dump_video_av1_param(AVCodecContext *avctx, QSVEncContext *q,
+ mfxExtBuffer **coding_opts)
+{
+mfxInfoMFX *info = &q->param.mfx;
+mfxExtAV1TileParam *av1_tile_param = (mfxExtAV1TileParam *)coding_opts[0];
+mfxExtAV1BitstreamParam *av1_bs_param = (mfxExtAV1BitstreamParam 
*)coding_opts[1];
+mfxExtCodingOption2 *co2 = (mfxExtCodingOption2*)coding_opts[2];
+mfxExtCodingOption3 *co3 = (mfxExtCodingOption3*)coding_opts[3];
+
+av_log(avctx, AV_LOG_VERBOSE, "profile: %s; level: %"PRIu16"\n",
+   print_profile(avctx->codec_id, info->CodecProfile), 
info->CodecLevel);
+
+av_log(avctx, AV_LOG_VERBOSE,
+   "GopPicSize: %"PRIu16"; GopRefDist: %"PRIu16"; GopOptFlag:%s%s; 
IdrInterval: %"PRIu16"\n",
+   info->GopPicSize, info->GopRefDist,
+   info->GopOptFlag & MFX_GOP_CLOSED ? " closed" : "",
+   info->GopOptFlag & MFX_GOP_STRICT ? " strict" : "",
+   info->IdrInterval);
+
+av_log(avctx, AV_LOG_VERBOSE, "TargetUsage: %"PRIu16"; RateControlMethod: 
%s\n",
+   info->TargetUsage, print_ratecontrol(info->RateControlMethod));
+
+if (info->RateControlMethod == MFX_RATECONTROL_CBR ||
+info->RateControlMethod == MFX_RATECONTROL_VBR)
+av_log(avctx, AV_LOG_VERBOSE,
+   "BufferSizeInKB: %"PRIu16"; InitialDelayInKB: %"PRIu16"; 
TargetKbps: %"PRIu16"; MaxKbps: %"PRIu16"; BRCParamMultiplier: %"PRIu16"\n",
+   info->BufferSizeInKB, info->InitialDelayInKB, info->TargetKbps, 
info->MaxKbps, info->BRCParamMultiplie