[FFmpeg-devel] [PATCH 2/2] avformat/webmdashenc: Use AVCodecDescriptors for codec names

2020-03-30 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/webmdashenc.c | 12 +---
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c
index 182a361eae..303cdd699b 100644
--- a/libavformat/webmdashenc.c
+++ b/libavformat/webmdashenc.c
@@ -61,17 +61,7 @@ typedef struct WebMDashMuxContext {
 
 static const char *get_codec_name(int codec_id)
 {
-switch (codec_id) {
-case AV_CODEC_ID_VP8:
-return "vp8";
-case AV_CODEC_ID_VP9:
-return "vp9";
-case AV_CODEC_ID_VORBIS:
-return "vorbis";
-case AV_CODEC_ID_OPUS:
-return "opus";
-}
-return NULL;
+return avcodec_descriptor_get(codec_id)->name;
 }
 
 static double get_duration(AVFormatContext *s)
-- 
2.20.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] avformat/webmdashenc: Check codec types

2020-03-30 Thread Andreas Rheinhardt
The WebM DASH Manifest muxer only supports VP8, VP9, Vorbis and Opus,
but there was no check for this. The codec type is used to get a pointer
to a string containing the codec name or NULL if it is not one of those
four codecs. Said pointer has then been used without further checks as
string for the %s conversion specifier in an avio_printf()) call which
is undefined behaviour.

This commit adds a check for the supported codec types.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/webmdashenc.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c
index d05b265330..182a361eae 100644
--- a/libavformat/webmdashenc.c
+++ b/libavformat/webmdashenc.c
@@ -516,6 +516,14 @@ static int webm_dash_manifest_write_header(AVFormatContext 
*s)
 double start = 0.0;
 int ret;
 WebMDashMuxContext *w = s->priv_data;
+
+for (unsigned i = 0; i < s->nb_streams; i++) {
+enum AVCodecID codec_id = s->streams[i]->codecpar->codec_id;
+if ((codec_id != AV_CODEC_ID_VP8) && (codec_id != AV_CODEC_ID_VP9) &&
+(codec_id != AV_CODEC_ID_VORBIS) && (codec_id != AV_CODEC_ID_OPUS))
+return AVERROR(EINVAL);
+}
+
 ret = parse_adaptation_sets(s);
 if (ret < 0) {
 goto fail;
-- 
2.20.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] [PATCH] POWER8 VSX vectorization libswscale/input.c Track ticket 5570

2020-03-30 Thread Pestov Vyacheslav
On 25.03.2020 1:12, Carl Eugen Hoyos wrote:

> Am Di., 24. März 2020 um 14:28 Uhr schrieb Pestov Vyacheslav
> :
>> yuy2ToY_c: 10157
>> yuy2ToY_c_vsx: 2353
>>
>> yuy2ToUV_c: 4907
>> yuy2ToUV_c_vsx: 1357
>>
>> rgb24ToY_c: 21172
>> rgb24ToY_c_vsx: 9191
>>
>> rgb24ToUV_c: 33568
>> rgb24ToUV_c_vsx: 12746
>>
>> bgr24ToY_c: 20983
>> bgr24ToY_c_vsx: 9381
>>
>> bgr24ToUV_c: 34513
>> bgr24ToUV_c_vsx: 12708
>>
>> monowhite2Y_c: 5247
>> monowhite2Y_c_vsx: 2099
>>
>> monoblack2Y_c: 5584
>> monoblack2Y_c_vsx: 1993
>>
>> uyvyToY_c: 10111
>> uyvyToY_c_vsx: 1780
>>
>> uyvyToUV_c: 4872
>> uyvyToUV_c_vsx: 1284
>>
>> nvXXtoUV_c: 5128
>> nvXXtoUV_c_vsx: 1456
>>
>> rgbaToA_c: 9930
>> rgbaToA_c_vsx: 2599
>>
>> bswap16Y_c: 10399
>> bswap16Y_c_vsx: 2451
>>
>> rgb16_32ToUV_half_c_template: 42350
>> rgb16_32ToUV_half_c_template_vsx: 18583
>>
>> bswap16UV_c: 11784
>> bswap16UV_c_vsx: 2873
>>
>> planar_rgb_to_y: 24602
>> planar_rgb_to_y_vsx: 10792
>>
>> planar_rgb_to_uv: 35601
>> planar_rgb_to_uv_vsx: 14112
>>
>> planar_rgb16_to_y: 25686
>> planar_rgb16_to_y_vsx: 10293
>>
>> planar_rgb16_to_uv: 36367
>> planar_rgb16_to_uv_vsx: 13575
>>
>> yvy2ToUV_c: 4879
>> yvy2ToUV_c_vsx: 1239
>>
>> read_ya16be_gray_c: 9591
>> read_ya16be_gray_c_vsx: 4164
>>
>> read_ya16be_alpha_c: 9390
>> read_ya16be_alpha_c_vsx: 1874
>>
>> read_ya16le_gray_c: 9884
>> read_ya16le_gray_c_vsx: 4224
>>
>> read_ya16le_alpha_c: 9403
>> read_ya16le_alpha_c_vsx: 2026
>>
>> planar_rgb_to_a: 10262
>> planar_rgb_to_a_vsx: 9361
>>
>> planar_rgb16_to_a: 9554
>> planar_rgb16_to_a_vsx: 9393
>>
>> read_ayuv64le_Y_c: 10457
>> read_ayuv64le_Y_c_vsx: 7703
>>
>> read_ayuv64le_A_c: 9404
>> read_ayuv64le_A_c_vsx: 2797
>>
>> read_ayuv64le_UV_c: 9464
>> read_ayuv64le_UV_c_vsx: 3781
>>
>> p010LEToY_c: 9546
>> p010LEToY_c_vsx: 2422
>>
>> p010LEToUV_c: 6390
>> p010LEToUV_c_vsx: 2681
>>
>> p010BEToY_c: 9836
>> p010BEToY_c_vsx: 2572
>>
>> p010BEToUV_c: 7022
>> p010BEToUV_c_vsx: 2660
>>
>> p016LEToUV_c: 5022
>> p016LEToUV_c_vsx: 2447
>>
>> p016BEToUV_c: 5293
>> p016BEToUV_c_vsx: 2307
> To make our lives a little easier, could you tell us what you tested
> and how we can reproduce your results?
>
> Also: Is your patch expected to be bit-exact? If yes, do you
> have a script that allows to compare C and vsx code?
> If not, how did you test your code?
> (Or does fate cover these conversions? I wouldn't expect so.)
>
> Thank you, Carl Eugen
> ___
> 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".

Hi, yes I am using some scripts(see attached archive):

1) Put macros into tested functions in input_vsx.c and input.c   (START_TIMER 
and STOP_TIMET). 
You can take files with macros from my dropbox 
https://www.dropbox.com/sh/eoed5pjp9a9psx0/AACpsa6PKGAIl5pYF58sHeRda?dl=0

2) I am generating some random input file with dd utility. For example:

dd if=/dev/urandom of=/tmp/test.raw bs=1024 count=40900

3) Run script script ffmpeg_bench.sh from directory where created test.raw

cd /tmp

bash ./ffmpeg_bench.sh

4) Run python3 script print_result.py.  This script takes the ffmpeg_bench 
results from files bench_cpu.txt and bench_vsx.txt, calculates the average 
values and displays in a convenient form 

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

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

[FFmpeg-devel] [PATCH V1 1/4] lavf/flvdec: set AVFMT_TS_DISCONT flag on FLV demuxer

2020-03-30 Thread Jun Zhao
From: Jun Zhao 

There have been some reports about FLV timestamp discontinuities present.
e,g, the file recorded from live RTMP FLV streaming, so add
AVFMT_TS_DISCONT flag on FLV demuxer and also update the fate test
fate-filter-aresample for test sample nellymoser-discont.flv.

BTW: live_flv demuxer also enabled the AVFMT_TS_DISCONT flag.

Signed-off-by: Jun Zhao 
---
 libavformat/flvdec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 7c3e5b0..82afc31 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -1365,6 +1365,7 @@ AVInputFormat ff_flv_demuxer = {
 .read_close = flv_read_close,
 .extensions = "flv",
 .priv_class = &flv_class,
+.flags  = AVFMT_TS_DISCONT
 };
 
 static const AVClass live_flv_class = {
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH V1 2/4] lavc/hevcdec: fix the HEVC decoder crash when memory over-read

2020-03-30 Thread Jun Zhao
From: qoroliang 

Fix an occasional crash for hevc decoder in ARM 64 platform, the
root cause is the memory over read(read cross the memory boundary)
in SAO NENO functions ff_hevc_sao_band_filter_neon_8 and
ff_hevc_sao_edge_filter_neon_8.

After this fix, the crash disapper in the massive Android phone
test.

Signed-off-by: qoroliang 
---
 libavcodec/arm/hevcdsp_sao_neon.S | 20 
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/libavcodec/arm/hevcdsp_sao_neon.S 
b/libavcodec/arm/hevcdsp_sao_neon.S
index 3471679..8fd9d1e 100644
--- a/libavcodec/arm/hevcdsp_sao_neon.S
+++ b/libavcodec/arm/hevcdsp_sao_neon.S
@@ -35,10 +35,10 @@ function ff_hevc_sao_band_filter_neon_8, export=1
 vmov.u16q15,  #1
 vmov.u8 q14,  #32
 0:  pld  [r1]
-vld1.8   {d16},  [r1], r3
 cmp  r5,#4
 beq  4f
 8:  subs r4,#1
+vld1.8   {d16},  [r1], r3
 vshr.u8  d17,   d16,  #3   // index = [src>>3]
 vshll.u8 q9,d17,  #1   // lowIndex = 2*index
 vadd.u16 q11,   q9,   q15  // highIndex = (2*index+1) << 8
@@ -54,7 +54,6 @@ function ff_hevc_sao_band_filter_neon_8, export=1
 vaddw.u8 q13,   q12,   d16
 vqmovun.s16  d8, q13
 vst1.8d8,   [r0],  r2
-vld1.8   {d16}, [r1],  r3
 bne  8b
 subs r5,#8
 beq  99f
@@ -65,6 +64,7 @@ function ff_hevc_sao_band_filter_neon_8, export=1
 mov r1, r7
 b0b
 4:  subs r4,#1
+vld1.32   {d16[0]},  [r1],  r3
 vshr.u8  d17,   d16,  #3  // src>>3
 vshll.u8 q9,d17,  #1   // lowIndex = 2*index
 vadd.u16 q11,   q9,   q15  // highIndex = (2*index+1) << 8
@@ -80,7 +80,6 @@ function ff_hevc_sao_band_filter_neon_8, export=1
 vaddw.u8 q13,   q12,   d16
 vqmovun.s16 d14,   q13
 vst1.32   d14[0],[r0], r2
-vld1.32   {d16[0]},  [r1], r3
 bne  4b
 b99f
 99:
@@ -110,12 +109,12 @@ function ff_hevc_sao_edge_filter_neon_8, export=1
 mov  r11,r1
 add  r11,r9   // src[x + b_stride]
 pld  [r1]
-vld1.8   {d16},  [r1],  r3// src[x]  8x8bit
-vld1.8   {d17},  [r10], r3// src[x + a_stride]
-vld1.8   {d18},  [r11], r3// src[x + b_stride]
 cmp  r5, #4
 beq  4f
 8:  subs r4, #1
+vld1.8   {d16},  [r1],  r3// src[x]  8x8bit
+vld1.8   {d17},  [r10], r3// src[x + a_stride]
+vld1.8   {d18},  [r11], r3// src[x + b_stride]
 vcgt.u8  d8, d16,   d17
 vshr.u8  d9, d8,#7
 vclt.u8  d8, d16,   d17
@@ -136,9 +135,6 @@ function ff_hevc_sao_edge_filter_neon_8, export=1
 vaddw.u8 q12,q11,   d16
 vqmovun.s16  d26,   q12
 vst1.8   d26,[r0],  r2
-vld1.8   {d16},  [r1],  r3// src[x]  8x8bit
-vld1.8   {d17},  [r10], r3// src[x + a_stride]
-vld1.8   {d18},  [r11], r3// src[x + b_stride]
 bne  8b
 subs r5, #8
 beq  99f
@@ -149,6 +145,9 @@ function ff_hevc_sao_edge_filter_neon_8, export=1
 mov  r1, r7
 b0b
 4:  subs r4,#1
+vld1.32   {d16[0]},  [r1],  r3
+vld1.32   {d17[0]},  [r10], r3// src[x + a_stride]
+vld1.32   {d18[0]},  [r11], r3// src[x + b_stride]
 vcgt.u8  d8, d16,   d17
 vshr.u8  d9, d8,#7
 vclt.u8  d8, d16,   d17
@@ -169,9 +168,6 @@ function ff_hevc_sao_edge_filter_neon_8, export=1
 vaddw.u8 q12,q11,   d16
 vqmovun.s16  d26,   q12
 vst1.32  d26[0], [r0],  r2
-vld1.32   {d16[0]},  [r1],  r3
-vld1.32   {d17[0]},  [r10], r3// src[x + a_stride]
-vld1.32   {d18[0]},  [r11], r3// src[x + b_stride]
 bne  4b
 b99f
 99:
-- 
2.7.4

___
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 V1 2/4] lavc/hevcdec: fix the HEVC decoder crash when memory over-read

2020-03-30 Thread myp...@gmail.com
On Mon, Mar 30, 2020 at 4:31 PM Jun Zhao  wrote:
>
> From: qoroliang 
>
> Fix an occasional crash for hevc decoder in ARM 64 platform, the
  typo: it's ARM 32 bits platform, not 64,
fixed in local
> root cause is the memory over read(read cross the memory boundary)
> in SAO NENO functions ff_hevc_sao_band_filter_neon_8 and
> ff_hevc_sao_edge_filter_neon_8.
>
> After this fix, the crash disapper in the massive Android phone
> test.
>
> Signed-off-by: qoroliang 
> ---
>  libavcodec/arm/hevcdsp_sao_neon.S | 20 
>  1 file changed, 8 insertions(+), 12 deletions(-)
>
> diff --git a/libavcodec/arm/hevcdsp_sao_neon.S 
> b/libavcodec/arm/hevcdsp_sao_neon.S
> index 3471679..8fd9d1e 100644
> --- a/libavcodec/arm/hevcdsp_sao_neon.S
> +++ b/libavcodec/arm/hevcdsp_sao_neon.S
> @@ -35,10 +35,10 @@ function ff_hevc_sao_band_filter_neon_8, export=1
>  vmov.u16q15,  #1
>  vmov.u8 q14,  #32
>  0:  pld  [r1]
> -vld1.8   {d16},  [r1], r3
>  cmp  r5,#4
>  beq  4f
>  8:  subs r4,#1
> +vld1.8   {d16},  [r1], r3
>  vshr.u8  d17,   d16,  #3   // index = [src>>3]
>  vshll.u8 q9,d17,  #1   // lowIndex = 2*index
>  vadd.u16 q11,   q9,   q15  // highIndex = (2*index+1) << 8
> @@ -54,7 +54,6 @@ function ff_hevc_sao_band_filter_neon_8, export=1
>  vaddw.u8 q13,   q12,   d16
>  vqmovun.s16  d8, q13
>  vst1.8d8,   [r0],  r2
> -vld1.8   {d16}, [r1],  r3
>  bne  8b
>  subs r5,#8
>  beq  99f
> @@ -65,6 +64,7 @@ function ff_hevc_sao_band_filter_neon_8, export=1
>  mov r1, r7
>  b0b
>  4:  subs r4,#1
> +vld1.32   {d16[0]},  [r1],  r3
>  vshr.u8  d17,   d16,  #3  // src>>3
>  vshll.u8 q9,d17,  #1   // lowIndex = 2*index
>  vadd.u16 q11,   q9,   q15  // highIndex = (2*index+1) << 8
> @@ -80,7 +80,6 @@ function ff_hevc_sao_band_filter_neon_8, export=1
>  vaddw.u8 q13,   q12,   d16
>  vqmovun.s16 d14,   q13
>  vst1.32   d14[0],[r0], r2
> -vld1.32   {d16[0]},  [r1], r3
>  bne  4b
>  b99f
>  99:
> @@ -110,12 +109,12 @@ function ff_hevc_sao_edge_filter_neon_8, export=1
>  mov  r11,r1
>  add  r11,r9   // src[x + b_stride]
>  pld  [r1]
> -vld1.8   {d16},  [r1],  r3// src[x]  8x8bit
> -vld1.8   {d17},  [r10], r3// src[x + a_stride]
> -vld1.8   {d18},  [r11], r3// src[x + b_stride]
>  cmp  r5, #4
>  beq  4f
>  8:  subs r4, #1
> +vld1.8   {d16},  [r1],  r3// src[x]  8x8bit
> +vld1.8   {d17},  [r10], r3// src[x + a_stride]
> +vld1.8   {d18},  [r11], r3// src[x + b_stride]
>  vcgt.u8  d8, d16,   d17
>  vshr.u8  d9, d8,#7
>  vclt.u8  d8, d16,   d17
> @@ -136,9 +135,6 @@ function ff_hevc_sao_edge_filter_neon_8, export=1
>  vaddw.u8 q12,q11,   d16
>  vqmovun.s16  d26,   q12
>  vst1.8   d26,[r0],  r2
> -vld1.8   {d16},  [r1],  r3// src[x]  8x8bit
> -vld1.8   {d17},  [r10], r3// src[x + a_stride]
> -vld1.8   {d18},  [r11], r3// src[x + b_stride]
>  bne  8b
>  subs r5, #8
>  beq  99f
> @@ -149,6 +145,9 @@ function ff_hevc_sao_edge_filter_neon_8, export=1
>  mov  r1, r7
>  b0b
>  4:  subs r4,#1
> +vld1.32   {d16[0]},  [r1],  r3
> +vld1.32   {d17[0]},  [r10], r3// src[x + a_stride]
> +vld1.32   {d18[0]},  [r11], r3// src[x + b_stride]
>  vcgt.u8  d8, d16,   d17
>  vshr.u8  d9, d8,#7
>  vclt.u8  d8, d16,   d17
> @@ -169,9 +168,6 @@ function ff_hevc_sao_edge_filter_neon_8, export=1
>  vaddw.u8 q12,q11,   d16
>  vqmovun.s16  d26,   q12
>  vst1.32  d26[0], [r0],  r2
> -vld1.32   {d16[0]},  [r1],  r3
> -vld1.32   {d17[0]},  [r10], r3// src[x + a_stride]
> -vld1.32   {d18[0]},  [r11], r3// src[x + b_stride]
>  bne  4b
>  b99f
>  99:
> --
> 2.7.4
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH V1 3/4] lavf/mpegts: support DOVIVideo Stream Descriptor

