Re: [FFmpeg-devel] Custom Video Encoding and Decoding

2020-07-29 Thread Alex Cohn
On Wed, Jul 29, 2020 at 9:12 AM Jaeho Bang  wrote:
>
> Dear members of ffmpeg-devel,
>
> I am currently working on a research project and from looking over the
> examples and documentation in the ffmpeg repository, I believe I need to
> implement a custom encoder / decoder to perform my task.
>
> To first explain the project idea, currently I am working mainly with
> surveillance footages. Using a traditional video decoder, I convert the
> video into series of image frames and perform clustering to create frame
> groups. Then using some performance metric, my algorithm selects a
> representative frame from each group. By implementing a custom encoder and
> decoder, I aim to improve the speed of extracting these representative
> frames.
>
> To further explain, I would like the custom encoder to be able to force the
> frames I have chosen (representative frames) to be i-frames. The assumption
> is that when analyzing videos, we only need to evaluate these
> representative frames instead of the whole video (this I have already
> experimentally confirmed), and extracting i-frames is faster than
> extracting a combination of i-frames, b-frames, and p-frames.
>
> Also, I would like to implement a decoder to quickly extract the series of
> frames I give as input (they will all be i-frames). Through preliminary
> experiments, I realized that extracting only i-frames by using the command
> 'select pict_type\I' query command only gives a 2x speed boost compared to
> extracting all frames within the video. Hopefully, by implementing a custom
> decoder, I aim to further increase this extraction speed.
>
> Is there any code I can refer to? Is my assumption of 'if I were to
> implement a custom decoder, the extraction speed would be faster than using
> the keyword select to get all the i frames' valid?
>
> Any help would be greatly appreciated. Thank you and have a wonderful day.
>
> Sincerely,
> Jaeho Bang
>
> --
> *Jaeho Bang*
> *PhD Student in Computer Science*
> Georgia Institute of Technology
> North Ave NW, Atlanta, GA 30332, USA

IMO, the x2 speed boost is a positive result, depending on the GOP
size. Decoding a series of P frames is much faster than for the same
amount of I frames. I don't believe some 'custom decoder' can improve
the situation further.

BR,
Alex Cohn
___
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] Custom Video Encoding and Decoding

2020-07-29 Thread Jaeho Bang
Dear Paul,
Thank you for the reply! I must have done a bad job explaining, sorry about
that. There is some underlying information that I have left out. My initial
clustering algorithm / representative frame selection algorithm actually
spits out a frame importance hierarchy. I want to implement a custom
decoder because it needs to process inputs such as 'select 100 most
important frames of this video'. Rather than decoding the entire video and
choosing the 100 most important frames based on frame importance hierarchy,
I want to only decode the frames that I specify (By having a custom
encoder, I have already forced these frames to be i-frames, hence minimum
computation is required). The goal of this decoder is to minimize memory
footprint (since decoding entire video into image frames increases memory
usage by 100x according to my experiments) while maximizing decoding speed.
Does this provide a clearer reason why I am thinking of implementing a
custom decoder? Please feel free to ask for clarifications.

Thank you,
Jaeho Bang

On Wed, Jul 29, 2020 at 3:31 PM Paul B Mahol  wrote:

> On 7/29/20, Jaeho Bang  wrote:
> > Dear members of ffmpeg-devel,
> >
> > I am currently working on a research project and from looking over the
> > examples and documentation in the ffmpeg repository, I believe I need to
> > implement a custom encoder / decoder to perform my task.
> >
> > To first explain the project idea, currently I am working mainly with
> > surveillance footages. Using a traditional video decoder, I convert the
> > video into series of image frames and perform clustering to create frame
> > groups. Then using some performance metric, my algorithm selects a
> > representative frame from each group. By implementing a custom encoder
> and
> > decoder, I aim to improve the speed of extracting these representative
> > frames.
> >
> > To further explain, I would like the custom encoder to be able to force
> the
> > frames I have chosen (representative frames) to be i-frames. The
> assumption
> > is that when analyzing videos, we only need to evaluate these
> > representative frames instead of the whole video (this I have already
> > experimentally confirmed), and extracting i-frames is faster than
> > extracting a combination of i-frames, b-frames, and p-frames.
> >
> > Also, I would like to implement a decoder to quickly extract the series
> of
> > frames I give as input (they will all be i-frames). Through preliminary
> > experiments, I realized that extracting only i-frames by using the
> command
> > 'select pict_type\I' query command only gives a 2x speed boost compared
> to
> > extracting all frames within the video. Hopefully, by implementing a
> custom
> > decoder, I aim to further increase this extraction speed.
> >
> > Is there any code I can refer to? Is my assumption of 'if I were to
> > implement a custom decoder, the extraction speed would be faster than
> using
> > the keyword select to get all the i frames' valid?
> >
> > Any help would be greatly appreciated. Thank you and have a wonderful
> day.
> >
>
> Sorry, but with all due respect, the need for custom decoder does not
> make any sense.
>
> > Sincerely,
> > Jaeho Bang
> >
> > --
> > *Jaeho Bang*
> > *PhD Student in Computer Science*
> > Georgia Institute of Technology
> > North Ave NW, Atlanta, GA 30332, USA
> > ___
> > 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".



-- 
*Jaeho Bang*
*PhD Student in Robotics*
Georgia Institute of Technology
North Ave NW, Atlanta, GA 30332, USA
___
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] Custom Video Encoding and Decoding

2020-07-29 Thread Zhao Zhili


On July 29, 2020 3:13:34 PM GMT+08:00, Jaeho Bang  wrote:
>Dear Paul,
>Thank you for the reply! I must have done a bad job explaining, sorry
>about
>that. There is some underlying information that I have left out. My
>initial
>clustering algorithm / representative frame selection algorithm
>actually
>spits out a frame importance hierarchy. I want to implement a custom
>decoder because it needs to process inputs such as 'select 100 most
>important frames of this video'. Rather than decoding the entire video
>and
>choosing the 100 most important frames based on frame importance
>hierarchy,
>I want to only decode the frames that I specify (By having a custom
>encoder, I have already forced these frames to be i-frames, hence
>minimum
>computation is required). The goal of this decoder is to minimize
>memory
>footprint (since decoding entire video into image frames increases
>memory
>usage by 100x according to my experiments) while maximizing decoding
>speed.
>Does this provide a clearer reason why I am thinking of implementing a
>custom decoder? Please feel free to ask for clarifications.
>

You can add custom info to container or out-of-band to help select which packet 
to decoding. The custom info doesn't belong to the codec normally.

>Thank you,
>Jaeho Bang
>
>On Wed, Jul 29, 2020 at 3:31 PM Paul B Mahol  wrote:
>
>> On 7/29/20, Jaeho Bang  wrote:
>> > Dear members of ffmpeg-devel,
>> >
>> > I am currently working on a research project and from looking over
>the
>> > examples and documentation in the ffmpeg repository, I believe I
>need to
>> > implement a custom encoder / decoder to perform my task.
>> >
>> > To first explain the project idea, currently I am working mainly
>with
>> > surveillance footages. Using a traditional video decoder, I convert
>the
>> > video into series of image frames and perform clustering to create
>frame
>> > groups. Then using some performance metric, my algorithm selects a
>> > representative frame from each group. By implementing a custom
>encoder
>> and
>> > decoder, I aim to improve the speed of extracting these
>representative
>> > frames.
>> >
>> > To further explain, I would like the custom encoder to be able to
>force
>> the
>> > frames I have chosen (representative frames) to be i-frames. The
>> assumption
>> > is that when analyzing videos, we only need to evaluate these
>> > representative frames instead of the whole video (this I have
>already
>> > experimentally confirmed), and extracting i-frames is faster than
>> > extracting a combination of i-frames, b-frames, and p-frames.
>> >
>> > Also, I would like to implement a decoder to quickly extract the
>series
>> of
>> > frames I give as input (they will all be i-frames). Through
>preliminary
>> > experiments, I realized that extracting only i-frames by using the
>> command
>> > 'select pict_type\I' query command only gives a 2x speed boost
>compared
>> to
>> > extracting all frames within the video. Hopefully, by implementing
>a
>> custom
>> > decoder, I aim to further increase this extraction speed.
>> >
>> > Is there any code I can refer to? Is my assumption of 'if I were to
>> > implement a custom decoder, the extraction speed would be faster
>than
>> using
>> > the keyword select to get all the i frames' valid?
>> >
>> > Any help would be greatly appreciated. Thank you and have a
>wonderful
>> day.
>> >
>>
>> Sorry, but with all due respect, the need for custom decoder does not
>> make any sense.
>>
>> > Sincerely,
>> > Jaeho Bang
>> >
>> > --
>> > *Jaeho Bang*
>> > *PhD Student in Computer Science*
>> > Georgia Institute of Technology
>> > North Ave NW, Atlanta, GA 30332, USA
>> > ___
>> > 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".
>
>
>
>-- 
>*Jaeho Bang*
>*PhD Student in Robotics*
>Georgia Institute of Technology
>North Ave NW, Atlanta, GA 30332, USA
>___
>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".

-- 
使用 K-9 Mail 发送自我的Android设备。
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v3 1/2] avformat/url: fix logic for removing ".." path components

2020-07-29 Thread Nicolas George
Josef Zlomek (12020-07-28):
> Fixes: 8814
> 
> The logic for removing ".." path components and their corresponding
> upper directories was reworked.
> 
> Now, the function trim_double_dot_url splits the path by "/" into
> components, and processes the components one ny one:
> - if the component is "..", the last path component in output buffer is 
> removed
> - if the component is not empty, it is added to the output buffer
> No temporary buffers are used anymore.
> 
> Also the path containing no '/' after '://' is returned as it is.
> 
> The duplicate logic was removed from ff_make_absolute_url.

I am afraid ff_make_absolute_url() as it is is broken beyond repair. For
example:

http://server/menu redirect?url=http://otherserver/target =>
  redirect?url=http://otherserver/target

while the result should have been

http://server/redirect?url=http://otherserver/target

I will have a shot at rewriting it cleanly, with proper parsing of URL
components.

Regards,

-- 
  Nicolas George


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/4] [mips]: Fix register constraint error reported by clang.

2020-07-29 Thread Shiyou Yin
Clang report following error in aacsbr_mips.c,ac3dsp_mips.c and aacdec_mips.c:
"couldn't allocate output register for constraint 'r'"

Use 'f' constraint for float variable.
---
 libavcodec/mips/aacdec_mips.c |  2 +-
 libavcodec/mips/aacsbr_mips.c |  2 +-
 libavcodec/mips/sbrdsp_mips.c | 19 ++-
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/libavcodec/mips/aacdec_mips.c b/libavcodec/mips/aacdec_mips.c
index 8e30652..7f24789 100644
--- a/libavcodec/mips/aacdec_mips.c
+++ b/libavcodec/mips/aacdec_mips.c
@@ -340,7 +340,7 @@ static void update_ltp_mips(AACContext *ac, 
SingleChannelElement *sce)
 float *saved_ltp = sce->coeffs;
 const float *lwindow = ics->use_kb_window[0] ? ff_aac_kbd_long_1024 : 
ff_sine_1024;
 const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : 
ff_sine_128;
-float temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7;
+uint32_t temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7;
 
 if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
 float *p_saved_ltp = saved_ltp + 576;