2020-03-30 Thread Jun Zhao
From: vacingfang 

support DOVIVideo Stream Descriptor from Dolby Vision Streams
Within the MPEG-2 Transport Stream Format V1.2

From the spec: https://www.dolby.com/us/en/technologies/\
dolby-vision/dolby-vision-bitstreams-in-mpeg-2-transport-\
stream-multiplex-v1.2.pdf.

export the Dolby Vision profile/level with metadata.

Signed-off-by: vacingfang 
---
 libavformat/mpegts.c | 21 +
 1 file changed, 21 insertions(+)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 7f56bac..e035605 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2135,6 +2135,27 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, 
AVStream *st, int stream_type
 st->request_probe= 0;
 }
 break;
+case 0xb0: /* dolby vision video stream descriptor*/
+{
+int version_major, version_minor, profile, level;
+char str_buf[32];
+if (desc_end - *pp < 4) // 8 + 8 + 7 + 6 + 1 + 1 + 1
+return AVERROR_INVALIDDATA;
+
+version_major = get8(pp, desc_end);
+version_minor = get8(pp, desc_end);
+profile = get16(pp, desc_end);
+level   = (profile >> 3) & 0x3f;// 6 bits
+profile = (profile >> 9) & 0x7f;// 7 bits
+av_log(fc, AV_LOG_DEBUG, "dolby vision stream, version: %d.%d, 
profile: %d, level: %d\n",
+version_major, version_minor, profile, level);
+
+snprintf(str_buf, sizeof(str_buf), "%d", profile);
+av_dict_set(&st->metadata, "dovi_profile", str_buf, 0);
+snprintf(str_buf, sizeof(str_buf), "%d", level);
+av_dict_set(&st->metadata, "dovi_level", str_buf, 0);
+}
+break;
 default:
 break;
 }
-- 
2.7.4

___
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 V1 1/4] lavf/flvdec: set AVFMT_TS_DISCONT flag on FLV demuxer

2020-03-30 Thread myp...@gmail.com
On Mon, Mar 30, 2020 at 4:30 PM Jun Zhao  wrote:
>
> From: Jun Zhao 
>
> There have been some reports about FLV timestamp discontinuities present.
> e,g, the file recorded from live RTMP FLV streaming, so add
> AVFMT_TS_DISCONT flag on FLV demuxer and also update the fate test
> fate-filter-aresample for test sample nellymoser-discont.flv.
>
> BTW: live_flv demuxer also enabled the AVFMT_TS_DISCONT flag.
>
> Signed-off-by: Jun Zhao 
> ---
>  libavformat/flvdec.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
> index 7c3e5b0..82afc31 100644
> --- a/libavformat/flvdec.c
> +++ b/libavformat/flvdec.c
> @@ -1365,6 +1365,7 @@ AVInputFormat ff_flv_demuxer = {
>  .read_close = flv_read_close,
>  .extensions = "flv",
>  .priv_class = &flv_class,
> +.flags  = AVFMT_TS_DISCONT
>  };
>
>  static const AVClass live_flv_class = {
> --
> 2.7.4
>

Need to update the fate test ref file from:
https://drive.google.com/file/d/1hRKzJlkX-EIcV9SJnL5fnK4zx6QecgyC/view?usp=sharing
for this patch
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH V1 4/4] lavf/mov: support dvcC/dvvC box for Dolby Vision

2020-03-30 Thread Jun Zhao
From: vacingfang 

support dvcC/dvcC box from spec Dolby Vision Streams Within the
ISO Base MediaFile Format Version 2.1.2
(https://www.dolby.com/in/en/technologies/dolby-vision/dolby-vision\
-bitstreams-within-the-iso-base-media-file-format-v2.1.2.pdf)

And export the Dolby Vision profile/level with metadata.

Signed-off-by: vacingfang 
---
 libavformat/mov.c | 33 +
 1 file changed, 33 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index f280f36..76d90a7 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -6766,6 +6766,37 @@ static int mov_read_dmlp(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 return 0;
 }
 
+static int mov_read_dvcc_dvvc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+{
+AVStream *st;
+uint8_t version_major, version_minor, profile, level;
+char str_buf[32];
+uint16_t tmp;
+
+if (c->fc->nb_streams < 1)
+return 0;
+st = c->fc->streams[c->fc->nb_streams-1];
+
+if ((uint64_t)atom.size > (1<<30) || atom.size < 4)
+return AVERROR_INVALIDDATA;
+
+version_major = avio_r8(pb);
+version_minor = avio_r8(pb);
+
+tmp = avio_rb16(pb);
+profile = (tmp >> 9) & 0x7f;// 7bits
+level   = (tmp >> 3) & 0x3f;// 6 bits
+av_log(c, AV_LOG_DEBUG, "dolby vision stream, version: %d.%d, profile: %d, 
level: %d\n",
+version_major, version_minor, profile, level);
+
+snprintf(str_buf, sizeof(str_buf), "%d", profile);
+av_dict_set(&st->metadata, "dovi_profile", str_buf, 0);
+snprintf(str_buf, sizeof(str_buf), "%d", level);
+av_dict_set(&st->metadata, "dovi_level", str_buf, 0);
+
+return 0;
+}
+
 static const MOVParseTableEntry mov_default_parse_table[] = {
 { MKTAG('A','C','L','R'), mov_read_aclr },
 { MKTAG('A','P','R','G'), mov_read_avid },
@@ -6861,6 +6892,8 @@ static const MOVParseTableEntry mov_default_parse_table[] 
= {
 { MKTAG('v','p','c','C'), mov_read_vpcc },
 { MKTAG('m','d','c','v'), mov_read_mdcv },
 { MKTAG('c','l','l','i'), mov_read_clli },
+{ MKTAG('d','v','c','C'), mov_read_dvcc_dvvc },
+{ MKTAG('d','v','v','C'), mov_read_dvcc_dvvc },
 { 0, NULL }
 };
 
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH v1 1/2] avfilter/vf_subtitles: remove unneeded ifdef

2020-03-30 Thread lance . lmwang
From: Limin Wang 

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

diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c
index a3b4029af4..2f312b0ba8 100644
--- a/libavfilter/vf_subtitles.c
+++ b/libavfilter/vf_subtitles.c
@@ -30,10 +30,8 @@
 #include 
 
 #include "config.h"
-#if CONFIG_SUBTITLES_FILTER
-# include "libavcodec/avcodec.h"
-# include "libavformat/avformat.h"
-#endif
+#include "libavcodec/avcodec.h"
+#include "libavformat/avformat.h"
 #include "libavutil/avstring.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
-- 
2.21.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 v1 2/2] avfilter/vf_subtitles: add force_style option for ass subtitle filter

2020-03-30 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 doc/filters.texi   |  4 
 libavfilter/vf_subtitles.c | 23 +++
 2 files changed, 27 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 328e984e92..d26d90d1bb 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -6399,6 +6399,10 @@ Slower shaper using OpenType for substitutions and 
positioning
 @end table
 
 The default is @code{auto}.
+
+@item force_style
+Override default style or script info parameters of the subtitles. It accepts a
+string containing ASS style format @code{KEY=VALUE} couples separated by ",".
 @end table
 
 @section atadenoise
diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c
index 2f312b0ba8..e3ad8b8d94 100644
--- a/libavfilter/vf_subtitles.c
+++ b/libavfilter/vf_subtitles.c
@@ -218,6 +218,7 @@ static const AVOption ass_options[] = {
 {"auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = -1},  
INT_MIN, INT_MAX, FLAGS, "shaping_mode"},
 {"simple",  "simple shaping",  0, AV_OPT_TYPE_CONST, {.i64 = 
ASS_SHAPING_SIMPLE},  INT_MIN, INT_MAX, FLAGS, "shaping_mode"},
 {"complex", "complex shaping", 0, AV_OPT_TYPE_CONST, {.i64 = 
ASS_SHAPING_COMPLEX}, INT_MIN, INT_MAX, FLAGS, "shaping_mode"},
+{"force_style",  "force subtitle style", OFFSET(force_style),  
AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS},
 {NULL},
 };
 
@@ -234,6 +235,28 @@ static av_cold int init_ass(AVFilterContext *ctx)
 /* Initialize fonts */
 ass_set_fonts(ass->renderer, NULL, NULL, 1, NULL, 1);
 
+if (ass->force_style) {
+char **list = NULL;
+char *temp = NULL;
+char *ptr = av_strtok(ass->force_style, ",", &temp);
+int i = 0;
+while (ptr) {
+av_dynarray_add(&list, &i, ptr);
+if (!list) {
+ret = AVERROR(ENOMEM);
+return ret;
+}
+ptr = av_strtok(NULL, ",", &temp);
+}
+av_dynarray_add(&list, &i, NULL);
+if (!list) {
+ret = AVERROR(ENOMEM);
+return ret;
+}
+ass_set_style_overrides(ass->library, list);
+av_free(list);
+}
+
 ass->track = ass_read_file(ass->library, ass->filename, NULL);
 if (!ass->track) {
 av_log(ctx, AV_LOG_ERROR,
-- 
2.21.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 1/7] libavutil: add API for exporting video frame quantizers

2020-03-30 Thread Anton Khirnov
From: Juan De León 

This is intended to replace the deprecated the AV_FRAME_DATA_QP_TABLE*
API and extend it to a wider range of codecs.

In the future, it may also be extended to support other encoding
parameters such as motion vectors.

Additional changes by Anton Khirnov  with suggestions
by Lynne .

Signed-off-by: Juan De León 
Signed-off-by: Michael Niedermayer 
Signed-off-by: Anton Khirnov 
---
 libavutil/Makefile   |   4 +-
 libavutil/frame.c|   1 +
 libavutil/frame.h|   5 ++
 libavutil/video_enc_params.c |  78 +
 libavutil/video_enc_params.h | 128 +++
 5 files changed, 215 insertions(+), 1 deletion(-)
 create mode 100644 libavutil/video_enc_params.c
 create mode 100644 libavutil/video_enc_params.h

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 8feb029a3a..8c76052c97 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -79,6 +79,7 @@ HEADERS = adler32.h   
  \
   tree.h\
   twofish.h \
   version.h \
+  video_enc_params.h\
   xtea.h\
   tea.h \
   tx.h  \
@@ -165,7 +166,8 @@ OBJS = adler32.o
\
tx.o \
tx_float.o   \
tx_double.o  \
-   tx_int32.o
+   tx_int32.o  
\
+   video_enc_params.o
 
 OBJS-$(CONFIG_CUDA) += hwcontext_cuda.o
 OBJS-$(CONFIG_D3D11VA)  += hwcontext_d3d11va.o
diff --git a/libavutil/frame.c b/libavutil/frame.c
index e4038096c2..2f9ba5b6c0 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -842,6 +842,7 @@ const char *av_frame_side_data_name(enum 
AVFrameSideDataType type)
 #endif
 case AV_FRAME_DATA_DYNAMIC_HDR_PLUS: return "HDR Dynamic Metadata 
SMPTE2094-40 (HDR10+)";
 case AV_FRAME_DATA_REGIONS_OF_INTEREST: return "Regions Of Interest";
+case AV_FRAME_DATA_VIDEO_ENC_PARAMS:return "Video encoding 
parameters";
 }
 return NULL;
 }
diff --git a/libavutil/frame.h b/libavutil/frame.h
index b5afb58634..fc67db0f6c 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -179,6 +179,11 @@ enum AVFrameSideDataType {
  * array element is implied by AVFrameSideData.size / 
AVRegionOfInterest.self_size.
  */
 AV_FRAME_DATA_REGIONS_OF_INTEREST,
+
+/**
+ * Encoding parameters for a video frame, as described by AVVideoEncParams.
+ */
+AV_FRAME_DATA_VIDEO_ENC_PARAMS,
 };
 
 enum AVActiveFormatDescription {
diff --git a/libavutil/video_enc_params.c b/libavutil/video_enc_params.c
new file mode 100644
index 00..43668dcd12
--- /dev/null
+++ b/libavutil/video_enc_params.c
@@ -0,0 +1,78 @@
+/*
+ * 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 
+
+#include "buffer.h"
+#include "common.h"
+#include "frame.h"
+#include "mem.h"
+#include "video_enc_params.h"
+
+AVVideoEncParams *av_video_enc_params_alloc(unsigned int nb_blocks, size_t 
*out_size)
+{
+AVVideoEncParams *par;
+size_t size;
+int i;
+
+size = sizeof(*par);
+if (nb_blocks > SIZE_MAX / sizeof(AVVideoBlockParams) ||
+nb_blocks * sizeof(AVVideoBlockParams) > SIZE_MAX - size)
+return NULL;
+size += sizeof(AVVideoBlockParams) * nb_blocks;
+
+par = av_mallocz(size);
+if (!par)
+return NULL;
+
+par->nb_blocks = nb_blocks;
+par->block_size= sizeof(AVVideoBlockParams);
+par->blocks_offset = sizeof(*par);
+
+par->type = AV_VIDEO_ENC_PARAMS_NONE;
+
+if (out_size)
+*out_size = size;
+
+

[FFmpeg-devel] [PATCH 5/7] h264dec: support exporting QP tables through the AVVideoEncParams API

2020-03-30 Thread Anton Khirnov
---
 libavcodec/h264_picture.c|  8 +-
 libavcodec/h264_slice.c  |  9 +++
 libavcodec/h264dec.c | 48 
 libavcodec/h264dec.h |  6 +
 libavutil/video_enc_params.h |  1 +
 5 files changed, 71 insertions(+), 1 deletion(-)

diff --git a/libavcodec/h264_picture.c b/libavcodec/h264_picture.c
index 2113947d1d..eec5e9fb9a 100644
--- a/libavcodec/h264_picture.c
+++ b/libavcodec/h264_picture.c
@@ -54,6 +54,7 @@ void ff_h264_unref_picture(H264Context *h, H264Picture *pic)
 
 av_buffer_unref(&pic->qscale_table_buf);
 av_buffer_unref(&pic->mb_type_buf);
+av_buffer_unref(&pic->pps_buf);
 for (i = 0; i < 2; i++) {
 av_buffer_unref(&pic->motion_val_buf[i]);
 av_buffer_unref(&pic->ref_index_buf[i]);
@@ -77,12 +78,14 @@ int ff_h264_ref_picture(H264Context *h, H264Picture *dst, 
H264Picture *src)
 
 dst->qscale_table_buf = av_buffer_ref(src->qscale_table_buf);
 dst->mb_type_buf  = av_buffer_ref(src->mb_type_buf);
-if (!dst->qscale_table_buf || !dst->mb_type_buf) {
+dst->pps_buf  = av_buffer_ref(src->pps_buf);
+if (!dst->qscale_table_buf || !dst->mb_type_buf || !dst->pps_buf) {
 ret = AVERROR(ENOMEM);
 goto fail;
 }
 dst->qscale_table = src->qscale_table;
 dst->mb_type  = src->mb_type;
+dst->pps  = src->pps;
 
 for (i = 0; i < 2; i++) {
 dst->motion_val_buf[i] = av_buffer_ref(src->motion_val_buf[i]);
@@ -120,6 +123,9 @@ int ff_h264_ref_picture(H264Context *h, H264Picture *dst, 
H264Picture *src)
 dst->recovered = src->recovered;
 dst->invalid_gap   = src->invalid_gap;
 dst->sei_recovery_frame_cnt = src->sei_recovery_frame_cnt;
+dst->mb_width  = src->mb_width;
+dst->mb_height = src->mb_height;
+dst->mb_stride = src->mb_stride;
 
 return 0;
 fail:
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index af30f6267b..775bf94f2e 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -243,6 +243,15 @@ static int alloc_picture(H264Context *h, H264Picture *pic)
 pic->ref_index[i]  = pic->ref_index_buf[i]->data;
 }
 
+pic->pps_buf = av_buffer_ref(h->ps.pps_ref);
+if (!pic->pps_buf)
+goto fail;
+pic->pps = (const PPS*)pic->pps_buf->data;
+
+pic->mb_width  = h->mb_width;
+pic->mb_height = h->mb_height;
+pic->mb_stride = h->mb_stride;
+
 return 0;
 fail:
 ff_h264_unref_picture(h, pic);
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index fec1adfeed..242eeb9677 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -32,6 +32,8 @@
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
 #include "libavutil/stereo3d.h"
+#include "libavutil/video_enc_params.h"
+
 #include "internal.h"
 #include "bytestream.h"
 #include "cabac.h"
@@ -831,6 +833,43 @@ static int get_consumed_bytes(int pos, int buf_size)
 return pos;
 }
 
+static int h264_export_enc_params(AVFrame *f, H264Picture *p)
+{
+AVVideoEncParams *par;
+unsigned int nb_mb = p->mb_height * p->mb_width;
+unsigned int x, y;
+
+par = av_video_enc_params_create_side_data(f, nb_mb);
+if (!par)
+return AVERROR(ENOMEM);
+
+par->type = AV_VIDEO_ENC_PARAMS_H264;
+
+par->qp = p->pps->init_qp;
+
+par->delta_qp[1][0] = p->pps->chroma_qp_index_offset[0];
+par->delta_qp[1][1] = p->pps->chroma_qp_index_offset[0];
+par->delta_qp[2][0] = p->pps->chroma_qp_index_offset[1];
+par->delta_qp[2][1] = p->pps->chroma_qp_index_offset[1];
+
+for (y = 0; y < p->mb_height; y++)
+for (x = 0; x < p->mb_width; x++) {
+const unsigned int block_idx = y * p->mb_width + x;
+const unsigned int mb_xy = y * p->mb_stride + x;
+AVVideoBlockParams *b = av_video_enc_params_block(par, block_idx);
+
+b->src_x = x * 16;
+b->src_y = y * 16;
+b->w = 16;
+b->h = 16;
+
+b->delta_qp = p->qscale_table[mb_xy] - par->qp;
+}
+
+
+return 0;
+}
+
 static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
 {
 AVFrame *src = srcp->f;
@@ -845,7 +884,16 @@ static int output_frame(H264Context *h, AVFrame *dst, 
H264Picture *srcp)
 if (srcp->sei_recovery_frame_cnt == 0)
 dst->key_frame = 1;
 
+if (h->avctx->export_side_data & AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS) {
+ret = h264_export_enc_params(dst, srcp);
+if (ret < 0)
+goto fail;
+}
+
 return 0;
+fail:
+av_frame_unref(dst);
+return ret;
 }
 
 static int is_extra(const uint8_t *buf, int buf_size)
diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h
index 530e2d4071..29c4d4e42c 100644
--- a/libavcodec/h264dec.h
+++ b/libavcodec/h264dec.h
@@ -161,6 +161,12 @@ typedef struct H264Picture {
 int recovered;  ///< picture at IDR or recovery point + recovery 
count
 int invalid_gap;
 int s

[FFmpeg-devel] [PATCH 3/7] lavc: add a flag for exporting AVVideoEncParams from decoders

2020-03-30 Thread Anton Khirnov
---
 libavcodec/avcodec.h   | 5 +
 libavcodec/options_table.h | 1 +
 2 files changed, 6 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 78c483c25c..436a21f99c 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1120,6 +1120,11 @@ typedef struct RcOverride{
  * Export encoder Producer Reference Time through packet side data
  */
 #define AV_CODEC_EXPORT_DATA_PRFT(1 << 1)
+/**
+ * Decoding only.
+ * Export the AVVideoEncParams structure through frame side data.
+ */
+#define AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS (1 << 2)
 
 /**
  * Pan Scan area.
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 54366747ca..695fa5c211 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -81,6 +81,7 @@ static const AVOption avcodec_options[] = {
 {"export_side_data", "Export metadata as side data", OFFSET(export_side_data), 
AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT}, 0, UINT_MAX, A|V|S|D|E, 
"export_side_data"},
 {"mvs", "export motion vectors through frame side data", 0, AV_OPT_TYPE_CONST, 
{.i64 = AV_CODEC_EXPORT_DATA_MVS}, INT_MIN, INT_MAX, V|D, "export_side_data"},
 {"prft", "export Producer Reference Time through packet side data", 0, 
AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_PRFT}, INT_MIN, INT_MAX, 
A|V|S|E, "export_side_data"},
+{"venc_params", "export video encoding parameters through frame side data", 0, 
AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS}, INT_MIN, 
INT_MAX, A|V|S|E, "export_side_data"},
 {"time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, 
INT_MAX},
 {"g", "set the group of picture (GOP) size", OFFSET(gop_size), 
AV_OPT_TYPE_INT, {.i64 = 12 }, INT_MIN, INT_MAX, V|E},
 {"ar", "set audio sampling rate (in Hz)", OFFSET(sample_rate), 
AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, A|D|E},
-- 
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".

[FFmpeg-devel] [PATCH 2/7] vf_showinfo: support AV_FRAME_DATA_VIDEO_ENC_PARAMS

2020-03-30 Thread Anton Khirnov
---
 libavfilter/vf_showinfo.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 71534d1fa8..0025ee63fc 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -36,6 +36,7 @@
 #include "libavutil/timestamp.h"
 #include "libavutil/timecode.h"
 #include "libavutil/mastering_display_metadata.h"
+#include "libavutil/video_enc_params.h"
 
 #include "avfilter.h"
 #include "internal.h"
@@ -170,6 +171,25 @@ static void dump_content_light_metadata(AVFilterContext 
*ctx, AVFrameSideData *s
metadata->MaxCLL, metadata->MaxFALL);
 }
 
+static void dump_video_enc_params(AVFilterContext *ctx, AVFrameSideData *sd)
+{
+AVVideoEncParams *par = (AVVideoEncParams*)sd->data;
+int plane, acdc;
+
+av_log(ctx, AV_LOG_INFO, "video encoding parameters: type %d; ", 
par->type);
+if (par->qp)
+av_log(ctx, AV_LOG_INFO, "qp=%d; ", par->qp);
+for (plane = 0; plane < FF_ARRAY_ELEMS(par->delta_qp); plane++)
+for (acdc = 0; acdc < FF_ARRAY_ELEMS(par->delta_qp[plane]); acdc++) {
+int delta_qp = par->delta_qp[plane][acdc];
+if (delta_qp)
+av_log(ctx, AV_LOG_INFO, "delta_qp[%d][%d]=%d; ",
+   plane, acdc, delta_qp);
+}
+if (par->nb_blocks)
+av_log(ctx, AV_LOG_INFO, "%u blocks; ", par->nb_blocks);
+}
+
 static void dump_color_property(AVFilterContext *ctx, AVFrame *frame)
 {
 const char *color_range_str = av_color_range_name(frame->color_range);
@@ -351,6 +371,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 av_log(ctx, AV_LOG_INFO, "GOP timecode - %s", tcbuf);
 break;
 }
+case AV_FRAME_DATA_VIDEO_ENC_PARAMS:
+dump_video_enc_params(ctx, sd);
+break;
 default:
 av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)",
sd->type, sd->size);
-- 
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".

[FFmpeg-devel] [PATCH 6/7] vp9dec: factorise freeing per-tile allocated data

2020-03-30 Thread Anton Khirnov
---
 libavcodec/vp9.c | 36 
 1 file changed, 16 insertions(+), 20 deletions(-)

diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index 7ee375d4d0..e03891887b 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -93,6 +93,12 @@ static void vp9_free_entries(AVCodecContext *avctx) {}
 static int vp9_alloc_entries(AVCodecContext *avctx, int n) { return 0; }
 #endif
 
+static void vp9_tile_data_free(VP9TileData *td)
+{
+av_freep(&td->b_base);
+av_freep(&td->block_base);
+}
+
 static void vp9_frame_unref(AVCodecContext *avctx, VP9Frame *f)
 {
 ff_thread_release_buffer(avctx, &f->tf);
@@ -281,10 +287,8 @@ static int update_size(AVCodecContext *avctx, int w, int h)
 #undef assign
 
 if (s->td) {
-for (i = 0; i < s->active_tile_cols; i++) {
-av_freep(&s->td[i].b_base);
-av_freep(&s->td[i].block_base);
-}
+for (i = 0; i < s->active_tile_cols; i++)
+vp9_tile_data_free(&s->td[i]);
 }
 
 if (s->s.h.bpp != s->last_bpp) {
@@ -306,8 +310,7 @@ static int update_block_buffers(AVCodecContext *avctx)
 if (td->b_base && td->block_base && s->block_alloc_using_2pass == 
s->s.frames[CUR_FRAME].uses_2pass)
 return 0;
 
-av_free(td->b_base);
-av_free(td->block_base);
+vp9_tile_data_free(td);
 chroma_blocks = 64 * 64 >> (s->ss_h + s->ss_v);
 chroma_eobs   = 16 * 16 >> (s->ss_h + s->ss_v);
 if (s->s.frames[CUR_FRAME].uses_2pass) {
@@ -324,12 +327,9 @@ static int update_block_buffers(AVCodecContext *avctx)
 td->uveob_base[0] = td->eob_base + 16 * 16 * sbs;
 td->uveob_base[1] = td->uveob_base[0] + chroma_eobs * sbs;
 } else {
-for (i = 1; i < s->active_tile_cols; i++) {
-if (s->td[i].b_base && s->td[i].block_base) {
-av_free(s->td[i].b_base);
-av_free(s->td[i].block_base);
-}
-}
+for (i = 1; i < s->active_tile_cols; i++)
+vp9_tile_data_free(&s->td[i]);
+
 for (i = 0; i < s->active_tile_cols; i++) {
 s->td[i].b_base = av_malloc(sizeof(VP9Block));
 s->td[i].block_base = av_mallocz((64 * 64 + 2 * chroma_blocks) * 
bytesperpixel * sizeof(int16_t) +
@@ -773,10 +773,8 @@ static int decode_frame_header(AVCodecContext *avctx,
 VP56RangeCoder *rc;
 
 if (s->td) {
-for (i = 0; i < s->active_tile_cols; i++) {
-av_free(s->td[i].b_base);
-av_free(s->td[i].block_base);
-}
+for (i = 0; i < s->active_tile_cols; i++)
+vp9_tile_data_free(&s->td[i]);
 av_free(s->td);
 }
 
@@ -1204,10 +1202,8 @@ static void free_buffers(VP9Context *s)
 int i;
 
 av_freep(&s->intra_pred_data[0]);
-for (i = 0; i < s->active_tile_cols; i++) {
-av_freep(&s->td[i].b_base);
-av_freep(&s->td[i].block_base);
-}
+for (i = 0; i < s->active_tile_cols; i++)
+vp9_tile_data_free(&s->td[i]);
 }
 
 static av_cold int vp9_decode_free(AVCodecContext *avctx)
-- 
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".

[FFmpeg-devel] [PATCH 7/7] vp9dec: support exporting QP tables through the AVVideoEncParams API

2020-03-30 Thread Anton Khirnov
---
 libavcodec/vp9.c | 74 
 libavcodec/vp9block.c|  8 
 libavcodec/vp9dec.h  |  8 
 libavutil/video_enc_params.h |  1 +
 4 files changed, 91 insertions(+)

diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index e03891887b..8baf337f1b 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -34,6 +34,7 @@
 #include "vp9dec.h"
 #include "libavutil/avassert.h"
 #include "libavutil/pixdesc.h"
+#include "libavutil/video_enc_params.h"
 
 #define VP9_SYNCCODE 0x498342
 
@@ -97,6 +98,7 @@ static void vp9_tile_data_free(VP9TileData *td)
 {
 av_freep(&td->b_base);
 av_freep(&td->block_base);
+av_freep(&td->block_structure);
 }
 
 static void vp9_frame_unref(AVCodecContext *avctx, VP9Frame *f)
@@ -326,6 +328,12 @@ static int update_block_buffers(AVCodecContext *avctx)
 td->eob_base = (uint8_t *) (td->uvblock_base[1] + sbs * chroma_blocks 
* bytesperpixel);
 td->uveob_base[0] = td->eob_base + 16 * 16 * sbs;
 td->uveob_base[1] = td->uveob_base[0] + chroma_eobs * sbs;
+
+if (avctx->export_side_data & AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS) {
+td->block_structure = av_malloc_array(s->cols * s->rows, 
sizeof(*td->block_structure));
+if (!td->block_structure)
+return AVERROR(ENOMEM);
+}
 } else {
 for (i = 1; i < s->active_tile_cols; i++)
 vp9_tile_data_free(&s->td[i]);
@@ -341,6 +349,12 @@ static int update_block_buffers(AVCodecContext *avctx)
 s->td[i].eob_base = (uint8_t *) (s->td[i].uvblock_base[1] + 
chroma_blocks * bytesperpixel);
 s->td[i].uveob_base[0] = s->td[i].eob_base + 16 * 16;
 s->td[i].uveob_base[1] = s->td[i].uveob_base[0] + chroma_eobs;
+
+if (avctx->export_side_data & 
AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS) {
+s->td[i].block_structure = av_malloc_array(s->cols * s->rows, 
sizeof(*td->block_structure));
+if (!s->td[i].block_structure)
+return AVERROR(ENOMEM);
+}
 }
 }
 s->block_alloc_using_2pass = s->s.frames[CUR_FRAME].uses_2pass;
@@ -1475,6 +1489,59 @@ int loopfilter_proc(AVCodecContext *avctx)
 }
 #endif
 
+static int vp9_export_enc_params(VP9Context *s, VP9Frame *frame)
+{
+AVVideoEncParams *par;
+unsigned int tile, nb_blocks = 0;
+
+if (s->s.h.segmentation.enabled) {
+for (tile = 0; tile < s->active_tile_cols; tile++)
+nb_blocks += s->td[tile].nb_block_structure;
+}
+
+par = av_video_enc_params_create_side_data(frame->tf.f, nb_blocks);
+if (!par)
+return AVERROR(ENOMEM);
+
+par->type = AV_VIDEO_ENC_PARAMS_VP9;
+
+par->qp = s->s.h.yac_qi;
+par->delta_qp[0][0] = s->s.h.ydc_qdelta;
+par->delta_qp[1][0] = s->s.h.uvdc_qdelta;
+par->delta_qp[2][0] = s->s.h.uvdc_qdelta;
+par->delta_qp[1][1] = s->s.h.uvac_qdelta;
+par->delta_qp[2][1] = s->s.h.uvac_qdelta;
+
+if (nb_blocks) {
+unsigned int block = 0;
+unsigned int tile, block_tile;
+
+for (tile = 0; tile < s->active_tile_cols; tile++) {
+VP9TileData *td = &s->td[tile];
+
+for (block_tile = 0; block_tile < td->nb_block_structure; 
block_tile++) {
+AVVideoBlockParams *b = av_video_enc_params_block(par, 
block++);
+unsigned int  row = td->block_structure[block_tile].row;
+unsigned int  col = td->block_structure[block_tile].col;
+uint8_tseg_id = frame->segmentation_map[row * 8 * 
s->sb_cols + col];
+
+b->src_x = col * 8;
+b->src_y = row * 8;
+b->w = 1 << (3 + 
td->block_structure[block_tile].block_size_idx_x);
+b->h = 1 << (3 + 
td->block_structure[block_tile].block_size_idx_y);
+
+if (s->s.h.segmentation.feat[seg_id].q_enabled) {
+b->delta_qp = s->s.h.segmentation.feat[seg_id].q_val;
+if (s->s.h.segmentation.absolute_vals)
+b->delta_qp -= par->qp;
+}
+}
+}
+}
+
+return 0;
+}
+
 static int vp9_decode_frame(AVCodecContext *avctx, void *frame,
 int *got_frame, AVPacket *pkt)
 {
@@ -1621,6 +1688,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 s->td[i].eob = s->td[i].eob_base;
 s->td[i].uveob[0] = s->td[i].uveob_base[0];
 s->td[i].uveob[1] = s->td[i].uveob_base[1];
+s->td[i].nb_block_structure = 0;
 }
 
 #if HAVE_THREADS
@@ -1677,6 +1745,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
 } while (s->pass++ == 1);
 ff_thread_report_progress(&s->s.frames[CUR_FRAME].tf, INT_MAX, 0);
 
+if (avctx->export_side_data & AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS) {
+ret = vp9_export_enc_params(s, &s->s.frames[CUR_FRAME]);
+if (ret < 0)
+return ret;
+}
+
 fin

[FFmpeg-devel] [PATCH 4/7] mpegvideo: use the AVVideoEncParams API for exporting QP tables

2020-03-30 Thread Anton Khirnov
Do it only when requested with the AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS
flag.

Drop previous code using the long-deprecated AV_FRAME_DATA_QP_TABLE*
API.
---
 libavcodec/h263dec.c |  6 --
 libavcodec/mpeg12dec.c   |  5 +++--
 libavcodec/mpegpicture.c |  1 +
 libavcodec/mpegpicture.h |  1 +
 libavcodec/mpegvideo.c   | 39 
 libavcodec/mpegvideo.h   |  8 +++-
 libavcodec/rv10.c|  5 +++--
 libavcodec/rv34.c|  5 +++--
 libavutil/video_enc_params.h |  2 ++
 9 files changed, 55 insertions(+), 17 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 8ee844e298..a5793ea320 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -28,6 +28,8 @@
 #define UNCHECKED_BITSTREAM_READER 1
 
 #include "libavutil/cpu.h"
+#include "libavutil/video_enc_params.h"
+
 #include "avcodec.h"
 #include "error_resilience.h"
 #include "flv.h"
@@ -693,12 +695,12 @@ frame_end:
 if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0)
 return ret;
 ff_print_debug_info(s, s->current_picture_ptr, pict);
-ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, 
FF_QSCALE_TYPE_MPEG1);
+ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, 
AV_VIDEO_ENC_PARAMS_H263);
 } else if (s->last_picture_ptr) {
 if ((ret = av_frame_ref(pict, s->last_picture_ptr->f)) < 0)
 return ret;
 ff_print_debug_info(s, s->last_picture_ptr, pict);
-ff_mpv_export_qp_table(s, pict, s->last_picture_ptr, 
FF_QSCALE_TYPE_MPEG1);
+ff_mpv_export_qp_table(s, pict, s->last_picture_ptr, 
AV_VIDEO_ENC_PARAMS_H263);
 }
 
 if (s->last_picture_ptr || s->low_delay) {
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 67ce59d451..f35da4ce80 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -32,6 +32,7 @@
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
 #include "libavutil/stereo3d.h"
+#include "libavutil/video_enc_params.h"
 
 #include "avcodec.h"
 #include "bytestream.h"
@@ -2070,7 +2071,7 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict)
 if (ret < 0)
 return ret;
 ff_print_debug_info(s, s->current_picture_ptr, pict);
-ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, 
FF_QSCALE_TYPE_MPEG2);
+ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, 
AV_VIDEO_ENC_PARAMS_MPEG2);
 } else {
 if (avctx->active_thread_type & FF_THREAD_FRAME)
 s->picture_number++;
@@ -2081,7 +2082,7 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict)
 if (ret < 0)
 return ret;
 ff_print_debug_info(s, s->last_picture_ptr, pict);
-ff_mpv_export_qp_table(s, pict, s->last_picture_ptr, 
FF_QSCALE_TYPE_MPEG2);
+ff_mpv_export_qp_table(s, pict, s->last_picture_ptr, 
AV_VIDEO_ENC_PARAMS_MPEG2);
 }
 }
 
diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c
index 5fce25ec6e..6a079e795c 100644
--- a/libavcodec/mpegpicture.c
+++ b/libavcodec/mpegpicture.c
@@ -225,6 +225,7 @@ static int alloc_picture_tables(AVCodecContext *avctx, 
Picture *pic, int encodin
 
 pic->alloc_mb_width  = mb_width;
 pic->alloc_mb_height = mb_height;
+pic->alloc_mb_stride = mb_stride;
 
 return 0;
 }
diff --git a/libavcodec/mpegpicture.h b/libavcodec/mpegpicture.h
index 2db3d6733a..4bcd666797 100644
--- a/libavcodec/mpegpicture.h
+++ b/libavcodec/mpegpicture.h
@@ -69,6 +69,7 @@ typedef struct Picture {
 
 int alloc_mb_width; ///< mb_width used to allocate tables
 int alloc_mb_height;///< mb_height used to allocate tables
+int alloc_mb_stride;///< mb_stride used to allocate tables
 
 AVBufferRef *mb_mean_buf;
 uint8_t *mb_mean;   ///< Table for MB luminance
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 22cab2854b..7b43c643f6 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -32,6 +32,8 @@
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
 #include "libavutil/motion_vector.h"
+#include "libavutil/video_enc_params.h"
+
 #include "avcodec.h"
 #include "blockdsp.h"
 #include "h264chroma.h"
@@ -1439,16 +1441,37 @@ void ff_print_debug_info(MpegEncContext *s, Picture *p, 
AVFrame *pict)
  s->mb_width, s->mb_height, s->mb_stride, 
s->quarter_sample);
 }
 
-int ff_mpv_export_qp_table(MpegEncContext *s, AVFrame *f, Picture *p, int 
qp_type)
+int ff_mpv_export_qp_table(MpegEncContext *s, AVFrame *f, Picture *p,
+   enum AVVideoEncParamsType qp_type)
 {
-AVBufferRef *ref = av_buffer_ref(p->qscale_table_buf);
-int offset = 2*s->mb_stride + 1;
-if(!ref)
+AVVideoEncParams *par;
+unsigned int nb_mb = p->alloc_mb_height * p->alloc_mb_width;
+unsigned

Re: [FFmpeg-devel] new patch

2020-03-30 Thread Moritz Barsnick
On Tue, Feb 18, 2020 at 18:41:08 +0330, Mostafa Namazi fard wrote:
> I found this patch useful for prevent crash in http live stream.
> I'm using ffmpeg in my application for show http live when remote address
> send invalid data ffmpeg crash in this part and after my change it was
> fixed.

Can you post a reproducible example? Actually, it's preferred you open
a bug report for this. This should include a backtrace, as explained
here:
https://ffmpeg.org/bugreports.html

>  if (pls->needed && !pls->pkt.data) {
> -while (1) {
> +while (pls->ctx) {

As far as I can tell, pls->ctx should never turn NULL in this loop. I
believe you are just hiding a different root cause.

Regards,
Moritz
___
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/hlsenc: add hls_fmp4_init_refresh option

2020-03-30 Thread Steven Liu
add option for refresh init file after m3u8 refresh everytime.

Signed-off-by: Steven Liu 
---
 doc/muxers.texi  |  3 +++
 libavformat/hlsenc.c | 44 ++--
 2 files changed, 41 insertions(+), 6 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index d304181671..fc38f40bc9 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -836,6 +836,9 @@ fmp4 files may be used in HLS version 7 and above.
 @item hls_fmp4_init_filename @var{filename}
 Set filename to the fragment files header file, default filename is 
@file{init.mp4}.
 
+@item hls_fmp4_init_refresh @var{filename}
+Refresh init file after m3u8 file refresh every time, default is @var{0}.
+
 When @code{var_stream_map} is set with two or more variant streams, the
 @var{filename} pattern must contain the string "%v", this string specifies
 the position of variant stream index in the generated init file names.
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index a3c59432c5..6bc77ec17e 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -119,6 +119,7 @@ typedef struct VariantStream {
 int packets_written;
 int init_range_length;
 uint8_t *temp_buffer;
+uint8_t *init_buffer;
 
 AVFormatContext *avf;
 AVFormatContext *vtt_avf;
@@ -192,6 +193,7 @@ typedef struct HLSContext {
 char *segment_filename;
 char *fmp4_init_filename;
 int segment_type;
+int refresh_init_file;  ///< refresh init file into disk after refresh m3u8
 
 int use_localtime;  ///< flag to expand filename with localtime
 int use_localtime_mkdir;///< flag to mkdir dirname in timebased filename
@@ -982,7 +984,8 @@ static int sls_flag_check_duration_size(HLSContext *hls, 
VariantStream *vs)
 return ret;
 }
 
-static void sls_flag_file_rename(HLSContext *hls, VariantStream *vs, char 
*old_filename) {
+static void sls_flag_file_rename(HLSContext *hls, VariantStream *vs, char 
*old_filename)
+{
 if ((hls->flags & (HLS_SECOND_LEVEL_SEGMENT_SIZE | 
HLS_SECOND_LEVEL_SEGMENT_DURATION)) &&
 strlen(vs->current_segment_final_filename_fmt)) {
 ff_rename(old_filename, vs->avf->url, hls);
@@ -2234,6 +2237,25 @@ static int hls_write_header(AVFormatContext *s)
 return ret;
 }
 
+static int hls_init_file_refresh(AVFormatContext *s, VariantStream *vs)
+{
+HLSContext *hls = s->priv_data;
+AVDictionary *options = NULL;
+int ret = 0;
+
+set_http_options(s, &options, hls);
+ret = hlsenc_io_open(s, &vs->out, hls->fmp4_init_filename, &options);
+if (ret < 0) {
+av_dict_free(&options);
+return ret;
+}
+avio_write(vs->out, vs->init_buffer, vs->init_range_length);
+hlsenc_io_close(s, &vs->out, hls->fmp4_init_filename);
+av_dict_free(&options);
+
+return ret;
+}
+
 static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
 {
 HLSContext *hls = s->priv_data;
@@ -2246,7 +2268,6 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 int range_length = 0;
 const char *proto = NULL;
 int use_temp_file = 0;
-uint8_t *buffer = NULL;
 VariantStream *vs = NULL;
 char *old_filename = NULL;
 
@@ -2332,9 +2353,10 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 avio_flush(oc->pb);
 if (hls->segment_type == SEGMENT_TYPE_FMP4) {
 if (!vs->init_range_length) {
-range_length = avio_close_dyn_buf(oc->pb, &buffer);
-avio_write(vs->out, buffer, range_length);
-av_freep(&buffer);
+range_length = avio_close_dyn_buf(oc->pb, &vs->init_buffer);
+avio_write(vs->out, vs->init_buffer, range_length);
+if (!hls->refresh_init_file)
+av_freep(&vs->init_buffer);
 vs->init_range_length = range_length;
 avio_open_dyn_buf(&oc->pb);
 vs->packets_written = 0;
@@ -2446,6 +2468,14 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 }
 }
 
+if (hls->refresh_init_file && hls->segment_type == SEGMENT_TYPE_FMP4) {
+ret = hls_init_file_refresh(s, vs);
+if (ret < 0) {
+av_freep(&old_filename);
+return ret;
+}
+}
+
 if (hls->flags & HLS_SINGLE_FILE) {
 vs->number++;
 vs->start_pos += vs->size;
@@ -2510,7 +2540,8 @@ static void hls_free_variant_streams(struct HLSContext 
*hls)
 }
 
 avformat_free_context(vs->avf);
-
+if (!hls->refresh_init_file)
+av_freep(&vs->init_buffer);
 hls_free_segments(vs->segments);
 hls_free_segments(vs->old_segments);
 av_freep(&vs->m3u8_name);
@@ -3010,6 +3041,7 @@ static const AVOption options[] = {
 {"mpegts",   "make segment file to mpegts files in m3u8", 0, 
AV_OPT_TYPE_CONST, {.i64 = SEGMENT_TYPE_MPEGTS }, 0, UINT_MAX,   E, 
"segment_type"},
 {"fmp4",   "make s

Re: [FFmpeg-devel] [PATCH V2] avformat: Add Dynacolor MVC Demuxer

2020-03-30 Thread Moritz Barsnick
On Sat, Mar 28, 2020 at 13:32:42 +, Tom Needham wrote:
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA

You've inlined your patch again, and again it's corrupted by newlines.

> +unsigned char ff_dyna_callback_checksum(tBasicIdx *header)
> +{
> +int i;
> +unsigned char chksum = 0, *pHeader;
> +pHeader = (unsigned char *)header;
> +if (*pHeader == '@' && *(pHeader + 1) == '2') {

Is *header always guaranteed a size of at least two?

> +for (i = 0; i < sizeof(tBasicIdx) - 1; ++i) {

ffmpeg prefers "i++", and sizeof(variable) over sizeof(type).

> void ff_dyna_make_drv_header(tHeader *pHdr, int serno, unsigned int size, int 
> pic_type)

Is this used anywhere? From its contents, it looks like a function for
a muxer, not a demuxer:

> +// set basic header
> +pHdr->Basic.Header1 = '@';
> +pHdr->Basic.Header2 = '2';
> +pHdr->Basic.QI = (pHdr->Basic.WidthBase) ? 1 : 2;
[...]

> +tHeader *ff_dyna_get_audio_header(tHeader *frame, unsigned int chksum, 
> unsigned int audioserno)
> +{
> +//audio is ms adpcm. Each package size is 32(tHeader) +2048(ms adpcm).
> +tHeader *Header = frame;
> +Header->Basic.Header1 = '@';
> +Header->Basic.Header2 = '2';
> +Header->Basic.Size = 2048;

Ditto.

> +av_log(ctx, AV_LOG_DEBUG, "Parsing tBasicIdx Header \n");

You do have a log of debug messages (and a lot of empty spaces at the
end of each). They should probably not go into the final version.

> +cdata_L->Basic.NTSC_PAL = *(basicIdx_L)&0x01;
> +cdata_L->Basic.ImgMode = *(basicIdx_L) >> 1 & 0x01;
> +cdata_L->Basic.Audio = *(basicIdx_L) >> 2 & 0x01;
> +cdata_L->Basic.DST = *(basicIdx_L) >> 3 & 0x01;
> +cdata_L->Basic.Covert = *(basicIdx_L) >> 4 & 0x01;
> +cdata_L->Basic.Vloss = *(basicIdx_L) >> 5 & 0x01;
> +cdata_L->Basic.AlarmIn = *(basicIdx_L) >> 6 & 0x01;
> +cdata_L->Basic.Motion = *(basicIdx_L) >> 7 & 0x01;
> +cdata_L->Basic.ExtraEnable = *(basicIdx_L) >> 8 & 0x01;
> +cdata_L->Basic.EventEnable = *(basicIdx_L) >> 9 & 0x01;
> +cdata_L->Basic.PPS = *(basicIdx_L) >> 10 & 0x40;
> +cdata_L->Basic.Type = *(basicIdx_L) >> 16 & 0x08;
> +cdata_L->Basic.Channel = *(basicIdx_L) >> 19 & 0x20;
> +cdata_L->Basic.Chksum = *(basicIdx_L) >> 24 & 0xFF;

For readability, you could align all the '=', making it easier to see
which bits get mapped where.

(Other places as well.)

> +if (!stream_format) {
> +av_log(ctx, AV_LOG_WARNING, "File Has Unkown Stream Format:
> 0x%02X", stream_format);
> +return AVERROR_PATCHWELCOME;

Please use avpriv_report_missing_feature().

> +if (!ret) {
> +return AVERROR_PATCHWELCOME;

Also here.

> +hdr->unused_0 = (unsigned int)(pes[4] << 24 | pes[5] << 16 | pes[6] <<
> 8 | pes[7]);
> +hdr->unused_1 = (unsigned int)(pes[8] << 24 | pes[9] << 16 | pes[10]
> << 8 | pes[11]);
> +hdr->unused_2 = (unsigned int)(pes[12] << 24 | pes[13] << 16 | pes[14]
> << 8 | pes[15]);
> +hdr->unused_3 = (unsigned int)(pes[16] << 24 | pes[17] << 16 | pes[18]
> << 8 | pes[19]);
> +hdr->unused_4 = (unsigned int)(pes[20] << 24 | pes[21] << 16 | pes[22]
> << 8 | pes[23]);

There might be macros in ffmpeg for this.

> +static int dyna_read_probe(const AVProbeData *p)
> +{
> +unsigned char* bytes = av_malloc(p->buf_size);
> +
> +for (int i = 0; i < p->buf_size; i++) {
> +bytes[i] = p->buf[i];
> +}
Is this basically a memcpy?

> +if (bytes[0] == 0x40 && bytes[1] == 0x32 && bytes[2] == 0x10 &&
> bytes[3] == 0x20)

OK, but there's also a macro for this in ffmpeg.

> +tPesHeader *pes;
[...]
> +start = av_malloc(sizeof(AVIOContext));
> +memcpy(start, pb, sizeof(AVIOContext));
> +
> +pesData = av_malloc_array(PENTAMICRO_PES_HEADER_SIZE, 1);
> +pes = av_malloc(sizeof(tPesHeader));
[...]
> +ret = ff_dyna_read_file_header(ctx, pb, pesData, pes, &size, &time,
> +&priv->header, &basicIdx_H, &basicIdx_L);
> +
> +if (ret)
> +return AVERROR_INVALIDDATA;

You do realize that every malloc() has to be complemented with a
free(), even in the error case? See other demuxers: You'd have a goto
here, and a cleanup block at the end of the function, with a label.

> +size = (priv->pes_header.size_bit7to0 & 0xFF)
> +| ((priv->pes_header.size_bit10to8 & 0x04)) << 15
> +| ((priv->pes_header.size_bit14to11 & 0x08) << 11)
> +| ((priv->pes_header.size_bit21to15 & 0x7F) << 8);

Wrong indentation.

> +if (ret < 0)
> +return ret;
> +
> +return ret;

I'm not sure this makes sense. ;-)

> +static int dyna_read_close(AVFormatContext *ctx)
> +{
> +return 0;
> +}

You can probably just not define a close callback if it doesn't do
anything (but I'm not sure).

> +size = (priv->pes_header.size_bit7to0 & 0xFF)
> +| ((priv->pes_header.size_bit10t

Re: [FFmpeg-devel] [PATCH v4] examples/extract_mvs.c: dont disply motionless vectors

2020-03-30 Thread Moritz Barsnick
On Sat, Mar 21, 2020 at 12:46:09 +0800, numberwolf wrote:
> Subject: examples/extract_mvs.c: dont disply motionless vectors

Two typos in the commit message: -> don't display

> Reviewed-by: Paul B Mahol 

Please don't do this. (Not speaking for Paul here, but in general, this
doesn't really make sense.)

Moritz
___
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] [FFmpeg-cvslog] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-03-30 Thread Carl Eugen Hoyos
Am Fr., 27. März 2020 um 19:00 Uhr schrieb phunkyfish :
>
> ffmpeg | branch: master | phunkyfish  | Mon Mar  2 
> 19:21:09 2020 +| [b71685865fe761925feedda3cd0b288224d9a509] | committer: 
> Aman Gupta
>
> avformat/rtp: Pass sources and block filter addresses via sdp file for rtp
>
> Signed-off-by: Aman Gupta 
>
> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b71685865fe761925feedda3cd0b288224d9a509
> ---
>
>  libavformat/rtsp.c | 49 -
>  1 file changed, 40 insertions(+), 9 deletions(-)
>
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index cd6fc32a29..a69484d78b 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p)
>  static int rtp_read_header(AVFormatContext *s)
>  {
>  uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
> -char host[500], sdp[500];
> -int ret, port;
> +char host[500], sdp[1000], filters_buf[1000];
> +int ret, port, sdp_length, nc;
>  URLContext* in = NULL;
>  int payload_type;
>  AVCodecParameters *par = NULL;
> @@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s)
>  AVIOContext pb;
>  socklen_t addrlen = sizeof(addr);
>  RTSPState *rt = s->priv_data;
> +const char *p;
>
>  if (!ff_network_init())
>  return AVERROR(EIO);
> @@ -2513,13 +2514,40 @@ static int rtp_read_header(AVFormatContext *s)
>  av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &port,
>   NULL, 0, s->url);
>
> -snprintf(sdp, sizeof(sdp),
> - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
> - addr.ss_family == AF_INET ? 4 : 6, host,
> - par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
> - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
> - port, payload_type);
> -av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
> +sdp_length = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,

Could this be reverted, the used variable is not initialized?

Carl Eugen
___
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 v7 1/3] libavcodec/jpeg2000dec.c: Split function and modify structs for PPM marker support

2020-03-30 Thread Moritz Barsnick
On Mon, Mar 30, 2020 at 10:36:30 +0530, gautamr...@gmail.com wrote:
> -if (bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8) {
> -if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
> -s->g = tile->tile_part[++(*tp_index)].tpg;
> +// Select appropriate stream to read from
> +if (tile->has_ppt) {
> +s->g = tile->packed_headers_stream;
> +} else {
> +s->g = tile->tile_part[*tp_index].tpg;
> +if (bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8) 
> {
> +if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
> +s->g = tile->tile_part[++(*tp_index)].tpg;
> +}

Identation looks incorrect here.

Moritz
___
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 v7 2/3] libavcodec/jpeg2000dec.c: Add support for PPT marker

2020-03-30 Thread Moritz Barsnick
On Mon, Mar 30, 2020 at 10:36:31 +0530, gautamr...@gmail.com wrote:
> +tile->has_ppt = 1;  // this tile has a ppt marker
> +/*Zppt = */ bytestream2_get_byte(&s->g);

For readability, please place the explanation of what has been ignored
behind the statement. (This line looks commented out when not looking
closely enough.)

> +tile->packed_headers = av_malloc_array(n - 3, sizeof(uint8_t));
> +memcpy(tile->packed_headers, s->g.buffer, sizeof(uint8_t)*(n - 3));

sizeof(uint8_t) is always 1. If any of the types (src, dst) are subject
to change, please reference sizeof(variable) instead.

(Also other places in the patchset.)

> @@ -1088,6 +1128,8 @@ static int 
> jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
>  if (bytestream2_peek_be32(&s->g) == JPEG2000_SOP_FIXED_BYTES)
>  bytestream2_skip(&s->g, JPEG2000_SOP_BYTE_LENGTH);
>  }
> +
> +
>  for (bandno = 0; bandno < rlevel->nbands; bandno++) {
>  Jpeg2000Band *band = rlevel->band + bandno;
>  Jpeg2000Prec *prec = band->prec + precno;

Unneccessary change.

> -// Save state of stream
> +// Save stream state

Didn't you introduce this comment in the previous patch? No use in
fixing something in a followup patch, just make it correct in the first
one. (Other comments as well, AFAICT.)

> +if ((ret = jpeg2000_decode_packet_header(s, 
> tile, tp_index,
> +  codsty, rlevel,
> +  precno, layno,
> +  qntsty->expn + 
> (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
> +  
> qntsty->nguardbits, &process_data)) < 0)

Wrong indentation (but we're moving really far to the right now ;->).
(Other parts as well.)

> +if ((ret = jpeg2000_decode_packet_data(s, tile, 
> tp_index,
>codsty, rlevel,
>precno, layno,
>qntsty->expn + 
> (reslevelno ? 3 * (reslevelno - 1) + 1 : 0),
>
> qntsty->nguardbits)) < 0)

Ditto, but this is part of the original, so the indentation can be
fixed in a subsequent patch.

> @@ -1419,6 +1520,7 @@ static int 
> jpeg2000_decode_packets(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile
>  int tp_index = 0;
>
>  s->bit_index = 8;
> +
>  if (tile->poc.nb_poc) {
>  for (i=0; ipoc.nb_poc; i++) {
>  Jpeg2000POCEntry *e = &tile->poc.poc[i];

Unneccessary change.

Cheers,
Moritz
___
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 v7 3/3] libavcodec/jpeg2000dec.c: Handle non EOC streams

2020-03-30 Thread Moritz Barsnick
On Mon, Mar 30, 2020 at 10:36:32 +0530, gautamr...@gmail.com wrote:
> +av_log(s->avctx, AV_LOG_WARNING, "Mising EOC Marker.\n");

Typo: Missing

Moritz
___
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 V1 4/4] lavf/mov: support dvcC/dvvC box for Dolby Vision

2020-03-30 Thread Jan Ekström
On Mon, Mar 30, 2020 at 12:20 PM Jun Zhao  wrote:
>
> From: vacingfang 
>
> support dvcC/dvcC box from spec Dolby Vision Streams Within the
> ISO Base MediaFile Format Version 2.1.2
> (https://www.dolby.com/in/en/technologies/dolby-vision/dolby-vision\
> -bitstreams-within-the-iso-base-media-file-format-v2.1.2.pdf)
>
> And export the Dolby Vision profile/level with metadata.
>
> Signed-off-by: vacingfang 
> ---
>  libavformat/mov.c | 33 +
>  1 file changed, 33 insertions(+)
>
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index f280f36..76d90a7 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -6766,6 +6766,37 @@ static int mov_read_dmlp(MOVContext *c, AVIOContext 
> *pb, MOVAtom atom)
>  return 0;
>  }
>
> +static int mov_read_dvcc_dvvc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
> +{
> +AVStream *st;
> +uint8_t version_major, version_minor, profile, level;
> +char str_buf[32];
> +uint16_t tmp;
> +
> +if (c->fc->nb_streams < 1)
> +return 0;
> +st = c->fc->streams[c->fc->nb_streams-1];
> +
> +if ((uint64_t)atom.size > (1<<30) || atom.size < 4)
> +return AVERROR_INVALIDDATA;
> +
> +version_major = avio_r8(pb);
> +version_minor = avio_r8(pb);
> +
> +tmp = avio_rb16(pb);
> +profile = (tmp >> 9) & 0x7f;// 7bits
> +level   = (tmp >> 3) & 0x3f;// 6 bits
> +av_log(c, AV_LOG_DEBUG, "dolby vision stream, version: %d.%d, profile: 
> %d, level: %d\n",
> +version_major, version_minor, profile, level);
> +
> +snprintf(str_buf, sizeof(str_buf), "%d", profile);
> +av_dict_set(&st->metadata, "dovi_profile", str_buf, 0);
> +snprintf(str_buf, sizeof(str_buf), "%d", level);
> +av_dict_set(&st->metadata, "dovi_level", str_buf, 0);
> +

Hi,

I would really prefer a piece of side data here. Means that the
structure would be defined, and you wouldn't need to do string <-> int
switches around (as well as the possibility of just passing this along
so that the muxer on the other side could then re-create the
DOVIConfigurationBox in case writing it gets implemented.

Best regards,
Jan
___
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 V1 3/4] lavf/mpegts: support DOVIVideo Stream Descriptor

2020-03-30 Thread Jan Ekström
On Mon, Mar 30, 2020 at 11:53 AM Jun Zhao  wrote:
>
> From: vacingfang 
>
> support DOVIVideo Stream Descriptor from Dolby Vision Streams
> Within the MPEG-2 Transport Stream Format V1.2
>
> From the spec: https://www.dolby.com/us/en/technologies/\
> dolby-vision/dolby-vision-bitstreams-in-mpeg-2-transport-\
> stream-multiplex-v1.2.pdf.
>
> export the Dolby Vision profile/level with metadata.
>
> Signed-off-by: vacingfang 
> ---
>  libavformat/mpegts.c | 21 +
>  1 file changed, 21 insertions(+)
>
> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> index 7f56bac..e035605 100644
> --- a/libavformat/mpegts.c
> +++ b/libavformat/mpegts.c
> @@ -2135,6 +2135,27 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, 
> AVStream *st, int stream_type
>  st->request_probe= 0;
>  }
>  break;
> +case 0xb0: /* dolby vision video stream descriptor*/
> +{
> +int version_major, version_minor, profile, level;
> +char str_buf[32];
> +if (desc_end - *pp < 4) // 8 + 8 + 7 + 6 + 1 + 1 + 1
> +return AVERROR_INVALIDDATA;
> +
> +version_major = get8(pp, desc_end);
> +version_minor = get8(pp, desc_end);
> +profile = get16(pp, desc_end);
> +level   = (profile >> 3) & 0x3f;// 6 bits
> +profile = (profile >> 9) & 0x7f;// 7 bits
> +av_log(fc, AV_LOG_DEBUG, "dolby vision stream, version: %d.%d, 
> profile: %d, level: %d\n",
> +version_major, version_minor, profile, level);
> +
> +snprintf(str_buf, sizeof(str_buf), "%d", profile);
> +av_dict_set(&st->metadata, "dovi_profile", str_buf, 0);

Ditto for the side data point. Not only would it enable to not have
the whole string<->int conversions out of the way, but also you would
gain the information if the stream has RPUs, or if it's EL/BL etc.

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

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

Re: [FFmpeg-devel] [PATCH] configure: Do not abort when cross-compiling to the native CPU

2020-03-30 Thread David Michael
On Sun, Mar 22, 2020 at 11:01 PM David Michael  wrote:
> On Mon, Mar 16, 2020 at 9:16 AM David Michael  wrote:
> > On Sat, Mar 7, 2020 at 10:32 AM David Michael  wrote:
> > > Using a compiler with a different host triplet is considered
> > > cross-compiling, even when it is for the same architecture as the
> > > build system.  With such a cross-compiler, it is still valid to
> > > optimize builds with --cpu=host.  Drop the condition that aborts in
> > > this case, since a cross-compiler for an incompatible architecture
> > > will fail with -mtune=native anyway.
> > >
> > > Signed-off-by: David Michael 
> > > ---
> > >
> > > Hi,
> > >
> > > I am building software in a ChromeOS-style environment where the native
> > > build system creates a cross-compiler with a different vendor string for
> > > each supported architecture, and cross-compiled packages are installed
> > > into their own root directory.  The build system's architecture is not
> > > handled any differently, so packages compatible with the native
> > > architecture are still technically being cross-compiled.
> > >
> > > When I changed settings to tune for the native CPU so I can produce an
> > > installation optimized to run on the build system hardware, FFmpeg fails
> > > from this seemingly redundant test.  Can it just be dropped?
> > >
> > > Thanks.
> > >
> > > David
> > >
> > >  configure | 3 ---
> > >  1 file changed, 3 deletions(-)
> > >
> > > diff --git a/configure b/configure
> > > index 06e3a7b2a8..69ffdeb3ed 100755
> > > --- a/configure
> > > +++ b/configure
> > > @@ -4785,9 +4785,6 @@ if test -n "$sysroot"; then
> > >  fi
> > >
> > >  if test "$cpu" = host; then
> > > -enabled cross_compile &&
> > > -die "--cpu=host makes no sense when cross-compiling."
> > > -
> > >  case "$cc_type" in
> > >  gcc|llvm_gcc)
> > >  check_native(){
> > > --
> > > 2.21.1
> >
> > Ping.
>
> Ping.

Ping.
___
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 v7 3/3] libavcodec/jpeg2000dec.c: Handle non EOC streams

2020-03-30 Thread Gautam Ramakrishnan
On Mon, Mar 30, 2020 at 7:44 PM Moritz Barsnick  wrote:
>
> On Mon, Mar 30, 2020 at 10:36:32 +0530, gautamr...@gmail.com wrote:
> > +av_log(s->avctx, AV_LOG_WARNING, "Mising EOC Marker.\n");
>
> Typo: Missing
>
> Moritz
> ___
> 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".

Hi Moritz,

Thanks for the review. Cannot believe so many mistakes!
I'll submit a v8.

-- 
-
Gautam |
___
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 v8 1/3] libavcodec/jpeg2000dec.c: Split function and modify structs for PPM marker support

2020-03-30 Thread gautamramk
From: Gautam Ramakrishnan 

---
 libavcodec/jpeg2000dec.c | 48 ++--
 1 file changed, 41 insertions(+), 7 deletions(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 7103cd6ceb..9d52969821 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -83,6 +83,10 @@ typedef struct Jpeg2000Tile {
 Jpeg2000QuantStyle  qntsty[4];
 Jpeg2000POC poc;
 Jpeg2000TileParttile_part[32];
+uint8_t has_ppt;// whether this tile has a ppt 
marker
+uint8_t *packed_headers;// contains packed headers. 
Used only along with PPT marker
+int packed_headers_size;// size in bytes of the packed 
headers
+GetByteContext  packed_headers_stream;  // byte context corresponding 
to packed headers
 uint16_t tp_idx;// Tile-part index
 int coord[2][2];// border coordinates {{x0, x1}, {y0, 
y1}}
 } Jpeg2000Tile;
@@ -935,21 +939,32 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext 
*s, Jpeg2000Tile *tile,
 int bandno, cblkno, ret, nb_code_blocks;
 int cwsno;
 
+// This part decodes the packet header
+
 if (layno < rlevel->band[0].prec[precno].decoded_layers)
 return 0;
 rlevel->band[0].prec[precno].decoded_layers = layno + 1;
-
-if (bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8) {
-if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
-s->g = tile->tile_part[++(*tp_index)].tpg;
+// Select appropriate stream to read from
+if (tile->has_ppt) {
+s->g = tile->packed_headers_stream;
+} else {
+s->g = tile->tile_part[*tp_index].tpg;
+if (bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8) {
+if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
+s->g = tile->tile_part[++(*tp_index)].tpg;
+}
 }
+if (bytestream2_peek_be32(&s->g) == JPEG2000_SOP_FIXED_BYTES)
+bytestream2_skip(&s->g, JPEG2000_SOP_BYTE_LENGTH);
 }
 
-if (bytestream2_peek_be32(&s->g) == JPEG2000_SOP_FIXED_BYTES)
-bytestream2_skip(&s->g, JPEG2000_SOP_BYTE_LENGTH);
-
 if (!(ret = get_bits(s, 1))) {
 jpeg2000_flush(s);
+// Save state of stream
+if (tile->has_ppt)
+tile->packed_headers_stream = s->g;
+else
+tile->tile_part[*tp_index].tpg = s->g;
 return 0;
 } else if (ret < 0)
 return ret;
@@ -1056,6 +1071,23 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext 
*s, Jpeg2000Tile *tile,
 av_log(s->avctx, AV_LOG_ERROR, "EPH marker not found. instead 
%X\n", bytestream2_peek_be32(&s->g));
 }
 
+if (tile->has_ppt)
+tile->packed_headers_stream = s->g;
+else
+tile->tile_part[*tp_index].tpg = s->g;
+
+// This part decodes the packet data.
+// Select appropriate stream to read from
+s->g = tile->tile_part[*tp_index].tpg;
+if (tile->has_ppt) {
+if (bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8) {
+if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
+s->g = tile->tile_part[++(*tp_index)].tpg;
+}
+}
+if (bytestream2_peek_be32(&s->g) == JPEG2000_SOP_FIXED_BYTES)
+bytestream2_skip(&s->g, JPEG2000_SOP_BYTE_LENGTH);
+}
 for (bandno = 0; bandno < rlevel->nbands; bandno++) {
 Jpeg2000Band *band = rlevel->band + bandno;
 Jpeg2000Prec *prec = band->prec + precno;
@@ -1097,6 +1129,8 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext 
*s, Jpeg2000Tile *tile,
 av_freep(&cblk->lengthinc);
 }
 }