diff --git a/libavcodec/mips/aacsbr_mips.c b/libavcodec/mips/aacsbr_mips.c
index 2e0cd72..5ef5e68 100644
--- a/libavcodec/mips/aacsbr_mips.c
+++ b/libavcodec/mips/aacsbr_mips.c
@@ -333,7 +333,7 @@ static void sbr_hf_assemble_mips(float Y1[38][64][2],
 int indexnoise = ch_data->f_indexnoise;
 int indexsine  = ch_data->f_indexsine;
 float *g_temp1, *q_temp1, *pok, *pok1;
-float temp1, temp2, temp3, temp4;
+uint32_t temp1, temp2, temp3, temp4;
 int size = m_max;
 
 if (sbr->reset) {
diff --git a/libavcodec/mips/sbrdsp_mips.c b/libavcodec/mips/sbrdsp_mips.c
index 83039fd..1c87c99 100644
--- a/libavcodec/mips/sbrdsp_mips.c
+++ b/libavcodec/mips/sbrdsp_mips.c
@@ -796,9 +796,9 @@ static void sbr_hf_apply_noise_2_mips(float (*Y)[2], const 
float *s_m,
  const float *q_filt, int noise,
  int kx, int m_max)
 {
-int m;
+int m, temp0, temp1;
 float *ff_table;
-float y0,y1, temp0, temp1, temp2, temp3, temp4, temp5;
+float y0, y1, temp2, temp3, temp4, temp5;
 
 for (m = 0; m < m_max; m++) {
 
@@ -808,14 +808,14 @@ static void sbr_hf_apply_noise_2_mips(float (*Y)[2], 
const float *s_m,
 
 __asm__ volatile(
 "lwc1   %[y0],   0(%[Y1])  
\n\t"
-"lwc1   %[temp1],0(%[s_m1])
\n\t"
+"lwc1   %[temp3],0(%[s_m1])
\n\t"
 "addiu  %[noise],%[noise],  1  
\n\t"
 "andi   %[noise],%[noise],  0x1ff  
\n\t"
 "sll%[temp0],%[noise],  3  
\n\t"
 PTR_ADDU "%[ff_table],%[ff_sbr_noise_table],%[temp0]   
\n\t"
-"sub.s  %[y0],   %[y0], %[temp1]   
\n\t"
-"mfc1   %[temp3],%[temp1]  
\n\t"
-"bne%[temp3],$0,1f 
\n\t"
+"sub.s  %[y0],   %[y0], %[temp3]   
\n\t"
+"mfc1   %[temp1],%[temp3]  
\n\t"
+"bne%[temp1],$0,1f 
\n\t"
 "lwc1   %[y1],   4(%[Y1])  
\n\t"
 "lwc1   %[temp2],0(%[q_filt1]) 
\n\t"
 "lwc1   %[temp4],0(%[ff_table])
\n\t"
@@ -826,9 +826,10 @@ static void sbr_hf_apply_noise_2_mips(float (*Y)[2], const 
float *s_m,
 "1:
\n\t"
 "swc1   %[y0],   0(%[Y1])  
\n\t"
 
-: [temp0]"=&r"(temp0), [ff_table]"=&r"(ff_table), [y0]"=&f"(y0),
-  [y1]"=&f"(y1), [temp1]"=&f"(temp1), [temp2]"=&f"(temp2),
-  [temp3]"=&r"(temp3), [temp4]"=&f"(temp4), [temp5]"=&f"(temp5)
+: [temp0]"=&r"(temp0), [temp1]"=&r"(temp1), [y0]"=&f"(y0),
+  [y1]"=&f"(y1), [ff_table]"=&r"(ff_table),
+  [temp2]"=&f"(temp2), [temp3]"=&f"(temp3),
+  [temp4]"=&f"(temp4), [temp5]"=&f"(temp5)
 : [ff_sbr_noise_table]"r"(ff_sbr_noise_table), [noise]"r"(noise),
   [Y1]"r"(Y1), [s_m1]"r"(s_m1), [q_filt1]"r"(q_filt1)
 : "memory"
-- 
2.1.0

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

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

[FFmpeg-devel] [PATCH 3/4] [mips]: Fix a bug in get_cabac_inline_mips.

2020-07-29 Thread Shiyou Yin
Failed fate case: fate-h264-conformance-caba2_sony_e
Clang is more strict in the use of register constraint.
---
 libavcodec/mips/cabac.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mips/cabac.h b/libavcodec/mips/cabac.h
index c595915..3d09e93 100644
--- a/libavcodec/mips/cabac.h
+++ b/libavcodec/mips/cabac.h
@@ -109,7 +109,7 @@ static av_always_inline int 
get_cabac_inline_mips(CABACContext *c,
   [lps_off]"i"(H264_LPS_RANGE_OFFSET),
   [mlps_off]"i"(H264_MLPS_STATE_OFFSET + 128),
   [norm_off]"i"(H264_NORM_SHIFT_OFFSET),
-  [cabac_mask]"i"(CABAC_MASK)
+  [cabac_mask]"r"(CABAC_MASK)
 : "memory"
 );
 
-- 
2.1.0

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

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

[FFmpeg-devel] [PATCH 2/4] [mips]: Fix prob that 'ulw' and 'uld' unsupported by clang.

2020-07-29 Thread Shiyou Yin
GCC support these two synthesized instruction, but clang does not yet.
Use machine instruction instead to adapt clang compiler.
---
 libavutil/mips/generic_macros_msa.h | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/libavutil/mips/generic_macros_msa.h 
b/libavutil/mips/generic_macros_msa.h
index 267d4e6..bb25e9f 100644
--- a/libavutil/mips/generic_macros_msa.h
+++ b/libavutil/mips/generic_macros_msa.h
@@ -111,10 +111,11 @@
 uint32_t val_lw_m;   \
  \
 __asm__ volatile (   \
-"ulw  %[val_lw_m],  %[psrc_lw_m]  \n\t"  \
+"lwr %[val_lw_m], 0(%[psrc_lw_m]) \n\t"  \
+"lwl %[val_lw_m], 3(%[psrc_lw_m]) \n\t"  \
  \
-: [val_lw_m] "=r" (val_lw_m) \
-: [psrc_lw_m] "m" (*psrc_lw_m)   \
+: [val_lw_m] "=&r"(val_lw_m) \
+: [psrc_lw_m] "r"(psrc_lw_m) \
 );   \
  \
 val_lw_m;\
@@ -127,10 +128,11 @@
 uint64_t val_ld_m = 0;   \
  \
 __asm__ volatile (   \
-"uld  %[val_ld_m],  %[psrc_ld_m]  \n\t"  \
+"ldr %[val_ld_m], 0(%[psrc_ld_m]) \n\t"  \
+"ldl %[val_ld_m], 7(%[psrc_ld_m]) \n\t"  \
  \
-: [val_ld_m] "=r" (val_ld_m) \
-: [psrc_ld_m] "m" (*psrc_ld_m)   \
+: [val_ld_m] "=&r" (val_ld_m)\
+: [psrc_ld_m] "r" (psrc_ld_m)\
 );   \
  \
 val_ld_m;\
-- 
2.1.0

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

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

[FFmpeg-devel] [PATCH 0/4] [mips]: Adapt clang compiler for mips.

2020-07-29 Thread Shiyou Yin
Fixed four prob encountered when compiling ffmpeg with clang on mips.
configure: ./configure --disable-mmi  --cc=clang --cxx=clang++ --ld=clang

[PATCH 1/4] [mips]: Fix register constraint error reported by clang.
[PATCH 2/4] [mips]: Fix prob that 'ulw' and 'uld' unsupported by clang.
[PATCH 3/4] [mips]: Fix a bug in get_cabac_inline_mips.
[PATCH 4/4] [mips]: Fix segfault in imdct36_mips_float.

___
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] [mips]: Fix segfault in imdct36_mips_float.

2020-07-29 Thread Shiyou Yin
'li.s' is a synthesized instruction, it does not work properly
when compiled with clang on mips, and A segfault occurred.
---
 libavcodec/mips/aacpsdsp_mips.c   |  13 +-
 libavcodec/mips/aacpsy_mips.h |  14 +-
 libavcodec/mips/fft_mips.c|  12 +-
 libavcodec/mips/mpegaudiodsp_mips_float.c | 492 +++---
 4 files changed, 264 insertions(+), 267 deletions(-)

diff --git a/libavcodec/mips/aacpsdsp_mips.c b/libavcodec/mips/aacpsdsp_mips.c
index ef47e31..f635413 100644
--- a/libavcodec/mips/aacpsdsp_mips.c
+++ b/libavcodec/mips/aacpsdsp_mips.c
@@ -293,16 +293,17 @@ static void ps_decorrelate_mips(float (*out)[2], float 
(*delay)[2],
 float phi_fract0 = phi_fract[0];
 float phi_fract1 = phi_fract[1];
 float temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8, temp9;
+float f1, f2, f3;
 
 float *p_delay_end = (p_delay + (len << 1));
 
 /* merged 2 loops */
+f1 = 0.65143905753106;
+f2 = 0.56471812200776;
+f3 = 0.48954165955695;
 __asm__ volatile(
 ".setpush\n\t"
 ".setnoreorder   \n\t"
-"li.s%[ag0],0.65143905753106 \n\t"
-"li.s%[ag1],0.56471812200776 \n\t"
-"li.s%[ag2],0.48954165955695 \n\t"
 "mul.s   %[ag0],%[ag0],%[g_decay_slope]  \n\t"
 "mul.s   %[ag1],%[ag1],%[g_decay_slope]  \n\t"
 "mul.s   %[ag2],%[ag2],%[g_decay_slope]  \n\t"
@@ -378,10 +379,10 @@ static void ps_decorrelate_mips(float (*out)[2], float 
(*delay)[2],
   [temp3]"=&f"(temp3), [temp4]"=&f"(temp4), [temp5]"=&f"(temp5),
   [temp6]"=&f"(temp6), [temp7]"=&f"(temp7), [temp8]"=&f"(temp8),
   [temp9]"=&f"(temp9), [p_delay]"+r"(p_delay), 
[p_ap_delay]"+r"(p_ap_delay),
-  [p_Q_fract]"+r"(p_Q_fract), [p_t_gain]"+r"(p_t_gain), 
[p_out]"+r"(p_out),
-  [ag0]"=&f"(ag0), [ag1]"=&f"(ag1), [ag2]"=&f"(ag2)
+  [p_Q_fract]"+r"(p_Q_fract), [p_t_gain]"+r"(p_t_gain), 
[p_out]"+r"(p_out)
 : [phi_fract0]"f"(phi_fract0), [phi_fract1]"f"(phi_fract1),
-  [p_delay_end]"r"(p_delay_end), [g_decay_slope]"f"(g_decay_slope)
+  [p_delay_end]"r"(p_delay_end), [g_decay_slope]"f"(g_decay_slope),
+  [ag0]"f"(f1), [ag1]"f"(f2), [ag2]"f"(f3)
 : "memory"
 );
 }
diff --git a/libavcodec/mips/aacpsy_mips.h b/libavcodec/mips/aacpsy_mips.h
index a1fe5cc..7d27d32 100644
--- a/libavcodec/mips/aacpsy_mips.h
+++ b/libavcodec/mips/aacpsy_mips.h
@@ -135,11 +135,11 @@ static void psy_hp_filter_mips(const float *firbuf, float 
*hpfsmpl, const float
 float coeff3 = psy_fir_coeffs[7];
 float coeff4 = psy_fir_coeffs[9];
 
+float f1 = 32768.0;
 __asm__ volatile (
 ".set push  \n\t"
 ".set noreorder \n\t"
 
-"li.s   $f12,   32768   \n\t"
 "1: \n\t"
 "lwc1   $f0,40(%[fb])   \n\t"
 "lwc1   $f1,4(%[fb])\n\t"
@@ -203,14 +203,14 @@ static void psy_hp_filter_mips(const float *firbuf, float 
*hpfsmpl, const float
 "madd.s %[sum2],%[sum2],$f9,%[coeff4]   \n\t"
 "madd.s %[sum4],%[sum4],$f6,%[coeff4]   \n\t"
 "madd.s %[sum3],%[sum3],$f3,%[coeff4]   \n\t"
-"mul.s  %[sum1],%[sum1],$f12\n\t"
-"mul.s  %[sum2],%[sum2],$f12\n\t"
+"mul.s  %[sum1],%[sum1],%[f1]   \n\t"
+"mul.s  %[sum2],%[sum2],%[f1]   \n\t"
 "madd.s %[sum4],%[sum4],$f11,   %[coeff4]   \n\t"
 "madd.s %[sum3],%[sum3],$f8,%[coeff4]   \n\t"
 "swc1   %[sum1],0(%[hp])\n\t"
 "swc1   %[sum2],4(%[hp])\n\t"
-"mul.s  %[sum4],%[sum4],$f12\n\t"
-"mul.s  %[sum3],%[sum3],$f12\n\t"
+"mul.s  %[sum4],%[sum4],%[f1]   \n\t"
+"mul.s  %[sum3],%[sum3],%[f1]   \n\t"
 "swc1   %[sum4],12(%[hp])   \n\t"
 "swc1   %[sum3],8(%[hp])\n\t"
 "bne%[fb],  %[fb_end],  1b  \n\t"
@@ -223,9 +223,9 @@ static void psy_hp_filter_mips(const float *firbuf, float 
*hpfsmpl, const float
   [fb]"+r"(fb), [hp]"+r"(hp)
 : [coeff0]"f"(coeff0), [coeff1]"f"(coeff1),
   [coeff2]"f"(coeff2), [coeff3]"f"(coeff3),
-  [coeff4]"f"(coeff4), [fb_end]"r"(fb_end)
+  [coeff

Re: [FFmpeg-devel] [PATCH v3 1/2] avformat/url: fix logic for removing ".." path components

2020-07-29 Thread Zlomek, Josef
On Wed, Jul 29, 2020 at 12:01 PM Nicolas George  wrote:

> I am afraid ff_make_absolute_url() as it is is broken beyond repair. For
> example:
>
> http://server/menu redirect?url=http://otherserver/target =>
>   redirect?url=http://otherserver/target
>
> while the result should have been
>
> http://server/redirect?url=http://otherserver/target
>
> I will have a shot at rewriting it cleanly, with proper parsing of URL
> components.
>

I also noticed that there are many more bugs in ff_make_absolute_url()
I just fixed one of them.
I am looking forward for your complete fix.

Best regards,
Josef
___
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/5] avutil/channel_layout: add 22.2 layout

2020-07-29 Thread Jan Ekström
Requires some extraneous top side and bottom front channels to be
defined.

According to STD-B59v2, the defined channel layout is:
- FL
- FR
- FC
- LFE1
- BL
- BR
- FLc
- FRc
- BC
- LFE2
- SiL
- SiR
- TpFL
- TpFR
- TpFC
- TpC
- TpBL
- TpBR
- TpSiL
- TpSiR
- TpBC
- BtFC
- BtFL
- BtFR
---
 doc/APIchanges | 5 +
 libavutil/channel_layout.c | 6 ++
 libavutil/channel_layout.h | 6 ++
 libavutil/version.h| 2 +-
 4 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 72a4833fbc..d839b2c413 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,11 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2020-06-16 - xx - lavu 56.58.100 - channel_layout.h
+  Add AV_CH_LAYOUT_22POINT2 together with its newly required pieces:
+  AV_CH_TOP_SIDE_LEFT, AV_CH_TOP_SIDE_RIGHT, AV_CH_BOTTOM_FRONT_LEFT,
+  AV_CH_BOTTOM_FRONT_CENTER, AV_CH_BOTTOM_FRONT_RIGHT.
+
 2020-07-xx - xx - lavu 56.57.100 - cpu.h
   Add AV_CPU_FLAG_MMI and AV_CPU_FLAG_MSA.
 
diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c
index 3bd5ee29b7..d6bfc74927 100644
--- a/libavutil/channel_layout.c
+++ b/libavutil/channel_layout.c
@@ -62,6 +62,11 @@ static const struct channel_name channel_names[] = {
 [33] = { "SDL",   "surround direct left"  },
 [34] = { "SDR",   "surround direct right" },
 [35] = { "LFE2",  "low frequency 2"   },
+[36] = { "TSL",   "top side left" },
+[37] = { "TSR",   "top side right"},
+[38] = { "BFL",   "bottom front left" },
+[39] = { "BFC",   "bottom front center"   },
+[40] = { "BFR",   "bottom front right"},
 };
 
 static const char *get_channel_name(int channel_id)
@@ -104,6 +109,7 @@ static const struct {
 { "octagonal",   8,  AV_CH_LAYOUT_OCTAGONAL },
 { "hexadecagonal", 16, AV_CH_LAYOUT_HEXADECAGONAL },
 { "downmix", 2,  AV_CH_LAYOUT_STEREO_DOWNMIX, },
+{ "22.2",  24, AV_CH_LAYOUT_22POINT2, },
 };
 
 static uint64_t get_channel_layout_single(const char *name, int name_len)
diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h
index 50bb8f03c5..43297505cb 100644
--- a/libavutil/channel_layout.h
+++ b/libavutil/channel_layout.h
@@ -71,6 +71,11 @@
 #define AV_CH_SURROUND_DIRECT_LEFT   0x0002ULL
 #define AV_CH_SURROUND_DIRECT_RIGHT  0x0004ULL
 #define AV_CH_LOW_FREQUENCY_20x0008ULL
+#define AV_CH_TOP_SIDE_LEFT  0x0010ULL
+#define AV_CH_TOP_SIDE_RIGHT 0x0020ULL
+#define AV_CH_BOTTOM_FRONT_LEFT  0x0040ULL
+#define AV_CH_BOTTOM_FRONT_CENTER0x0080ULL
+#define AV_CH_BOTTOM_FRONT_RIGHT 0x0100ULL
 
 /** Channel mask value used for AVCodecContext.request_channel_layout
 to indicate that the user requests the channel order of the decoder output
@@ -110,6 +115,7 @@
 #define AV_CH_LAYOUT_OCTAGONAL 
(AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_CENTER|AV_CH_BACK_RIGHT)
 #define AV_CH_LAYOUT_HEXADECAGONAL 
(AV_CH_LAYOUT_OCTAGONAL|AV_CH_WIDE_LEFT|AV_CH_WIDE_RIGHT|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT|AV_CH_TOP_BACK_CENTER|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT)
 #define AV_CH_LAYOUT_STEREO_DOWNMIX(AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT)
+#define AV_CH_LAYOUT_22POINT2  
(AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_BACK_CENTER|AV_CH_LOW_FREQUENCY_2|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_CENTER|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT|AV_CH_TOP_SIDE_LEFT|AV_CH_TOP_SIDE_RIGHT|AV_CH_TOP_BACK_CENTER|AV_CH_BOTTOM_FRONT_CENTER|AV_CH_BOTTOM_FRONT_LEFT|AV_CH_BOTTOM_FRONT_RIGHT)
 
 enum AVMatrixEncoding {
 AV_MATRIX_ENCODING_NONE,
diff --git a/libavutil/version.h b/libavutil/version.h
index 975fb87f31..3e7e1f410b 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  56
-#define LIBAVUTIL_VERSION_MINOR  57
+#define LIBAVUTIL_VERSION_MINOR  58
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
2.26.2

___
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/5] avcodec/aacdectab: add mapping for 22.2

2020-07-29 Thread Jan Ekström
Utilizes the newly added 22.2 channel layout for channel_layout 13.
---
 libavcodec/aacdectab.h | 23 +--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/libavcodec/aacdectab.h b/libavcodec/aacdectab.h
index baf51a74bf..c54a3eb943 100644
--- a/libavcodec/aacdectab.h
+++ b/libavcodec/aacdectab.h
@@ -35,9 +35,9 @@
 
 #include 
 
-static const int8_t tags_per_config[16] = { 0, 1, 1, 2, 3, 3, 4, 5, 0, 0, 0, 
4, 5, 0, 5, 0 };
+static const int8_t tags_per_config[16] = { 0, 1, 1, 2, 3, 3, 4, 5, 0, 0, 0, 
4, 5, 16, 5, 0 };
 
-static const uint8_t aac_channel_layout_map[16][5][3] = {
+static const uint8_t aac_channel_layout_map[16][16][3] = {
 { { TYPE_SCE, 0, AAC_CHANNEL_FRONT }, },
 { { TYPE_CPE, 0, AAC_CHANNEL_FRONT }, },
 { { TYPE_SCE, 0, AAC_CHANNEL_FRONT }, { TYPE_CPE, 0, AAC_CHANNEL_FRONT }, 
},
@@ -50,6 +50,24 @@ static const uint8_t aac_channel_layout_map[16][5][3] = {
 { { 0, } },
 { { TYPE_SCE, 0, AAC_CHANNEL_FRONT }, { TYPE_CPE, 0, AAC_CHANNEL_FRONT }, 
{ TYPE_CPE, 1, AAC_CHANNEL_BACK }, { TYPE_SCE, 1, AAC_CHANNEL_BACK }, { 
TYPE_LFE, 0, AAC_CHANNEL_LFE  }, },
 { { TYPE_SCE, 0, AAC_CHANNEL_FRONT }, { TYPE_CPE, 0, AAC_CHANNEL_FRONT }, 
{ TYPE_CPE, 1, AAC_CHANNEL_SIDE }, { TYPE_CPE, 2, AAC_CHANNEL_BACK }, { 
TYPE_LFE, 0, AAC_CHANNEL_LFE  }, },
+{
+  { TYPE_SCE, 0, AAC_CHANNEL_FRONT }, // SCE1 = FC,
+  { TYPE_CPE, 0, AAC_CHANNEL_FRONT }, // CPE1 = FLc and FRc,
+  { TYPE_CPE, 1, AAC_CHANNEL_FRONT }, // CPE2 = FL and FR,
+  { TYPE_CPE, 2, AAC_CHANNEL_SIDE  }, // CPE3 = SiL and SiR,
+  { TYPE_CPE, 3, AAC_CHANNEL_BACK  }, // CPE4 = BL and BR,
+  { TYPE_SCE, 1, AAC_CHANNEL_BACK  }, // SCE2 = BC,
+  { TYPE_LFE, 0, AAC_CHANNEL_LFE   }, // LFE1 = LFE1,
+  { TYPE_LFE, 1, AAC_CHANNEL_LFE   }, // LFE2 = LFE2,
+  { TYPE_SCE, 2, AAC_CHANNEL_FRONT }, // SCE3 = TpFC,
+  { TYPE_CPE, 4, AAC_CHANNEL_FRONT }, // CPE5 = TpFL and TpFR,
+  { TYPE_CPE, 5, AAC_CHANNEL_SIDE  }, // CPE6 = TpSiL and TpSiR,
+  { TYPE_SCE, 3, AAC_CHANNEL_FRONT }, // SCE4 = TpC,
+  { TYPE_CPE, 6, AAC_CHANNEL_BACK  }, // CPE7 = TpBL and TpBR,
+  { TYPE_SCE, 4, AAC_CHANNEL_BACK  }, // SCE5 = TpBC,
+  { TYPE_SCE, 5, AAC_CHANNEL_FRONT }, // SCE6 = BtFC,
+  { TYPE_CPE, 7, AAC_CHANNEL_FRONT }, // CPE8 = BtFL and BtFR
+},
 { { 0, } },
 /* TODO: Add 7+1 TOP configuration */
 };
@@ -67,6 +85,7 @@ static const uint64_t aac_channel_layout[16] = {
 0,
 AV_CH_LAYOUT_6POINT1,
 AV_CH_LAYOUT_7POINT1,
+AV_CH_LAYOUT_22POINT2,
 0,
 /* AV_CH_LAYOUT_7POINT1_TOP, */
 };
-- 
2.26.2

___
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 0/5 v2] 22.2 channel layout support for AAC decoding

2020-07-29 Thread Jan Ekström
Now that we actually have sample(s) for channel_config 13, it was possible
to see at which various points the AAC decoder fails attempting to parse
the bit stream.

As the feature `-request_channel_layout 9223372036854775808` 
(AV_CH_LAYOUT_NATIVE)
seems to work, the channel order has been validated both visually with
Audacity, as well as by logging the post-reorder element ordering:

(what specific CPE/SCE/LFE elements mean is documented in the
`avcodec/aacdectab: add mapping for 22.2` commit):

Setting layout map list after reorder...
tag 0 = { pos: (null) (3), syn_elem: CPE, elem_id: 1 }
tag 1 = { pos: FC (4), syn_elem: SCE, elem_id: 0 }
tag 2 = { pos: LFE (8), syn_elem: LFE, elem_id: 0 }
tag 3 = { pos: (null) (30), syn_elem: CPE, elem_id: 3 }
tag 4 = { pos: (null) (c0), syn_elem: CPE, elem_id: 0 }
tag 5 = { pos: BC (100), syn_elem: SCE, elem_id: 1 }
tag 6 = { pos: LFE2 (8), syn_elem: LFE, elem_id: 1 }
tag 7 = { pos: (null) (600), syn_elem: CPE, elem_id: 2 }
tag 8 = { pos: (null) (5000), syn_elem: CPE, elem_id: 4 }
tag 9 = { pos: TFC (2000), syn_elem: SCE, elem_id: 2 }
tag 10 = { pos: TC (800), syn_elem: SCE, elem_id: 3 }
tag 11 = { pos: (null) (28000), syn_elem: CPE, elem_id: 6 }
tag 12 = { pos: (null) (30), syn_elem: CPE, elem_id: 5 }
tag 13 = { pos: TBC (1), syn_elem: SCE, elem_id: 4 }
tag 14 = { pos: BFC (80), syn_elem: SCE, elem_id: 5 }
tag 15 = { pos: (null) (140), syn_elem: CPE, elem_id: 7 }

swresample seems to give out the correct channels for 5.1 and stereo
downmix (checked with ffmpeg.c by utilizing `-channel_layout` 5.1 and stereo),
although the default downmix logic seems to lower the volume somewhat.

Fixes #8714

Jan Ekström (5):
  avutil/channel_layout: add 22.2 layout
  avcodec/mpeg4audio: add newer channel_coding mappings
  avcodec/aacdectab: add mapping for 22.2
  avcodec/aacdec_template: mark second LFE element as LFE2
  avcodec/aacdec_template: add support for 22.2 / channel_config 13

 doc/APIchanges   |  5 ++
 libavcodec/aacdec_template.c | 98 
 libavcodec/aacdectab.h   | 23 -
 libavcodec/mpeg4audio.c  | 17 ++-
 libavcodec/mpeg4audio.h  |  2 +-
 libavutil/channel_layout.c   |  6 +++
 libavutil/channel_layout.h   |  6 +++
 libavutil/version.h  |  2 +-
 8 files changed, 142 insertions(+), 17 deletions(-)

-- 
2.26.2

___
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/5] avcodec/aacdec_template: add support for 22.2 / channel_config 13

2020-07-29 Thread Jan Ekström
---
 libavcodec/aacdec_template.c | 89 +++-
 1 file changed, 78 insertions(+), 11 deletions(-)

diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index 21db12fdab..8c5048cc13 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -387,17 +387,77 @@ static uint64_t sniff_channel_order(uint8_t 
(*layout_map)[3], int tags)
 i++;
 }
 
-// Must choose a stable sort
+// The previous checks would end up at 8 at this point for 22.2
+if (tags == 16 && i == 8) {
+e2c_vec[i] = (struct elem_to_channel) {
+.av_position  = AV_CH_TOP_FRONT_CENTER,
+.syn_ele  = layout_map[i][0],
+.elem_id  = layout_map[i][1],
+.aac_position = layout_map[i][2]
+}; i++;
+i += assign_pair(e2c_vec, layout_map, i,
+ AV_CH_TOP_FRONT_LEFT,
+ AV_CH_TOP_FRONT_RIGHT,
+ AAC_CHANNEL_FRONT);
+i += assign_pair(e2c_vec, layout_map, i,
+ AV_CH_TOP_SIDE_LEFT,
+ AV_CH_TOP_SIDE_RIGHT,
+ AAC_CHANNEL_SIDE);
+e2c_vec[i] = (struct elem_to_channel) {
+.av_position  = AV_CH_TOP_CENTER,
+.syn_ele  = layout_map[i][0],
+.elem_id  = layout_map[i][1],
+.aac_position = layout_map[i][2]
+}; i++;
+i += assign_pair(e2c_vec, layout_map, i,
+ AV_CH_TOP_BACK_LEFT,
+ AV_CH_TOP_BACK_RIGHT,
+ AAC_CHANNEL_BACK);
+e2c_vec[i] = (struct elem_to_channel) {
+.av_position  = AV_CH_TOP_BACK_CENTER,
+.syn_ele  = layout_map[i][0],
+.elem_id  = layout_map[i][1],
+.aac_position = layout_map[i][2]
+}; i++;
+e2c_vec[i] = (struct elem_to_channel) {
+.av_position  = AV_CH_BOTTOM_FRONT_CENTER,
+.syn_ele  = layout_map[i][0],
+.elem_id  = layout_map[i][1],
+.aac_position = layout_map[i][2]
+}; i++;
+i += assign_pair(e2c_vec, layout_map, i,
+ AV_CH_BOTTOM_FRONT_LEFT,
+ AV_CH_BOTTOM_FRONT_RIGHT,
+ AAC_CHANNEL_FRONT);
+}
+
 total_non_cc_elements = n = i;
-do {
-int next_n = 0;
-for (i = 1; i < n; i++)
-if (e2c_vec[i - 1].av_position > e2c_vec[i].av_position) {
-FFSWAP(struct elem_to_channel, e2c_vec[i - 1], e2c_vec[i]);
-next_n = i;
-}
-n = next_n;
-} while (n > 0);
+
+if (tags == 16 && total_non_cc_elements == 16) {
+// For 22.2 reorder the result as needed
+FFSWAP(struct elem_to_channel, e2c_vec[2], e2c_vec[0]);   // FL & FR 
first (final), FC third
+FFSWAP(struct elem_to_channel, e2c_vec[2], e2c_vec[1]);   // FC second 
(final), FLc & FRc third
+FFSWAP(struct elem_to_channel, e2c_vec[6], e2c_vec[2]);   // LFE1 
third (final), FLc & FRc seventh
+FFSWAP(struct elem_to_channel, e2c_vec[4], e2c_vec[3]);   // BL & BR 
fourth (final), SiL & SiR fifth
+FFSWAP(struct elem_to_channel, e2c_vec[6], e2c_vec[4]);   // FLc & FRc 
fifth (final), SiL & SiR seventh
+FFSWAP(struct elem_to_channel, e2c_vec[7], e2c_vec[6]);   // LFE2 
seventh (final), SiL & SiR eight (final)
+FFSWAP(struct elem_to_channel, e2c_vec[9], e2c_vec[8]);   // TpFL & 
TpFR ninth (final), TFC tenth (final)
+FFSWAP(struct elem_to_channel, e2c_vec[11], e2c_vec[10]); // TC 
eleventh (final), TpSiL & TpSiR twelth
+FFSWAP(struct elem_to_channel, e2c_vec[12], e2c_vec[11]); // TpBL & 
TpBR twelth (final), TpSiL & TpSiR thirteenth (final)
+} else {
+// For everything else, utilize the AV channel position define as a
+// stable sort.
+do {
+int next_n = 0;
+for (i = 1; i < n; i++)
+if (e2c_vec[i - 1].av_position > e2c_vec[i].av_position) {
+FFSWAP(struct elem_to_channel, e2c_vec[i - 1], e2c_vec[i]);
+next_n = i;
+}
+n = next_n;
+} while (n > 0);
+
+}
 
 layout = 0;
 for (i = 0; i < total_non_cc_elements; i++) {
@@ -535,7 +595,7 @@ static int set_default_channel_config(AACContext *ac, 
AVCodecContext *avctx,
   int channel_config)
 {
 if (channel_config < 1 || (channel_config > 7 && channel_config < 11) ||
-channel_config > 12) {
+channel_config > 13) {
 av_log(avctx, AV_LOG_ERROR,
"invalid default channel configuration (%d)\n",
channel_config);
@@ -615,6 +675,13 @@ static ChannelElement *get_che(AACContext *ac, int type, 
int elem_id)
 /* For indexed channel configurations map the channels solely based
  * on position. *

[FFmpeg-devel] [PATCH 4/5] avcodec/aacdec_template: mark second LFE element as LFE2

2020-07-29 Thread Jan Ekström
We now have the capability to do this.
---
 libavcodec/aacdec_template.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index a473e1bad7..21db12fdab 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -368,6 +368,15 @@ static uint64_t sniff_channel_order(uint8_t 
(*layout_map)[3], int tags)
 };
 i++;
 }
+if (i < tags && layout_map[i][2] == AAC_CHANNEL_LFE) {
+e2c_vec[i] = (struct elem_to_channel) {
+.av_position  = AV_CH_LOW_FREQUENCY_2,
+.syn_ele  = TYPE_LFE,
+.elem_id  = layout_map[i][1],
+.aac_position = AAC_CHANNEL_LFE
+};
+i++;
+}
 while (i < tags && layout_map[i][2] == AAC_CHANNEL_LFE) {
 e2c_vec[i] = (struct elem_to_channel) {
 .av_position  = UINT64_MAX,
-- 
2.26.2

___
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 v2 1/2] libavcodec: add support for animated WebP decoding

2020-07-29 Thread Josef Zlomek
Fixes: 4907

Adds support for decoding of animated WebP.

The WebP parser now splits the input stream into packets containing one frame.

The WebP decoder adds the animation related features according to the specs:
https://developers.google.com/speed/webp/docs/riff_container#animation
The frames of the animation may be smaller than the image canvas.
Therefore, the frame is decoded to a temporary frame,
then it is blended into the canvas, the canvas is copied to the output frame,
and finally the frame is disposed from the canvas.

The output to AV_PIX_FMT_YUVA420P/AV_PIX_FMT_YUV420P is still supported.
The background color is specified only as BGRA in the WebP file
so it is converted to YUVA if YUV formats are output.

Signed-off-by: Josef Zlomek 
---
 Changelog|   1 +
 libavcodec/codec_desc.c  |   3 +-
 libavcodec/webp.c| 790 ---
 libavcodec/webp.h|  44 +++
 libavcodec/webp_parser.c | 128 ---
 5 files changed, 863 insertions(+), 103 deletions(-)
 create mode 100644 libavcodec/webp.h

diff --git a/Changelog b/Changelog
index c37ffa82e1..51268221a9 100644
--- a/Changelog
+++ b/Changelog
@@ -9,6 +9,7 @@ version :
 - VDPAU accelerated HEVC 10/12bit decoding
 - ADPCM IMA Ubisoft APM encoder
 - Rayman 2 APM muxer
+- animated WebP parser/decoder
 
 
 version 4.3:
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index ced00bd34c..947682f7c4 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1251,8 +1251,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .type  = AVMEDIA_TYPE_VIDEO,
 .name  = "webp",
 .long_name = NULL_IF_CONFIG_SMALL("WebP"),
-.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY |
- AV_CODEC_PROP_LOSSLESS,
+.props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS,
 .mime_types= MT("image/webp"),
 },
 {
diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index c6d0206846..43c00990ec 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -35,12 +35,15 @@
  * Exif metadata
  * ICC profile
  *
+ * @author Josef Zlomek, Pexeso Inc. 
+ * Animation
+ *
  * Unimplemented:
- *   - Animation
  *   - XMP metadata
  */
 
 #include "libavutil/imgutils.h"
+#include "libavutil/colorspace.h"
 
 #define BITSTREAM_READER_LE
 #include "avcodec.h"
@@ -50,12 +53,7 @@
 #include "internal.h"
 #include "thread.h"
 #include "vp8.h"
-
-#define VP8X_FLAG_ANIMATION 0x02
-#define VP8X_FLAG_XMP_METADATA  0x04
-#define VP8X_FLAG_EXIF_METADATA 0x08
-#define VP8X_FLAG_ALPHA 0x10
-#define VP8X_FLAG_ICC   0x20
+#include "webp.h"
 
 #define MAX_PALETTE_SIZE256
 #define MAX_CACHE_BITS  11
@@ -188,6 +186,8 @@ typedef struct ImageContext {
 typedef struct WebPContext {
 VP8Context v;   /* VP8 Context used for lossy decoding 
*/
 GetBitContext gb;   /* bitstream reader for main image 
chunk */
+ThreadFrame canvas_frame;   /* ThreadFrame for canvas */
+AVFrame *frame; /* AVFrame for decoded frame */
 AVFrame *alpha_frame;   /* AVFrame for alpha data decompressed 
from VP8L */
 AVCodecContext *avctx;  /* parent AVCodecContext */
 int initialized;/* set once the VP8 context is 
initialized */
@@ -198,9 +198,23 @@ typedef struct WebPContext {
 int alpha_data_size;/* alpha chunk data size */
 int has_exif;   /* set after an EXIF chunk has been 
processed */
 int has_iccp;   /* set after an ICCP chunk has been 
processed */
-int width;  /* image width */
-int height; /* image height */
-int lossless;   /* indicates lossless or lossy */
+int vp8x_flags; /* global flags from VP8X chunk */
+int canvas_width;   /* canvas width */
+int canvas_height;  /* canvas height */
+int anmf_flags; /* frame flags from ANMF chunk */
+int width;  /* frame width */
+int height; /* frame height */
+int pos_x;  /* frame position X */
+int pos_y;  /* frame position Y */
+int prev_anmf_flags;/* previous frame flags from ANMF 
chunk */
+int prev_width; /* previous frame width */
+int prev_height;/* previous frame height */
+int prev_pos_x; /* previous frame position X */
+int prev_pos_y; /* previous frame position Y */
+int await_progress; /* value of progress to wait for */
+uint8_t background_argb[4]; /* background color in ARGB format */
+uint

[FFmpeg-devel] [PATCH v2 2/2] libavformat: add WebP demuxer

2020-07-29 Thread Josef Zlomek
Fixes: 4907

Adds support for demuxing of animated WebP.

The WebP demuxer splits the input stream into packets containing one frame.
It also sets the timing information and marks the key frames properly.

Signed-off-by: Josef Zlomek 
---
 Changelog|   1 +
 doc/demuxers.texi|  28 +++
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/webpdec.c| 475 +++
 5 files changed, 506 insertions(+)
 create mode 100644 libavformat/webpdec.c

diff --git a/Changelog b/Changelog
index 51268221a9..f42d5f3ea6 100644
--- a/Changelog
+++ b/Changelog
@@ -10,6 +10,7 @@ version :
 - ADPCM IMA Ubisoft APM encoder
 - Rayman 2 APM muxer
 - animated WebP parser/decoder
+- animated WebP demuxer
 
 
 version 4.3:
diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 3c15ab9eee..f935c49b48 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -832,4 +832,32 @@ which in turn, acts as a ceiling for the size of scripts 
that can be read.
 Default is 1 MiB.
 @end table
 
+@section webp
+
+Animated WebP demuxer.
+
+It accepts the following options:
+
+@table @option
+@item -min_delay @var{int}
+Set the minimum valid delay between frames in milliseconds.
+Range is 0 to 6. Default value is 10.
+
+@item -max_webp_delay @var{int}
+Set the maximum valid delay between frames in milliseconds.
+Range is 0 to 16777215. Default value is 16777215 (over four hours),
+the maximum value allowed by the specification.
+
+@item -default_delay @var{int}
+Set the default delay between frames in milliseconds.
+Range is 0 to 6. Default value is 100.
+
+@item -ignore_loop @var{bool}
+WebP files can contain information to loop a certain number of times
+(or infinitely). If @option{ignore_loop} is set to true, then the loop
+setting from the input will be ignored and looping will not occur.
+If set to false, then looping will occur and will cycle the number
+of times according to the WebP. Default value is true.
+@end table
+
 @c man end DEMUXERS
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 62d8cbb54e..cf0c19edbc 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -558,6 +558,7 @@ OBJS-$(CONFIG_WEBM_MUXER)+= matroskaenc.o 
matroska.o \
 wv.o vorbiscomment.o
 OBJS-$(CONFIG_WEBM_DASH_MANIFEST_MUXER)  += webmdashenc.o
 OBJS-$(CONFIG_WEBM_CHUNK_MUXER)  += webm_chunk.o
+OBJS-$(CONFIG_WEBP_DEMUXER)  += webpdec.o
 OBJS-$(CONFIG_WEBP_MUXER)+= webpenc.o
 OBJS-$(CONFIG_WEBVTT_DEMUXER)+= webvttdec.o subtitles.o
 OBJS-$(CONFIG_WEBVTT_MUXER)  += webvttenc.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index fd9e46e233..7883cb5499 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -456,6 +456,7 @@ extern AVOutputFormat ff_webm_muxer;
 extern AVInputFormat  ff_webm_dash_manifest_demuxer;
 extern AVOutputFormat ff_webm_dash_manifest_muxer;
 extern AVOutputFormat ff_webm_chunk_muxer;
+extern AVInputFormat  ff_webp_demuxer;
 extern AVOutputFormat ff_webp_muxer;
 extern AVInputFormat  ff_webvtt_demuxer;
 extern AVOutputFormat ff_webvtt_muxer;
diff --git a/libavformat/webpdec.c b/libavformat/webpdec.c
new file mode 100644
index 00..070aafdd19
--- /dev/null
+++ b/libavformat/webpdec.c
@@ -0,0 +1,475 @@
+/*
+ * WebP demuxer
+ * Copyright (c) 2020 Pexeso Inc.
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * WebP demuxer.
+ */
+
+#include "avformat.h"
+#include "avio_internal.h"
+#include "internal.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/opt.h"
+#include "libavcodec/webp.h"
+
+typedef struct WebPDemuxContext {
+const AVClass *class;
+/**
+ * Time span in milliseconds before the next frame
+ * should be drawn on screen.
+ */
+int delay;
+/**
+ * Minimum allowed delay between frames in milliseconds.
+ * Values below this threshold are considered to be invalid
+ * and set to value of default_delay.
+ */
+int min_delay;
+int max_delay;
+int default_delay;
+
+/*
+ * loop options
+ */
+int ignore_loop;///< ignore loop setting
+int num_loop;  

[FFmpeg-devel] [PATCH 2/5] avcodec/mpeg4audio: add newer channel_coding mappings

2020-07-29 Thread Jan Ekström
Additionally, add comments regarding their definitions. Based on
ARIB STD-B32, which bases on 14496-3:2009 and 14496-3:2009/AMD4.
---
 libavcodec/mpeg4audio.c | 17 +++--
 libavcodec/mpeg4audio.h |  2 +-
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mpeg4audio.c b/libavcodec/mpeg4audio.c
index 0d83fb8d25..77cf2fb61c 100644
--- a/libavcodec/mpeg4audio.c
+++ b/libavcodec/mpeg4audio.c
@@ -64,8 +64,21 @@ const int avpriv_mpeg4audio_sample_rates[16] = {
 24000, 22050, 16000, 12000, 11025, 8000, 7350
 };
 
-const uint8_t ff_mpeg4audio_channels[8] = {
-0, 1, 2, 3, 4, 5, 6, 8
+const uint8_t ff_mpeg4audio_channels[14] = {
+0,
+1, // mono (1/0)
+2, // stereo (2/0)
+3, // 3/0
+4, // 3/1
+5, // 3/2
+6, // 3/2.1
+8, // 5/2.1
+0,
+0,
+0,
+7, // 3/3.1
+8, // 3/2/2.1
+24 // 3/3/3 - 5/2/3 - 3/0/0.2
 };
 
 static inline int get_object_type(GetBitContext *gb)
diff --git a/libavcodec/mpeg4audio.h b/libavcodec/mpeg4audio.h
index 4b390e0f42..c4cdc1508c 100644
--- a/libavcodec/mpeg4audio.h
+++ b/libavcodec/mpeg4audio.h
@@ -46,7 +46,7 @@ typedef struct MPEG4AudioConfig {
 } MPEG4AudioConfig;
 
 extern av_export_avcodec const int avpriv_mpeg4audio_sample_rates[16];
-extern const uint8_t ff_mpeg4audio_channels[8];
+extern const uint8_t ff_mpeg4audio_channels[14];
 
 /**
  * Parse MPEG-4 systems extradata from a potentially unaligned GetBitContext 
to retrieve audio configuration.
-- 
2.26.2

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

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

[FFmpeg-devel] [PATCH] avformat/apm: fix APM_FILE_HEADER_SIZE value

2020-07-29 Thread Zane van Iperen
Value was incorrectly changed in 3bf1be210150b435c51c7c8eb8fd05a1fca08814.

Signed-off-by: Zane van Iperen 
---
 libavformat/apm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/apm.c b/libavformat/apm.c
index 4c5844c83e..38a0f6382a 100644
--- a/libavformat/apm.c
+++ b/libavformat/apm.c
@@ -26,7 +26,7 @@
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
 
-#define APM_FILE_HEADER_SIZE18
+#define APM_FILE_HEADER_SIZE20
 #define APM_FILE_EXTRADATA_SIZE 80
 #define APM_EXTRADATA_SIZE  28
 
@@ -287,7 +287,7 @@ static int apm_write_trailer(AVFormatContext *s)
 int64_t file_size, data_size;
 
 file_size = avio_tell(s->pb);
-data_size = file_size - (APM_FILE_HEADER_SIZE + 2 + 
APM_FILE_EXTRADATA_SIZE);
+data_size = file_size - (APM_FILE_HEADER_SIZE + APM_FILE_EXTRADATA_SIZE);
 
 if (file_size >= UINT32_MAX) {
 av_log(s, AV_LOG_ERROR,
-- 
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] avformat/apm: fix APM_FILE_HEADER_SIZE value

2020-07-29 Thread Zane van Iperen
On Wed, 29 Jul 2020 12:14:40 +
"Zane van Iperen"  wrote:

> 
> Value was incorrectly changed in
> 3bf1be210150b435c51c7c8eb8fd05a1fca08814.
> 

I'll apply this tomorrow if no objections.

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

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

Re: [FFmpeg-devel] [PATCH v3 1/2] avformat/url: fix logic for removing ".." path components

2020-07-29 Thread Nicolas George
Zlomek, Josef (12020-07-29):
> I also noticed that there are many more bugs in ff_make_absolute_url()
> I just fixed one of them.
> I am looking forward for your complete fix.

I think the key to a working version is to properly parse URLs first.
Then we can parse the base and relative part, and build the absolute URL
from the components, simplifying the path component, and only the path
component, at the same time.

Here is my preliminary code for parsing, in case somebody wants to look
at it.

Next step is to use it for rewriting ff_make_absolute_url(). Possibly,
use it for av_url_split() too.

Regards,

-- 
  Nicolas George
From 6e874f86d3ab3c8b69a12d118cce0a10333848dc Mon Sep 17 00:00:00 2001
From: Nicolas George 
Date: Wed, 29 Jul 2020 14:39:20 +0200
Subject: [PATCH] lavf/url: add ff_url_decompose().

Signed-off-by: Nicolas George 
---
 libavformat/tests/url.c | 33 
 libavformat/url.c   | 69 +
 libavformat/url.h   | 37 ++
 tests/ref/fate/url  | 45 +++
 4 files changed, 184 insertions(+)

diff --git a/libavformat/tests/url.c b/libavformat/tests/url.c
index 1d961a1b43..1b69b4cea8 100644
--- a/libavformat/tests/url.c
+++ b/libavformat/tests/url.c
@@ -21,6 +21,31 @@
 #include "libavformat/url.h"
 #include "libavformat/avformat.h"
 
+static void test_decompose(const char *url)
+{
+URLComponents uc;
+int len, ret;
+
+printf("%s =>\n", url);
+ret = ff_url_decompose(&uc, url, NULL);
+if (ret < 0) {
+printf("  error: %s\n", av_err2str(ret));
+return;
+}
+#define PRINT_COMPONENT(comp) \
+len = uc.url_component_end_##comp - uc.comp; \
+if (len) printf("  "#comp": %.*s\n", len, uc.comp);
+PRINT_COMPONENT(scheme);
+PRINT_COMPONENT(authority);
+PRINT_COMPONENT(userinfo);
+PRINT_COMPONENT(host);
+PRINT_COMPONENT(port);
+PRINT_COMPONENT(path);
+PRINT_COMPONENT(query);
+PRINT_COMPONENT(fragment);
+printf("\n");
+}
+
 static void test(const char *base, const char *rel)
 {
 char buf[200], buf2[200];
@@ -51,6 +76,14 @@ static void test2(const char *url)
 
 int main(void)
 {
+printf("Testing ff_url_decompose:\n\n");
+test_decompose("http://user:pass@ffmpeg:8080/dir/file?query#fragment";);
+test_decompose("http://ffmpeg/dir/file";);
+test_decompose("file:///dev/null");
+test_decompose("file:/dev/null");
+test_decompose("http://[::1]/dev/null";);
+test_decompose("http://[::1]:8080/dev/null";);
+test_decompose("//ffmpeg/dev/null");
 printf("Testing ff_make_absolute_url:\n");
 test(NULL, "baz");
 test("/foo/bar", "baz");
diff --git a/libavformat/url.c b/libavformat/url.c
index 20463a6674..7612a2ee6e 100644
--- a/libavformat/url.c
+++ b/libavformat/url.c
@@ -78,6 +78,75 @@ int ff_url_join(char *str, int size, const char *proto,
 return strlen(str);
 }
 
+static const char *find_delim(const char *delim, const char *cur, const char *end)
+{
+while (cur < end && !strchr(delim, *cur))
+cur++;
+return cur;
+}
+
+int ff_url_decompose(URLComponents *uc, const char *url, const char *end)
+{
+const char *cur, *aend, *p;
+
+if (!end)
+end = url + strlen(url);
+cur = uc->url = url;
+
+/* scheme */
+uc->scheme = cur;
+p = find_delim(":/", cur, end); /* lavf "schemes" can contain options */
+if (*p == ':')
+cur = p + 1;
+
+/* authority */
+uc->authority = cur;
+if (end - cur >= 2 && cur[0] == '/' && cur[1] == '/') {
+cur += 2;
+aend = find_delim("/", cur, end);
+
+/* userinfo */
+uc->userinfo = cur;
+p = find_delim("@", cur, aend);
+if (*p == '@')
+cur = p + 1;
+
+/* host */
+uc->host = cur;
+if (*cur == '[') { /* hello IPv6, thanks for using colons! */
+p = find_delim("]", cur, aend);
+if (*p != ']')
+return AVERROR(EINVAL);
+if (p + 1 < aend && p[1] != ':')
+return AVERROR(EINVAL);
+cur = p + 1;
+} else {
+cur = find_delim(":", cur, aend);
+}
+
+/* port */
+uc->port = cur;
+cur = aend;
+} else {
+uc->userinfo = uc->host = uc->port = cur;
+}
+
+/* path */
+uc->path = cur;
+cur = find_delim("?#", cur, end);
+
+/* query */
+uc->query = cur;
+if (*cur == '?')
+cur = find_delim("#", cur, end);
+
+/* fragment */
+uc->fragment = cur;
+
+uc->end = end;
+return 0;
+}
+
 static void trim_double_dot_url(char *buf, const char *rel, int size)
 {
 const char *p = rel;
diff --git a/libavformat/url.h b/libavformat/url.h
index de0d30aca0..99d453b378 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -344,4 +344,41 @@ const AVClass *ff_urlcontext_child_class_iterate(void **iter);
 const URLProtocol **ffurl_get_protocols(const char *whitelist,
 

Re: [FFmpeg-devel] [PATCH] avformat/apm: fix APM_FILE_HEADER_SIZE value

2020-07-29 Thread Andreas Rheinhardt
Zane van Iperen:
> On Wed, 29 Jul 2020 12:14:40 +
> "Zane van Iperen"  wrote:
> 
>>
>> Value was incorrectly changed in
>> 3bf1be210150b435c51c7c8eb8fd05a1fca08814.
>>
> 
> I'll apply this tomorrow if no objections.
> 

The best place for such small comments is directly below the --- in the
email containing the patch. You can use the --annotate option to git
send-email for this.

- Andreas

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

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

[FFmpeg-devel] [PATCH V2 2/2] FATE/dnn: add unit test for dnn avgpool layer

2020-07-29 Thread Ting Fu
'make fate-dnn-layer-avgpool' to run the test

Signed-off-by: Ting Fu 
---
 tests/dnn/.gitignore   |   1 +
 tests/dnn/Makefile |   1 +
 tests/dnn/dnn-layer-avgpool-test.c | 202 +
 tests/fate/dnn.mak |   5 +
 4 files changed, 209 insertions(+)
 create mode 100644 tests/dnn/dnn-layer-avgpool-test.c

diff --git a/tests/dnn/.gitignore b/tests/dnn/.gitignore
index 1fcd2410b4..b847a01177 100644
--- a/tests/dnn/.gitignore
+++ b/tests/dnn/.gitignore
@@ -4,3 +4,4 @@
 /dnn-layer-pad-test
 /dnn-layer-mathbinary-test
 /dnn-layer-mathunary-test
+/dnn-layer-avgpool-test
diff --git a/tests/dnn/Makefile b/tests/dnn/Makefile
index 64591b7851..8afdfab5d3 100644
--- a/tests/dnn/Makefile
+++ b/tests/dnn/Makefile
@@ -4,6 +4,7 @@ DNNTESTPROGS += dnn-layer-depth2space
 DNNTESTPROGS += dnn-layer-mathbinary
 DNNTESTPROGS += dnn-layer-maximum
 DNNTESTPROGS += dnn-layer-mathunary
+DNNTESTPROGS += dnn-layer-avgpool
 
 DNNTESTOBJS  := $(DNNTESTOBJS:%=$(DNNTESTSDIR)%) 
$(DNNTESTPROGS:%=$(DNNTESTSDIR)/%-test.o)
 DNNTESTPROGS := $(DNNTESTPROGS:%=$(DNNTESTSDIR)/%-test$(EXESUF))
diff --git a/tests/dnn/dnn-layer-avgpool-test.c 
b/tests/dnn/dnn-layer-avgpool-test.c
new file mode 100644
index 00..1c47f9330d
--- /dev/null
+++ b/tests/dnn/dnn-layer-avgpool-test.c
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 2020
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include //?
+#include "libavfilter/dnn/dnn_backend_native_layer_avgpool.h"
+
+#define EPSON 0.1
+
+static int test_with_same(void)
+{
+// the input data and expected data are generated with below python code.
+/*
+import tensorflow as tf
+import numpy as np
+
+x = tf.placeholder(tf.float32, shape=[1, None, None, 3])
+y = tf.layers.average_pooling2d(x, pool_size=[2,2], strides=[1,1], 
padding='VALID')
+data = np.random.rand(1, 5, 6, 3);
+
+sess=tf.Session()
+sess.run(tf.global_variables_initializer())
+
+output = sess.run(y, feed_dict={x: data})
+
+print("input:")
+print(data.shape)
+print(list(data.flatten()))
+
+print("output:")
+print(output.shape)
+print(list(output.flatten()))
+*/
+
+AvgPoolParams params;
+DnnOperand operands[2];
+int32_t input_indexes[1];
+float input[1*5*6*3] = {
+0.7461309859908424, 0.7567538372797069, 0.07662743569678687, 
0.8882112610336333, 0.9720443314026668, 0.3337200343220823, 0.4421032129780248,
+0.14940809044964876, 0.6773177061961277, 0.9778844630669781, 
0.6522650522626998, 0.0317651530878591, 0.31259897552911364, 0.6235936821891896,
+0.40016094349542775, 0.4599222930032276, 0.7893807222960093, 
0.8475986363538283, 0.5058802717647394, 0.7827005363222633, 0.3032188123727916,
+0.8983728631302361, 0.20622408444965523, 0.22966072303869878, 
0.09535751273161308, 0.8760709100995375, 0.9982324154558745, 0.7904595468621013,
+0.13883671508879347, 0.9332751439533138, 0.0010861680752152214, 
0.3607210449251048, 0.6600652759586171, 0.7629572058138805, 0.29441975810476106,
+0.2683471432889405, 0.22574580829831536, 0.8893251976212904, 
0.3907737043801005, 0.6421829842863968, 0.6670373870457297, 0.9383850793160277,
+0.4120458907436003, 0.3589847212711481, 0.48047736550128983, 
0.6428192648418949, 0.0313661686292348, 0.429357100401472, 0.5123413386514056,
+0.8492446404097114, 0.9045286128486804, 0.8123708563814285, 
0.3943245008451698, 0.9576713003177785, 0.5985610965938726, 0.9350833279543561,
+0.8010079897491659, 0.45882114217642866, 0.35275037908941487, 
0.4555844661432271, 0.12352455940255314, 0.37801756635035544, 
0.2824056214573083,
+0.6229462823245029, 0.7235305681391472, 0.5408259266122064, 
0.12142224381781208, 0.34431198802873686, 0.7112823816321276, 
0.6307144385115417,
+0.8136734589018082, 0.842095618140585, 0.8602767724004784, 
0.6649236853766185, 0.5184782829419623, 0.9119607270982825, 0.3084111974561645,
+0.39460705638161364, 0.17710447526170836, 0.1715485945814199, 
0.17277563576521882, 0.40188232428735704, 0.22847985411491878, 
0.4135361701550696,
+0.24621846601980057, 0.6576588108454774, 0.6063336087333997, 
0.6452342242996931, 0.7071689702737508, 0.1973416063

[FFmpeg-devel] [PATCH V2 1/2] dnn/native: add native support for avg_pool

2020-07-29 Thread Ting Fu
Not support pooling strides in channel dimension now.
It can be tested with the model generated with below python script:

import tensorflow as tf
import numpy as np
import imageio

in_img = imageio.imread('input_odd.jpg')
in_img = in_img.astype(np.float32)/255.0
in_data = in_img[np.newaxis, :]

x = tf.placeholder(tf.float32, shape=[1, None, None, 3], name='dnn_in')
x_pool = tf.nn.avg_pool(x, ksize=[1,2,2,1], strides=[1,2,2,1], padding='SAME') 
#please alter the params as needed
y = tf.identity(x_pool, name='dnn_out')

sess=tf.Session()
sess.run(tf.global_variables_initializer())

graph_def = tf.graph_util.convert_variables_to_constants(sess, sess.graph_def, 
['dnn_out'])
tf.train.write_graph(graph_def, '.', 'image_process.pb', as_text=False)

print("image_process.pb generated, please use \
path_to_ffmpeg/tools/python/convert.py to generate image_process.model\n")

output = sess.run(y, feed_dict={x: in_data})
imageio.imsave("out.jpg", np.squeeze(output))

Signed-off-by: Ting Fu 
---
 libavfilter/dnn/Makefile  |   1 +
 libavfilter/dnn/dnn_backend_native.h  |   2 +
 .../dnn/dnn_backend_native_layer_avgpool.c| 147 ++
 .../dnn/dnn_backend_native_layer_avgpool.h|  35 +
 .../dnn/dnn_backend_native_layer_conv2d.h |   3 +-
 libavfilter/dnn/dnn_backend_native_layers.c   |   2 +
 tools/python/convert_from_tensorflow.py   |  35 -
 7 files changed, 222 insertions(+), 3 deletions(-)
 create mode 100644 libavfilter/dnn/dnn_backend_native_layer_avgpool.c
 create mode 100644 libavfilter/dnn/dnn_backend_native_layer_avgpool.h

diff --git a/libavfilter/dnn/Makefile b/libavfilter/dnn/Makefile
index d90137ec42..e0957073ee 100644
--- a/libavfilter/dnn/Makefile
+++ b/libavfilter/dnn/Makefile
@@ -1,6 +1,7 @@
 OBJS-$(CONFIG_DNN)   += dnn/dnn_interface.o
 OBJS-$(CONFIG_DNN)   += dnn/dnn_backend_native.o
 OBJS-$(CONFIG_DNN)   += dnn/dnn_backend_native_layers.o
+OBJS-$(CONFIG_DNN)   += 
dnn/dnn_backend_native_layer_avgpool.o
 OBJS-$(CONFIG_DNN)   += 
dnn/dnn_backend_native_layer_pad.o
 OBJS-$(CONFIG_DNN)   += 
dnn/dnn_backend_native_layer_conv2d.o
 OBJS-$(CONFIG_DNN)   += 
dnn/dnn_backend_native_layer_depth2space.o
diff --git a/libavfilter/dnn/dnn_backend_native.h 
b/libavfilter/dnn/dnn_backend_native.h
index 62191ffe88..26e9a33387 100644
--- a/libavfilter/dnn/dnn_backend_native.h
+++ b/libavfilter/dnn/dnn_backend_native.h
@@ -43,10 +43,12 @@ typedef enum {
 DLT_MAXIMUM = 4,
 DLT_MATH_BINARY = 5,
 DLT_MATH_UNARY = 6,
+DLT_AVG_POOL = 7,
 DLT_COUNT
 } DNNLayerType;
 
 typedef enum {DOT_INPUT = 1, DOT_OUTPUT = 2, DOT_INTERMEDIATE = DOT_INPUT | 
DOT_OUTPUT} DNNOperandType;
+typedef enum {VALID, SAME, SAME_CLAMP_TO_EDGE} DNNPaddingParam;
 
 typedef struct Layer{
 DNNLayerType type;
diff --git a/libavfilter/dnn/dnn_backend_native_layer_avgpool.c 
b/libavfilter/dnn/dnn_backend_native_layer_avgpool.c
new file mode 100644
index 00..a6ebb0db8f
--- /dev/null
+++ b/libavfilter/dnn/dnn_backend_native_layer_avgpool.c
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2020
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * DNN native backend implementation.
+ */
+
+#include "libavutil/avassert.h"
+#include "dnn_backend_native_layer_avgpool.h"
+
+int dnn_load_layer_avg_pool(Layer *layer, AVIOContext *model_file_context, int 
file_size, int operands_num)
+{
+AvgPoolParams *avgpool_params;
+int dnn_size = 0;
+avgpool_params = av_malloc(sizeof(*avgpool_params));
+if(!avgpool_params)
+return 0;
+
+avgpool_params->strides = (int32_t)avio_rl32(model_file_context);
+avgpool_params->padding_method = (int32_t)avio_rl32(model_file_context);
+avgpool_params->in_channels = (int32_t)avio_rl32(model_file_context);
+avgpool_params->out_channels = (int32_t)avio_rl32(model_file_context);
+avgpool_params->kernel_size = (int32_t)avio_rl32(model_file_context);
+dnn_size += 20;
+
+if (dnn_size > file_size || avgpool_params->in_channels <= 0 ||
+avgpool_params->out_channels <= 0 || avgpool_params->kernel_size <= 0 
||
+

Re: [FFmpeg-devel] [PATCH 0/5 v2] 22.2 channel layout support for AAC decoding

2020-07-29 Thread Lynne
Jul 29, 2020, 13:39 by jee...@gmail.com:

> Now that we actually have sample(s) for channel_config 13, it was possible
> to see at which various points the AAC decoder fails attempting to parse
> the bit stream.
>
> As the feature `-request_channel_layout 9223372036854775808` 
> (AV_CH_LAYOUT_NATIVE)
> seems to work, the channel order has been validated both visually with
> Audacity, as well as by logging the post-reorder element ordering:
>
> (what specific CPE/SCE/LFE elements mean is documented in the
> `avcodec/aacdectab: add mapping for 22.2` commit):
>
> Setting layout map list after reorder...
> tag 0 = { pos: (null) (3), syn_elem: CPE, elem_id: 1 }
> tag 1 = { pos: FC (4), syn_elem: SCE, elem_id: 0 }
> tag 2 = { pos: LFE (8), syn_elem: LFE, elem_id: 0 }
> tag 3 = { pos: (null) (30), syn_elem: CPE, elem_id: 3 }
> tag 4 = { pos: (null) (c0), syn_elem: CPE, elem_id: 0 }
> tag 5 = { pos: BC (100), syn_elem: SCE, elem_id: 1 }
> tag 6 = { pos: LFE2 (8), syn_elem: LFE, elem_id: 1 }
> tag 7 = { pos: (null) (600), syn_elem: CPE, elem_id: 2 }
> tag 8 = { pos: (null) (5000), syn_elem: CPE, elem_id: 4 }
> tag 9 = { pos: TFC (2000), syn_elem: SCE, elem_id: 2 }
> tag 10 = { pos: TC (800), syn_elem: SCE, elem_id: 3 }
> tag 11 = { pos: (null) (28000), syn_elem: CPE, elem_id: 6 }
> tag 12 = { pos: (null) (30), syn_elem: CPE, elem_id: 5 }
> tag 13 = { pos: TBC (1), syn_elem: SCE, elem_id: 4 }
> tag 14 = { pos: BFC (80), syn_elem: SCE, elem_id: 5 }
> tag 15 = { pos: (null) (140), syn_elem: CPE, elem_id: 7 }
>
> swresample seems to give out the correct channels for 5.1 and stereo
> downmix (checked with ffmpeg.c by utilizing `-channel_layout` 5.1 and stereo),
> although the default downmix logic seems to lower the volume somewhat.
>
> Fixes #8714
>
> Jan Ekström (5):
>  avutil/channel_layout: add 22.2 layout
>  avcodec/mpeg4audio: add newer channel_coding mappings
>  avcodec/aacdectab: add mapping for 22.2
>  avcodec/aacdec_template: mark second LFE element as LFE2
>  avcodec/aacdec_template: add support for 22.2 / channel_config 13
>
>  doc/APIchanges   |  5 ++
>  libavcodec/aacdec_template.c | 98 
>  libavcodec/aacdectab.h   | 23 -
>  libavcodec/mpeg4audio.c  | 17 ++-
>  libavcodec/mpeg4audio.h  |  2 +-
>  libavutil/channel_layout.c   |  6 +++
>  libavutil/channel_layout.h   |  6 +++
>  libavutil/version.h  |  2 +-
>  8 files changed, 142 insertions(+), 17 deletions(-)
>

Patchset looks good to me.
___
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] libavcodec/pgxdec Fix pix format selection error

2020-07-29 Thread gautamramk
From: Gautam Ramakrishnan 

This patch makes the pgx decoder select the correct
byte order instead of selecting big endian format for
16 bit images.
---
 libavcodec/pgxdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/pgxdec.c b/libavcodec/pgxdec.c
index 93b9f4e7a0..a72d6fe6fe 100644
--- a/libavcodec/pgxdec.c
+++ b/libavcodec/pgxdec.c
@@ -137,7 +137,7 @@ static int pgx_decode_frame(AVCodecContext *avctx, void 
*data,
 avctx->pix_fmt = AV_PIX_FMT_GRAY8;
 bpp = 8;
 } else if (depth <= 16) {
-avctx->pix_fmt = AV_PIX_FMT_GRAY16BE;
+avctx->pix_fmt = AV_PIX_FMT_GRAY16;
 bpp = 16;
 } else {
 av_log(avctx, AV_LOG_ERROR, "Maximum depth of 16 bits supported.\n");
-- 
2.17.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/j2kenc: Encoding up to 16 bits

2020-07-29 Thread gautamramk
From: Gautam Ramakrishnan 

This patch allows the JPEG2000 encoder to
encode images to up to 16 bits.
---
 libavcodec/j2kenc.c | 99 ++---
 1 file changed, 57 insertions(+), 42 deletions(-)

diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 38643c9a28..5ebc1f3a99 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -298,7 +298,7 @@ static int put_siz(Jpeg2000EncoderContext *s)
 bytestream_put_be16(&s->buf, s->ncomponents); // CSiz
 
 for (i = 0; i < s->ncomponents; i++){ // Ssiz_i XRsiz_i, YRsiz_i
-bytestream_put_byte(&s->buf, 7);
+bytestream_put_byte(&s->buf, s->cbps[i] - 1);
 bytestream_put_byte(&s->buf, i?1buf, i?1numXtiles * s->numYtiles; tileno++){
-Jpeg2000Tile *tile = s->tile + tileno;
-if (s->planar){
-for (compno = 0; compno < s->ncomponents; compno++){
-Jpeg2000Component *comp = tile->comp + compno;
-int *dst = comp->i_data;
-line = s->picture->data[compno]
-   + comp->coord[1][0] * s->picture->linesize[compno]
-   + comp->coord[0][0];
-for (y = comp->coord[1][0]; y < comp->coord[1][1]; y++){
-uint8_t *ptr = line;
-for (x = comp->coord[0][0]; x < comp->coord[0][1]; x++)
-*dst++ = *ptr++ - (1 << 7);
-line += s->picture->linesize[compno];
-}
-}
-} else{
-line = s->picture->data[0] + tile->comp[0].coord[1][0] * 
s->picture->linesize[0]
-   + tile->comp[0].coord[0][0] * s->ncomponents;
-
-i = 0;
-for (y = tile->comp[0].coord[1][0]; y < tile->comp[0].coord[1][1]; 
y++){
-uint8_t *ptr = line;
-for (x = tile->comp[0].coord[0][0]; x < 
tile->comp[0].coord[0][1]; x++, i++){
-for (compno = 0; compno < s->ncomponents; compno++){
-tile->comp[compno].i_data[i] = *ptr++  - (1 << 7);
-}
-}
-line += s->picture->linesize[0];
-}
-}
+#define COPY_FRAME(D, PIXEL)   
 \
+static void copy_frame_ ##D(Jpeg2000EncoderContext *s) 
 \
+{  
 \
+int tileno, compno, i, y, x;   
 \
+PIXEL *line;   
 \
+for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++){  
 \
+Jpeg2000Tile *tile = s->tile + tileno; 
 \
+if (s->planar){
 \
+for (compno = 0; compno < s->ncomponents; compno++){   
 \
+Jpeg2000Component *comp = tile->comp + compno; 
 \
+int *dst = comp->i_data;   
 \
+int cbps = s->cbps[compno];
 \
+line = (PIXEL*)s->picture->data[compno]
 \
+   + comp->coord[1][0] * (s->picture->linesize[compno] 
/ sizeof(PIXEL)) \
+   + comp->coord[0][0];
 \
+for (y = comp->coord[1][0]; y < comp->coord[1][1]; y++){   
 \
+PIXEL *ptr = line; 
 \
+for (x = comp->coord[0][0]; x < comp->coord[0][1]; 
x++) \
+*dst++ = *ptr++ - (1 << (cbps - 1));   
 \
+line += s->picture->linesize[com

Re: [FFmpeg-devel] [PATCH v2 1/2] libavcodec: add support for animated WebP decoding

2020-07-29 Thread Zlomek, Josef
On Wed, Jul 29, 2020 at 5:43 PM Lynne  wrote:

> Jul 29, 2020, 14:05 by jo...@pex.com:
>
> > +if (canvas->format == AV_PIX_FMT_ARGB) {
> > +height = canvas->height;
> > +memset(canvas->data[0], 0, height * canvas->linesize[0]);
> >
>
> At least some of those image-wide memsets can be replaced with
> av_image_fill_black.
>

For the canvas, the transparent black is needed (alpha = 0),
av_image_fill_black sets alpha = 255.
The background color has to be blended in the end when generating the
output frame,
otherwise one example file would not be decoded correctly.

> +// divide by 255 and round to nearest
> > +// apply a fast variant: (X+127)/255 = ((X+127)*257+257)>>16 =
> ((X+128)*257)>>16
> > +#define FAST_DIV255(x) x) + 128) * 257) >> 16)
> >
>
> If you don't need nearest rounding a div would likely be faster,
> especially at this range.
>

I did not expect that div by 255 was fast. I'll do some benchmarks.
I took this macro from libavcodec/pngdec.c

Thank you also for  the rest of suggestions, I'll implement them.

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

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

Re: [FFmpeg-devel] [PATCH] tests/imgutils: test the output of av_image_fill_* functions

2020-07-29 Thread James Almer
On 7/27/2020 5:03 PM, James Almer wrote:
> Signed-off-by: James Almer 
> ---
> Should prevent regressions like the one fixed in 5ce47d0aad
>  libavutil/tests/imgutils.c |  38 
>  tests/ref/fate/imgutils| 183 +
>  2 files changed, 221 insertions(+)

Will apply soon.
___
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] Create and populate AVStream side data packet with contents of ISOBMFF edit list entries

2020-07-29 Thread Matthew Szatmary
Create and populate AVStream side data packet with contents of ISOBMFF
edit list entries

Signed-off-by: Matthew Szatmary 
---
 Changelog   |  1 +
 libavcodec/packet.h | 14 ++
 libavformat/mov.c   | 17 -
 3 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index c37ffa82e1..2d719dd3b1 100644
--- a/Changelog
+++ b/Changelog
@@ -9,6 +9,7 @@ version :
 - VDPAU accelerated HEVC 10/12bit decoding
 - ADPCM IMA Ubisoft APM encoder
 - Rayman 2 APM muxer
+- AV_PKT_DATA_EDIT_LIST added to AVStream side_data


 version 4.3:
diff --git a/libavcodec/packet.h b/libavcodec/packet.h
index 0a19a0eff3..5faa594cf5 100644
--- a/libavcodec/packet.h
+++ b/libavcodec/packet.h
@@ -290,6 +290,20 @@ enum AVPacketSideDataType {
  */
 AV_PKT_DATA_S12M_TIMECODE,

+/**
+ * ISO media file edit list side data packet
+ * The structure is repeated for each entry in the edit list
+ * The number of entries can be calculated
+ * by dividing the packet size by the entry size
+ * Each entry is 20 bytes and is laid out as follows:
+ * @code
+ * s64le duration
+ * s64le time
+ * float32le rate
+ * @endcode
+ */
+AV_PKT_DATA_EDIT_LIST,
+
 /**
  * The number of side data types.
  * This is not part of the public API/ABI in the sense that it may
diff --git a/libavformat/mov.c b/libavformat/mov.c
index d16840f3df..bb2c940e80 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4317,7 +4317,6 @@ static int mov_read_trak(MOVContext *c,
AVIOContext *pb, MOVAtom atom)
 av_freep(&sc->keyframes);
 av_freep(&sc->stts_data);
 av_freep(&sc->stps_data);
-av_freep(&sc->elst_data);
 av_freep(&sc->rap_group);

 return 0;
@@ -7662,6 +7661,22 @@ static int mov_read_header(AVFormatContext *s)
 AVStream *st = s->streams[i];
 MOVStreamContext *sc = st->priv_data;

+if (sc->elst_data) {
+uint8_t *elst_data;
+elst_data = av_stream_new_side_data(st,
AV_PKT_DATA_EDIT_LIST, sc->elst_count * 20);
+
+if (!elst_data)
+goto fail;
+
+for (j = 0; j < sc->elst_count; j++) {
+AV_WB64((elst_data+(j*20)), sc->elst_data[j].duration);
+AV_WB64((elst_data+(j*20)+8), sc->elst_data[j].time);
+AV_WB32((elst_data+(j*20)+16), sc->elst_data[j].rate);
+}
+
+av_freep(&sc->elst_data);
+}
+
 switch (st->codecpar->codec_type) {
 case AVMEDIA_TYPE_AUDIO:
 err = ff_replaygain_export(st, s->metadata);
-- 
2.27.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] AVWriter again (was: v2 1/2] avformat/url: check double dot is not to parent directory)

2020-07-29 Thread Alexander Strasser
On 2020-07-28 20:43 +0800, zhilizhao wrote:
> > On Jul 28, 2020, at 8:02 PM, Nicolas George  wrote:
> >
> > zhilizhao (12020-07-28):
> >> I think jb is referring to
> >>
> >> FILE *open_memstream(char **bufp, size_t *sizep);
> >> https://linux.die.net/man/3/open_memstream 
> >> 
> >>
> >> VLC has a wrapper for it:
> >>
> >> https://code.videolan.org/videolan/vlc/-/blob/master/include/vlc_memstream.h
> >>  
> >> 
> >
> > Oh. Thanks. I had not realized such an useful function had been
> > standardized.
> >
> > That means the argument about it being in lavf is wotrhless. But these
> > two arguments:
> >
> >>> - avio_open_dyn_buf() always uses dynamic allocation. AVWriter starts
> >>> entirely on the stack (or whatever we want), and only resorts to
> >>> dynamic allocation if the buffer becomes too large. As a corollary,
> >>> avio_open_dyn_buf() requires an error check at the beginning, which
> >>> AVWriter does not.
>
> fmemopen() can work with memory on stack or on heap, although it doesn’t
> support switch between the two dynamically. It’s a good to have feature like
> the small string optimization in std::string, but i’m not too keen on it.
>
> >>>
> >>> - AVWriter is polymorphic. I have shown only av_dynbuf_writer(), but
> >>> there are others, and applications can implement their own. That is
> >>> the key to the "wonderful features" I have evoked. I would be happy to
> >>> tell more about them.
> >
> > apply to open_memstream() too.
> >
> > Please ask me about the wonderful features ;)
>
> Please, what wonderful features are in your plan?

I would say FILE * is polymorphic as well.

Maybe we are not in control to provide more implementations, the
question still would be which implementations we would want.


  Alexander
___
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] Create and populate AVStream side data packet with contents of ISOBMFF edit list entries

2020-07-29 Thread Andreas Rheinhardt
Matthew Szatmary:
> Create and populate AVStream side data packet with contents of ISOBMFF
> edit list entries
> 
> Signed-off-by: Matthew Szatmary 
> ---
>  Changelog   |  1 +
>  libavcodec/packet.h | 14 ++
>  libavformat/mov.c   | 17 -
>  3 files changed, 31 insertions(+), 1 deletion(-)
> 
> diff --git a/Changelog b/Changelog
> index c37ffa82e1..2d719dd3b1 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -9,6 +9,7 @@ version :
>  - VDPAU accelerated HEVC 10/12bit decoding
>  - ADPCM IMA Ubisoft APM encoder
>  - Rayman 2 APM muxer
> +- AV_PKT_DATA_EDIT_LIST added to AVStream side_data
> 
> 
>  version 4.3:
> diff --git a/libavcodec/packet.h b/libavcodec/packet.h
> index 0a19a0eff3..5faa594cf5 100644
> --- a/libavcodec/packet.h
> +++ b/libavcodec/packet.h
> @@ -290,6 +290,20 @@ enum AVPacketSideDataType {
>   */
>  AV_PKT_DATA_S12M_TIMECODE,
> 
> +/**
> + * ISO media file edit list side data packet
> + * The structure is repeated for each entry in the edit list
> + * The number of entries can be calculated
> + * by dividing the packet size by the entry size
> + * Each entry is 20 bytes and is laid out as follows:
> + * @code
> + * s64le duration
> + * s64le time
> + * float32le rate

You are obviously copying the MOVElst structure; yet the rate is a 16.16
fixed point number in the file and not a float, so one should probably
use this.

> + * @endcode
> + */
> +AV_PKT_DATA_EDIT_LIST,
> +
>  /**
>   * The number of side data types.
>   * This is not part of the public API/ABI in the sense that it may
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index d16840f3df..bb2c940e80 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -4317,7 +4317,6 @@ static int mov_read_trak(MOVContext *c,
> AVIOContext *pb, MOVAtom atom)
>  av_freep(&sc->keyframes);
>  av_freep(&sc->stts_data);
>  av_freep(&sc->stps_data);
> -av_freep(&sc->elst_data);

This is still needed, namely if an error happens before you can attach
the stream side-data. E.g. if an invalid edit list is found and
standards compliance is set to strict. Or if av_stream_new_side_data()
fails.

>  av_freep(&sc->rap_group);
> 
>  return 0;
> @@ -7662,6 +7661,22 @@ static int mov_read_header(AVFormatContext *s)
>  AVStream *st = s->streams[i];
>  MOVStreamContext *sc = st->priv_data;
> 
> +if (sc->elst_data) {
> +uint8_t *elst_data;
> +elst_data = av_stream_new_side_data(st,
> AV_PKT_DATA_EDIT_LIST, sc->elst_count * 20);

I wonder whether it would be advantageouos to use
av_stream_add_side_data() here.

> +
> +if (!elst_data)
> +goto fail;
> +
> +for (j = 0; j < sc->elst_count; j++) {
> +AV_WB64((elst_data+(j*20)), sc->elst_data[j].duration);
> +AV_WB64((elst_data+(j*20)+8), sc->elst_data[j].time);

"WB" stands for "Write Big-endian", yet your documentation says that it
is supposed to be little-endian.

> +AV_WB32((elst_data+(j*20)+16), sc->elst_data[j].rate);
> +}
> +
> +av_freep(&sc->elst_data);
> +}
> +
>  switch (st->codecpar->codec_type) {
>  case AVMEDIA_TYPE_AUDIO:
>  err = ff_replaygain_export(st, s->metadata);
> 

___
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] [RFC] lavc, lavfmt: add FLIF decoding support

2020-07-29 Thread Andreas Rheinhardt
Anamitra Ghorui:
> This patch implements non interlaced decoding of FLIF16 images with all
> transforms except for one, FrameLookback which is being tested.
> 
> Several test files have been attached. The above mentioned transform
> and interlaced decoding is being tested and will be implemented shortly.
> 
> The main reason of posting this patch now is to ask advice on deflate
> decompression (or inflate) on the metadata segments of the format.
> The reference decoder of the format [1] uses lodepng, and by extension,
> deflate for generating the metadata segments. Therefore these segments
> should be able to be decoded by zlib's deflate routines. However it does
> not work and returns saying that the data is invalid.
> I have tried isolating the metadata using a hex editor, and then using
> zlib's example program [2] to decode it. However it also says that it's
> invalid data.
> Can you please tell me what I am doing wrong in libavformat/flifdec.c?
> 
> [1]: https://github.com/FLIF-hub/FLIF
> [2]: https://zlib.net/zpipe.c
> 
> Co-authored-by: Anamitra Ghorui 
> Co-authored-by: Karhtik K. Khullar 
> 
> Signed-off-by: Anamitra Ghorui 
> ---

[...]

> +
> +#if 0
> +// CONFIG_ZLIB
> +static int flif_inflate(FLIFDemuxContext *s, unsigned char *buf, int 
> buf_size,
> +unsigned char *out_buf, int *out_buf_size)

I did not look thoroughly at it at all, but this is already wrong:
flif_inflate allocates out_buf and in order to return it, the parameter
must be of type unsigned char ** (or uint8_t ** (that is preferred here)).

> +{
> +int ret;
> +z_stream *stream = &s->stream;
> +
> +if (!s->active) {
> +s->active = 1;
> +stream->zalloc   = Z_NULL;
> +stream->zfree= Z_NULL;
> +stream->opaque   = Z_NULL;
> +stream->avail_in = 0;
> +stream->next_in  = Z_NULL;
> +ret   = inflateInit(stream);
> +
> +if (ret != Z_OK)
> +return ret;
> +
> +*out_buf_size = buf_size;
> +out_buf = av_realloc(out_buf, buf_size);
> +if (!out_buf)
> +return AVERROR(ENOMEM);
> +}
> +
> +stream->next_in  = buf;
> +stream->avail_in = buf_size;
> +if(stream->total_out >= *out_buf_size) {
> +out_buf = av_realloc(out_buf, (*out_buf_size) * 2);
> +if (!out_buf)
> +return AVERROR(ENOMEM);
> +*out_buf_size *= 2;
> +}
> +
> +stream->next_out  = out_buf + stream->total_out;
> +stream->avail_out = *out_buf_size - stream->total_out - 1; // Last byte 
> should be NULL char
> +
> +ret = inflate(stream, Z_PARTIAL_FLUSH);
> +
> +switch (ret) {
> +case Z_NEED_DICT:
> +case Z_DATA_ERROR:
> +(void)inflateEnd(stream);
> +return AVERROR(EINVAL);
> +case Z_MEM_ERROR:
> +(void)inflateEnd(stream);
> +return AVERROR(ENOMEM);
> +}
> +
> +if (ret == Z_STREAM_END) {
> +ret = 0;
> +s->active = 0;
> +out_buf[stream->total_out - 1] = '\0';
> +(void) inflateEnd(stream);
> +} else
> +ret = AVERROR(EAGAIN);
> +
> +return ret; // Return Z_BUF_ERROR/EAGAN as long as input is incomplete.
> +}
> +
> +#endif
> +
> +static int flif16_probe(const AVProbeData *p)
> +{
> +uint32_t vlist[3] = {0};
> +unsigned int count = 0, pos = 0;
> +
> +// Magic Number
> +if (memcmp(p->buf, flif16_header, 4)) {
> +return 0;
> +}
> +
> +for(int i = 0; i < 2 + (((p->buf[4] >> 4) > 4) ? 1 : 0); ++i) {
> +while (p->buf[5 + pos] > 127) {
> +if (!(count--)) {
> +return 0;
> +}
> +VARINT_APPEND(vlist[i], p->buf[5 + pos]);
> +++pos;
> +}
> +VARINT_APPEND(vlist[i], p->buf[5 + pos]);
> +count = 0;
> +}
> +
> +if (!((vlist[0] + 1) && (vlist[1] + 1)))
> +return 0;
> +
> +if (((p->buf[4] >> 4) > 4) && !(vlist[2] + 2))
> +return 0;
> +
> +return AVPROBE_SCORE_MAX;
> +}
> +
> +static int flif16_read_header(AVFormatContext *s)
> +{
> +// FLIFDemuxContext *dc = s->priv_data;
> +GetByteContext gb;
> +FLIF16RangeCoder rc;
> +
> +AVIOContext *pb  = s->pb;
> +AVStream*st;
> +
> +uint32_t vlist[3] = {0};
> +uint32_t flag, animated, temp;
> +uint32_t bpc = 0;
> +// uint8_t tag[5] = {0};
> +uint8_t buf[BUF_SIZE];
> +uint32_t metadata_size = 0;
> +// uint8_t *out_buf = NULL;
> +// int out_buf_size = 0;
> +
> +unsigned int count = 4;
> +int ret;
> +int format;
> +int segment = 0, i = 0;
> +int64_t duration = 0;
> +uint8_t loops = 0;
> +uint8_t num_planes;
> +uint8_t num_frames;
> +
> +// Magic Number
> +if (avio_rl32(pb) != (*((uint32_t *) flif16_header))) {
> +av_log(s, AV_LOG_ERROR, "bad magic number\n");
> +return AVERROR(EINVAL);
> +}
> +
> +st = avformat_new_stream(s, NULL);
> +flag

Re: [FFmpeg-devel] [PATCH v3 1/2] avformat/url: fix logic for removing ".." path components

2020-07-29 Thread Marton Balint



On Wed, 29 Jul 2020, Nicolas George wrote:


Zlomek, Josef (12020-07-29):

I also noticed that there are many more bugs in ff_make_absolute_url()
I just fixed one of them.
I am looking forward for your complete fix.


I think the key to a working version is to properly parse URLs first.
Then we can parse the base and relative part, and build the absolute URL
from the components, simplifying the path component, and only the path
component, at the same time.

Here is my preliminary code for parsing, in case somebody wants to look
at it.


Thanks for working on this. I agree that proper (as RFC compliant as it 
can be) URL parsing is needed here. Probably we should clearly document 
differences from RFC compliant parsing, if we cannot do it entirely RFC 
compliantly...



diff --git a/libavformat/url.c b/libavformat/url.c
index 20463a6674..7612a2ee6e 100644
--- a/libavformat/url.c
+++ b/libavformat/url.c
@@ -78,6 +78,75 @@ int ff_url_join(char *str, int size, const char *proto,
 return strlen(str);
 }

+static const char *find_delim(const char *delim, const char *cur, const char 
*end)
+{
+while (cur < end && !strchr(delim, *cur))
+cur++;
+return cur;
+}
+
+int ff_url_decompose(URLComponents *uc, const char *url, const char *end)
+{
+const char *cur, *aend, *p;
+
+if (!end)
+end = url + strlen(url);
+cur = uc->url = url;
+
+/* scheme */
+uc->scheme = cur;
+p = find_delim(":/", cur, end); /* lavf "schemes" can contain options */
+if (*p == ':')
+cur = p + 1;
+
+/* authority */
+uc->authority = cur;
+if (end - cur >= 2 && cur[0] == '/' && cur[1] == '/') {
+cur += 2;
+aend = find_delim("/", cur, end);


? and # can also separate authority from the rest.


+
+/* userinfo */
+uc->userinfo = cur;
+p = find_delim("@", cur, aend);
+if (*p == '@')
+cur = p + 1;
+
+/* host */
+uc->host = cur;
+if (*cur == '[') { /* hello IPv6, thanks for using colons! */
+p = find_delim("]", cur, aend);
+if (*p != ']')
+return AVERROR(EINVAL);
+if (p + 1 < aend && p[1] != ':')
+return AVERROR(EINVAL);
+cur = p + 1;
+} else {
+cur = find_delim(":", cur, aend);
+}
+
+/* port */
+uc->port = cur;
+cur = aend;
+} else {
+uc->userinfo = uc->host = uc->port = cur;
+}
+
+/* path */
+uc->path = cur;
+cur = find_delim("?#", cur, end);
+
+/* query */
+uc->query = cur;
+if (*cur == '?')
+cur = find_delim("#", cur, end);
+
+/* fragment */
+uc->fragment = cur;
+
+uc->end = end;
+return 0;
+}
+
 static void trim_double_dot_url(char *buf, const char *rel, int size)
 {
 const char *p = rel;
diff --git a/libavformat/url.h b/libavformat/url.h
index de0d30aca0..99d453b378 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -344,4 +344,41 @@ const AVClass *ff_urlcontext_child_class_iterate(void 
**iter);
 const URLProtocol **ffurl_get_protocols(const char *whitelist,
 const char *blacklist);

+typedef struct URLComponents {
+const char *url;/**< whole URL, for reference */
+const char *scheme; /**< possibly including lavf-specific options */
+const char *authority;  /**< "//" if it is a real URL */
+const char *userinfo;   /**< including final '@' if present */
+const char *host;
+const char *port;   /**< including initial ':' if present */
+const char *path;
+const char *query;  /**< including initial '?' if present */
+const char *fragment;   /**< including initial '#' if present */
+const char *end;
+} URLComponents;
+
+#define url_component_end_scheme  authority
+#define url_component_end_authority   userinfo
+#define url_component_end_userinfohost
+#define url_component_end_hostport
+#define url_component_end_portpath
+#define url_component_end_pathquery
+#define url_component_end_query   fragment
+#define url_component_end_fragmentend


I am not sure about this approach, the known characters at the end 
or at the start will make further operations a bit harder. I'd just 
simply add another field for each URL component to signal the end, e.g.


url
url_end
scheme
scheme_end
...

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

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

Re: [FFmpeg-devel] [PATCH 1/2] avdevice/decklink_dec: mark the field flag if framerate > 30FPS

2020-07-29 Thread Marton Balint




> > > > > if you tested with SDI with TC.
> > > > > 00:00:00:24
> > > > > 00:00:00:24
> > > > > 00:00:00:00
> > > > > 00:00:00:00


I did tests, and depending on which timecode you select, and the timecode 
formats which are available in the SDI signal, this really can be the 
case, so you were right that the decklink API usually does not provide the 
proper timecode as string, only the value of "raw" timecodes in the 
signal, regardless of used frame rate.


I could not test, but assume that if a high frame rate timecode is 
detected then valid string timecode is returned. Otherwise max 30fps 
timecode.



> I have tested with bmdTimecodeFieldMark
> flag, it's not set as expected for testing. I have no clue how to get
> the flag as the API provide the TC string is same for the frame pair.
> Maybe I miss something.


SMPTE ST 12-2 has a good overview of the used signalling in section 7. 
Basically for 50/60 fps different timecode types (VITC1, VITC2) are used 
for different parity frames.


We have to be smart here to generate proper timecode, because the decklink 
API does not tell you which timecode it had found for an rp188any query... 
I suggest the following:


- If the user selects high frame rate timecode (not available as an
  option at the moment, but can be added), then use that directly.
- If the user selects rp188any then
  - Query high frame rate timecode, if exists use that directly.
  - Otherwise
- for <= 30fps query rp188any and use that directly
- for > 30fps
  - query VITC1, if exists use that with frame doubling and field flag
checking
  - otherwise query VITC2, if exists use that with frame doubling
and field flag checking
  - otherwise query LTC, if exists use that with frame doubling and
field flag checking
  - note that this special ordering of querying the timecode types
is slightly different from what the decklink API does and it
should be mentioned in the docs.
- Otherwise
  - for <= 30fps query the selected timecode and use that directly
  - for > 30fps query the selected timecode and use that with frame
doubling and field flag checking

Also probably it is better to use IDeckLinkTimecode->GetComponents() and 
use av_timecode_get_smpte() instead of using the string value.


Regards,
Marton
___
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] libsvt_av1: remove forced-idr option

2020-07-29 Thread James Almer
On 7/29/2020 5:47 PM, Lynne wrote:
> This option is directly copy-pasted from the SVT1-HEVC wrapper and has 
> no place in the options for an AV1 encoder.
> 
> AV1 has no H.264/5 IDR frames nor anything like them.
> All this option does is change all real keyframes to an intra-only
> AV1 frame, which is not seekable. Hence, any streams encoded with
> this option enabled will not be seekable.

Can confirm it creates streams with a single key-frame at the beginning.

> 
> Having an option that breaks encoded streams this much is not what
> we'd like. If SVT-AV1 developers would like to have an open-gop
> option a patch to enable that could be added with an appropriate
> name and after a discussion, rather than slipping through reviews.

Will apply.
___
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] libavcodec/pgxdec Fix pix format selection error

2020-07-29 Thread Michael Niedermayer
On Wed, Jul 29, 2020 at 09:19:11PM +0530, gautamr...@gmail.com wrote:
> From: Gautam Ramakrishnan 
> 
> This patch makes the pgx decoder select the correct
> byte order instead of selecting big endian format for
> 16 bit images.
> ---
>  libavcodec/pgxdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

thx

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

Asymptotically faster algorithms should always be preferred if you have
asymptotical amounts of data


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] avformat/hlsenc: increase initial program date time precision

2020-07-29 Thread Marton Balint



On Tue, 28 Jul 2020, Steven Liu wrote:


Marton Balint  于2020年7月28日周二 上午4:15写道:




On Sun, 19 Jul 2020, Marton Balint wrote:

>
>
> On Sun, 19 Jul 2020, Steven Liu wrote:
>
>> Zhao Zhili  于2020年7月19日周日 下午6:26写道:
>>>
>>>
>>>
>>> > On Jul 19, 2020, at 5:20 PM, Steven Liu  wrote:
>>> >
>>> > Marton Balint  于2020年7月19日周日 上午6:04写道:
>>> >>
>>> >> Also query time only once, not for every variant stream, otherwise
> variant
>>> >> streams might get a slightly different initial program date time. And
> we can
>>> >> set this unconditionally because HLS_PROGRAM_DATE_TIME flag is checked
>>> >> elsewhere.
>>> >>
>>> >> Signed-off-by: Marton Balint 
>>> >> ---
>>> >> libavformat/hlsenc.c | 8 ++--
>>> >> 1 file changed, 2 insertions(+), 6 deletions(-)
>>> >>
>>> >> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>>> >> index df84e6487d..39ff1fa1e7 100644
>>> >> --- a/libavformat/hlsenc.c
>>> >> +++ b/libavformat/hlsenc.c
>>> >> @@ -2704,6 +2704,7 @@ static int hls_init(AVFormatContext *s)
>>> >> char *p = NULL;
>>> >> int http_base_proto = ff_is_http_proto(s->url);
>>> >> int fmp4_init_filename_len = strlen(hls->fmp4_init_filename) + 1;
>>> >> +double initial_program_date_time = av_gettime() / 100.0;
>>> > is it AV_TIME_BASE?
>>>
>>> According to the documentation of av_gettime, it's not related to
> AV_TIME_BASE.
>>>
>>> /**
>>>  * Get the current time in microseconds.
>>>  */
>>> int64_t av_gettime(void);
>> I saw
>> /**
>> * Internal time base represented as integer
>> */
>>
>> #define AV_TIME_BASE100
>> Do you mean cannot av_gettime() / AV_TIME_BASE?
>
> av_gettime() is always microsec according to docs, even if AV_TIME_BASE is
> not 100. In practice however AV_TIME_BASE is assumed to be 100 in
> a lot of places, so one can't really change it.
>
> IMHO it is cleaner to use 100.0 instead of AV_TIME_BASE, because
> AV_TIME_BASE is integer, so you'd have to use (double)AV_TIME_BASE and
> that would be ugly. So I'd rather keep 100.0.

Ping, thanks,

I have no question about it, thanks for your clarify respond, LGTM.


Thanks, applied.

Regards,
Marton
___
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] fftools/ffmpeg: make specifying thread_queue_size turn on threaded input

2020-07-29 Thread Marton Balint



On Mon, 27 Jul 2020, Marton Balint wrote:




On Sat, 18 Jul 2020, Marton Balint wrote:

Threaded input can increase smoothness of e.g. x11grab significantly. 

Before

this patch, in order to activate threaded input the user had to specify a
"dummy" additional input, with this change it is no longer required.


Ping, will apply soon.


Applied.

Regards,
Marton



Regards,
Marton



Signed-off-by: Marton Balint 
---
doc/ffmpeg.texi  | 5 +++--
fftools/ffmpeg.c | 6 --
fftools/ffmpeg_opt.c | 3 ++-
3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 70b8965d7f..267ddfe8b5 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1689,8 +1689,9 @@ not start from timestamp 0, such as transport 

streams.

@item -thread_queue_size @var{size} (@emph{input})
This option sets the maximum number of queued packets when reading from the
file or device. With low latency / high rate live streams, packets may be
-discarded if they are not read in a timely manner; raising this value can
-avoid it.
+discarded if they are not read in a timely manner; setting this value can
+force ffmpeg to use a separate input thread and read packets as soon as 

they

+arrive. By default ffmpeg only do this if multiple inputs are specified.

@item -sdp_file @var{file} (@emph{global})
Print sdp information for an output stream to @var{file}.
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 2e9448ea2b..173ac3c9a0 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -4051,7 +4051,9 @@ static int init_input_thread(int i)
int ret;
InputFile *f = input_files[i];

-if (nb_input_files == 1)
+if (f->thread_queue_size < 0)
+f->thread_queue_size = (nb_input_files > 1 ? 8 : 0);
+if (!f->thread_queue_size)
return 0;

if (f->ctx->pb ? !f->ctx->pb->seekable :
@@ -4105,7 +4107,7 @@ static int get_input_packet(InputFile *f, AVPacket 

*pkt)

}

#if HAVE_THREADS
-if (nb_input_files > 1)
+if (f->thread_queue_size)
return get_input_packet_mt(f, pkt);
#endif
return av_read_frame(f->ctx, pkt);
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 9d1489ce01..853550a142 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -228,6 +228,7 @@ static void init_options(OptionsContext *o)
o->limit_filesize = UINT64_MAX;
o->chapters_input_file = INT_MAX;
o->accurate_seek  = 1;
+o->thread_queue_size = -1;
}

static int show_hwaccels(void *optctx, const char *opt, const char *arg)
@@ -1270,7 +1271,7 @@ static int open_input_file(OptionsContext *o, const 

char *filename)

f->duration = 0;
f->time_base = (AVRational){ 1, 1 };
#if HAVE_THREADS
-f->thread_queue_size = o->thread_queue_size > 0 ? o->thread_queue_size 

: 8;

+f->thread_queue_size = o->thread_queue_size;
#endif

/* check if all codec options have been used */
--
2.26.2

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

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

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

Re: [FFmpeg-devel] [PATCH 1/2] libavcodec/j2kenc: Encoding up to 16 bits

2020-07-29 Thread Michael Niedermayer
On Wed, Jul 29, 2020 at 09:19:10PM +0530, gautamr...@gmail.com wrote:
> From: Gautam Ramakrishnan 
> 
> This patch allows the JPEG2000 encoder to
> encode images to up to 16 bits.
> ---
>  libavcodec/j2kenc.c | 99 ++---
>  1 file changed, 57 insertions(+), 42 deletions(-)

will apply

thx

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

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato


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 v3 1/2] avformat/url: fix logic for removing ".." path components

2020-07-29 Thread Nicolas George
Marton Balint (12020-07-29):
> Thanks for working on this. I agree that proper (as RFC compliant as it can
> be) URL parsing is needed here. Probably we should clearly document
> differences from RFC compliant parsing, if we cannot do it entirely RFC
> compliantly...

Indeed. Unfortunately, that may cause some trouble, but not for right
now.

> ? and # can also separate authority from the rest.

Thanks, fixed.

> I am not sure about this approach, the known characters at the end or at the
> start will make further operations a bit harder. I'd just simply add another
> field for each URL component to signal the end, e.g.

I considered this, but it was not actually convenient.

I have something that works, but it needs polishing and more testing.
But you can have a peek.

Regards,

-- 
  Nicolas George
>From d6c429e879ffe3cdce0af6d22854dbbcce6c8222 Mon Sep 17 00:00:00 2001
From: Nicolas George 
Date: Thu, 30 Jul 2020 00:02:10 +0200
Subject: [PATCH] WIP lavf/url: rewrite ff_make_absolute_url().

Signed-off-by: Nicolas George 
---
 libavformat/url.c | 223 +++---
 libavformat/url.h |   4 +-
 2 files changed, 96 insertions(+), 131 deletions(-)

diff --git a/libavformat/url.c b/libavformat/url.c
index 26aaab4019..fa265e90ea 100644
--- a/libavformat/url.c
+++ b/libavformat/url.c
@@ -27,6 +27,7 @@
 #if CONFIG_NETWORK
 #include "network.h"
 #endif
+#include "libavutil/avassert.h"
 #include "libavutil/avstring.h"
 
 /**
@@ -152,146 +153,110 @@ int ff_url_decompose(URLComponents *uc, const char *url, const char *end)
 return 0;
 }
 
-static void trim_double_dot_url(char *buf, const char *rel, int size)
+static int append_path(char *root, char *out_end, char **rout,
+   const char *in, const char *in_end)
 {
-const char *p = rel;
-const char *root = rel;
-char tmp_path[MAX_URL_SIZE] = {0, };
-char *sep;
-char *node;
-
-/* Get the path root of the url which start by "://" */
-if (p && (sep = strstr(p, "://"))) {
-sep += 3;
-root = strchr(sep, '/');
-if (!root)
-return;
-}
-
-/* set new current position if the root node is changed */
-p = root;
-while (p && (node = strstr(p, ".."))) {
-av_strlcat(tmp_path, p, node - p + strlen(tmp_path));
-p = node + 3;
-sep = strrchr(tmp_path, '/');
-if (sep)
-sep[0] = '\0';
-else
-tmp_path[0] = '\0';
+char *out = *rout;
+const char *d, *next;
+
+if (in < in_end && *in == '/')
+in++; /* already taken care of */
+while (in < in_end) {
+d = find_delim("/", in, in_end);
+next = d + (d < in_end && *d == '/');
+if (d - in == 1 && in[0] == '.') {
+/* skip */
+} else if (out > root && /* "../" at the very beginning really means "../" */
+   d - in == 2 && in[0] == '.' && in[1] == '.') {
+av_assert1(out[-1] == '/');
+if (out - root > 1)
+while (out > root && (--out)[-1] != '/');
+} else {
+if (out_end - out < next - in)
+return AVERROR(ENOMEM);
+memcpy(out, in, next - in);
+out += next - in;
+}
+in = next;
 }
-
-if (!av_stristart(p, "/", NULL) && root != rel)
-av_strlcat(tmp_path, "/", size);
-
-av_strlcat(tmp_path, p, size);
-/* start set buf after temp path process. */
-av_strlcpy(buf, rel, root - rel + 1);
-
-if (!av_stristart(tmp_path, "/", NULL) && root != rel)
-av_strlcat(buf, "/", size);
-
-av_strlcat(buf, tmp_path, size);
+*rout = out;
+return 0;
 }
 
-void ff_make_absolute_url(char *buf, int size, const char *base,
+int ff_make_absolute_url(char *buf, int size, const char *base,
   const char *rel)
 {
-char *sep, *path_query;
-char *root, *p;
-char tmp_path[MAX_URL_SIZE];
-
-memset(tmp_path, 0, sizeof(tmp_path));
-/* Absolute path, relative to the current server */
-if (base && strstr(base, "://") && rel[0] == '/') {
-if (base != buf)
-av_strlcpy(buf, base, size);
-sep = strstr(buf, "://");
-if (sep) {
-/* Take scheme from base url */
-if (rel[1] == '/') {
-sep[1] = '\0';
-} else {
-/* Take scheme and host from base url */
-sep += 3;
-sep = strchr(sep, '/');
-if (sep)
-*sep = '\0';
-}
+URLComponents ub, uc;
+char *out, *out_end, *path;
+const char *keep;
+int ret;
+
+//const char *scheme; /**< possibly including lavf-specific options */
+//const char *authority;  /**< "//" if it is a real URL */
+//const char *userinfo;   /**< including final '@' if present */
+//const char *host;
+//const char *port;   /**< including initial ':' if present */
+//const char *p

[FFmpeg-devel] [PATCH] avcodec/options_table: make AVCodecContext->level search for child constants

2020-07-29 Thread James Almer
This change makes it possible for child encoders to define custom level
option names which can be used for setting the AVCodecContext->level.

Based on 337fe4bcc2

Signed-off-by: James Almer 
---
 libavcodec/options_table.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 8ba137f51e..1d0db1b5a4 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -264,8 +264,8 @@ static const AVOption avcodec_options[] = {
 {"profile", NULL, OFFSET(profile), AV_OPT_TYPE_INT, {.i64 = FF_PROFILE_UNKNOWN 
}, INT_MIN, INT_MAX, V|A|E|CC, "avctx.profile"},
 {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_UNKNOWN }, INT_MIN, 
INT_MAX, V|A|E, "avctx.profile"},
 {"main10",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_HEVC_MAIN_10 }, 
INT_MIN, INT_MAX, V|E, "avctx.profile"},
-{"level", NULL, OFFSET(level), AV_OPT_TYPE_INT, {.i64 = FF_LEVEL_UNKNOWN }, 
INT_MIN, INT_MAX, V|A|E, "level"},
-{"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LEVEL_UNKNOWN }, INT_MIN, 
INT_MAX, V|A|E, "level"},
+{"level", NULL, OFFSET(level), AV_OPT_TYPE_INT, {.i64 = FF_LEVEL_UNKNOWN }, 
INT_MIN, INT_MAX, V|A|E|CC, "avctx.level"},
+{"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LEVEL_UNKNOWN }, INT_MIN, 
INT_MAX, V|A|E, "avctx.level"},
 {"lowres", "decode at 1= 1/2, 2=1/4, 3=1/8 resolutions", OFFSET(lowres), 
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|A|D},
 #if FF_API_PRIVATE_OPT
 {"skip_threshold", "frame skip threshold", OFFSET(frame_skip_threshold), 
AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-- 
2.27.0

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

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

Re: [FFmpeg-devel] [PATCH] avformat/apm: fix APM_FILE_HEADER_SIZE value

2020-07-29 Thread Zane van Iperen
On Wed, 29 Jul 2020 15:09:28 +0200
"Andreas Rheinhardt"  wrote:

> 
> Zane van Iperen:
> > On Wed, 29 Jul 2020 12:14:40 +
> > "Zane van Iperen"  wrote:
> >
> >>
> >> Value was incorrectly changed in
> >> 3bf1be210150b435c51c7c8eb8fd05a1fca08814.
> >>
> >
> > I'll apply this tomorrow if no objections.
> >
> 
> The best place for such small comments is directly below the --- in
> the email containing the patch. You can use the --annotate option to
> git send-email for this.
> 
Huh, I actually had no idea that existed. Thanks!

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

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

Re: [FFmpeg-devel] [PATCH 0/4] [mips]: Adapt clang compiler for mips.

2020-07-29 Thread Michael Niedermayer
On Wed, Jul 29, 2020 at 06:10:57PM +0800, Shiyou Yin wrote:
> Fixed four prob encountered when compiling ffmpeg with clang on mips.
> configure: ./configure --disable-mmi  --cc=clang --cxx=clang++ --ld=clang
> 
> [PATCH 1/4] [mips]: Fix register constraint error reported by clang.
> [PATCH 2/4] [mips]: Fix prob that 'ulw' and 'uld' unsupported by clang.
> [PATCH 3/4] [mips]: Fix a bug in get_cabac_inline_mips.
> [PATCH 4/4] [mips]: Fix segfault in imdct36_mips_float.

will apply patchset

thx

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

If a bugfix only changes things apparently unrelated to the bug with no
further explanation, that is a good sign that the bugfix is wrong.


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] libsvt-av1: Consistently use - rather than _

2020-07-29 Thread Mark Thompson
Matching libaom-av1.
---
 libavcodec/libsvt_av1.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/libsvt_av1.c b/libavcodec/libsvt_av1.c
index c7ae5f9691..3229551d2b 100644
--- a/libavcodec/libsvt_av1.c
+++ b/libavcodec/libsvt_av1.c
@@ -483,7 +483,7 @@ static const AVOption options[] = {
 { "3level", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 3 },  INT_MIN, 
INT_MAX, VE, "hielevel" },
 { "4level", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 4 },  INT_MIN, 
INT_MAX, VE, "hielevel" },
 
-{ "la_depth", "Look ahead distance [0, 120]", OFFSET(la_depth),
+{ "la-depth", "Look ahead distance [0, 120]", OFFSET(la_depth),
   AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 120, VE },
 
 { "preset", "Encoding preset [0, 8]",
@@ -533,7 +533,7 @@ static const AVOption options[] = {
 { "qp", "QP value for intra frames", OFFSET(qp),
   AV_OPT_TYPE_INT, { .i64 = 50 }, 0, 63, VE },
 
-{ "sc_detection", "Scene change detection", OFFSET(scd),
+{ "sc-detection", "Scene change detection", OFFSET(scd),
   AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
 
 { "tile-columns", "Log2 of number of tile columns to use", 
OFFSET(tile_columns), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, VE},
@@ -543,7 +543,7 @@ static const AVOption options[] = {
 };
 
 static const AVClass class = {
-.class_name = "libsvt_av1",
+.class_name = "libsvt-av1",
 .item_name  = av_default_item_name,
 .option = options,
 .version= LIBAVUTIL_VERSION_INT,
@@ -558,7 +558,7 @@ static const AVCodecDefault eb_enc_defaults[] = {
 };
 
 AVCodec ff_libsvt_av1_encoder = {
-.name   = "libsvt_av1",
+.name   = "libsvt-av1",
 .long_name  = NULL_IF_CONFIG_SMALL("SVT-AV1(Scalable Video Technology 
for AV1) encoder"),
 .priv_data_size = sizeof(SvtContext),
 .type   = AVMEDIA_TYPE_VIDEO,
@@ -573,5 +573,5 @@ AVCodec ff_libsvt_av1_encoder = {
 .priv_class = &class,
 .defaults   = eb_enc_defaults,
 .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
-.wrapper_name   = "libsvt_av1",
+.wrapper_name   = "libsvtav1",
 };
-- 
2.27.0

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

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

[FFmpeg-devel] [PATCH 2/2] libsvt-av1: Fix the documentation to match the actual options

2020-07-29 Thread Mark Thompson
---
 doc/encoders.texi   | 44 +++--
 libavcodec/libsvt_av1.c |  6 +++---
 2 files changed, 37 insertions(+), 13 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index af7d2ba983..d05ecca8db 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1697,31 +1697,55 @@ You need to explicitly configure the build with 
@code{--enable-libsvtav1}.
 @subsection Options
 
 @table @option
+@item profile
+Set the encoding profile.
+
+@item level
+Set the operating point level.
+
+@item tier
+Set the operating point tier.
+
+@item rc
+Set the rate control mode to use.
+
+Possible modes:
+@table @option
+@item cqp
+Constant quantizer: use fixed values of qindex (dependent on the frame type)
+throughout the stream.  This mode is the default.
+
+@item vbr
+Variable bitrate: use a target bitrate for the whole stream.
+
+@item cvbr
+Constrained variable bitrate: use a target bitrate for each GOP.
+@end table
+
 @item qmax
-Sets the maximum quantizer to use when using bitrate mode.
+Set the maximum quantizer to use when using a bitrate mode.
 
 @item qmin
-Sets the minimum quantizer to use when using bitrate mode.
+Set the minimum quantizer to use when using a bitrate mode.
 
 @item qp
-Uses quantizer mode to encode at the given quantizer (0-63).
+Set the quantizer used in cqp rate control mode (0-63).
 
-@item hielevel
+@item sc-detection
 Enable scene change detection.
 
-@item la_depth
+@item la-depth
 Set number of frames to look ahead (0-120).
 
 @item preset
-Set encoding preset.
-
-@item tier
+Set the quality-speed tradeoff, in the range 0 to 8.  Higher values are
+faster but lower quality.  Defaults to 8 (highest speed).
 
 @item tile-rows
-Selects how many rows of tiles to encode with (0-6).
+Set log2 of the number of rows of tiles to use (0-6).
 
 @item tile-columns
-Selects how many columns of tiles to encode with (0-4).
+Set log2 of the number of columns of tiles to use (0-4).
 
 @end table
 
diff --git a/libavcodec/libsvt_av1.c b/libavcodec/libsvt_av1.c
index 3229551d2b..e3d932d134 100644
--- a/libavcodec/libsvt_av1.c
+++ b/libavcodec/libsvt_av1.c
@@ -489,7 +489,7 @@ static const AVOption options[] = {
 { "preset", "Encoding preset [0, 8]",
   OFFSET(enc_mode), AV_OPT_TYPE_INT, { .i64 = MAX_ENC_PRESET }, 0, 
MAX_ENC_PRESET, VE },
 
-{ "tier", "Set tier (general_tier_flag)", OFFSET(tier),
+{ "tier", "Set operating point tier", OFFSET(tier),
   AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE, "tier" },
 { "main", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, VE, "tier" },
 { "high", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, VE, "tier" },
@@ -526,11 +526,11 @@ static const AVOption options[] = {
 
 { "rc", "Bit rate control mode", OFFSET(rc_mode),
   AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 3, VE , "rc"},
-{ "cqp", "Const Quantization Parameter", 0, AV_OPT_TYPE_CONST, { .i64 
= 0 },  INT_MIN, INT_MAX, VE, "rc" },
+{ "cqp", "Constant quantizer", 0, AV_OPT_TYPE_CONST, { .i64 = 0 },  
INT_MIN, INT_MAX, VE, "rc" },
 { "vbr", "Variable Bit Rate, use a target bitrate for the entire 
stream", 0, AV_OPT_TYPE_CONST, { .i64 = 1 },  INT_MIN, INT_MAX, VE, "rc" },
 { "cvbr", "Constrained Variable Bit Rate, use a target bitrate for 
each GOP", 0, AV_OPT_TYPE_CONST,{ .i64 = 2 },  INT_MIN, INT_MAX, VE, "rc" },
 
-{ "qp", "QP value for intra frames", OFFSET(qp),
+{ "qp", "Quantizer to use with cqp rate control mode", OFFSET(qp),
   AV_OPT_TYPE_INT, { .i64 = 50 }, 0, 63, VE },
 
 { "sc-detection", "Scene change detection", OFFSET(scd),
-- 
2.27.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] Create and populate AVStream side data packet with contents of ISOBMFF edit list entries

2020-07-29 Thread Matthew Szatmary
On Wed, Jul 29, 2020 at 12:22 PM Andreas Rheinhardt
 wrote:
>
> Matthew Szatmary:
> > Create and populate AVStream side data packet with contents of ISOBMFF
> > edit list entries
> >
> > Signed-off-by: Matthew Szatmary 
> > ---
> >  Changelog   |  1 +
> >  libavcodec/packet.h | 14 ++
> >  libavformat/mov.c   | 17 -
> >  3 files changed, 31 insertions(+), 1 deletion(-)
> >
> > diff --git a/Changelog b/Changelog
> > index c37ffa82e1..2d719dd3b1 100644
> > --- a/Changelog
> > +++ b/Changelog
> > @@ -9,6 +9,7 @@ version :
> >  - VDPAU accelerated HEVC 10/12bit decoding
> >  - ADPCM IMA Ubisoft APM encoder
> >  - Rayman 2 APM muxer
> > +- AV_PKT_DATA_EDIT_LIST added to AVStream side_data
> >
> >
> >  version 4.3:
> > diff --git a/libavcodec/packet.h b/libavcodec/packet.h
> > index 0a19a0eff3..5faa594cf5 100644
> > --- a/libavcodec/packet.h
> > +++ b/libavcodec/packet.h
> > @@ -290,6 +290,20 @@ enum AVPacketSideDataType {
> >   */
> >  AV_PKT_DATA_S12M_TIMECODE,
> >
> > +/**
> > + * ISO media file edit list side data packet
> > + * The structure is repeated for each entry in the edit list
> > + * The number of entries can be calculated
> > + * by dividing the packet size by the entry size
> > + * Each entry is 20 bytes and is laid out as follows:
> > + * @code
> > + * s64le duration
> > + * s64le time
> > + * float32le rate
Good point, I will make that change.

>
> You are obviously copying the MOVElst structure; yet the rate is a 16.16
> fixed point number in the file and not a float, so one should probably
> use this.
>
> > + * @endcode
> > + */
> > +AV_PKT_DATA_EDIT_LIST,
> > +
> >  /**
> >   * The number of side data types.
> >   * This is not part of the public API/ABI in the sense that it may
> > diff --git a/libavformat/mov.c b/libavformat/mov.c
> > index d16840f3df..bb2c940e80 100644
> > --- a/libavformat/mov.c
> > +++ b/libavformat/mov.c
> > @@ -4317,7 +4317,6 @@ static int mov_read_trak(MOVContext *c,
> > AVIOContext *pb, MOVAtom atom)
> >  av_freep(&sc->keyframes);
> >  av_freep(&sc->stts_data);
> >  av_freep(&sc->stps_data);
> > -av_freep(&sc->elst_data);
>
> This is still needed, namely if an error happens before you can attach
> the stream side-data. E.g. if an invalid edit list is found and
> standards compliance is set to strict. Or if av_stream_new_side_data()
> fails.

av_freep(&sc->elst_data); is also called in mov_read_close, So it
would only leak if the API was used incorrectly. But that said, I
think I can move the logic to mov_read_trak, and make the whole point
moot. I was just trying to keep it near the other side_data calls.

>
> >  av_freep(&sc->rap_group);
> >
> >  return 0;
> > @@ -7662,6 +7661,22 @@ static int mov_read_header(AVFormatContext *s)
> >  AVStream *st = s->streams[i];
> >  MOVStreamContext *sc = st->priv_data;
> >
> > +if (sc->elst_data) {
> > +uint8_t *elst_data;
> > +elst_data = av_stream_new_side_data(st,
> > AV_PKT_DATA_EDIT_LIST, sc->elst_count * 20);
>
> I wonder whether it would be advantageouos to use
> av_stream_add_side_data() here.

av_stream_new_side_data is just a wrapper for av_malloc +
av_stream_add_side_data

> > +
> > +if (!elst_data)
> > +goto fail;
> > +
> > +for (j = 0; j < sc->elst_count; j++) {
> > +AV_WB64((elst_data+(j*20)), sc->elst_data[j].duration);
> > +AV_WB64((elst_data+(j*20)+8), sc->elst_data[j].time);
>
> "WB" stands for "Write Big-endian", yet your documentation says that it
> is supposed to be little-endian.

thanks, new patch included


>
> > +AV_WB32((elst_data+(j*20)+16), sc->elst_data[j].rate);
> > +}
> > +
> > +av_freep(&sc->elst_data);
> > +}
> > +
> >  switch (st->codecpar->codec_type) {
> >  case AVMEDIA_TYPE_AUDIO:
> >  err = ff_replaygain_export(st, s->metadata);
> >
>
> ___
> 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".


Create and populate AVStream side data packet with contents of ISOBMFF
edit list entries

Signed-off-by: Matthew Szatmary 
---
 Changelog   |  1 +
 libavcodec/packet.h | 15 +++
 libavformat/mov.c   | 15 +++
 3 files changed, 31 insertions(+)

diff --git a/Changelog b/Changelog
index 6f648bff2b..d51e836301 100644
--- a/Changelog
+++ b/Changelog
@@ -10,6 +10,7 @@ version :
 - ADPCM IMA Ubisoft APM encoder
 - Rayman 2 APM muxer
 - AV1 encoding support SVT-AV1
+- AV_PKT_DATA_EDIT_LIST added to AVStream side_data


 version 4.3:
diff --git a/libavcodec/packet.h b/libavcodec/packet.h
index 0a19a0eff3..1f0e3405ed 100644
--- a/libavcodec/packet.h
+

Re: [FFmpeg-devel] [PATCH] avcodec/options_table: make AVCodecContext->level search for child constants

2020-07-29 Thread James Almer
On 7/29/2020 7:08 PM, James Almer wrote:
> This change makes it possible for child encoders to define custom level
> option names which can be used for setting the AVCodecContext->level.
> 
> Based on 337fe4bcc2
> 
> Signed-off-by: James Almer 
> ---
>  libavcodec/options_table.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed by jkqxz on IRC, and pushed.
___
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] Create and populate AVStream side data packet with contents of ISOBMFF edit list entries

2020-07-29 Thread Matthew Szatmary
Create and populate AVStream side data packet with contents of ISOBMFF
edit list entries

Signed-off-by: Matthew Szatmary 
---
 Changelog   |  1 +
 libavcodec/packet.h | 15 +++
 libavformat/mov.c   | 15 +++
 3 files changed, 31 insertions(+)

diff --git a/Changelog b/Changelog
index 6f648bff2b..d51e836301 100644
--- a/Changelog
+++ b/Changelog
@@ -10,6 +10,7 @@ version :
 - ADPCM IMA Ubisoft APM encoder
 - Rayman 2 APM muxer
 - AV1 encoding support SVT-AV1
+- AV_PKT_DATA_EDIT_LIST added to AVStream side_data


 version 4.3:
diff --git a/libavcodec/packet.h b/libavcodec/packet.h
index 0a19a0eff3..1f0e3405ed 100644
--- a/libavcodec/packet.h
+++ b/libavcodec/packet.h
@@ -290,6 +290,21 @@ enum AVPacketSideDataType {
  */
 AV_PKT_DATA_S12M_TIMECODE,

+/**
+ * ISO media file edit list side data packet
+ * The structre is repeated for each entry in the edit list
+ * The number of entries can be calculated
+ * by dividing the total size by the entry size
+ * Each entry is 20 bytes and is laid out as follows:
+ * @code
+ * s64be segment duration
+ * s64be media time
+ * s16be media rate
+ * s16be media rate fraction
+ * @endcode
+ */
+AV_PKT_DATA_EDIT_LIST,
+
 /**
  * The number of side data types.
  * This is not part of the public API/ABI in the sense that it may
diff --git a/libavformat/mov.c b/libavformat/mov.c
index d16840f3df..fbfcdddf3f 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4311,6 +4311,21 @@ static int mov_read_trak(MOVContext *c,
AVIOContext *pb, MOVAtom atom)
 && sc->time_scale == st->codecpar->sample_rate) {
 st->need_parsing = AVSTREAM_PARSE_FULL;
 }
+
+if (sc->elst_data) {
+int i;
+uint8_t *elst_data;
+elst_data = av_stream_new_side_data(st,
AV_PKT_DATA_EDIT_LIST, sc->elst_count * 20);
+if (elst_data) {
+for (i = 0; i < sc->elst_count; i++) {
+uint32_t media_rate = (uint32_t)sc->elst_data[i].rate
* 65536.0;
+AV_WB64((elst_data+(i*20)), sc->elst_data[i].duration);
+AV_WB64((elst_data+(i*20)+8), sc->elst_data[i].time);
+AV_WB32((elst_data+(i*20)+16), media_rate);
+}
+}
+}
+
 /* Do not need those anymore. */
 av_freep(&sc->chunk_offsets);
 av_freep(&sc->sample_sizes);
-- 
2.27.0

On Wed, Jul 29, 2020 at 3:56 PM Matthew Szatmary  wrote:
>
> On Wed, Jul 29, 2020 at 12:22 PM Andreas Rheinhardt
>  wrote:
> >
> > Matthew Szatmary:
> > > Create and populate AVStream side data packet with contents of ISOBMFF
> > > edit list entries
> > >
> > > Signed-off-by: Matthew Szatmary 
> > > ---
> > >  Changelog   |  1 +
> > >  libavcodec/packet.h | 14 ++
> > >  libavformat/mov.c   | 17 -
> > >  3 files changed, 31 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/Changelog b/Changelog
> > > index c37ffa82e1..2d719dd3b1 100644
> > > --- a/Changelog
> > > +++ b/Changelog
> > > @@ -9,6 +9,7 @@ version :
> > >  - VDPAU accelerated HEVC 10/12bit decoding
> > >  - ADPCM IMA Ubisoft APM encoder
> > >  - Rayman 2 APM muxer
> > > +- AV_PKT_DATA_EDIT_LIST added to AVStream side_data
> > >
> > >
> > >  version 4.3:
> > > diff --git a/libavcodec/packet.h b/libavcodec/packet.h
> > > index 0a19a0eff3..5faa594cf5 100644
> > > --- a/libavcodec/packet.h
> > > +++ b/libavcodec/packet.h
> > > @@ -290,6 +290,20 @@ enum AVPacketSideDataType {
> > >   */
> > >  AV_PKT_DATA_S12M_TIMECODE,
> > >
> > > +/**
> > > + * ISO media file edit list side data packet
> > > + * The structure is repeated for each entry in the edit list
> > > + * The number of entries can be calculated
> > > + * by dividing the packet size by the entry size
> > > + * Each entry is 20 bytes and is laid out as follows:
> > > + * @code
> > > + * s64le duration
> > > + * s64le time
> > > + * float32le rate
> Good point, I will make that change.
>
> >
> > You are obviously copying the MOVElst structure; yet the rate is a 16.16
> > fixed point number in the file and not a float, so one should probably
> > use this.
> >
> > > + * @endcode
> > > + */
> > > +AV_PKT_DATA_EDIT_LIST,
> > > +
> > >  /**
> > >   * The number of side data types.
> > >   * This is not part of the public API/ABI in the sense that it may
> > > diff --git a/libavformat/mov.c b/libavformat/mov.c
> > > index d16840f3df..bb2c940e80 100644
> > > --- a/libavformat/mov.c
> > > +++ b/libavformat/mov.c
> > > @@ -4317,7 +4317,6 @@ static int mov_read_trak(MOVContext *c,
> > > AVIOContext *pb, MOVAtom atom)
> > >  av_freep(&sc->keyframes);
> > >  av_freep(&sc->stts_data);
> > >  av_freep(&sc->stps_data);
> > > -av_freep(&sc->elst_data);
> >
> > This is still needed, namely if an error happens before you can attach
> > the stream side-data. E.g. if an invalid edit list is found and
> > stand

Re: [FFmpeg-devel] [PATCH] [RFC] lavc, lavfmt: add FLIF decoding support

2020-07-29 Thread Anamitra Ghorui
It appears that the patch is faulty. I will be reposting it. Sorry
for the inconvenience.

___
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] Create and populate AVStream side data packet with contents of ISOBMFF edit list entries

2020-07-29 Thread Thierry Foucu
On Wed, Jul 29, 2020 at 4:02 PM Matthew Szatmary  wrote:

> Create and populate AVStream side data packet with contents of ISOBMFF
> edit list entries
>
> Signed-off-by: Matthew Szatmary 
> ---
>  Changelog   |  1 +
>  libavcodec/packet.h | 15 +++
>  libavformat/mov.c   | 15 +++
>  3 files changed, 31 insertions(+)
>
> diff --git a/Changelog b/Changelog
> index 6f648bff2b..d51e836301 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -10,6 +10,7 @@ version :
>  - ADPCM IMA Ubisoft APM encoder
>  - Rayman 2 APM muxer
>  - AV1 encoding support SVT-AV1
> +- AV_PKT_DATA_EDIT_LIST added to AVStream side_data
>
>
>  version 4.3:
> diff --git a/libavcodec/packet.h b/libavcodec/packet.h
> index 0a19a0eff3..1f0e3405ed 100644
> --- a/libavcodec/packet.h
> +++ b/libavcodec/packet.h
> @@ -290,6 +290,21 @@ enum AVPacketSideDataType {
>   */
>  AV_PKT_DATA_S12M_TIMECODE,
>
> +/**
> + * ISO media file edit list side data packet
> + * The structre is repeated for each entry in the edit list
> + * The number of entries can be calculated
> + * by dividing the total size by the entry size
> + * Each entry is 20 bytes and is laid out as follows:
> + * @code
> + * s64be segment duration
> + * s64be media time
> + * s16be media rate
> + * s16be media rate fraction
> + * @endcode
> + */
> +AV_PKT_DATA_EDIT_LIST,
>

This seems to be really MP4 centric. Did you check if such patch sent out
for RFC in 2018 could do it?

https://patchwork.ffmpeg.org/project/ffmpeg/patch/1522179841-34881-2-git-send-email-derek.buitenh...@gmail.com/


> +
>  /**
>   * The number of side data types.
>   * This is not part of the public API/ABI in the sense that it may
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index d16840f3df..fbfcdddf3f 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -4311,6 +4311,21 @@ static int mov_read_trak(MOVContext *c,
> AVIOContext *pb, MOVAtom atom)
>  && sc->time_scale == st->codecpar->sample_rate) {
>  st->need_parsing = AVSTREAM_PARSE_FULL;
>  }
> +
> +if (sc->elst_data) {
> +int i;
> +uint8_t *elst_data;
> +elst_data = av_stream_new_side_data(st,
> AV_PKT_DATA_EDIT_LIST, sc->elst_count * 20);
> +if (elst_data) {
> +for (i = 0; i < sc->elst_count; i++) {
> +uint32_t media_rate = (uint32_t)sc->elst_data[i].rate
> * 65536.0;
> +AV_WB64((elst_data+(i*20)), sc->elst_data[i].duration);
> +AV_WB64((elst_data+(i*20)+8), sc->elst_data[i].time);
> +AV_WB32((elst_data+(i*20)+16), media_rate);
>

Don't you need to know the global timescale and the stream timescale to
make sense of those values?


> +}
> +}
> +}
> +
>  /* Do not need those anymore. */
>  av_freep(&sc->chunk_offsets);
>  av_freep(&sc->sample_sizes);
> --
> 2.27.0
>
> On Wed, Jul 29, 2020 at 3:56 PM Matthew Szatmary 
> wrote:
> >
> > On Wed, Jul 29, 2020 at 12:22 PM Andreas Rheinhardt
> >  wrote:
> > >
> > > Matthew Szatmary:
> > > > Create and populate AVStream side data packet with contents of
> ISOBMFF
> > > > edit list entries
> > > >
> > > > Signed-off-by: Matthew Szatmary 
> > > > ---
> > > >  Changelog   |  1 +
> > > >  libavcodec/packet.h | 14 ++
> > > >  libavformat/mov.c   | 17 -
> > > >  3 files changed, 31 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/Changelog b/Changelog
> > > > index c37ffa82e1..2d719dd3b1 100644
> > > > --- a/Changelog
> > > > +++ b/Changelog
> > > > @@ -9,6 +9,7 @@ version :
> > > >  - VDPAU accelerated HEVC 10/12bit decoding
> > > >  - ADPCM IMA Ubisoft APM encoder
> > > >  - Rayman 2 APM muxer
> > > > +- AV_PKT_DATA_EDIT_LIST added to AVStream side_data
> > > >
> > > >
> > > >  version 4.3:
> > > > diff --git a/libavcodec/packet.h b/libavcodec/packet.h
> > > > index 0a19a0eff3..5faa594cf5 100644
> > > > --- a/libavcodec/packet.h
> > > > +++ b/libavcodec/packet.h
> > > > @@ -290,6 +290,20 @@ enum AVPacketSideDataType {
> > > >   */
> > > >  AV_PKT_DATA_S12M_TIMECODE,
> > > >
> > > > +/**
> > > > + * ISO media file edit list side data packet
> > > > + * The structure is repeated for each entry in the edit list
> > > > + * The number of entries can be calculated
> > > > + * by dividing the packet size by the entry size
> > > > + * Each entry is 20 bytes and is laid out as follows:
> > > > + * @code
> > > > + * s64le duration
> > > > + * s64le time
> > > > + * float32le rate
> > Good point, I will make that change.
> >
> > >
> > > You are obviously copying the MOVElst structure; yet the rate is a
> 16.16
> > > fixed point number in the file and not a float, so one should probably
> > > use this.
> > >
> > > > + * @endcode
> > > > + */
> > > > +AV_PKT_DATA_EDIT_LIST,
> > > > +
> > > >  /**
> > > >   * The number of si

[FFmpeg-devel] [PATCH] libsvt_av1: remove forced-idr option

2020-07-29 Thread Lynne
This option is directly copy-pasted from the SVT1-HEVC wrapper and has 
no place in the options for an AV1 encoder.

AV1 has no H.264/5 IDR frames nor anything like them.
All this option does is change all real keyframes to an intra-only
AV1 frame, which is not seekable. Hence, any streams encoded with
this option enabled will not be seekable.

Having an option that breaks encoded streams this much is not what
we'd like. If SVT-AV1 developers would like to have an open-gop
option a patch to enable that could be added with an appropriate
name and after a discussion, rather than slipping through reviews.
>From 24e3d31c2c41cb5f7ac5d450323130f8baf8463d Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Wed, 29 Jul 2020 22:38:44 +0200
Subject: [PATCH] libsvt_av1: remove forced-idr option

This option is directly copy-pasted from the SVT1-HEVC wrapper and has
no place in the options for an AV1 encoder.

AV1 has no H.264/5 IDR frames nor anything like them.
All this option does is change all real keyframes to an intra-only
AV1 frame, which is not seekable. Hence, any streams encoded with
this option enabled will not be seekable.

Having an option that breaks encoded streams this much is not what
we'd like. If SVT-AV1 developers would like to have an open-gop
option a patch to enable that could be added with an appropriate
name and after a discussion, rather than slipping through reviews.
---
 libavcodec/libsvt_av1.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/libavcodec/libsvt_av1.c b/libavcodec/libsvt_av1.c
index b30211d15b..c7ae5f9691 100644
--- a/libavcodec/libsvt_av1.c
+++ b/libavcodec/libsvt_av1.c
@@ -67,8 +67,6 @@ typedef struct SvtContext {
 int scd;
 int qp;
 
-int forced_idr;
-
 int tier;
 
 int tile_columns;
@@ -212,7 +210,7 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param,
 param->min_qp_allowed   = avctx->qmin;
 }
 
-param->intra_refresh_type   = svt_enc->forced_idr + 1;
+param->intra_refresh_type   = 2; /* Real keyframes only */
 
 if (svt_enc->la_depth >= 0)
 param->look_ahead_distance  = svt_enc->la_depth;
@@ -538,9 +536,6 @@ static const AVOption options[] = {
 { "sc_detection", "Scene change detection", OFFSET(scd),
   AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
 
-{ "forced-idr", "If forcing keyframes, force them as IDR frames", OFFSET(forced_idr),
-  AV_OPT_TYPE_BOOL,   { .i64 = 1 }, 0, 1, VE },
-
 { "tile-columns", "Log2 of number of tile columns to use", OFFSET(tile_columns), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, VE},
 { "tile-rows", "Log2 of number of tile rows to use", OFFSET(tile_rows), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 6, VE},
 
-- 
2.28.0.163.g6104cc2f0b6

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

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

Re: [FFmpeg-devel] [PATCH V2 1/2] dnn/native: add native support for avg_pool

2020-07-29 Thread Fu, Ting


> -Original Message-
> From: ffmpeg-devel  On Behalf Of Ting Fu
> Sent: Wednesday, July 29, 2020 10:11 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH V2 1/2] dnn/native: add native support for
> avg_pool
> 
> Not support pooling strides in channel dimension now.
> It can be tested with the model generated with below python script:
> 
> import tensorflow as tf
> import numpy as np
> import imageio
> 
> in_img = imageio.imread('input_odd.jpg') in_img =
> in_img.astype(np.float32)/255.0 in_data = in_img[np.newaxis, :]
> 
> x = tf.placeholder(tf.float32, shape=[1, None, None, 3], name='dnn_in') x_pool
> = tf.nn.avg_pool(x, ksize=[1,2,2,1], strides=[1,2,2,1], padding='SAME') 
> #please
> alter the params as needed y = tf.identity(x_pool, name='dnn_out')
> 
> sess=tf.Session()
> sess.run(tf.global_variables_initializer())
> 
> graph_def = tf.graph_util.convert_variables_to_constants(sess, sess.graph_def,
> ['dnn_out']) tf.train.write_graph(graph_def, '.', 'image_process.pb',
> as_text=False)
> 
> print("image_process.pb generated, please use \
> path_to_ffmpeg/tools/python/convert.py to generate image_process.model\n")
> 
> output = sess.run(y, feed_dict={x: in_data}) imageio.imsave("out.jpg",
> np.squeeze(output))
> 
> Signed-off-by: Ting Fu 
> ---
>  libavfilter/dnn/Makefile  |   1 +
>  libavfilter/dnn/dnn_backend_native.h  |   2 +
>  .../dnn/dnn_backend_native_layer_avgpool.c| 147 ++
>  .../dnn/dnn_backend_native_layer_avgpool.h|  35 +
>  .../dnn/dnn_backend_native_layer_conv2d.h |   3 +-
>  libavfilter/dnn/dnn_backend_native_layers.c   |   2 +
>  tools/python/convert_from_tensorflow.py   |  35 -
>  7 files changed, 222 insertions(+), 3 deletions(-)  create mode 100644
> libavfilter/dnn/dnn_backend_native_layer_avgpool.c
>  create mode 100644 libavfilter/dnn/dnn_backend_native_layer_avgpool.h
> 
> diff --git a/libavfilter/dnn/Makefile b/libavfilter/dnn/Makefile index
> d90137ec42..e0957073ee 100644
> --- a/libavfilter/dnn/Makefile
> +++ b/libavfilter/dnn/Makefile
> @@ -1,6 +1,7 @@
>  OBJS-$(CONFIG_DNN)   += dnn/dnn_interface.o
>  OBJS-$(CONFIG_DNN)   += dnn/dnn_backend_native.o
>  OBJS-$(CONFIG_DNN)   += 
> dnn/dnn_backend_native_layers.o
> +OBJS-$(CONFIG_DNN)   +=
> dnn/dnn_backend_native_layer_avgpool.o
>  OBJS-$(CONFIG_DNN)   += 
> dnn/dnn_backend_native_layer_pad.o
>  OBJS-$(CONFIG_DNN)   +=
> dnn/dnn_backend_native_layer_conv2d.o
>  OBJS-$(CONFIG_DNN)   +=
> dnn/dnn_backend_native_layer_depth2space.o
[...]
> 
> 
> +def dump_avg_pool_to_file(self, node, f):
> +assert(node.op == 'AvgPool')
> +self.layer_number = self.layer_number + 1
> +self.converted_nodes.add(node.name)
> +node0 = self.name_node_dict[node.input[0]]
> +strides = node.attr['strides']
> +assert(strides.list.i[1]==strides.list.i[2])
> +assert(strides.list.i[0]==1)
> +assert(strides.list.i[3]==1)

Since the tensorflow do not support pooling strides in batch dimension, and 
current do not support pooling in channel dimension,
added two assert here.

> +strides = strides.list.i[1]
> +filter_node = node.attr['ksize']
> +input_name = node.input[0]
> +
> +assert(filter_node.list.i[0]==1)
> +assert(filter_node.list.i[3]==1)

Same as above, the tensorflow do not support pooling ksize in both batch 
dimension and channel dimension.

> +filter_height = filter_node.list.i[1]
> +filter_width = filter_node.list.i[2]
> +
> +in_channels = node0.attr['shape'].shape.dim[3].size
> +out_channels = in_channels
> +padding = node.attr['padding'].s.decode("utf-8")
> +np.array([self.op2code[node.op], strides, 
> self.pool_paddings[padding],
> in_channels, out_channels,
> +  filter_height],dtype=np.uint32).tofile(f)
> +
> +input_operand_index = self.add_operand(input_name,
> Operand.IOTYPE_INPUT)
> +output_operand_index = self.add_operand(node.name,
> Operand.IOTYPE_OUTPUT)
> +np.array([input_operand_index,
> + output_operand_index],dtype=np.uint32).tofile(f)
> +
> +
>  def dump_layers_to_file(self, f):
>  for node in self.nodes:
>  if node.name in self.converted_nodes:
> @@ -311,6 +342,8 @@ class TFConverter:
> 
>  if node.op == 'Conv2D':
>  self.dump_simple_conv2d_to_file(node, f)
> +if node.op == 'AvgPool':
> +self.dump_avg_pool_to_file(node, f)
>  elif node.op == 'DepthToSpace':
>  self.dump_depth2space_to_file(node, f)
>  elif node.op == 'MirrorPad':
> --
> 2.17.1
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/m

Re: [FFmpeg-devel] [PATCH 1/2] avdevice/decklink_dec: mark the field flag if framerate > 30FPS

2020-07-29 Thread lance . lmwang
On Wed, Jul 29, 2020 at 10:16:33PM +0200, Marton Balint wrote:
> 
> 
> > > > > > > > > if you tested with SDI with TC.
> > > > > > > > > 00:00:00:24
> > > > > > > > > 00:00:00:24
> > > > > > > > > 00:00:00:00
> > > > > > > > > 00:00:00:00
> 
> I did tests, and depending on which timecode you select, and the timecode
> formats which are available in the SDI signal, this really can be the case,
> so you were right that the decklink API usually does not provide the proper
> timecode as string, only the value of "raw" timecodes in the signal,
> regardless of used frame rate.
> 
> I could not test, but assume that if a high frame rate timecode is detected
> then valid string timecode is returned. Otherwise max 30fps timecode.
> 
> > > > > I have tested with bmdTimecodeFieldMark
> > > > > flag, it's not set as expected for testing. I have no clue how to get
> > > > > the flag as the API provide the TC string is same for the frame pair.
> > > > > Maybe I miss something.
> 
> SMPTE ST 12-2 has a good overview of the used signalling in section 7.
> Basically for 50/60 fps different timecode types (VITC1, VITC2) are used for
> different parity frames.
> 
> We have to be smart here to generate proper timecode, because the decklink
> API does not tell you which timecode it had found for an rp188any query... I
> suggest the following:
> 
> - If the user selects high frame rate timecode (not available as an
>   option at the moment, but can be added), then use that directly.
> - If the user selects rp188any then
>   - Query high frame rate timecode, if exists use that directly.
>   - Otherwise
> - for <= 30fps query rp188any and use that directly
> - for > 30fps
>   - query VITC1, if exists use that with frame doubling and field flag
> checking
>   - otherwise query VITC2, if exists use that with frame doubling
> and field flag checking
>   - otherwise query LTC, if exists use that with frame doubling and
> field flag checking
>   - note that this special ordering of querying the timecode types
> is slightly different from what the decklink API does and it
> should be mentioned in the docs.
> - Otherwise
>   - for <= 30fps query the selected timecode and use that directly
>   - for > 30fps query the selected timecode and use that with frame
> doubling and field flag checking
The suggestion is very clear, I lacks the different TC test signal so I can't
try to implement and test it yet.

> 
> Also probably it is better to use IDeckLinkTimecode->GetComponents() and use
> av_timecode_get_smpte() instead of using the string value.

Yes, the TC format is rp188any when I test, I recall I have try to get by 
GetComponents, 
the result is consistent with string() before, I'll try to retest again if I 
test signal is avaiable.


> 
> Regards,
> Marton
> ___
> 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".

-- 
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 V2 1/2] dnn/native: add native support for avg_pool

2020-07-29 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel  On Behalf Of Fu, Ting
> Sent: 2020年7月30日 9:43
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH V2 1/2] dnn/native: add native support for
> avg_pool
> 
> 
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of Ting
> > Fu
> > Sent: Wednesday, July 29, 2020 10:11 PM
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: [FFmpeg-devel] [PATCH V2 1/2] dnn/native: add native support
> > for avg_pool
> >
> > Not support pooling strides in channel dimension now.
> > It can be tested with the model generated with below python script:
> >
> > import tensorflow as tf
> > import numpy as np
> > import imageio
> >
> > in_img = imageio.imread('input_odd.jpg') in_img =
> > in_img.astype(np.float32)/255.0 in_data = in_img[np.newaxis, :]
> >
> > x = tf.placeholder(tf.float32, shape=[1, None, None, 3],
> > name='dnn_in') x_pool = tf.nn.avg_pool(x, ksize=[1,2,2,1],
> > strides=[1,2,2,1], padding='SAME') #please alter the params as needed
> > y = tf.identity(x_pool, name='dnn_out')
> >
> > sess=tf.Session()
> > sess.run(tf.global_variables_initializer())
> >
> > graph_def = tf.graph_util.convert_variables_to_constants(sess,
> > sess.graph_def,
> > ['dnn_out']) tf.train.write_graph(graph_def, '.', 'image_process.pb',
> > as_text=False)
> >
> > print("image_process.pb generated, please use \
> > path_to_ffmpeg/tools/python/convert.py to generate
> > image_process.model\n")
> >
> > output = sess.run(y, feed_dict={x: in_data}) imageio.imsave("out.jpg",
> > np.squeeze(output))
> >
> > Signed-off-by: Ting Fu 
> > ---
> >  libavfilter/dnn/Makefile  |   1 +
> >  libavfilter/dnn/dnn_backend_native.h  |   2 +
> >  .../dnn/dnn_backend_native_layer_avgpool.c| 147
> ++
> >  .../dnn/dnn_backend_native_layer_avgpool.h|  35 +
> >  .../dnn/dnn_backend_native_layer_conv2d.h |   3 +-
> >  libavfilter/dnn/dnn_backend_native_layers.c   |   2 +
> >  tools/python/convert_from_tensorflow.py   |  35 -
> >  7 files changed, 222 insertions(+), 3 deletions(-)  create mode
> > 100644 libavfilter/dnn/dnn_backend_native_layer_avgpool.c
> >  create mode 100644 libavfilter/dnn/dnn_backend_native_layer_avgpool.h
> >
> > diff --git a/libavfilter/dnn/Makefile b/libavfilter/dnn/Makefile index
> > d90137ec42..e0957073ee 100644
> > --- a/libavfilter/dnn/Makefile
> > +++ b/libavfilter/dnn/Makefile
> > @@ -1,6 +1,7 @@
> >  OBJS-$(CONFIG_DNN)   +=
> dnn/dnn_interface.o
> >  OBJS-$(CONFIG_DNN)   +=
> dnn/dnn_backend_native.o
> >  OBJS-$(CONFIG_DNN)   +=
> dnn/dnn_backend_native_layers.o
> > +OBJS-$(CONFIG_DNN)   +=
> > dnn/dnn_backend_native_layer_avgpool.o
> >  OBJS-$(CONFIG_DNN)   +=
> dnn/dnn_backend_native_layer_pad.o
> >  OBJS-$(CONFIG_DNN)   +=
> > dnn/dnn_backend_native_layer_conv2d.o
> >  OBJS-$(CONFIG_DNN)   +=
> > dnn/dnn_backend_native_layer_depth2space.o
> [...]
> >
> >
> > +def dump_avg_pool_to_file(self, node, f):
> > +assert(node.op == 'AvgPool')
> > +self.layer_number = self.layer_number + 1
> > +self.converted_nodes.add(node.name)
> > +node0 = self.name_node_dict[node.input[0]]
> > +strides = node.attr['strides']
> > +assert(strides.list.i[1]==strides.list.i[2])
> > +assert(strides.list.i[0]==1)
> > +assert(strides.list.i[3]==1)
> 
> Since the tensorflow do not support pooling strides in batch dimension, and
> current do not support pooling in channel dimension, added two assert here.

thanks, and please add the comments within the code.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH V2 1/2] dnn/native: add native support for avg_pool

2020-07-29 Thread Fu, Ting


> -Original Message-
> From: ffmpeg-devel  On Behalf Of Guo,
> Yejun
> Sent: Thursday, July 30, 2020 10:02 AM
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH V2 1/2] dnn/native: add native support for
> avg_pool
> 
> 
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of Fu,
> > Ting
> > Sent: 2020年7月30日 9:43
> > To: FFmpeg development discussions and patches
> > 
> > Subject: Re: [FFmpeg-devel] [PATCH V2 1/2] dnn/native: add native
> > support for avg_pool
> >
> >
> >
> > > -Original Message-
> > > From: ffmpeg-devel  On Behalf Of
> > > Ting Fu
> > > Sent: Wednesday, July 29, 2020 10:11 PM
> > > To: ffmpeg-devel@ffmpeg.org
> > > Subject: [FFmpeg-devel] [PATCH V2 1/2] dnn/native: add native
> > > support for avg_pool
> > >
> > > Not support pooling strides in channel dimension now.
> > > It can be tested with the model generated with below python script:
> > >
> > > import tensorflow as tf
> > > import numpy as np
> > > import imageio
> > >
> > > in_img = imageio.imread('input_odd.jpg') in_img =
> > > in_img.astype(np.float32)/255.0 in_data = in_img[np.newaxis, :]
> > >
> > > x = tf.placeholder(tf.float32, shape=[1, None, None, 3],
> > > name='dnn_in') x_pool = tf.nn.avg_pool(x, ksize=[1,2,2,1],
> > > strides=[1,2,2,1], padding='SAME') #please alter the params as
> > > needed y = tf.identity(x_pool, name='dnn_out')
> > >
> > > sess=tf.Session()
> > > sess.run(tf.global_variables_initializer())
> > >
> > > graph_def = tf.graph_util.convert_variables_to_constants(sess,
> > > sess.graph_def,
> > > ['dnn_out']) tf.train.write_graph(graph_def, '.',
> > > 'image_process.pb',
> > > as_text=False)
> > >
> > > print("image_process.pb generated, please use \
> > > path_to_ffmpeg/tools/python/convert.py to generate
> > > image_process.model\n")
> > >
> > > output = sess.run(y, feed_dict={x: in_data})
> > > imageio.imsave("out.jpg",
> > > np.squeeze(output))
> > >
> > > Signed-off-by: Ting Fu 
> > > ---
> > >  libavfilter/dnn/Makefile  |   1 +
> > >  libavfilter/dnn/dnn_backend_native.h  |   2 +
> > >  .../dnn/dnn_backend_native_layer_avgpool.c| 147
> > ++
> > >  .../dnn/dnn_backend_native_layer_avgpool.h|  35 +
> > >  .../dnn/dnn_backend_native_layer_conv2d.h |   3 +-
> > >  libavfilter/dnn/dnn_backend_native_layers.c   |   2 +
> > >  tools/python/convert_from_tensorflow.py   |  35 -
> > >  7 files changed, 222 insertions(+), 3 deletions(-)  create mode
> > > 100644 libavfilter/dnn/dnn_backend_native_layer_avgpool.c
> > >  create mode 100644
> > > libavfilter/dnn/dnn_backend_native_layer_avgpool.h
> > >
> > > diff --git a/libavfilter/dnn/Makefile b/libavfilter/dnn/Makefile
> > > index d90137ec42..e0957073ee 100644
> > > --- a/libavfilter/dnn/Makefile
> > > +++ b/libavfilter/dnn/Makefile
> > > @@ -1,6 +1,7 @@
> > >  OBJS-$(CONFIG_DNN)   +=
> > dnn/dnn_interface.o
> > >  OBJS-$(CONFIG_DNN)   +=
> > dnn/dnn_backend_native.o
> > >  OBJS-$(CONFIG_DNN)   +=
> > dnn/dnn_backend_native_layers.o
> > > +OBJS-$(CONFIG_DNN)   +=
> > > dnn/dnn_backend_native_layer_avgpool.o
> > >  OBJS-$(CONFIG_DNN)   +=
> > dnn/dnn_backend_native_layer_pad.o
> > >  OBJS-$(CONFIG_DNN)   +=
> > > dnn/dnn_backend_native_layer_conv2d.o
> > >  OBJS-$(CONFIG_DNN)   +=
> > > dnn/dnn_backend_native_layer_depth2space.o
> > [...]
> > >
> > >
> > > +def dump_avg_pool_to_file(self, node, f):
> > > +assert(node.op == 'AvgPool')
> > > +self.layer_number = self.layer_number + 1
> > > +self.converted_nodes.add(node.name)
> > > +node0 = self.name_node_dict[node.input[0]]
> > > +strides = node.attr['strides']
> > > +assert(strides.list.i[1]==strides.list.i[2])
> > > +assert(strides.list.i[0]==1)
> > > +assert(strides.list.i[3]==1)
> >
> > Since the tensorflow do not support pooling strides in batch
> > dimension, and current do not support pooling in channel dimension, added
> two assert here.
> 
> thanks, and please add the comments within the code.

Thank you Yejun,
if no further comments, this would be the only difference in patch V3.

> ___
> 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 1/2] libsvt-av1: Consistently use - rather than _

2020-07-29 Thread James Almer
On 7/29/2020 7:50 PM, Mark Thompson wrote:
> Matching libaom-av1.
> ---
>  libavcodec/libsvt_av1.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/libsvt_av1.c b/libavcodec/libsvt_av1.c
> index c7ae5f9691..3229551d2b 100644
> --- a/libavcodec/libsvt_av1.c
> +++ b/libavcodec/libsvt_av1.c
> @@ -483,7 +483,7 @@ static const AVOption options[] = {
>  { "3level", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 3 },  INT_MIN, 
> INT_MAX, VE, "hielevel" },
>  { "4level", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 4 },  INT_MIN, 
> INT_MAX, VE, "hielevel" },
>  
> -{ "la_depth", "Look ahead distance [0, 120]", OFFSET(la_depth),
> +{ "la-depth", "Look ahead distance [0, 120]", OFFSET(la_depth),
>AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 120, VE },
>  
>  { "preset", "Encoding preset [0, 8]",
> @@ -533,7 +533,7 @@ static const AVOption options[] = {
>  { "qp", "QP value for intra frames", OFFSET(qp),
>AV_OPT_TYPE_INT, { .i64 = 50 }, 0, 63, VE },
>  
> -{ "sc_detection", "Scene change detection", OFFSET(scd),
> +{ "sc-detection", "Scene change detection", OFFSET(scd),
>AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
>  
>  { "tile-columns", "Log2 of number of tile columns to use", 
> OFFSET(tile_columns), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, VE},
> @@ -543,7 +543,7 @@ static const AVOption options[] = {
>  };
>  
>  static const AVClass class = {
> -.class_name = "libsvt_av1",
> +.class_name = "libsvt-av1",
>  .item_name  = av_default_item_name,
>  .option = options,
>  .version= LIBAVUTIL_VERSION_INT,
> @@ -558,7 +558,7 @@ static const AVCodecDefault eb_enc_defaults[] = {
>  };
>  
>  AVCodec ff_libsvt_av1_encoder = {
> -.name   = "libsvt_av1",
> +.name   = "libsvt-av1",
>  .long_name  = NULL_IF_CONFIG_SMALL("SVT-AV1(Scalable Video 
> Technology for AV1) encoder"),
>  .priv_data_size = sizeof(SvtContext),
>  .type   = AVMEDIA_TYPE_VIDEO,
> @@ -573,5 +573,5 @@ AVCodec ff_libsvt_av1_encoder = {
>  .priv_class = &class,
>  .defaults   = eb_enc_defaults,
>  .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
> -.wrapper_name   = "libsvt_av1",
> +.wrapper_name   = "libsvtav1",
>  };

The name could also be simply libsvtav1, same as the library (and the
configure option), since unlike libvpx and (in theory) libaom, no other
codec will be supported by it. HEVC is in a different library.

LGTM either way.
___
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] Create and populate AVStream side data packet with contents of ISOBMFF edit list entries

2020-07-29 Thread Andreas Rheinhardt
Matthew Szatmary:
> On Wed, Jul 29, 2020 at 12:22 PM Andreas Rheinhardt
>  wrote:
>>
>> Matthew Szatmary:
>>> Create and populate AVStream side data packet with contents of ISOBMFF
>>> edit list entries
>>>
>>> Signed-off-by: Matthew Szatmary 
>>> ---
>>>  Changelog   |  1 +
>>>  libavcodec/packet.h | 14 ++
>>>  libavformat/mov.c   | 17 -
>>>  3 files changed, 31 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/Changelog b/Changelog
>>> index c37ffa82e1..2d719dd3b1 100644
>>> --- a/Changelog
>>> +++ b/Changelog
>>> @@ -9,6 +9,7 @@ version :
>>>  - VDPAU accelerated HEVC 10/12bit decoding
>>>  - ADPCM IMA Ubisoft APM encoder
>>>  - Rayman 2 APM muxer
>>> +- AV_PKT_DATA_EDIT_LIST added to AVStream side_data
>>>
>>>
>>>  version 4.3:
>>> diff --git a/libavcodec/packet.h b/libavcodec/packet.h
>>> index 0a19a0eff3..5faa594cf5 100644
>>> --- a/libavcodec/packet.h
>>> +++ b/libavcodec/packet.h
>>> @@ -290,6 +290,20 @@ enum AVPacketSideDataType {
>>>   */
>>>  AV_PKT_DATA_S12M_TIMECODE,
>>>
>>> +/**
>>> + * ISO media file edit list side data packet
>>> + * The structure is repeated for each entry in the edit list
>>> + * The number of entries can be calculated
>>> + * by dividing the packet size by the entry size
>>> + * Each entry is 20 bytes and is laid out as follows:
>>> + * @code
>>> + * s64le duration
>>> + * s64le time
>>> + * float32le rate
> Good point, I will make that change.
> 
>>
>> You are obviously copying the MOVElst structure; yet the rate is a 16.16
>> fixed point number in the file and not a float, so one should probably
>> use this.
>>
>>> + * @endcode
>>> + */
>>> +AV_PKT_DATA_EDIT_LIST,
>>> +
>>>  /**
>>>   * The number of side data types.
>>>   * This is not part of the public API/ABI in the sense that it may
>>> diff --git a/libavformat/mov.c b/libavformat/mov.c
>>> index d16840f3df..bb2c940e80 100644
>>> --- a/libavformat/mov.c
>>> +++ b/libavformat/mov.c
>>> @@ -4317,7 +4317,6 @@ static int mov_read_trak(MOVContext *c,
>>> AVIOContext *pb, MOVAtom atom)
>>>  av_freep(&sc->keyframes);
>>>  av_freep(&sc->stts_data);
>>>  av_freep(&sc->stps_data);
>>> -av_freep(&sc->elst_data);
>>
>> This is still needed, namely if an error happens before you can attach
>> the stream side-data. E.g. if an invalid edit list is found and
>> standards compliance is set to strict. Or if av_stream_new_side_data()
>> fails.
> 
> av_freep(&sc->elst_data); is also called in mov_read_close, So it
> would only leak if the API was used incorrectly. But that said, I
> think I can move the logic to mov_read_trak, and make the whole point
> moot. I was just trying to keep it near the other side_data calls.
> 

Sorry, I thought you were removing the av_freep() from mov_read_close();
I didn't realize that it would also be freed in mov_read_trak().

>>
>>>  av_freep(&sc->rap_group);
>>>
>>>  return 0;
>>> @@ -7662,6 +7661,22 @@ static int mov_read_header(AVFormatContext *s)
>>>  AVStream *st = s->streams[i];
>>>  MOVStreamContext *sc = st->priv_data;
>>>
>>> +if (sc->elst_data) {
>>> +uint8_t *elst_data;
>>> +elst_data = av_stream_new_side_data(st,
>>> AV_PKT_DATA_EDIT_LIST, sc->elst_count * 20);
>>
>> I wonder whether it would be advantageouos to use
>> av_stream_add_side_data() here.
> 
> av_stream_new_side_data is just a wrapper for av_malloc +
> av_stream_add_side_data

Yes, and as such I hoped that it could be used to avoid the allocation;
but it is impossible: The MOVElst struct will have padding at the end so
that its size is 24 (ordinarily; compilers are free to insert even more
padding), so that it can't be reused anyway.

> 
>>> +
>>> +if (!elst_data)
>>> +goto fail;
>>> +
>>> +for (j = 0; j < sc->elst_count; j++) {
>>> +AV_WB64((elst_data+(j*20)), sc->elst_data[j].duration);
>>> +AV_WB64((elst_data+(j*20)+8), sc->elst_data[j].time);
>>
>> "WB" stands for "Write Big-endian", yet your documentation says that it
>> is supposed to be little-endian.
> 
> thanks, new patch included
> 
> 
>>
>>> +AV_WB32((elst_data+(j*20)+16), sc->elst_data[j].rate);
>>> +}
>>> +
>>> +av_freep(&sc->elst_data);
>>> +}
>>> +
>>>  switch (st->codecpar->codec_type) {
>>>  case AVMEDIA_TYPE_AUDIO:
>>>  err = ff_replaygain_export(st, s->metadata);
>>>
>>
>> ___
>> 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".
> 
> 
> Create and populate AVStream side data packet with contents of ISOBMFF
> edit list entries
> 
> Signed-off-by: Matthew Szatmary 
> ---
>  Changelog   |  1 +
>  libavcodec/packet.h 

Re: [FFmpeg-devel] [aarch64] improve hscale by 50% with multi-threading

2020-07-29 Thread Sebastian Pop
On Sat, Jul 18, 2020 at 1:35 AM Michael Niedermayer 
wrote:

> Multithreading support should be added in a architecture independant way
>
>
Attached patch moves helper threads up from hscale to
chr_h_scale and lum_h_scale in an architecture independent way.
This new version of the patch improves performance
by up to 135% on Graviton2 Arm64 and by up to 95% on Intel.
Compared to the previous version of the patch,
there is more uninterrupted work per thread that results
in better performance.

Please let me know how I can improve the patch.

There are other functions (lum_convert and chr_convert)
that may benefit from multi-threading.
I have not seen these functions appearing on a hot profile.
Is there a benchmark for those functions?

Thanks,
Sebastian


0001-improve-hscale-with-multi-threading.patch
Description: Binary data
___
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".