+// Save state of stream
+tile->tile_part[*tp_index].tpg = s->g;
 return 0;
 }
 
-- 
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 v8 3/3] libavcodec/jpeg2000dec.c: Handle non EOC streams

2020-03-30 Thread gautamramk
From: Gautam Ramakrishnan 

This patch allows decoding of j2k streams which do
not have an EOC marker.
---
 libavcodec/jpeg2000dec.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 23e43ff052..d27d753992 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -2085,8 +2085,12 @@ static int 
jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
 
 len = bytestream2_get_be16(&s->g);
 if (len < 2 || bytestream2_get_bytes_left(&s->g) < len - 2) {
-av_log(s->avctx, AV_LOG_ERROR, "Invalid len %d left=%d\n", len, 
bytestream2_get_bytes_left(&s->g));
-return AVERROR_INVALIDDATA;
+if (s->avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT) {
+av_log(s->avctx, AV_LOG_ERROR, "Invalid len %d left=%d\n", 
len, bytestream2_get_bytes_left(&s->g));
+return AVERROR_INVALIDDATA;
+}
+av_log(s->avctx, AV_LOG_WARNING, "Missing EOC Marker.\n");
+break;
 }
 
 switch (marker) {
-- 
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 v8 2/3] libavcodec/jpeg2000dec.c: Add support for PPT marker

2020-03-30 Thread gautamramk
From: Gautam Ramakrishnan 

This patch adds functional changes to support the
PPT marker.
---
 libavcodec/jpeg2000dec.c | 209 ++-
 1 file changed, 162 insertions(+), 47 deletions(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 9d52969821..23e43ff052 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -859,6 +859,39 @@ static int get_plt(Jpeg2000DecoderContext *s, int n)
 return 0;
 }
 
+static int get_ppt(Jpeg2000DecoderContext *s, int n)
+{
+Jpeg2000Tile *tile;
+
+if (s->curtileno < 0)
+return AVERROR_INVALIDDATA;
+
+tile = &s->tile[s->curtileno];
+if (tile->tp_idx != 0) {
+av_log(s->avctx, AV_LOG_ERROR,
+   "PPT marker can occur only on first tile part of a tile.\n");
+return AVERROR_INVALIDDATA;
+}
+
+tile->has_ppt = 1;  // this tile has a ppt marker
+/*Zppt = */ bytestream2_get_byte(&s->g); // Zppt is skipped and not used
+if (!tile->packed_headers) {
+tile->packed_headers = av_malloc_array(n - 3, 1);
+memcpy(tile->packed_headers, s->g.buffer, n - 3);
+tile->packed_headers_size = n - 3;
+} else {
+tile->packed_headers = av_realloc_array(tile->packed_headers,
+tile->packed_headers_size + n 
- 3,
+1);
+memcpy(tile->packed_headers + tile->packed_headers_size,
+   s->g.buffer, n - 3);
+tile->packed_headers_size += n - 3;
+}
+bytestream2_skip(&s->g, n - 3);
+
+return 0;
+}
+
 static int init_tile(Jpeg2000DecoderContext *s, int tileno)
 {
 int compno;
@@ -931,20 +964,21 @@ static int getlblockinc(Jpeg2000DecoderContext *s)
 return res;
 }
 
-static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile 
*tile, int *tp_index,
-  Jpeg2000CodingStyle *codsty,
-  Jpeg2000ResLevel *rlevel, int precno,
-  int layno, uint8_t *expn, int numgbits)
+static int jpeg2000_decode_packet_header(Jpeg2000DecoderContext *s, 
Jpeg2000Tile *tile,
+ int *tp_index,
+ Jpeg2000CodingStyle *codsty,
+ Jpeg2000ResLevel *rlevel, int precno,
+ int layno, uint8_t *expn, int 
numgbits,
+ int *process_data)
 {
 int bandno, cblkno, ret, nb_code_blocks;
-int cwsno;
 
-// This part decodes the packet header
-
-if (layno < rlevel->band[0].prec[precno].decoded_layers)
+if (layno < rlevel->band[0].prec[precno].decoded_layers) {
+*process_data = 0;
 return 0;
+}
 rlevel->band[0].prec[precno].decoded_layers = layno + 1;
-// Select appropriate stream to read from
+// Select stream to read from
 if (tile->has_ppt) {
 s->g = tile->packed_headers_stream;
 } else {
@@ -960,12 +994,8 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext 
*s, Jpeg2000Tile *tile,
 
 if (!(ret = get_bits(s, 1))) {
 jpeg2000_flush(s);
-// Save state of stream
-if (tile->has_ppt)
-tile->packed_headers_stream = s->g;
-else
-tile->tile_part[*tp_index].tpg = s->g;
-return 0;
+*process_data = 0;
+goto end;
 } else if (ret < 0)
 return ret;
 
@@ -1070,14 +1100,24 @@ static int 
jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
 else
 av_log(s->avctx, AV_LOG_ERROR, "EPH marker not found. instead 
%X\n", bytestream2_peek_be32(&s->g));
 }
-
+end:
+// Save state of stream
 if (tile->has_ppt)
 tile->packed_headers_stream = s->g;
 else
 tile->tile_part[*tp_index].tpg = s->g;
+return 0;
+}
+
+static int jpeg2000_decode_packet_data(Jpeg2000DecoderContext *s, Jpeg2000Tile 
*tile,
+   int *tp_index,
+   Jpeg2000CodingStyle *codsty,
+   Jpeg2000ResLevel *rlevel, int precno,
+   int layno, uint8_t *expn, int numgbits)
+{
+int bandno, cblkno, nb_code_blocks;
+int cwsno;
 
-// This part decodes the packet data.
-// Select appropriate stream to read from
 s->g = tile->tile_part[*tp_index].tpg;
 if (tile->has_ppt) {
 if (bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8) {
@@ -1158,13 +1198,27 @@ static int 
jpeg2000_decode_packets_po_iteration(Jpeg2000DecoderContext *s, Jpeg2
 Jpeg2000ResLevel *rlevel = tile->comp[compno].reslevel 
+
 reslevelno;
 ok_reslevel = 1;
-for (precno = 0; precno < rlevel->num_precincts_x * 
rlevel->num_p

Re: [FFmpeg-devel] [PATCH] configure: Do not abort when cross-compiling to the native CPU

2020-03-30 Thread Derek Buitenhuis
On 07/03/2020 15:32, David Michael wrote:
> Using a compiler with a different host triplet is considered
> cross-compiling, even when it is for the same architecture as the
> build system.  With such a cross-compiler, it is still valid to
> optimize builds with --cpu=host.  Drop the condition that aborts in
> this case, since a cross-compiler for an incompatible architecture
> will fail with -mtune=native anyway.

Is there a reason you would set the cross-prefix instead of just the --cc, etc.
when compiling natively?

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

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

Re: [FFmpeg-devel] [PATCH] configure: Do not abort when cross-compiling to the native CPU

2020-03-30 Thread David Michael
On Mon, Mar 30, 2020 at 1:00 PM Derek Buitenhuis
 wrote:
> On 07/03/2020 15:32, David Michael wrote:
> > Using a compiler with a different host triplet is considered
> > cross-compiling, even when it is for the same architecture as the
> > build system.  With such a cross-compiler, it is still valid to
> > optimize builds with --cpu=host.  Drop the condition that aborts in
> > this case, since a cross-compiler for an incompatible architecture
> > will fail with -mtune=native anyway.
>
> Is there a reason you would set the cross-prefix instead of just the --cc, 
> etc.
> when compiling natively?

I want everything to use the cross-prefixed versions since those tools
are configured to build software in a sysroot using a different set of
compiler features than software in the minimal build root.  I am using
the same process as when cross-compiling OS images for other
incompatible architectures; configuring tuning for the build system's
CPU is just another valid use of this setup.

Thanks.

David
___
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 04/21] avformat: Redo cleanup of demuxer upon read_header() failure

2020-03-30 Thread Nicolas George
Andreas Rheinhardt (12020-03-24):
> I reconsidered this and I think I got it exactly wrong: libavdevice is
> linked against libavformat, not the other way around. Therefore one can
> swap the libavformat against a newer one, but one is not allowed to
> update libavdevice without also updating libavformat. (This presumes
> that the usual rules apply in this scenario; I haven't seen any
> exception documented for the special case of the heavily interwoven
> libavdevice and libavformat, so I guess there is none.)
> 
> This means that adding new fields to AVInputFormat (and using them) is
> not possible, because said AVInputFormat might come from an older
> version of libavdevice and might therefore not have these fields.

I would like to emphasize that this whole issue is again a drawback of
having the libraries reside in separate shared objects. A situation for
which I have yet to be told a single actual benefit.

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

Re: [FFmpeg-devel] [PATCH] lavf/matroskadec: Demux the PixelCrop* values

2020-03-30 Thread Neil Birkbeck
On Fri, Apr 15, 2016 at 4:06 AM wm4  wrote:

> On Wed, 6 Apr 2016 17:09:21 -0600
> Nic Wolfe  wrote:
>
> > Thanks for elaborating wm4. Out of curiosity when you say "generic"
> > and "normal" metadata what do you mean? Are you talking about using
> > generic key names or is there another way to store metadata?
> >
> > I have attached a patch which adds a new AVPacketSideDataType and uses
> > that type to store crop values in the AVStream's side data if they're
> > found during Matroska demuxing. I have included a comment in avcodec.h
> > with some of the info Dave shared above but I'm not sure if that is
> > sufficient to call this "well defined".
> >
> > I'm aware that this is a complex topic and this patch is certainly not
> > comprehensive but hopefully it is a step in the right direction.
>
> I think this is much better. The problem are still the semantics. I
> tried to discuss it in Libav, but nothing conclusive has emerged.
>
> Maybe you could send this patch to libav-devel for discussion? (I feel
> a bit sorry for playing this ping pong with a first time contributor.
> If anyone has a better idea how to continue this, please make a
> suggestion.)
>
> By the way, it's not a good idea to send base64 encoded patches. I
> don't think most mail clients can expand them automatically. It
> makes review harder. Just attach them normally. Also, try to avoid
> top-posting.
>

Reviving this thread, as it seems to have the most context on the topic of
PixelCrop in MKV.

I was also investigating adding support for PixelCrop* fields (
https://matroska.org/technical/specs/index.html) for a particular case of
cropping additional padding off the bottom of the image (e.g.,
PixelWidth=1920, PixelHeight=1088, PixelCropBottom=8,
PixelCrop{Top,Right,Left}=0, DisplayWidth=1920, DisplayHeight=1080) which
is required due to a hardware constraint (and codec bitrstream doesn't
support the crop, unlike say h264/hevc). For my use-case, propagating the
MKV fields through to the AVFrame::crop* and silently applying the crop
would be ideal behavior, but I realize that may not generalize to others.

It seems there is still a bunch of complexity around the various edge cases
and interaction with metadata in the container/codec (e.g., which one takes
precedent?).  And the PixelCrop fields also come up in (
https://trac.ffmpeg.org/ticket/7437), where it seems the fields might be a
natural destination for contents of mov/mp4 "clap" atom (
https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html#//apple_ref/doc/uid/TP4939-CH205-125850).
This seems partially relevant, as perhaps a common SideData element can
contain the "clap" and  "PixelCrop*" (if possible)--making the interface
more consistent for applications and transmuxing cases

Is an incremental way forward to:
-Support application level support by extract the PixelCrop fields and
exporting as AVStream side data (perhaps works for 'clap' atom too). [say
by revisiting the AVPacketSideData patch in this thread]
-Support transmuxing use case: add support to muxers, mapping between
relevant containers, where/if applicable.
-Support auto-apply decode case. I guess this is close to what autorotate
does. Need to be sure to strip strip metadata so it doesn't get muxed into
output.


Any alternatives, or objections, to at least exporting these fields as
stream side data as a first step?


> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
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/movenc: stop guessing colr atom values

2020-03-30 Thread Michael Bradshaw
See [1]. Apple requests that colr atom values be 2 ("unspecified") for
Dolby Vision.

Please review.
--Michael

[1]:
https://developer.apple.com/av-foundation/High-Dynamic-Range-Metadata-for-Apple-Devices.pdf


0001-avformat-movenc-stop-guessing-colr-atom-values.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".

Re: [FFmpeg-devel] [PATCH V1 1/4] lavf/flvdec: set AVFMT_TS_DISCONT flag on FLV demuxer

2020-03-30 Thread Michael Niedermayer
On Mon, Mar 30, 2020 at 04:22:51PM +0800, Jun Zhao wrote:
> From: Jun Zhao 
> 
> There have been some reports about FLV timestamp discontinuities present.
> e,g, the file recorded from live RTMP FLV streaming, so add
> AVFMT_TS_DISCONT flag on FLV demuxer and also update the fate test
> fate-filter-aresample for test sample nellymoser-discont.flv.
> 
> BTW: live_flv demuxer also enabled the AVFMT_TS_DISCONT flag.

Maybe i misunderstand but this sounds like you have a live_flv
file and its demuxed by the non live demuxer.
IIRC AVFMT_TS_DISCONT is the main difference between the 2

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

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes


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] avformat/movenc: write the colr atom by default

2020-03-30 Thread Michael Bradshaw
The write_colr flag has been marked as experimental for over 5 years. I
propose we do the following (as implemented by the attached patch):

   - Write the colr atom by default for mp4/mov if any of the following:
  - The primaries/trc/matrix are all specified, OR
  - There is an ICC profile, OR
  - The user specified +write_colr
   - Remove the experimental notice from the write_colr flag.
   - Keep the write_colr flag for situations where the user wants to write
   the colr atom even if the color info is unspecified (e.g.,
   http://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/259334.html)

This fixes https://trac.ffmpeg.org/ticket/7961

Please review.
--Michael


0001-avformat-movenc-write-the-colr-atom-by-default.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".

Re: [FFmpeg-devel] [PATCH] avformat/movenc: write the colr atom by default

2020-03-30 Thread Andreas Rheinhardt
Michael Bradshaw:
> The write_colr flag has been marked as experimental for over 5 years. I
> propose we do the following (as implemented by the attached patch):
> 
>- Write the colr atom by default for mp4/mov if any of the following:
>   - The primaries/trc/matrix are all specified, OR
>   - There is an ICC profile, OR
>   - The user specified +write_colr
>- Remove the experimental notice from the write_colr flag.
>- Keep the write_colr flag for situations where the user wants to write
>the colr atom even if the color info is unspecified (e.g.,
>http://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/259334.html)
> 
> This fixes https://trac.ffmpeg.org/ticket/7961
> 
Why is all this information not in the commit message? (In commit
message style of course, i.e. no "I propose".)

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

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

Re: [FFmpeg-devel] [PATCH 4/7] mpegvideo: use the AVVideoEncParams API for exporting QP tables

2020-03-30 Thread Michael Niedermayer
On Mon, Mar 30, 2020 at 01:45:23PM +0200, Anton Khirnov wrote:
> Do it only when requested with the AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS
> flag.
> 
> Drop previous code using the long-deprecated AV_FRAME_DATA_QP_TABLE*
> API.
> ---
>  libavcodec/h263dec.c |  6 --
>  libavcodec/mpeg12dec.c   |  5 +++--
>  libavcodec/mpegpicture.c |  1 +
>  libavcodec/mpegpicture.h |  1 +
>  libavcodec/mpegvideo.c   | 39 
>  libavcodec/mpegvideo.h   |  8 +++-
>  libavcodec/rv10.c|  5 +++--
>  libavcodec/rv34.c|  5 +++--
>  libavutil/video_enc_params.h |  2 ++
>  9 files changed, 55 insertions(+), 17 deletions(-)

This seems to break fate-filter-pp
TESTfilter-pp
--- ./tests/ref/fate/filter-pp  2020-03-25 02:01:55.010219361 +0100
+++ tests/data/fate/filter-pp   2020-03-30 23:52:46.611521793 +0200
@@ -3,8 +3,8 @@
 #codec_id 0: rawvideo
 #dimensions 0: 352x288
 #sar 0: 1/1
-0,  1,  1,1,   152064, 0x0af8a873
-0,  2,  2,1,   152064, 0xaeb99897
-0,  3,  3,1,   152064, 0x8f3712c8
-0,  4,  4,1,   152064, 0x5bf6a64c
-0,  5,  5,1,   152064, 0x262de352
+0,  1,  1,1,   152064, 0x3588a88c
+0,  2,  2,1,   152064, 0x91dd9897
+0,  3,  3,1,   152064, 0xef9b12c2
+0,  4,  4,1,   152064, 0x83a2a64f
+0,  5,  5,1,   152064, 0xc4dae34e
Test filter-pp failed. Look at tests/data/fate/filter-pp.err for details.
tests/Makefile:250: recipe for target 'fate-filter-pp' failed
make: *** [fate-filter-pp] Error 1


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

The real ebay dictionary, page 2
"100% positive feedback" - "All either got their money back or didnt complain"
"Best seller ever, very honest" - "Seller refunded buyer after failed scam"


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]lavf/movenc: Do not write empty av1C boxes

2020-03-30 Thread Carl Eugen Hoyos
Hi!

Attached patch avoids writing an mp4 file that cannot be read by
FFmpeg (only be vlc) in some use cases.

Please comment, Carl Eugen
From 42b5e30f3bf13620a41ed92181f7b0358873e764 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Tue, 31 Mar 2020 00:17:44 +0200
Subject: [PATCH] lavf/movenc: Do not write an empty av1C box.

---
 libavformat/movenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 1c178fc4bc..8cdd406335 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2098,7 +2098,7 @@ static int mov_write_video_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex
 mov_write_uuid_tag_ipod(pb);
 } else if (track->par->codec_id == AV_CODEC_ID_VP9) {
 mov_write_vpcc_tag(mov->fc, pb, track);
-} else if (track->par->codec_id == AV_CODEC_ID_AV1) {
+} else if (track->par->codec_id == AV_CODEC_ID_AV1 && track->vos_len > 0) {
 mov_write_av1c_tag(pb, track);
 } else if (track->par->codec_id == AV_CODEC_ID_VC1 && track->vos_len > 0)
 mov_write_dvc1_tag(pb, track);
-- 
2.24.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/movenc: write the colr atom by default

2020-03-30 Thread Michael Bradshaw
On Mon, Mar 30, 2020 at 3:46 PM Andreas Rheinhardt <
andreas.rheinha...@gmail.com> wrote:

> Why is all this information not in the commit message? (In commit
> message style of course, i.e. no "I propose".)


For reasons that I'm happy to discuss in a separate thread to avoid
derailing this one. Attached is a patch with an updated commit message that
includes this information in the commit message.


0001-avformat-movenc-write-the-colr-atom-by-default.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".

Re: [FFmpeg-devel] [PATCH] avformat/movenc: stop guessing colr atom values

2020-03-30 Thread Carl Eugen Hoyos
Am Mo., 30. März 2020 um 22:28 Uhr schrieb Michael Bradshaw
:
>
> See [1]. Apple requests that colr atom values be 2 ("unspecified") for
> Dolby Vision.

> // e.g., Dolby Vision for Apple devices should be set to 
> AVCOL_PRI_UNSPECIFIED.

But not every call of the mov muxer is done for Dolby Vision
samples or do I misunderstand?

Carl Eugen
___
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] libavformat/oggdec.c: Check return value from avio_read()

2020-03-30 Thread John Rummell
Refactoring my previous patch into smaller items. Starting with the one
found by the Chromium fuzzers.


0001-libavformat-oggdec.c-Check-return-value-from-avio_re.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".

[FFmpeg-devel] [PATCH] libavformat/mov.c: Free aes_decrypt to avoid leaking memory

2020-03-30 Thread John Rummell
Another one found by the Chromium fuzzers.


0001-libavformat-mov.c-Free-aes_decrypt-to-avoid-leaking-.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".

Re: [FFmpeg-devel] [PATCH] avformat/movenc: stop guessing colr atom values

2020-03-30 Thread Michael Bradshaw
On Mon, Mar 30, 2020 at 4:23 PM Carl Eugen Hoyos  wrote:

> But not every call of the mov muxer is done for Dolby Vision
> samples or do I misunderstand?


You're right that most muxing doesn't involve Dolby Vision. However, even
for cases that don't involve Dolby Vision I still think guessing is the
wrong thing to do and we should respect "unspecified" since we really don't
know. I'd be okay with maybe emitting a warning if we're writing
unspecified values.
___
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]lavf/movenc: Do not write empty av1C boxes

2020-03-30 Thread James Almer
On 3/30/2020 7:19 PM, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch avoids writing an mp4 file that cannot be read by
> FFmpeg (only be vlc) in some use cases.
> 
> Please comment, Carl Eugen

This enables writing non compliant files, so no.
We should instead check the return value of mov_write_av1c_tag() (and
that function in turn check the return value of ff_isom_write_av1c()),
and propagate it.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH]lavf/movenc: Do not write empty av1C boxes

2020-03-30 Thread Carl Eugen Hoyos
Am Di., 31. März 2020 um 00:35 Uhr schrieb James Almer :
>
> On 3/30/2020 7:19 PM, Carl Eugen Hoyos wrote:
> > Hi!
> >
> > Attached patch avoids writing an mp4 file that cannot be read by
> > FFmpeg (only be vlc) in some use cases.
> >
> > Please comment, Carl Eugen
>
> This enables writing non compliant files, so no.

The current situation is that unreadable files are
written, so I don't think this is a very useful answer.

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

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

Re: [FFmpeg-devel] [PATCH]ffmpeg: Do not exit if alleged error was only worth a debug information

2020-03-30 Thread Carl Eugen Hoyos
Am Mi., 15. Jan. 2020 um 16:56 Uhr schrieb Marton Balint :
>
>
>
> On Wed, 15 Jan 2020, Carl Eugen Hoyos wrote:
>
> > Hi!
> >
> > Attached patch fixes hard-to-understand behaviour of ffmpeg for some
> > mp4 input files, a hard exit following a debug message.
>
> I don't think such an mp4 file is strictly valid, therefore the behavior
> of the program should remain the same, it should exit.
>
> It might make more sense to force an AV_LOG_ERROR level for
> the message if exit_on_error is set.

Done.

Carl Eugen
___
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]lavfi/minterpolate: Allow bigger resolutions if SIZE_MAX is big

2020-03-30 Thread Carl Eugen Hoyos
Am Sa., 28. März 2020 um 13:54 Uhr schrieb Carl Eugen Hoyos
:

> Attached patch allows to work-around ticket #7140, tested on a system
> with a lot of memory.

Ping.

Carl Eugen
___
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/movenc: stop guessing colr atom values

2020-03-30 Thread Carl Eugen Hoyos
Am Di., 31. März 2020 um 00:33 Uhr schrieb Michael Bradshaw
:
>
> On Mon, Mar 30, 2020 at 4:23 PM Carl Eugen Hoyos  wrote:
>
> > But not every call of the mov muxer is done for Dolby Vision
> > samples or do I misunderstand?
>
> You're right that most muxing doesn't involve Dolby Vision. However, even
> for cases that don't involve Dolby Vision I still think guessing is the
> wrong thing to do

I believe there is some historical evidence that this guessing is needed
to get visually correct output in many cases.

Carl Eugen
___
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]lavf/movenc: Do not write empty av1C boxes

2020-03-30 Thread James Almer
On 3/30/2020 7:44 PM, Carl Eugen Hoyos wrote:
> Am Di., 31. März 2020 um 00:35 Uhr schrieb James Almer :
>>
>> On 3/30/2020 7:19 PM, Carl Eugen Hoyos wrote:
>>> Hi!
>>>
>>> Attached patch avoids writing an mp4 file that cannot be read by
>>> FFmpeg (only be vlc) in some use cases.
>>>
>>> Please comment, Carl Eugen
>>
>> This enables writing non compliant files, so no.
> 
> The current situation is that unreadable files are
> written, so I don't think this is a very useful answer.
> 
> Carl Eugen

Both the current situation and the one you propose are unacceptable.
Hence me asking you to propagate errors instead of ignoring them in this
kind of scenario, seeing it's not a valid one.
___
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/movenc: stop guessing colr atom values

2020-03-30 Thread Michael Bradshaw
On Mon, Mar 30, 2020 at 4:48 PM Carl Eugen Hoyos  wrote:

> I believe there is some historical evidence that this guessing is needed
> to get visually correct output in many cases.


I haven't found any evidence of that. This guessing has been part of the
code since the write_colr flag was originally added. Unfortunately I don't
see the original patch in the ffmpeg-devel archives so I don't know what
discussions there were around it originally. But I would counter with the
following:

   1. The user can guess if they want using
   the -color_primaries/-color_trc/-colorspace flags.
   2. If ffmpeg does want to guess, this is the wrong place to do it. There
   are various parts of ffmpeg that deal with color primaries/trc/space. The
   right way to guess this info is higher up in the pipeline where it can be
   consistently applied throughout the pipeline and bitstream. Doing it
   locally here is just begging for one part of ffmpeg to make one assumption
   and this part to make a different assumption, which would be even worse.
   3. Building on point 2, this is an especially bad place to guess this
   because the color info is a property of the input, not the output.

If this really breaks things for people (which I highly doubt it will) they
can always send a patch with a better and more robust implementation. But I
feel strongly that we should not stabilize the write_colr flag with this
auto-guessing logic. We really shouldn't have people depend on it and
should encourage them to use the -color_primaries/-color_trc/-colorspace
flags themselves for better color guessing.
___
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/movenc: add write_clli flag to write clli atom

2020-03-30 Thread Michael Bradshaw
The clli atom isn't in ISO/IEC 14496-12:2015 so the flag is marked as
experimental and the clli atom is not written by default.

The clli atom is referenced by e.g., [1][2] and is already parsed in FFmpeg
in mov.c.

Once ISO/IEC 14496-12 standardizes the clli atom (which I assume it will?)
then we can switch this to write the clli atom by default (if the metadata
exists) and remove the write_clli flag.

[1]:
https://aomedia.org/wp-content/uploads/2018/09/AV1-ISO-Base-Media-File-Format-Binding-Specification.pdf
[2]:
https://developer.apple.com/av-foundation/High-Dynamic-Range-Metadata-for-Apple-Devices.pdf


0001-avformat-movenc-add-write_clli-flag-to-write-clli-at.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".

Re: [FFmpeg-devel] [PATCH v8 1/3] libavcodec/jpeg2000dec.c: Split function and modify structs for PPM marker support

2020-03-30 Thread Michael Niedermayer
On Mon, Mar 30, 2020 at 09:51:53PM +0530, gautamr...@gmail.com wrote:
> From: Gautam Ramakrishnan 
> 
> ---
>  libavcodec/jpeg2000dec.c | 48 ++--
>  1 file changed, 41 insertions(+), 7 deletions(-)
> 
> diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> index 7103cd6ceb..9d52969821 100644
> --- a/libavcodec/jpeg2000dec.c
> +++ b/libavcodec/jpeg2000dec.c
> @@ -83,6 +83,10 @@ typedef struct Jpeg2000Tile {
>  Jpeg2000QuantStyle  qntsty[4];
>  Jpeg2000POC poc;
>  Jpeg2000TileParttile_part[32];
> +uint8_t has_ppt;// whether this tile has a 
> ppt marker
> +uint8_t *packed_headers;// contains packed headers. 
> Used only along with PPT marker
> +int packed_headers_size;// size in bytes of the 
> packed headers
> +GetByteContext  packed_headers_stream;  // byte context 
> corresponding to packed headers
>  uint16_t tp_idx;// Tile-part index
>  int coord[2][2];// border coordinates {{x0, x1}, 
> {y0, y1}}
>  } Jpeg2000Tile;
> @@ -935,21 +939,32 @@ static int 
> jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
>  int bandno, cblkno, ret, nb_code_blocks;
>  int cwsno;
>  
> +// This part decodes the packet header
> +
>  if (layno < rlevel->band[0].prec[precno].decoded_layers)
>  return 0;
>  rlevel->band[0].prec[precno].decoded_layers = layno + 1;
> -
> -if (bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8) {
> -if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
> -s->g = tile->tile_part[++(*tp_index)].tpg;
> +// Select appropriate stream to read from
> +if (tile->has_ppt) {
> +s->g = tile->packed_headers_stream;
> +} else {
> +s->g = tile->tile_part[*tp_index].tpg;
> +if (bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8) {
> +if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
> +s->g = tile->tile_part[++(*tp_index)].tpg;
> +}
>  }
> +if (bytestream2_peek_be32(&s->g) == JPEG2000_SOP_FIXED_BYTES)
> +bytestream2_skip(&s->g, JPEG2000_SOP_BYTE_LENGTH);
>  }
>  
> -if (bytestream2_peek_be32(&s->g) == JPEG2000_SOP_FIXED_BYTES)
> -bytestream2_skip(&s->g, JPEG2000_SOP_BYTE_LENGTH);
> -
>  if (!(ret = get_bits(s, 1))) {
>  jpeg2000_flush(s);
> +// Save state of stream
> +if (tile->has_ppt)
> +tile->packed_headers_stream = s->g;
> +else
> +tile->tile_part[*tp_index].tpg = s->g;
>  return 0;
>  } else if (ret < 0)
>  return ret;
> @@ -1056,6 +1071,23 @@ static int 
> jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
>  av_log(s->avctx, AV_LOG_ERROR, "EPH marker not found. instead 
> %X\n", bytestream2_peek_be32(&s->g));
>  }
>  
> +if (tile->has_ppt)
> +tile->packed_headers_stream = s->g;
> +else
> +tile->tile_part[*tp_index].tpg = s->g;
> +
> +// This part decodes the packet data.
> +// Select appropriate stream to read from
> +s->g = tile->tile_part[*tp_index].tpg;
> +if (tile->has_ppt) {
> +if (bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8) {
> +if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
> +s->g = tile->tile_part[++(*tp_index)].tpg;
> +}
> +}
> +if (bytestream2_peek_be32(&s->g) == JPEG2000_SOP_FIXED_BYTES)
> +bytestream2_skip(&s->g, JPEG2000_SOP_BYTE_LENGTH);
> +}
>  for (bandno = 0; bandno < rlevel->nbands; bandno++) {
>  Jpeg2000Band *band = rlevel->band + bandno;
>  Jpeg2000Prec *prec = band->prec + precno;
> @@ -1097,6 +1129,8 @@ static int 
> jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
>  av_freep(&cblk->lengthinc);
>  }
>  }
> +// Save state of stream
> +tile->tile_part[*tp_index].tpg = s->g;
>  return 0;
>  }

has_ppt is never set in this also it is specific to the new functional code.
it and all branches which depend on it being 1 should be in the 2nd patch.

The function split should be in the first patch instead

Its probably easiest if you first merge the 2 patches and then remove all
ppt feature specific code which was added. what remains should be the first
patch. the diff from that to the final result would be the 2nd.
At least i think that would bring it closer to what the idea is with this
split. you / we need to take a look at how this looks after doing it.
There may still be obvious things that can be cleaned up ...

thx

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

No snowflake in an avalanche ever feels responsible. -- Voltaire


signature.asc
Description: PGP signature
_

Re: [FFmpeg-devel] [PATCH V1 1/4] lavf/flvdec: set AVFMT_TS_DISCONT flag on FLV demuxer

2020-03-30 Thread myp...@gmail.com
On Tue, Mar 31, 2020 at 5:29 AM Michael Niedermayer
 wrote:
>
> On Mon, Mar 30, 2020 at 04:22:51PM +0800, Jun Zhao wrote:
> > From: Jun Zhao 
> >
> > There have been some reports about FLV timestamp discontinuities present.
> > e,g, the file recorded from live RTMP FLV streaming, so add
> > AVFMT_TS_DISCONT flag on FLV demuxer and also update the fate test
> > fate-filter-aresample for test sample nellymoser-discont.flv.
> >
> > BTW: live_flv demuxer also enabled the AVFMT_TS_DISCONT flag.
>
> Maybe i misunderstand but this sounds like you have a live_flv
> file and its demuxed by the non live demuxer.
> IIRC AVFMT_TS_DISCONT is the main difference between the 2
>
Yes, it's as you think, and I think we can merge/combine the flv
demuxer and live_flvdec demuxer with AVFMT_TS_DISCONT flag
___
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 V1 4/4] lavf/mov: support dvcC/dvvC box for Dolby Vision

2020-03-30 Thread myp...@gmail.com
On Mon, Mar 30, 2020 at 10:56 PM Jan Ekström  wrote:
>
> On Mon, Mar 30, 2020 at 12:20 PM Jun Zhao  wrote:
> >
> > From: vacingfang 
> >
> > support dvcC/dvcC box from spec Dolby Vision Streams Within the
> > ISO Base MediaFile Format Version 2.1.2
> > (https://www.dolby.com/in/en/technologies/dolby-vision/dolby-vision\
> > -bitstreams-within-the-iso-base-media-file-format-v2.1.2.pdf)
> >
> > And export the Dolby Vision profile/level with metadata.
> >
> > Signed-off-by: vacingfang 
> > ---
> >  libavformat/mov.c | 33 +
> >  1 file changed, 33 insertions(+)
> >
> > diff --git a/libavformat/mov.c b/libavformat/mov.c
> > index f280f36..76d90a7 100644
> > --- a/libavformat/mov.c
> > +++ b/libavformat/mov.c
> > @@ -6766,6 +6766,37 @@ static int mov_read_dmlp(MOVContext *c, AVIOContext 
> > *pb, MOVAtom atom)
> >  return 0;
> >  }
> >
> > +static int mov_read_dvcc_dvvc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
> > +{
> > +AVStream *st;
> > +uint8_t version_major, version_minor, profile, level;
> > +char str_buf[32];
> > +uint16_t tmp;
> > +
> > +if (c->fc->nb_streams < 1)
> > +return 0;
> > +st = c->fc->streams[c->fc->nb_streams-1];
> > +
> > +if ((uint64_t)atom.size > (1<<30) || atom.size < 4)
> > +return AVERROR_INVALIDDATA;
> > +
> > +version_major = avio_r8(pb);
> > +version_minor = avio_r8(pb);
> > +
> > +tmp = avio_rb16(pb);
> > +profile = (tmp >> 9) & 0x7f;// 7bits
> > +level   = (tmp >> 3) & 0x3f;// 6 bits
> > +av_log(c, AV_LOG_DEBUG, "dolby vision stream, version: %d.%d, profile: 
> > %d, level: %d\n",
> > +version_major, version_minor, profile, level);
> > +
> > +snprintf(str_buf, sizeof(str_buf), "%d", profile);
> > +av_dict_set(&st->metadata, "dovi_profile", str_buf, 0);
> > +snprintf(str_buf, sizeof(str_buf), "%d", level);
> > +av_dict_set(&st->metadata, "dovi_level", str_buf, 0);
> > +
>
> Hi,
>
> I would really prefer a piece of side data here. Means that the
> structure would be defined, and you wouldn't need to do string <-> int
> switches around (as well as the possibility of just passing this along
> so that the muxer on the other side could then re-create the
> DOVIConfigurationBox in case writing it gets implemented.
>
> Best regards,
> Jan
I like this idea, will follow the comments, tks
___
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: add hls_fmp4_init_refresh option

2020-03-30 Thread Andreas Rheinhardt
Steven Liu:
> add option for refresh init file after m3u8 refresh everytime.
> 
> Signed-off-by: Steven Liu 
> ---
>  doc/muxers.texi  |  3 +++
>  libavformat/hlsenc.c | 44 ++--
>  2 files changed, 41 insertions(+), 6 deletions(-)
> 
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index d304181671..fc38f40bc9 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -836,6 +836,9 @@ fmp4 files may be used in HLS version 7 and above.
>  @item hls_fmp4_init_filename @var{filename}
>  Set filename to the fragment files header file, default filename is 
> @file{init.mp4}.
>  
> +@item hls_fmp4_init_refresh @var{filename}
> +Refresh init file after m3u8 file refresh every time, default is @var{0}.

The first "refresh" means "resend", doesn't it? Using "refresh" suggests
that the init file will be resent with slightly different content each
time it is sent; yet this doesn't seem to be the case.

> +
>  When @code{var_stream_map} is set with two or more variant streams, the
>  @var{filename} pattern must contain the string "%v", this string specifies
>  the position of variant stream index in the generated init file names.
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index a3c59432c5..6bc77ec17e 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -119,6 +119,7 @@ typedef struct VariantStream {
>  int packets_written;
>  int init_range_length;
>  uint8_t *temp_buffer;
> +uint8_t *init_buffer;
>  
>  AVFormatContext *avf;
>  AVFormatContext *vtt_avf;
> @@ -192,6 +193,7 @@ typedef struct HLSContext {
>  char *segment_filename;
>  char *fmp4_init_filename;
>  int segment_type;
> +int refresh_init_file;  ///< refresh init file into disk after refresh 
> m3u8
>  
>  int use_localtime;  ///< flag to expand filename with localtime
>  int use_localtime_mkdir;///< flag to mkdir dirname in timebased filename
> @@ -982,7 +984,8 @@ static int sls_flag_check_duration_size(HLSContext *hls, 
> VariantStream *vs)
>  return ret;
>  }
>  
> -static void sls_flag_file_rename(HLSContext *hls, VariantStream *vs, char 
> *old_filename) {
> +static void sls_flag_file_rename(HLSContext *hls, VariantStream *vs, char 
> *old_filename)
> +{

Stray change.

>  if ((hls->flags & (HLS_SECOND_LEVEL_SEGMENT_SIZE | 
> HLS_SECOND_LEVEL_SEGMENT_DURATION)) &&
>  strlen(vs->current_segment_final_filename_fmt)) {
>  ff_rename(old_filename, vs->avf->url, hls);
> @@ -2234,6 +2237,25 @@ static int hls_write_header(AVFormatContext *s)
>  return ret;
>  }
>  
> +static int hls_init_file_refresh(AVFormatContext *s, VariantStream *vs)
> +{
> +HLSContext *hls = s->priv_data;
> +AVDictionary *options = NULL;
> +int ret = 0;
> +
> +set_http_options(s, &options, hls);
> +ret = hlsenc_io_open(s, &vs->out, hls->fmp4_init_filename, &options);

You should free options here unconditionally before checking for errors.

> +if (ret < 0) {
> +av_dict_free(&options);
> +return ret;
> +}
> +avio_write(vs->out, vs->init_buffer, vs->init_range_length);
> +hlsenc_io_close(s, &vs->out, hls->fmp4_init_filename);
> +av_dict_free(&options);
> +
> +return ret;
> +}
> +
>  static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
>  {
>  HLSContext *hls = s->priv_data;
> @@ -2246,7 +2268,6 @@ static int hls_write_packet(AVFormatContext *s, 
> AVPacket *pkt)
>  int range_length = 0;
>  const char *proto = NULL;
>  int use_temp_file = 0;
> -uint8_t *buffer = NULL;
>  VariantStream *vs = NULL;
>  char *old_filename = NULL;
>  
> @@ -2332,9 +2353,10 @@ static int hls_write_packet(AVFormatContext *s, 
> AVPacket *pkt)
>  avio_flush(oc->pb);
>  if (hls->segment_type == SEGMENT_TYPE_FMP4) {
>  if (!vs->init_range_length) {
> -range_length = avio_close_dyn_buf(oc->pb, &buffer);
> -avio_write(vs->out, buffer, range_length);
> -av_freep(&buffer);
> +range_length = avio_close_dyn_buf(oc->pb, &vs->init_buffer);

You are relying on this code to be executed only once to not produce
memleaks in case refresh_init_file is set, aren't you? If so, is it
actually certain that range_length can't be zero in some weird corner case?

> +avio_write(vs->out, vs->init_buffer, range_length);
> +if (!hls->refresh_init_file)
> +av_freep(&vs->init_buffer);
>  vs->init_range_length = range_length;
>  avio_open_dyn_buf(&oc->pb);
>  vs->packets_written = 0;
> @@ -2446,6 +2468,14 @@ static int hls_write_packet(AVFormatContext *s, 
> AVPacket *pkt)
>  }
>  }
>  
> +if (hls->refresh_init_file && hls->segment_type == 
> SEGMENT_TYPE_FMP4) {
> +ret = hls_init_file_refresh(s, vs);
> +if (ret < 0) {
> +av_freep(&old

Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: add hls_fmp4_init_refresh option

2020-03-30 Thread Steven Liu


> 2020年3月31日 上午10:06,Andreas Rheinhardt  写道:
> 
> Steven Liu:
>> add option for refresh init file after m3u8 refresh everytime.
>> 
>> Signed-off-by: Steven Liu 
>> ---
>> doc/muxers.texi  |  3 +++
>> libavformat/hlsenc.c | 44 ++--
>> 2 files changed, 41 insertions(+), 6 deletions(-)
>> 
>> diff --git a/doc/muxers.texi b/doc/muxers.texi
>> index d304181671..fc38f40bc9 100644
>> --- a/doc/muxers.texi
>> +++ b/doc/muxers.texi
>> @@ -836,6 +836,9 @@ fmp4 files may be used in HLS version 7 and above.
>> @item hls_fmp4_init_filename @var{filename}
>> Set filename to the fragment files header file, default filename is 
>> @file{init.mp4}.
>> 
>> +@item hls_fmp4_init_refresh @var{filename}
>> +Refresh init file after m3u8 file refresh every time, default is @var{0}.
> 
> The first "refresh" means "resend", doesn't it? Using "refresh" suggests
> that the init file will be resent with slightly different content each
> time it is sent; yet this doesn't seem to be the case.
I cannot sure resend or rewrite, but your suggestion maybe right.
> 
>> +
>> When @code{var_stream_map} is set with two or more variant streams, the
>> @var{filename} pattern must contain the string "%v", this string specifies
>> the position of variant stream index in the generated init file names.
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index a3c59432c5..6bc77ec17e 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -119,6 +119,7 @@ typedef struct VariantStream {
>> int packets_written;
>> int init_range_length;
>> uint8_t *temp_buffer;
>> +uint8_t *init_buffer;
>> 
>> AVFormatContext *avf;
>> AVFormatContext *vtt_avf;
>> @@ -192,6 +193,7 @@ typedef struct HLSContext {
>> char *segment_filename;
>> char *fmp4_init_filename;
>> int segment_type;
>> +int refresh_init_file;  ///< refresh init file into disk after refresh 
>> m3u8
>> 
>> int use_localtime;  ///< flag to expand filename with localtime
>> int use_localtime_mkdir;///< flag to mkdir dirname in timebased filename
>> @@ -982,7 +984,8 @@ static int sls_flag_check_duration_size(HLSContext *hls, 
>> VariantStream *vs)
>> return ret;
>> }
>> 
>> -static void sls_flag_file_rename(HLSContext *hls, VariantStream *vs, char 
>> *old_filename) {
>> +static void sls_flag_file_rename(HLSContext *hls, VariantStream *vs, char 
>> *old_filename)
>> +{
> 
> Stray change.
> 
>> if ((hls->flags & (HLS_SECOND_LEVEL_SEGMENT_SIZE | 
>> HLS_SECOND_LEVEL_SEGMENT_DURATION)) &&
>> strlen(vs->current_segment_final_filename_fmt)) {
>> ff_rename(old_filename, vs->avf->url, hls);
>> @@ -2234,6 +2237,25 @@ static int hls_write_header(AVFormatContext *s)
>> return ret;
>> }
>> 
>> +static int hls_init_file_refresh(AVFormatContext *s, VariantStream *vs)
>> +{
>> +HLSContext *hls = s->priv_data;
>> +AVDictionary *options = NULL;
>> +int ret = 0;
>> +
>> +set_http_options(s, &options, hls);
>> +ret = hlsenc_io_open(s, &vs->out, hls->fmp4_init_filename, &options);
> 
> You should free options here unconditionally before checking for errors.
Ok,
> 
>> +if (ret < 0) {
>> +av_dict_free(&options);
>> +return ret;
>> +}
>> +avio_write(vs->out, vs->init_buffer, vs->init_range_length);
>> +hlsenc_io_close(s, &vs->out, hls->fmp4_init_filename);
>> +av_dict_free(&options);
>> +
>> +return ret;
>> +}
>> +
>> static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
>> {
>> HLSContext *hls = s->priv_data;
>> @@ -2246,7 +2268,6 @@ static int hls_write_packet(AVFormatContext *s, 
>> AVPacket *pkt)
>> int range_length = 0;
>> const char *proto = NULL;
>> int use_temp_file = 0;
>> -uint8_t *buffer = NULL;
>> VariantStream *vs = NULL;
>> char *old_filename = NULL;
>> 
>> @@ -2332,9 +2353,10 @@ static int hls_write_packet(AVFormatContext *s, 
>> AVPacket *pkt)
>> avio_flush(oc->pb);
>> if (hls->segment_type == SEGMENT_TYPE_FMP4) {
>> if (!vs->init_range_length) {
>> -range_length = avio_close_dyn_buf(oc->pb, &buffer);
>> -avio_write(vs->out, buffer, range_length);
>> -av_freep(&buffer);
>> +range_length = avio_close_dyn_buf(oc->pb, &vs->init_buffer);
> 
> You are relying on this code to be executed only once to not produce
> memleaks in case refresh_init_file is set, aren't you?
Yes,

> If so, is it
> actually certain that range_length can't be zero in some weird corner case?
Can you give me one example to describe this comment? The oc->pb is not null 
here.
> 
>> +avio_write(vs->out, vs->init_buffer, range_length);
>> +if (!hls->refresh_init_file)
>> +av_freep(&vs->init_buffer);
>> vs->init_range_length = range_length;
>> avio_open_dyn_buf(&oc->pb);
>> vs->packets_written = 0;
>> @@ -2446,6 +

Re: [FFmpeg-devel] [PATCH v8 1/3] libavcodec/jpeg2000dec.c: Split function and modify structs for PPM marker support

2020-03-30 Thread Gautam Ramakrishnan
On Tue, Mar 31, 2020 at 6:10 AM Michael Niedermayer
 wrote:
>
> On Mon, Mar 30, 2020 at 09:51:53PM +0530, gautamr...@gmail.com wrote:
> > From: Gautam Ramakrishnan 
> >
> > ---
> >  libavcodec/jpeg2000dec.c | 48 ++--
> >  1 file changed, 41 insertions(+), 7 deletions(-)
> >
> > diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> > index 7103cd6ceb..9d52969821 100644
> > --- a/libavcodec/jpeg2000dec.c
> > +++ b/libavcodec/jpeg2000dec.c
> > @@ -83,6 +83,10 @@ typedef struct Jpeg2000Tile {
> >  Jpeg2000QuantStyle  qntsty[4];
> >  Jpeg2000POC poc;
> >  Jpeg2000TileParttile_part[32];
> > +uint8_t has_ppt;// whether this tile has a 
> > ppt marker
> > +uint8_t *packed_headers;// contains packed 
> > headers. Used only along with PPT marker
> > +int packed_headers_size;// size in bytes of the 
> > packed headers
> > +GetByteContext  packed_headers_stream;  // byte context 
> > corresponding to packed headers
> >  uint16_t tp_idx;// Tile-part index
> >  int coord[2][2];// border coordinates {{x0, x1}, 
> > {y0, y1}}
> >  } Jpeg2000Tile;
> > @@ -935,21 +939,32 @@ static int 
> > jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
> >  int bandno, cblkno, ret, nb_code_blocks;
> >  int cwsno;
> >
> > +// This part decodes the packet header
> > +
> >  if (layno < rlevel->band[0].prec[precno].decoded_layers)
> >  return 0;
> >  rlevel->band[0].prec[precno].decoded_layers = layno + 1;
> > -
> > -if (bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8) {
> > -if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
> > -s->g = tile->tile_part[++(*tp_index)].tpg;
> > +// Select appropriate stream to read from
> > +if (tile->has_ppt) {
> > +s->g = tile->packed_headers_stream;
> > +} else {
> > +s->g = tile->tile_part[*tp_index].tpg;
> > +if (bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8) {
> > +if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
> > +s->g = tile->tile_part[++(*tp_index)].tpg;
> > +}
> >  }
> > +if (bytestream2_peek_be32(&s->g) == JPEG2000_SOP_FIXED_BYTES)
> > +bytestream2_skip(&s->g, JPEG2000_SOP_BYTE_LENGTH);
> >  }
> >
> > -if (bytestream2_peek_be32(&s->g) == JPEG2000_SOP_FIXED_BYTES)
> > -bytestream2_skip(&s->g, JPEG2000_SOP_BYTE_LENGTH);
> > -
> >  if (!(ret = get_bits(s, 1))) {
> >  jpeg2000_flush(s);
> > +// Save state of stream
> > +if (tile->has_ppt)
> > +tile->packed_headers_stream = s->g;
> > +else
> > +tile->tile_part[*tp_index].tpg = s->g;
> >  return 0;
> >  } else if (ret < 0)
> >  return ret;
> > @@ -1056,6 +1071,23 @@ static int 
> > jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
> >  av_log(s->avctx, AV_LOG_ERROR, "EPH marker not found. instead 
> > %X\n", bytestream2_peek_be32(&s->g));
> >  }
> >
> > +if (tile->has_ppt)
> > +tile->packed_headers_stream = s->g;
> > +else
> > +tile->tile_part[*tp_index].tpg = s->g;
> > +
> > +// This part decodes the packet data.
> > +// Select appropriate stream to read from
> > +s->g = tile->tile_part[*tp_index].tpg;
> > +if (tile->has_ppt) {
> > +if (bytestream2_get_bytes_left(&s->g) == 0 && s->bit_index == 8) {
> > +if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
> > +s->g = tile->tile_part[++(*tp_index)].tpg;
> > +}
> > +}
> > +if (bytestream2_peek_be32(&s->g) == JPEG2000_SOP_FIXED_BYTES)
> > +bytestream2_skip(&s->g, JPEG2000_SOP_BYTE_LENGTH);
> > +}
> >  for (bandno = 0; bandno < rlevel->nbands; bandno++) {
> >  Jpeg2000Band *band = rlevel->band + bandno;
> >  Jpeg2000Prec *prec = band->prec + precno;
> > @@ -1097,6 +1129,8 @@ static int 
> > jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
> >  av_freep(&cblk->lengthinc);
> >  }
> >  }
> > +// Save state of stream
> > +tile->tile_part[*tp_index].tpg = s->g;
> >  return 0;
> >  }
>
> has_ppt is never set in this also it is specific to the new functional code.
> it and all branches which depend on it being 1 should be in the 2nd patch.
>
> The function split should be in the first patch instead
>
Sure, now its clear. Shall do that

> Its probably easiest if you first merge the 2 patches and then remove all
> ppt feature specific code which was added. what remains should be the first
> patch. the diff from that to the final result would be the 2nd.
> At least i think that would bring it closer to what the idea is with this
> split. you / we need to take a look at how this looks 

Re: [FFmpeg-devel] [PATCH] libavformat/amr.c: Check return value from avio_read()

2020-03-30 Thread John Rummell
Hit send too soon. Patch attached.

On Mon, Mar 30, 2020 at 9:44 PM John Rummell  wrote:

> Another uninitialized memory access detected by the Chromium fuzzers.
>


0001-libavformat-amr.c-Check-return-value-from-avio_read.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".

Re: [FFmpeg-devel] [PATCH] Fixing rare dshow input crash

2020-03-30 Thread Roger Pack
On Wed, Feb 26, 2020 at 4:36 AM Carl Eugen Hoyos  wrote:
>
> Am Mi., 26. Feb. 2020 um 06:57 Uhr schrieb Roger Pack :
> >
> > Original bigger patch is enough for now.  Please merge, thanks!
>
> What happened to your git account?

I never made one.  Do we still send in private keys for it?  If so to whom?
Thanks.

>
> Carl Eugen
> ___
> 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] [PATCH] libavformat/amr.c: Check return value from avio_read()

2020-03-30 Thread John Rummell
Another uninitialized memory access detected by the Chromium fuzzers.
___
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".