[FFmpeg-devel] [PATCH 2/2] lavf/vaapi_encode: fix to set the default max bitrate for AVC VBR

2018-03-11 Thread Pengfei Qu
And for VBR mode, generally the max bit rate is bigger than the taraget
bitrate. For CBR mode, the max bitrate is same as the target bitrate.
 when there is no specfic setting for the max bit rate parameter,
here the default value 95% is used to caculate the default max bitrate 
accordingly.

Signed-off-by: Pengfei Qu 
---
 libavcodec/vaapi_encode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 78347d4..47110cf 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -1164,8 +1164,8 @@ static av_cold int 
vaapi_encode_init_rate_control(AVCodecContext *avctx)
 } else {
 if (avctx->rc_max_rate < avctx->bit_rate) {
 // Max rate is unset or invalid, just use the normal bitrate.
-rc_bits_per_second   = avctx->bit_rate;
-rc_target_percentage = 100;
+rc_target_percentage = 95;
+rc_bits_per_second   = (unsigned long)(avctx->bit_rate * 100.0 / 
rc_target_percentage);
 } else {
 rc_bits_per_second   = avctx->rc_max_rate;
 rc_target_percentage = (unsigned long)(avctx->bit_rate * 100) / 
rc_bits_per_second;
-- 
2.9.3

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


[FFmpeg-devel] [PATCH 1/2] lavc/vaapi_encode: fix the caculation overflow

2018-03-11 Thread Pengfei Qu
this fix the overflow during the caculation before value assignment.

Signed-off-by: Pengfei Qu 
---
 libavcodec/vaapi_encode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 36c85a3..78347d4 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -1168,9 +1168,9 @@ static av_cold int 
vaapi_encode_init_rate_control(AVCodecContext *avctx)
 rc_target_percentage = 100;
 } else {
 rc_bits_per_second   = avctx->rc_max_rate;
-rc_target_percentage = (avctx->bit_rate * 100) / 
rc_bits_per_second;
+rc_target_percentage = (unsigned long)(avctx->bit_rate * 100) / 
rc_bits_per_second;
 }
-rc_window_size = (hrd_buffer_size * 1000) / avctx->bit_rate;
+rc_window_size = (unsigned long)(hrd_buffer_size * 1000) / 
avctx->bit_rate;
 }
 
 ctx->rc_params.misc.type = VAEncMiscParameterTypeRateControl;
-- 
2.9.3

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


Re: [FFmpeg-devel] [PATCH] ffprobe: fix infinite loop in subtitle decoding

2018-03-11 Thread wm4
On Sun, 11 Mar 2018 18:12:05 +0100
Marton Balint  wrote:

> Fixes a regression since 2a88ebd096f3c748a2d99ed1b60b22879b3c567c which caused
> an infinite loop in the subtitle decoding.
> 
> Fixes ticket #6796.
> 
> Signed-off-by: Marton Balint 
> ---
>  fftools/ffprobe.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
> index 967adbe30c..d8032bfddf 100644
> --- a/fftools/ffprobe.c
> +++ b/fftools/ffprobe.c
> @@ -2275,7 +2275,8 @@ static av_always_inline int process_frame(WriterContext 
> *w,
>  break;
>  
>  case AVMEDIA_TYPE_SUBTITLE:
> -ret = avcodec_decode_subtitle2(dec_ctx, , _frame, pkt);
> +if (*packet_new || !pkt->data)
> +ret = avcodec_decode_subtitle2(dec_ctx, , _frame, 
> pkt);
>  *packet_new = 0;
>  break;
>  default:

LGTM, but not sure why the "!pkt->data" check would be needed. The
flush packet sent at the end will have *packet_new==1.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH V2 04/11] lavc/extract_extradata_bsf: support dump options.

2018-03-11 Thread Jun Zhao

From b6af8d9d77411c15922d98b710f3c335ee898603 Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Thu, 8 Mar 2018 14:05:53 +0800
Subject: [PATCH V2 04/11] lavc/extract_extradata_bsf: support dump options.

support dump bit stream filter options

Signed-off-by: Jun Zhao 
---
 libavcodec/extract_extradata_bsf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/extract_extradata_bsf.c 
b/libavcodec/extract_extradata_bsf.c
index 1c386becd7..007a6a71f5 100644
--- a/libavcodec/extract_extradata_bsf.c
+++ b/libavcodec/extract_extradata_bsf.c
@@ -322,9 +322,10 @@ static const enum AVCodecID codec_ids[] = {
 };
 
 #define OFFSET(x) offsetof(ExtractExtradataContext, x)
+#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
 static const AVOption options[] = {
 { "remove", "remove the extradata from the bitstream", OFFSET(remove), 
AV_OPT_TYPE_INT,
-{ .i64 = 0 }, 0, 1 },
+{ .i64 = 0 }, 0, 1 , FLAGS},
 { NULL },
 };
 
-- 
2.14.1

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


[FFmpeg-devel] [PATCH V2 11/11] lavu/opt: update fate to support dump bit stream filter option.

2018-03-11 Thread Jun Zhao

From ec00625932e794c52c816d35cca5fade8cdfa4a9 Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Sat, 10 Mar 2018 13:35:03 +0800
Subject: [PATCH V2 11/11] lavu/opt: update fate to support dump bit stream
 filter option.

Signed-off-by: Jun Zhao 
---
 tests/ref/fate/opt | 50 +-
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/tests/ref/fate/opt b/tests/ref/fate/opt
index 7b47d429c5..6a7dbfa797 100644
--- a/tests/ref/fate/opt
+++ b/tests/ref/fate/opt
@@ -18,31 +18,31 @@ num64=1
 flt=0.33
 dbl=0.33
 TestContext AVOptions:
-  -num   E... set num (from 0 to 100) (default 0)
-  -toggleE... set toggle (from 0 to 1) (default 1)
-  -rational E... set rational (from 0 to 10) 
(default 1/1)
-  -string E... set string (default "default")
-  -escape E... set escape str (default "\=,")
-  -flags   E... set flags (default cool)
- cool E... set cool flag
- lame E... set lame flag
- mu   E... set mu flag
-  -size   E... set size (default "200x300")
-  -pix_fmt   E... set pixfmt (default 0bgr)
-  -sample_fmt E... set samplefmt (default s16)
-  -video_rate E... set videorate (default "25")
-  -duration E... set duration (default 0.001)
-  -color   E... set color (default "pink")
-  -cl E... set channel layout (default 
0x137)
-  -binE... set binary value
-  -bin1   E... set binary value
-  -bin2   E... set binary value
-  -num64   E... set num 64bit (from 0 to 100) 
(default 1)
-  -flt E... set float (from 0 to 100) (default 
0.33)
-  -dblE... set double (from 0 to 100) (default 
0.33)
-  -bool1 E... set boolean value (default auto)
-  -bool2 E... set boolean value (default true)
-  -bool3 E... set boolean value (default false)
+  -num   E set num (from 0 to 100) (default 0)
+  -toggleE set toggle (from 0 to 1) (default 
1)
+  -rational E set rational (from 0 to 10) 
(default 1/1)
+  -string E set string (default "default")
+  -escape E set escape str (default "\=,")
+  -flags   E set flags (default cool)
+ cool E set cool flag
+ lame E set lame flag
+ mu   E set mu flag
+  -size   E set size (default "200x300")
+  -pix_fmt   E set pixfmt (default 0bgr)
+  -sample_fmt E set samplefmt (default s16)
+  -video_rate E set videorate (default "25")
+  -duration E set duration (default 0.001)
+  -color   E set color (default "pink")
+  -cl E set channel layout (default 
0x137)
+  -binE set binary value
+  -bin1   E set binary value
+  -bin2   E set binary value
+  -num64   E set num 64bit (from 0 to 100) 
(default 1)
+  -flt E set float (from 0 to 100) (default 
0.33)
+  -dblE set double (from 0 to 100) 
(default 0.33)
+  -bool1 E set boolean value (default auto)
+  -bool2 E set boolean value (default true)
+  -bool3 E set boolean value (default false)
 
 Testing av_opt_is_set_to_default()
 name:   num default:1 error:
-- 
2.14.1

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


[FFmpeg-devel] [PATCH V2 10/11] doc/fftools-common-opts: allow printing bsf details.

2018-03-11 Thread Jun Zhao

From 4e2d8947a614c664be843532dfefa7976be4b720 Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Thu, 8 Mar 2018 15:18:11 +0800
Subject: [PATCH V2 10/11] doc/fftools-common-opts: allow printing bsf details.

Signed-off-by: Jun Zhao 
---
 doc/fftools-common-opts.texi | 4 
 1 file changed, 4 insertions(+)

diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi
index 185ec218d5..a0b0781050 100644
--- a/doc/fftools-common-opts.texi
+++ b/doc/fftools-common-opts.texi
@@ -102,6 +102,10 @@ Print detailed information about the muxer named 
@var{muxer_name}. Use the
 @item filter=@var{filter_name}
 Print detailed information about the filter name @var{filter_name}. Use the
 @option{-filters} option to get a list of all filters.
+
+@item bsf=@var{bit_stream_filter_name}
+Print detailed information about the bit stream filter name 
@var{bit_stream_filter_name}.
+Use the @option{-bsfs} option to get a list of all bit stream filters.
 @end table
 
 @item -version
-- 
2.14.1

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


[FFmpeg-devel] [PATCH V2 09/11] lavc/remove_extradata_bsf: support dump options.

2018-03-11 Thread Jun Zhao

From 6f808695a291f8ddf9b56b4d26d3e9fdd47aadd5 Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Thu, 8 Mar 2018 15:00:27 +0800
Subject: [PATCH V2 09/11] lavc/remove_extradata_bsf: support dump options.

support dump bit stream filter options

Signed-off-by: Jun Zhao 
---
 libavcodec/remove_extradata_bsf.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavcodec/remove_extradata_bsf.c 
b/libavcodec/remove_extradata_bsf.c
index d74391e547..b762079e05 100644
--- a/libavcodec/remove_extradata_bsf.c
+++ b/libavcodec/remove_extradata_bsf.c
@@ -90,12 +90,13 @@ static void remove_extradata_close(AVBSFContext *ctx)
 }
 
 #define OFFSET(x) offsetof(RemoveExtradataContext, x)
+#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
 static const AVOption options[] = {
-{ "freq", NULL, OFFSET(freq), AV_OPT_TYPE_INT, { .i64 = 
REMOVE_FREQ_KEYFRAME }, REMOVE_FREQ_KEYFRAME, REMOVE_FREQ_NONKEYFRAME, 0, 
"freq" },
-{ "k",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 
REMOVE_FREQ_NONKEYFRAME }, .unit = "freq" },
-{ "keyframe", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 
REMOVE_FREQ_KEYFRAME }, .unit = "freq" },
-{ "e",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = REMOVE_FREQ_ALL 
 }, .unit = "freq" },
-{ "all",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = REMOVE_FREQ_ALL 
 }, .unit = "freq" },
+{ "freq", NULL, OFFSET(freq), AV_OPT_TYPE_INT, { .i64 = 
REMOVE_FREQ_KEYFRAME }, REMOVE_FREQ_KEYFRAME, REMOVE_FREQ_NONKEYFRAME, FLAGS, 
"freq" },
+{ "k",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 
REMOVE_FREQ_NONKEYFRAME }, .flags = FLAGS, .unit = "freq" },
+{ "keyframe", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 
REMOVE_FREQ_KEYFRAME }, .flags = FLAGS, .unit = "freq" },
+{ "e",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = REMOVE_FREQ_ALL 
 }, .flags = FLAGS, .unit = "freq" },
+{ "all",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = REMOVE_FREQ_ALL 
 }, .flags = FLAGS, .unit = "freq" },
 { NULL },
 };
 
-- 
2.14.1

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


[FFmpeg-devel] [PATCH V2 08/11] lavc/noise_bsf: support dump options.

2018-03-11 Thread Jun Zhao

From be6e5bb9188574096f1a4de2d3c9c71e14aafe3e Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Thu, 8 Mar 2018 14:57:47 +0800
Subject: [PATCH V2 08/11] lavc/noise_bsf: support dump options.

support dump bit stream filter options.

Signed-off-by: Jun Zhao 
---
 libavcodec/noise_bsf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/noise_bsf.c b/libavcodec/noise_bsf.c
index 84b94032ad..6bb89507fc 100644
--- a/libavcodec/noise_bsf.c
+++ b/libavcodec/noise_bsf.c
@@ -78,9 +78,10 @@ fail:
 }
 
 #define OFFSET(x) offsetof(NoiseContext, x)
+#define FLAGS 
(AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_BSF_PARAM)
 static const AVOption options[] = {
-{ "amount", NULL, OFFSET(amount), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 
INT_MAX },
-{ "dropamount", NULL, OFFSET(dropamount), AV_OPT_TYPE_INT, { .i64 = 0 }, 
0, INT_MAX },
+{ "amount", NULL, OFFSET(amount), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 
INT_MAX, FLAGS },
+{ "dropamount", NULL, OFFSET(dropamount), AV_OPT_TYPE_INT, { .i64 = 0 }, 
0, INT_MAX, FLAGS },
 { NULL },
 };
 
-- 
2.14.1

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


[FFmpeg-devel] [PATCH V2 05/11] lavc/h264_metadata_bsf: support dump options.

2018-03-11 Thread Jun Zhao

From 70221e1330749ea09b2bfbe682326f4bad913c55 Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Thu, 8 Mar 2018 14:22:25 +0800
Subject: [PATCH V2 05/11] lavc/h264_metadata_bsf: support dump options.

support dump bit stream filter options

Signed-off-by: Jun Zhao 
---
 libavcodec/h264_metadata_bsf.c | 39 ---
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
index 466823cda6..12e739a354 100644
--- a/libavcodec/h264_metadata_bsf.c
+++ b/libavcodec/h264_metadata_bsf.c
@@ -451,63 +451,64 @@ static void h264_metadata_close(AVBSFContext *bsf)
 }
 
 #define OFFSET(x) offsetof(H264MetadataContext, x)
+#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
 static const AVOption h264_metadata_options[] = {
 { "aud", "Access Unit Delimiter NAL units",
 OFFSET(aud), AV_OPT_TYPE_INT,
-{ .i64 = PASS }, PASS, REMOVE, 0, "aud" },
-{ "pass",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PASS   }, .unit = "aud" },
-{ "insert", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = INSERT }, .unit = "aud" },
-{ "remove", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = REMOVE }, .unit = "aud" },
+{ .i64 = PASS }, PASS, REMOVE, FLAGS, "aud" },
+{ "pass",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PASS   }, .flags = FLAGS, 
.unit = "aud" },
+{ "insert", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = INSERT }, .flags = FLAGS, 
.unit = "aud" },
+{ "remove", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = REMOVE }, .flags = FLAGS, 
.unit = "aud" },
 
 { "sample_aspect_ratio", "Set sample aspect ratio (table E-1)",
 OFFSET(sample_aspect_ratio), AV_OPT_TYPE_RATIONAL,
-{ .dbl = 0.0 }, 0, 65535 },
+{ .dbl = 0.0 }, 0, 65535, FLAGS },
 
 { "video_format", "Set video format (table E-2)",
 OFFSET(video_format), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, 7 },
+{ .i64 = -1 }, -1, 7, FLAGS},
 { "video_full_range_flag", "Set video full range flag",
 OFFSET(video_full_range_flag), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, 1 },
+{ .i64 = -1 }, -1, 1, FLAGS },
 { "colour_primaries", "Set colour primaries (table E-3)",
 OFFSET(colour_primaries), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, 255 },
+{ .i64 = -1 }, -1, 255, FLAGS },
 { "transfer_characteristics", "Set transfer characteristics (table E-4)",
 OFFSET(transfer_characteristics), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, 255 },
+{ .i64 = -1 }, -1, 255, FLAGS },
 { "matrix_coefficients", "Set matrix coefficients (table E-5)",
 OFFSET(matrix_coefficients), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, 255 },
+{ .i64 = -1 }, -1, 255, FLAGS },
 
 { "chroma_sample_loc_type", "Set chroma sample location type (figure E-1)",
 OFFSET(chroma_sample_loc_type), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, 6 },
+{ .i64 = -1 }, -1, 6, FLAGS },
 
 { "tick_rate", "Set VUI tick rate (num_units_in_tick / time_scale)",
 OFFSET(tick_rate), AV_OPT_TYPE_RATIONAL,
-{ .dbl = 0.0 }, 0, UINT_MAX },
+{ .dbl = 0.0 }, 0, UINT_MAX, FLAGS },
 { "fixed_frame_rate_flag", "Set VUI fixed frame rate flag",
 OFFSET(fixed_frame_rate_flag), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, 1 },
+{ .i64 = -1 }, -1, 1, FLAGS },
 
 { "crop_left", "Set left border crop offset",
 OFFSET(crop_left), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, H264_MAX_WIDTH },
+{ .i64 = -1 }, -1, H264_MAX_WIDTH, FLAGS },
 { "crop_right", "Set right border crop offset",
 OFFSET(crop_right), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, H264_MAX_WIDTH },
+{ .i64 = -1 }, -1, H264_MAX_WIDTH, FLAGS },
 { "crop_top", "Set top border crop offset",
 OFFSET(crop_top), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, H264_MAX_HEIGHT },
+{ .i64 = -1 }, -1, H264_MAX_HEIGHT, FLAGS },
 { "crop_bottom", "Set bottom border crop offset",
 OFFSET(crop_bottom), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, H264_MAX_HEIGHT },
+{ .i64 = -1 }, -1, H264_MAX_HEIGHT, FLAGS },
 
 { "sei_user_data", "Insert SEI user data (UUID+string)",
-OFFSET(sei_user_data), AV_OPT_TYPE_STRING, { .str = NULL } },
+OFFSET(sei_user_data), AV_OPT_TYPE_STRING, { .str = NULL }, .flags = 
FLAGS },
 
 { "delete_filler", "Delete all filler (both NAL and SEI)",
-OFFSET(delete_filler), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1 },
+OFFSET(delete_filler), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1 , FLAGS},
 
 { NULL }
 };
-- 
2.14.1

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


[FFmpeg-devel] [PATCH V2 06/11] lavc/h265_metadata_bsf: support dump options.

2018-03-11 Thread Jun Zhao

From 914eb177fc86418f584a8472d83c8017a4531458 Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Thu, 8 Mar 2018 14:28:13 +0800
Subject: [PATCH V2 06/11] lavc/h265_metadata_bsf: support dump options.

support dump bit stream filter options

Signed-off-by: Jun Zhao 
---
 libavcodec/h265_metadata_bsf.c | 35 ++-
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/libavcodec/h265_metadata_bsf.c b/libavcodec/h265_metadata_bsf.c
index 2398ee95c5..2b5dd9debd 100644
--- a/libavcodec/h265_metadata_bsf.c
+++ b/libavcodec/h265_metadata_bsf.c
@@ -379,59 +379,60 @@ static void h265_metadata_close(AVBSFContext *bsf)
 }
 
 #define OFFSET(x) offsetof(H265MetadataContext, x)
+#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
 static const AVOption h265_metadata_options[] = {
 { "aud", "Access Unit Delimiter NAL units",
 OFFSET(aud), AV_OPT_TYPE_INT,
-{ .i64 = PASS }, PASS, REMOVE, 0, "aud" },
-{ "pass",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PASS   }, .unit = "aud" },
-{ "insert", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = INSERT }, .unit = "aud" },
-{ "remove", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = REMOVE }, .unit = "aud" },
+{ .i64 = PASS }, PASS, REMOVE, FLAGS, "aud" },
+{ "pass",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PASS   }, .flags = FLAGS, 
.unit = "aud" },
+{ "insert", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = INSERT }, .flags = FLAGS, 
.unit = "aud" },
+{ "remove", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = REMOVE }, .flags = FLAGS, 
.unit = "aud" },
 
 { "sample_aspect_ratio", "Set sample aspect ratio (table E-1)",
 OFFSET(sample_aspect_ratio), AV_OPT_TYPE_RATIONAL,
-{ .dbl = 0.0 }, 0, 65535 },
+{ .dbl = 0.0 }, 0, 65535, FLAGS },
 
 { "video_format", "Set video format (table E-2)",
 OFFSET(video_format), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, 7 },
+{ .i64 = -1 }, -1, 7, FLAGS },
 { "video_full_range_flag", "Set video full range flag",
 OFFSET(video_full_range_flag), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, 1 },
+{ .i64 = -1 }, -1, 1, FLAGS },
 { "colour_primaries", "Set colour primaries (table E-3)",
 OFFSET(colour_primaries), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, 255 },
+{ .i64 = -1 }, -1, 255, FLAGS },
 { "transfer_characteristics", "Set transfer characteristics (table E-4)",
 OFFSET(transfer_characteristics), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, 255 },
+{ .i64 = -1 }, -1, 255, FLAGS },
 { "matrix_coefficients", "Set matrix coefficients (table E-5)",
 OFFSET(matrix_coefficients), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, 255 },
+{ .i64 = -1 }, -1, 255, FLAGS },
 
 { "chroma_sample_loc_type", "Set chroma sample location type (figure E-1)",
 OFFSET(chroma_sample_loc_type), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, 6 },
+{ .i64 = -1 }, -1, 6, FLAGS },
 
 { "tick_rate",
 "Set VPS and VUI tick rate (num_units_in_tick / time_scale)",
 OFFSET(tick_rate), AV_OPT_TYPE_RATIONAL,
-{ .dbl = 0.0 }, 0, UINT_MAX },
+{ .dbl = 0.0 }, 0, UINT_MAX, FLAGS },
 { "num_ticks_poc_diff_one",
 "Set VPS and VUI number of ticks per POC increment",
 OFFSET(num_ticks_poc_diff_one), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, INT_MAX },
+{ .i64 = -1 }, -1, INT_MAX, FLAGS },
 
 { "crop_left", "Set left border crop offset",
 OFFSET(crop_left), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, HEVC_MAX_WIDTH },
+{ .i64 = -1 }, -1, HEVC_MAX_WIDTH, FLAGS },
 { "crop_right", "Set right border crop offset",
 OFFSET(crop_right), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, HEVC_MAX_WIDTH },
+{ .i64 = -1 }, -1, HEVC_MAX_WIDTH, FLAGS },
 { "crop_top", "Set top border crop offset",
 OFFSET(crop_top), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, HEVC_MAX_HEIGHT },
+{ .i64 = -1 }, -1, HEVC_MAX_HEIGHT, FLAGS },
 { "crop_bottom", "Set bottom border crop offset",
 OFFSET(crop_bottom), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, HEVC_MAX_HEIGHT },
+{ .i64 = -1 }, -1, HEVC_MAX_HEIGHT, FLAGS },
 
 { NULL }
 };
-- 
2.14.1

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


[FFmpeg-devel] [PATCH V2 07/11] lavc/mpeg2_metadata_bsf: support dump options.

2018-03-11 Thread Jun Zhao

From e1829b0456a20b6c6e2cfaedb2c581e8ad374d49 Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Thu, 8 Mar 2018 14:31:30 +0800
Subject: [PATCH V2 07/11] lavc/mpeg2_metadata_bsf: support dump options.

support dump bit stream filter options

Signed-off-by: Jun Zhao 
---
 libavcodec/mpeg2_metadata_bsf.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/libavcodec/mpeg2_metadata_bsf.c b/libavcodec/mpeg2_metadata_bsf.c
index 3bb6c1d549..6d5f581ab1 100644
--- a/libavcodec/mpeg2_metadata_bsf.c
+++ b/libavcodec/mpeg2_metadata_bsf.c
@@ -266,27 +266,28 @@ static void mpeg2_metadata_close(AVBSFContext *bsf)
 }
 
 #define OFFSET(x) offsetof(MPEG2MetadataContext, x)
+#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
 static const AVOption mpeg2_metadata_options[] = {
 { "display_aspect_ratio", "Set display aspect ratio (table 6-3)",
 OFFSET(display_aspect_ratio), AV_OPT_TYPE_RATIONAL,
-{ .dbl = 0.0 }, 0, 65535 },
+{ .dbl = 0.0 }, 0, 65535, FLAGS },
 
 { "frame_rate", "Set frame rate",
 OFFSET(frame_rate), AV_OPT_TYPE_RATIONAL,
-{ .dbl = 0.0 }, 0, UINT_MAX },
+{ .dbl = 0.0 }, 0, UINT_MAX, FLAGS },
 
 { "video_format", "Set video format (table 6-6)",
 OFFSET(video_format), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, 7 },
+{ .i64 = -1 }, -1, 7, FLAGS },
 { "colour_primaries", "Set colour primaries (table 6-7)",
 OFFSET(colour_primaries), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, 255 },
+{ .i64 = -1 }, -1, 255, FLAGS },
 { "transfer_characteristics", "Set transfer characteristics (table 6-8)",
 OFFSET(transfer_characteristics), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, 255 },
+{ .i64 = -1 }, -1, 255, FLAGS },
 { "matrix_coefficients", "Set matrix coefficients (table 6-9)",
 OFFSET(matrix_coefficients), AV_OPT_TYPE_INT,
-{ .i64 = -1 }, -1, 255 },
+{ .i64 = -1 }, -1, 255, FLAGS },
 
 { NULL }
 };
-- 
2.14.1

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


[FFmpeg-devel] [PATCH V2 01/11] lavu/opt: add AV_OPT_FLAG_BSF_PARAM

2018-03-11 Thread Jun Zhao
V2: update opt fate test ref file
From 5cd2a18ebe1494e11b08e33ca5587f7d17f41964 Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Thu, 8 Mar 2018 13:47:23 +0800
Subject: [PATCH V2 01/11] lavu/opt: add AV_OPT_FLAG_BSF_PARAM

add AV_OPT_FLAG_BSF_PARAM for bit stream filter options.

Signed-off-by: Jun Zhao 
---
 libavutil/opt.c | 1 +
 libavutil/opt.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index df88663e3f..3b0aab4ee8 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1181,6 +1181,7 @@ static void opt_list(void *obj, void *av_log_obj, const 
char *unit,
 av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & 
AV_OPT_FLAG_SUBTITLE_PARAM) ? 'S' : '.');
 av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & 
AV_OPT_FLAG_EXPORT) ? 'X' : '.');
 av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & 
AV_OPT_FLAG_READONLY)   ? 'R' : '.');
+av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & 
AV_OPT_FLAG_BSF_PARAM)  ? 'B' : '.');
 
 if (opt->help)
 av_log(av_log_obj, AV_LOG_INFO, " %s", opt->help);
diff --git a/libavutil/opt.h b/libavutil/opt.h
index 391720f2e2..07da68ea23 100644
--- a/libavutil/opt.h
+++ b/libavutil/opt.h
@@ -287,6 +287,7 @@ typedef struct AVOption {
  * This flag only makes sense when AV_OPT_FLAG_EXPORT is also set.
  */
 #define AV_OPT_FLAG_READONLY128
+#define AV_OPT_FLAG_BSF_PARAM   (1<<8) ///< a generic parameter which can 
be set by the user for bit stream filtering
 #define AV_OPT_FLAG_FILTERING_PARAM (1<<16) ///< a generic parameter which can 
be set by the user for filtering
 //FIXME think about enc-audio, ... style flags
 
-- 
2.14.1

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


[FFmpeg-devel] [PATCH V2 02/11] ffmpeg: support dump bit stream filter options.

2018-03-11 Thread Jun Zhao

From 32486e2c95683e1a215f5a4cbec3d4fc01a71e87 Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Thu, 8 Mar 2018 13:50:31 +0800
Subject: [PATCH V2 02/11] ffmpeg: support dump bit stream filter options.

Support dump bit stream filter option in ffmpeg -h full and
ffmpeg -h bsf=FooBar.

Signed-off-by: Jun Zhao 
---
 fftools/cmdutils.c   | 17 +
 fftools/ffmpeg_opt.c |  3 ++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 0c7d13c27a..f9d87f6724 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -1897,6 +1897,21 @@ static void show_help_filter(const char *name)
 }
 #endif
 
+static void show_help_bsf(const char *name)
+{
+const AVBitStreamFilter *bsf = av_bsf_get_by_name(name);
+
+if (!bsf) {
+av_log(NULL, AV_LOG_ERROR, "Unknown bit stream filter '%s'.\n", name);
+return;
+}
+
+printf("Bit stream filter %s\n", bsf->name);
+if (bsf->priv_class)
+show_help_children(bsf->priv_class, AV_OPT_FLAG_BSF_PARAM);
+printf("\n");
+}
+
 int show_help(void *optctx, const char *opt, const char *arg)
 {
 char *topic, *par;
@@ -1923,6 +1938,8 @@ int show_help(void *optctx, const char *opt, const char 
*arg)
 } else if (!strcmp(topic, "filter")) {
 show_help_filter(par);
 #endif
+} else if (!strcmp(topic, "bsf")) {
+show_help_bsf(par);
 } else {
 show_help_default(topic, par);
 }
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 1b591d9695..d7a7eb0662 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -3114,7 +3114,7 @@ void show_help_default(const char *opt, const char *arg)
"-h  -- print basic options\n"
"-h long -- print more options\n"
"-h full -- print all options (including all format and codec 
specific options, very long)\n"
-   "-h type=name -- print all options for the named 
decoder/encoder/demuxer/muxer/filter\n"
+   "-h type=name -- print all options for the named 
decoder/encoder/demuxer/muxer/filter/bsf\n"
"See man %s for detailed description of the options.\n"
"\n", program_name);
 
@@ -3159,6 +3159,7 @@ void show_help_default(const char *opt, const char *arg)
 #endif
 show_help_children(swr_get_class(), AV_OPT_FLAG_AUDIO_PARAM);
 show_help_children(avfilter_get_class(), AV_OPT_FLAG_VIDEO_PARAM | 
AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM);
+show_help_children(av_bsf_get_class(), AV_OPT_FLAG_VIDEO_PARAM | 
AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_BSF_PARAM);
 }
 }
 
-- 
2.14.1

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


[FFmpeg-devel] [PATCH V2 03/11] lavc/dump_extradata_bsf: support dump options.

2018-03-11 Thread Jun Zhao

From e45988a0feece217ffed7f019e2978572526b9e3 Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Thu, 8 Mar 2018 14:01:48 +0800
Subject: [PATCH V2 03/11] lavc/dump_extradata_bsf: support dump options.

support dump bit stream filter options

Signed-off-by: Jun Zhao 
---
 libavcodec/dump_extradata_bsf.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavcodec/dump_extradata_bsf.c b/libavcodec/dump_extradata_bsf.c
index fa7bc86e19..081ae5aa08 100644
--- a/libavcodec/dump_extradata_bsf.c
+++ b/libavcodec/dump_extradata_bsf.c
@@ -78,13 +78,14 @@ fail:
 }
 
 #define OFFSET(x) offsetof(DumpExtradataContext, x)
+#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
 static const AVOption options[] = {
 { "freq", "When do dump extradata", OFFSET(freq), AV_OPT_TYPE_INT,
-{ .i64 = DUMP_FREQ_KEYFRAME }, DUMP_FREQ_KEYFRAME, DUMP_FREQ_ALL, 0, 
"freq" },
-{ "k",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = DUMP_FREQ_KEYFRAME 
}, .unit = "freq" },
-{ "keyframe", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = DUMP_FREQ_KEYFRAME 
}, .unit = "freq" },
-{ "e",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = DUMP_FREQ_ALL  
}, .unit = "freq" },
-{ "all",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = DUMP_FREQ_ALL  
}, .unit = "freq" },
+{ .i64 = DUMP_FREQ_KEYFRAME }, DUMP_FREQ_KEYFRAME, DUMP_FREQ_ALL, 
FLAGS, "freq" },
+{ "k",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = DUMP_FREQ_KEYFRAME 
}, .flags = FLAGS, .unit = "freq" },
+{ "keyframe", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = DUMP_FREQ_KEYFRAME 
}, .flags = FLAGS, .unit = "freq" },
+{ "e",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = DUMP_FREQ_ALL  
}, .flags = FLAGS, .unit = "freq" },
+{ "all",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = DUMP_FREQ_ALL  
}, .flags = FLAGS, .unit = "freq" },
 { NULL },
 };
 
-- 
2.14.1

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


Re: [FFmpeg-devel] [PATCH 2/8] cbs_h265: Use helper macro for maximum values of fixed-width elements

2018-03-11 Thread Jun Zhao


On 2018/3/12 2:30, Mark Thompson wrote:
> Apply the same logic as the previous patch to H.265.  There are no cases
> which currently overflow here, but this is still more consistent.
> ---
>  libavcodec/cbs_h265_syntax_template.c | 16 
>  1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/libavcodec/cbs_h265_syntax_template.c 
> b/libavcodec/cbs_h265_syntax_template.c
> index dae7f2dd46..140c827c9d 100644
> --- a/libavcodec/cbs_h265_syntax_template.c
> +++ b/libavcodec/cbs_h265_syntax_template.c
> @@ -665,7 +665,7 @@ static int FUNC(sps_scc_extension)(CodedBitstreamContext 
> *ctx, RWContext *rw,
>: current->bit_depth_chroma_minus8 
> + 8;
>  for (i = 0; i <= 
> current->sps_num_palette_predictor_initializer_minus1; i++)
>  u(bit_depth, sps_palette_predictor_initializers[comp][i],
> -  0, (1 << bit_depth) - 1);
> +  0, MAX_UINT_BITS(bit_depth));
>  }
>  }
>  }
> @@ -827,7 +827,7 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, 
> RWContext *rw,
>  for (i = 0; i < current->num_long_term_ref_pics_sps; i++) {
>  u(current->log2_max_pic_order_cnt_lsb_minus4 + 4,
>lt_ref_pic_poc_lsb_sps[i],
> -  0, (1 << (current->log2_max_pic_order_cnt_lsb_minus4 + 4)) - 
> 1);
> +  0, MAX_UINT_BITS(current->log2_max_pic_order_cnt_lsb_minus4 + 
> 4));
>  flag(used_by_curr_pic_lt_sps_flag[i]);
>  }
>  }
> @@ -845,7 +845,7 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, 
> RWContext *rw,
>  flag(sps_multilayer_extension_flag);
>  flag(sps_3d_extension_flag);
>  flag(sps_scc_extension_flag);
> -u(4, sps_extension_4bits, 0, (1 << 4) - 1);
> +u(4, sps_extension_4bits, 0, MAX_UINT_BITS(4));
>  }
>  
>  if (current->sps_range_extension_flag)
> @@ -925,7 +925,7 @@ static int FUNC(pps_scc_extension)(CodedBitstreamContext 
> *ctx, RWContext *rw,
>: 
> current->chroma_bit_depth_entry_minus8 + 8;
>  for (i = 0; i < 
> current->pps_num_palette_predictor_initializer; i++)
>  u(bit_depth, pps_palette_predictor_initializers[comp][i],
> -  0, (1 << bit_depth) - 1);
> +  0, MAX_UINT_BITS(bit_depth));
>  }
>  }
>  }
> @@ -1038,7 +1038,7 @@ static int FUNC(pps)(CodedBitstreamContext *ctx, 
> RWContext *rw,
>  flag(pps_multilayer_extension_flag);
>  flag(pps_3d_extension_flag);
>  flag(pps_scc_extension_flag);
> -u(4, pps_extension_4bits, 0, (1 << 4) - 1);
> +u(4, pps_extension_4bits, 0, MAX_UINT_BITS(4));
>  }
>  if (current->pps_range_extension_flag)
>  CHECK(FUNC(pps_range_extension)(ctx, rw, current));
> @@ -1274,7 +1274,7 @@ static int 
> FUNC(slice_segment_header)(CodedBitstreamContext *ctx, RWContext *rw,
>  const H265RawSTRefPicSet *rps;
>  
>  u(sps->log2_max_pic_order_cnt_lsb_minus4 + 4, 
> slice_pic_order_cnt_lsb,
> -  0, (1 << (sps->log2_max_pic_order_cnt_lsb_minus4 + 4)) - 1);
> +  0, MAX_UINT_BITS(sps->log2_max_pic_order_cnt_lsb_minus4 + 4));
>  
>  flag(short_term_ref_pic_set_sps_flag);
>  if (!current->short_term_ref_pic_set_sps_flag) {
> @@ -1321,7 +1321,7 @@ static int 
> FUNC(slice_segment_header)(CodedBitstreamContext *ctx, RWContext *rw,
>  ++num_pic_total_curr;
>  } else {
>  u(sps->log2_max_pic_order_cnt_lsb_minus4 + 4, 
> poc_lsb_lt[i],
> -  0, (1 << (sps->log2_max_pic_order_cnt_lsb_minus4 + 
> 4)) - 1);
> +  0, 
> MAX_UINT_BITS(sps->log2_max_pic_order_cnt_lsb_minus4 + 4));
>  flag(used_by_curr_pic_lt_flag[i]);
>  if (current->used_by_curr_pic_lt_flag[i])
>  ++num_pic_total_curr;
> @@ -1487,7 +1487,7 @@ static int 
> FUNC(slice_segment_header)(CodedBitstreamContext *ctx, RWContext *rw,
>  ue(offset_len_minus1, 0, 31);
>  for (i = 0; i < current->num_entry_point_offsets; i++)
>  u(current->offset_len_minus1 + 1, 
> entry_point_offset_minus1[i],
> -  0, (1 << (current->offset_len_minus1 + 1)) - 1);
> +  0, MAX_UINT_BITS(current->offset_len_minus1 + 1));
>  }
>  }
>  
Other thing about cbs_265, now cbs_264 can support SEI, but cbs_265 not,
is it will support SEI in cbs_265?

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


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/nuv: rtjpeg with dimensions less than 16 would result in no decoded pixels thus reject it

2018-03-11 Thread Michael Niedermayer
On Tue, Feb 27, 2018 at 04:53:23PM +0100, Michael Niedermayer wrote:
> Fixes: Timeout
> Fixes: 
> 6297/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_NUV_fuzzer-4882404863901696
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/nuv.c | 3 +++
>  1 file changed, 3 insertions(+)

will apply


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

I do not agree with what you have to say, but I'll defend to the death your
right to say it. -- Voltaire


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


Re: [FFmpeg-devel] [PATCH] avcodec/wmalosslessdec: Reset num_saved_bits on error path

2018-03-11 Thread Michael Niedermayer
On Sun, Mar 11, 2018 at 09:41:06AM +0100, Paul B Mahol wrote:
> On 3/11/18, Michael Niedermayer  wrote:
> > Fixes: NULL pointer dereference
> > Fixes: poc-201803.wav
> > Found-by: GwanYeong Kim 
> >
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/wmalosslessdec.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> 
> OK

applied

thx

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

I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus


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


Re: [FFmpeg-devel] [PATCH 2/7] hwcontext_vaapi: Add support for legacy DRM mapping

2018-03-11 Thread Mark Thompson
On 12/03/18 00:01, Rostislav Pehlivanov wrote:
> On 11 March 2018 at 22:41, Mark Thompson  wrote:
> 
>> The old vaAcquireBufferHandle() API works in fewer cases and provides
>> less information than the current vaExportSurfaceHandle(), but it exists
>> on older versions and is already used by the OpenCL code.  This probably
>> doesn't have much use directly, but it will be used to replace the ad-hoc
>> OpenCL code in a following patch.
>> ---
>>  libavutil/hwcontext_vaapi.c | 191 ++
>> +++---
>>  1 file changed, 179 insertions(+), 12 deletions(-)
>>
>> ...
> 
> Why? libva 1.1.0 is 6 years old now. It doesn't make sense to have 2 pieces
> of code to do the same thing.

VAAPI 1.1.0 != libva 1.1.0.  VAAPI 1.1.0 is in libva 2.1.0, released last month.

(This is not confusing at all.)

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


Re: [FFmpeg-devel] [PATCH 4/7] hwcontext_opencl: Add support for mapping DRM objects to Beignet

2018-03-11 Thread Mark Thompson
On 11/03/18 23:59, Rostislav Pehlivanov wrote:
> On 11 March 2018 at 22:41, Mark Thompson  wrote:
> 
>> Also use that to support mapping VAAPI to Beignet.
>> ---
>>  configure|  16 +--
>>  libavutil/hwcontext_opencl.c | 264 +-
>> -
>>  2 files changed, 138 insertions(+), 142 deletions(-)
>>
>> ...
>>
> 
> Doesn't seem to work, at least on my machine:
> DRM frame layer 0 plane 0 is not representable in OpenCL: -22

What driver and input/output formats are you using?  What are the versions of 
all the relevant components, so I can maybe try to reproduce it?  (beignet, 
i965, libva, mesa, libdrm, .. others?)

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


Re: [FFmpeg-devel] [PATCH 01/10] lavu/opt: add AV_OPT_FLAG_BSF_PARAM

2018-03-11 Thread Jun Zhao


On 2018/3/10 3:32, Michael Niedermayer wrote:
> On Thu, Mar 08, 2018 at 04:41:43PM +0800, Jun Zhao wrote:
>>  opt.c |1 +
>>  opt.h |1 +
>>  2 files changed, 2 insertions(+)
>> f19d1e433e7008fa7ea9868c973367833dc86878  
>> 0001-lavu-opt-add-AV_OPT_FLAG_BSF_PARAM.patch
>> From 665692d981828ccc0875f9dcbf2c89f3495fcce6 Mon Sep 17 00:00:00 2001
>> From: Jun Zhao 
>> Date: Thu, 8 Mar 2018 13:47:23 +0800
>> Subject: [PATCH 01/10] lavu/opt: add AV_OPT_FLAG_BSF_PARAM
>>
>> add AV_OPT_FLAG_BSF_PARAM for bit stream filter options.
>>
>> Signed-off-by: Jun Zhao 
>> ---
>>  libavutil/opt.c | 1 +
>>  libavutil/opt.h | 1 +
>>  2 files changed, 2 insertions(+)
>>
>> diff --git a/libavutil/opt.c b/libavutil/opt.c
>> index df88663e3f..3b0aab4ee8 100644
>> --- a/libavutil/opt.c
>> +++ b/libavutil/opt.c
>> @@ -1181,6 +1181,7 @@ static void opt_list(void *obj, void *av_log_obj, 
>> const char *unit,
>>  av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & 
>> AV_OPT_FLAG_SUBTITLE_PARAM) ? 'S' : '.');
>>  av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & 
>> AV_OPT_FLAG_EXPORT) ? 'X' : '.');
>>  av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & 
>> AV_OPT_FLAG_READONLY)   ? 'R' : '.');
>> +av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & 
>> AV_OPT_FLAG_BSF_PARAM)  ? 'B' : '.');
>>  
>>  if (opt->help)
>>  av_log(av_log_obj, AV_LOG_INFO, " %s", opt->help);
> breaks fate
>
> [...]
Fix fate issue local, will submit V2. Tks.
>
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] avformat/mov: Fix integer overflows related to sample_duration

2018-03-11 Thread Michael Niedermayer
On Sat, Mar 10, 2018 at 10:48:16PM +0100, Michael Niedermayer wrote:
> Fixes: runtime error: signed integer overflow: -9166684017437101870 + 
> -2495066639299164439 cannot be represented in type
> 
> Fixes: Chromium bug 791349
> 
> Reported-by: Matt Wolenetz 
> Reviewed-by: Matt Wolenetz 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/mov.c | 20 +++-
>  1 file changed, 15 insertions(+), 5 deletions(-)

applied

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

Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable


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


Re: [FFmpeg-devel] [PATCH 2/7] hwcontext_vaapi: Add support for legacy DRM mapping

2018-03-11 Thread Rostislav Pehlivanov
On 11 March 2018 at 22:41, Mark Thompson  wrote:

> The old vaAcquireBufferHandle() API works in fewer cases and provides
> less information than the current vaExportSurfaceHandle(), but it exists
> on older versions and is already used by the OpenCL code.  This probably
> doesn't have much use directly, but it will be used to replace the ad-hoc
> OpenCL code in a following patch.
> ---
>  libavutil/hwcontext_vaapi.c | 191 ++
> +++---
>  1 file changed, 179 insertions(+), 12 deletions(-)
>
> diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
> index 99f76b9169..15f1c4d1c0 100644
> --- a/libavutil/hwcontext_vaapi.c
> +++ b/libavutil/hwcontext_vaapi.c
> @@ -1073,8 +1073,9 @@ static int vaapi_map_from_drm(AVHWFramesContext
> *src_fc, AVFrame *dst,
>  return 0;
>  }
>
> -static void vaapi_unmap_to_drm(AVHWFramesContext *dst_fc,
> -   HWMapDescriptor *hwmap)
> +#if VA_CHECK_VERSION(1, 1, 0)
> +static void vaapi_unmap_to_drm_esh(AVHWFramesContext *hwfc,
> +   HWMapDescriptor *hwmap)
>  {
>  AVDRMFrameDescriptor *drm_desc = hwmap->priv;
>  int i;
> @@ -1085,10 +1086,9 @@ static void vaapi_unmap_to_drm(AVHWFramesContext
> *dst_fc,
>  av_freep(_desc);
>  }
>
> -static int vaapi_map_to_drm(AVHWFramesContext *hwfc, AVFrame *dst,
> -const AVFrame *src, int flags)
> +static int vaapi_map_to_drm_esh(AVHWFramesContext *hwfc, AVFrame *dst,
> +const AVFrame *src, int flags)
>  {
> -#if VA_CHECK_VERSION(1, 1, 0)
>  AVVAAPIDeviceContext *hwctx = hwfc->device_ctx->hwctx;
>  VASurfaceID surface_id;
>  VAStatus vas;
> @@ -1140,7 +1140,7 @@ static int vaapi_map_to_drm(AVHWFramesContext
> *hwfc, AVFrame *dst,
>  }
>
>  err = ff_hwframe_map_create(src->hw_frames_ctx, dst, src,
> -_unmap_to_drm, drm_desc);
> +_unmap_to_drm_esh, drm_desc);
>  if (err < 0)
>  goto fail;
>
> @@ -1155,15 +1155,182 @@ fail:
>  close(va_desc.objects[i].fd);
>  av_freep(_desc);
>  return err;
> -#else
> -// Older versions without vaExportSurfaceHandle() are not supported -
> -// in theory this is possible with a combination of vaDeriveImage()
> -// and vaAcquireBufferHandle(), but it doesn't carry enough metadata
> -// to actually use the result in a generic way.
> -return AVERROR(ENOSYS);
> +}
>  #endif
> +
> +typedef struct VAAPIDRMImageBufferMapping {
> +VAImage  image;
> +VABufferInfo buffer_info;
> +
> +AVDRMFrameDescriptor drm_desc;
> +} VAAPIDRMImageBufferMapping;
> +
> +static void vaapi_unmap_to_drm_abh(AVHWFramesContext *hwfc,
> +  HWMapDescriptor *hwmap)
> +{
> +AVVAAPIDeviceContext *hwctx = hwfc->device_ctx->hwctx;
> +VAAPIDRMImageBufferMapping *mapping = hwmap->priv;
> +VASurfaceID surface_id;
> +VAStatus vas;
> +
> +surface_id = (VASurfaceID)(uintptr_t)hwmap->source->data[3];
> +av_log(hwfc, AV_LOG_DEBUG, "Unmap VAAPI surface %#x from DRM.\n",
> +   surface_id);
> +
> +// DRM PRIME file descriptors are closed by vaReleaseBufferHandle(),
> +// so we shouldn't close them separately.
> +
> +vas = vaReleaseBufferHandle(hwctx->display, mapping->image.buf);
> +if (vas != VA_STATUS_SUCCESS) {
> +av_log(hwfc, AV_LOG_ERROR, "Failed to release buffer "
> +   "handle of image %#x (derived from surface %#x): "
> +   "%d (%s).\n", mapping->image.buf, surface_id,
> +   vas, vaErrorStr(vas));
> +}
> +
> +vas = vaDestroyImage(hwctx->display, mapping->image.image_id);
> +if (vas != VA_STATUS_SUCCESS) {
> +av_log(hwfc, AV_LOG_ERROR, "Failed to destroy image "
> +   "derived from surface %#x: %d (%s).\n",
> +   surface_id, vas, vaErrorStr(vas));
> +}
> +
> +av_free(mapping);
>  }
> +
> +static int vaapi_map_to_drm_abh(AVHWFramesContext *hwfc, AVFrame *dst,
> +const AVFrame *src, int flags)
> +{
> +AVVAAPIDeviceContext *hwctx = hwfc->device_ctx->hwctx;
> +VAAPIDRMImageBufferMapping *mapping = NULL;
> +VASurfaceID surface_id;
> +VAStatus vas;
> +int err, i, p;
> +
> +surface_id = (VASurfaceID)(uintptr_t)src->data[3];
> +av_log(hwfc, AV_LOG_DEBUG, "Map VAAPI surface %#x to DRM.\n",
> +   surface_id);
> +
> +mapping = av_mallocz(sizeof(*mapping));
> +if (!mapping)
> +return AVERROR(ENOMEM);
> +
> +vas = vaDeriveImage(hwctx->display, surface_id,
> +>image);
> +if (vas != VA_STATUS_SUCCESS) {
> +av_log(hwfc, AV_LOG_ERROR, "Failed to derive image from "
> +   "surface %#x: %d (%s).\n",
> +   surface_id, vas, vaErrorStr(vas));
> +err = AVERROR(EIO);
> +goto fail;
> +}
> +
> +

Re: [FFmpeg-devel] [PATCH 4/7] hwcontext_opencl: Add support for mapping DRM objects to Beignet

2018-03-11 Thread Rostislav Pehlivanov
On 11 March 2018 at 22:41, Mark Thompson  wrote:

> Also use that to support mapping VAAPI to Beignet.
> ---
>  configure|  16 +--
>  libavutil/hwcontext_opencl.c | 264 +-
> -
>  2 files changed, 138 insertions(+), 142 deletions(-)
>
> diff --git a/configure b/configure
> index 5e38bdab17..5051fd1abf 100755
> --- a/configure
> +++ b/configure
> @@ -2137,6 +2137,7 @@ HAVE_LIST="
>  makeinfo_html
>  opencl_d3d11
>  opencl_drm_arm
> +opencl_drm_beignet
>  opencl_dxva2
>  opencl_vaapi_beignet
>  opencl_vaapi_intel_media
> @@ -6223,9 +6224,15 @@ enabled vaapi &&
>  check_cpp_condition "va/va.h" "VA_CHECK_VERSION(1, 0, 0)" &&
>  enable vaapi_1
>
> -if enabled_all opencl vaapi ; then
> +if enabled_all opencl libdrm ; then
>  check_type "CL/cl_intel.h" "clCreateImageFromFdINTEL_fn" &&
> -enable opencl_vaapi_beignet
> +enable opencl_drm_beignet
> +check_func_headers "CL/cl_ext.h" clImportMemoryARM &&
> +enable opencl_drm_arm
> +fi
> +
> +if enabled_all opencl vaapi ; then
> +enabled opencl_drm_beignet && enable opencl_vaapi_beignet
>  if enabled libmfx ; then
>  check_type "CL/cl.h CL/va_ext.h" 
> "clCreateFromVA_APIMediaSurfaceINTEL_fn"
> &&
>  enable opencl_vaapi_intel_media
> @@ -6242,11 +6249,6 @@ if enabled_all opencl d3d11va ; then
>  enable opencl_d3d11
>  fi
>
> -if enabled_all opencl libdrm ; then
> -check_func_headers "CL/cl_ext.h" clImportMemoryARM &&
> -enable opencl_drm_arm
> -fi
> -
>  enabled vdpau &&
>  check_cpp_condition vdpau/vdpau.h "defined 
> VDP_DECODER_PROFILE_MPEG4_PART2_ASP"
> ||
>  disable vdpau
> diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c
> index a725a491e2..334f87344e 100644
> --- a/libavutil/hwcontext_opencl.c
> +++ b/libavutil/hwcontext_opencl.c
> @@ -37,6 +37,12 @@
>  #include "hwcontext_vaapi.h"
>  #endif
>
> +#if HAVE_OPENCL_DRM_BEIGNET
> +#include 
> +#include 
> +#include "hwcontext_drm.h"
> +#endif
> +
>  #if HAVE_OPENCL_VAAPI_INTEL_MEDIA
>  #include 
>  #include 
> @@ -74,9 +80,9 @@ typedef struct OpenCLDeviceContext {
>  cl_platform_id platform_id;
>
>  // Platform/device-specific functions.
> -#if HAVE_OPENCL_VAAPI_BEIGNET
> -int vaapi_mapping_usable;
> -clCreateImageFromFdINTEL_fn  clCreateImageFromFdINTEL;
> +#if HAVE_OPENCL_DRM_BEIGNET
> +int beignet_drm_mapping_usable;
> +clCreateImageFromFdINTEL_fn clCreateImageFromFdINTEL;
>  #endif
>
>  #if HAVE_OPENCL_VAAPI_INTEL_MEDIA
> @@ -685,19 +691,19 @@ static int opencl_device_init(AVHWDeviceContext
> *hwdev)
>  }   \
>  } while (0)
>
> -#if HAVE_OPENCL_VAAPI_BEIGNET
> +#if HAVE_OPENCL_DRM_BEIGNET
>  {
>  int fail = 0;
>
>  CL_FUNC(clCreateImageFromFdINTEL,
> -"Intel DRM to OpenCL image mapping");
> +"Beignet DRM to OpenCL image mapping");
>
>  if (fail) {
> -av_log(hwdev, AV_LOG_WARNING, "VAAPI to OpenCL mapping "
> -   "not usable.\n");
> -priv->vaapi_mapping_usable = 0;
> +av_log(hwdev, AV_LOG_WARNING, "Beignet DRM to OpenCL "
> +   "mapping not usable.\n");
> +priv->beignet_drm_mapping_usable = 0;
>  } else {
> -priv->vaapi_mapping_usable = 1;
> +priv->beignet_drm_mapping_usable = 1;
>  }
>  }
>  #endif
> @@ -1187,7 +1193,8 @@ static int opencl_device_derive(AVHWDeviceContext
> *hwdev,
>  int err;
>  switch (src_ctx->type) {
>
> -#if HAVE_OPENCL_VAAPI_BEIGNET
> +#if HAVE_OPENCL_DRM_BEIGNET
> +case AV_HWDEVICE_TYPE_DRM:
>  case AV_HWDEVICE_TYPE_VAAPI:
>  {
>  // Surface mapping works via DRM PRIME fds with no special
> @@ -2028,175 +2035,151 @@ fail:
>  return err;
>  }
>
> -#if HAVE_OPENCL_VAAPI_BEIGNET
> +#if HAVE_OPENCL_DRM_BEIGNET
>
> -typedef struct VAAPItoOpenCLMapping {
> -VAImage  va_image;
> -VABufferInfo va_buffer_info;
> +typedef struct DRMBeignetToOpenCLMapping {
> +AVFrame  *drm_frame;
> +AVDRMFrameDescriptor *drm_desc;
>
>  AVOpenCLFrameDescriptor frame;
> -} VAAPItoOpenCLMapping;
> +} DRMBeignetToOpenCLMapping;
>
> -static void opencl_unmap_from_vaapi(AVHWFramesContext *src_fc,
> -HWMapDescriptor *hwmap)
> +static void opencl_unmap_from_drm_beignet(AVHWFramesContext *dst_fc,
> +  HWMapDescriptor *hwmap)
>  {
> -VAAPItoOpenCLMapping *mapping = hwmap->priv;
> -AVVAAPIDeviceContext *src_dev = src_fc->device_ctx->hwctx;
> -VASurfaceID surface_id;
> -VAStatus vas;
> +DRMBeignetToOpenCLMapping *mapping = hwmap->priv;
>  cl_int cle;
>  int i;
>
> -surface_id = (VASurfaceID)(uintptr_t)hwmap->source->data[3];
> -av_log(src_fc, AV_LOG_DEBUG, 

Re: [FFmpeg-devel] [PATCH 6/7] vf_scale_vaapi: Apply cropping rectangle to input

2018-03-11 Thread Rostislav Pehlivanov
On 11 March 2018 at 22:41, Mark Thompson  wrote:

> ---
>  libavfilter/vf_scale_vaapi.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/libavfilter/vf_scale_vaapi.c b/libavfilter/vf_scale_vaapi.c
> index c19e23ccd0..d6529d5235 100644
> --- a/libavfilter/vf_scale_vaapi.c
> +++ b/libavfilter/vf_scale_vaapi.c
> @@ -100,13 +100,13 @@ static int scale_vaapi_filter_frame(AVFilterLink
> *inlink, AVFrame *input_frame)
>
>  memset(, 0, sizeof(params));
>
> -// If there were top/left cropping, it could be taken into
> -// account here.
>  input_region = (VARectangle) {
> -.x  = 0,
> -.y  = 0,
> -.width  = input_frame->width,
> -.height = input_frame->height,
> +.x  = input_frame->crop_left,
> +.y  = input_frame->crop_top,
> +.width  = input_frame->width -
> + (input_frame->crop_left + input_frame->crop_right),
> +.height = input_frame->height -
> + (input_frame->crop_top + input_frame->crop_bottom),
>  };
>
>  params.surface = input_surface;
> --
> 2.16.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

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


Re: [FFmpeg-devel] [PATCH 3/7] hwcontext_vaapi: Pass correct read/write flags when exporting surfaces

2018-03-11 Thread Rostislav Pehlivanov
On 11 March 2018 at 22:41, Mark Thompson  wrote:

> ---
>  libavutil/hwcontext_vaapi.c | 11 ---
>  1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
> index 15f1c4d1c0..8e4bef9f1b 100644
> --- a/libavutil/hwcontext_vaapi.c
> +++ b/libavutil/hwcontext_vaapi.c
> @@ -1094,15 +1094,20 @@ static int vaapi_map_to_drm_esh(AVHWFramesContext
> *hwfc, AVFrame *dst,
>  VAStatus vas;
>  VADRMPRIMESurfaceDescriptor va_desc;
>  AVDRMFrameDescriptor *drm_desc = NULL;
> +uint32_t export_flags;
>  int err, i, j;
>
>  surface_id = (VASurfaceID)(uintptr_t)src->data[3];
>
> +export_flags = VA_EXPORT_SURFACE_SEPARATE_LAYERS;
> +if (flags & AV_HWFRAME_MAP_READ)
> +export_flags |= VA_EXPORT_SURFACE_READ_ONLY;
> +if (flags & AV_HWFRAME_MAP_WRITE)
> +export_flags |= VA_EXPORT_SURFACE_WRITE_ONLY;
> +
>  vas = vaExportSurfaceHandle(hwctx->display, surface_id,
>  VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2,
> -VA_EXPORT_SURFACE_READ_ONLY |
> -VA_EXPORT_SURFACE_SEPARATE_LAYERS,
> -_desc);
> +export_flags, _desc);
>  if (vas != VA_STATUS_SUCCESS) {
>  if (vas == VA_STATUS_ERROR_UNIMPLEMENTED)
>  return AVERROR(ENOSYS);
> --
> 2.16.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

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


Re: [FFmpeg-devel] [PATCH 7/7] doc/indevs: Add example using cropping to capture part of a plane

2018-03-11 Thread Rostislav Pehlivanov
On 11 March 2018 at 22:41, Mark Thompson  wrote:

> ---
>  doc/indevs.texi | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/doc/indevs.texi b/doc/indevs.texi
> index 6951940a93..02d1cb3d86 100644
> --- a/doc/indevs.texi
> +++ b/doc/indevs.texi
> @@ -462,6 +462,14 @@ Capture from CRTC ID 42 at 60fps, map the result to
> VAAPI, convert to NV12 and e
>  ffmpeg -crtc_id 42 -framerate 60 -f kmsgrab -i - -vf
> 'hwmap=derive_device=vaapi,scale_vaapi=w=1920:h=1080:format=nv12' -c:v
> h264_vaapi output.mp4
>  @end example
>
> +@item
> +To capture only part of a plane the output can be cropped - this can be
> used to capture
> +a single window, as long as it has a known absolute position.  For
> example, to capture
> +and encode the middle quarter of a 1920x1080 plane:
> +@example
> +ffmpeg -f kmsgrab -i - -vf 'hwmap=derive_device=vaapi,
> crop=960:540:480:270,scale_vaapi=format=nv12' -c:v h264_vaapi output.mp4
> +@end example
> +
>  @end itemize
>
>  @section libndi_newtek
> --
> 2.16.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

On a related note, deriving a vaapi device from kms has never worked for me:
libva: va_getDriverName() failed with operation failed,driver_name=i965
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avcodec/cscd: Error out when LZ* decompression fails

2018-03-11 Thread Michael Niedermayer
Fixes: Timeout
Fixes: 
6304/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CSCD_fuzzer-5754772461191168

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/cscd.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/cscd.c b/libavcodec/cscd.c
index 9e1dec9d96..35c4ee08c3 100644
--- a/libavcodec/cscd.c
+++ b/libavcodec/cscd.c
@@ -81,15 +81,19 @@ static int decode_frame(AVCodecContext *avctx, void *data, 
int *got_frame,
 switch ((buf[0] >> 1) & 7) {
 case 0: { // lzo compression
 int outlen = c->decomp_size, inlen = buf_size - 2;
-if (av_lzo1x_decode(c->decomp_buf, , [2], ))
+if (av_lzo1x_decode(c->decomp_buf, , [2], )) {
 av_log(avctx, AV_LOG_ERROR, "error during lzo 
decompression\n");
+return AVERROR_INVALIDDATA;
+}
 break;
 }
 case 1: { // zlib compression
 #if CONFIG_ZLIB
 unsigned long dlen = c->decomp_size;
-if (uncompress(c->decomp_buf, , [2], buf_size - 2) != 
Z_OK)
+if (uncompress(c->decomp_buf, , [2], buf_size - 2) != 
Z_OK) {
 av_log(avctx, AV_LOG_ERROR, "error during zlib 
decompression\n");
+return AVERROR_INVALIDDATA;
+}
 break;
 #else
 av_log(avctx, AV_LOG_ERROR, "compiled without zlib support\n");
-- 
2.16.2

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


Re: [FFmpeg-devel] [PATCH] h264_slice: correct atomics usage

2018-03-11 Thread Aman Gupta
On Sun, Mar 11, 2018 at 4:01 PM, Rostislav Pehlivanov 
wrote:

> Reported by tmm1
>
> Signed-off-by: Rostislav Pehlivanov 
> ---
>  libavcodec/h264_slice.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
> index 90e05ed8f1..b381397b4d 100644
> --- a/libavcodec/h264_slice.c
> +++ b/libavcodec/h264_slice.c
> @@ -2762,7 +2762,7 @@ int ff_h264_execute_decode_slices(H264Context *h)
>
>  sl = >slice_ctx[i];
>  if (CONFIG_ERROR_RESILIENCE) {
> -sl->er.error_count = 0;
> +sl->er.error_count = ATOMIC_VAR_INIT(0);
>  }
>
>  /* make sure none of those slices overlap */
> @@ -2786,7 +2786,8 @@ int ff_h264_execute_decode_slices(H264Context *h)
>  h->mb_y  = sl->mb_y;
>  if (CONFIG_ERROR_RESILIENCE) {
>  for (i = 1; i < context_count; i++)
> -h->slice_ctx[0].er.error_count +=
> h->slice_ctx[i].er.error_count;
> +atomic_fetch_add(>slice_ctx[0].er.error_count,
> + atomic_load(>slice_ctx[i].
> er.error_count));
>  }
>
>  if (h->postpone_filter) {
>

LGTM, thanks.


> --
> 2.16.2
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] h264_slice: correct atomics usage

2018-03-11 Thread Rostislav Pehlivanov
Reported by tmm1

Signed-off-by: Rostislav Pehlivanov 
---
 libavcodec/h264_slice.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 90e05ed8f1..b381397b4d 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -2762,7 +2762,7 @@ int ff_h264_execute_decode_slices(H264Context *h)
 
 sl = >slice_ctx[i];
 if (CONFIG_ERROR_RESILIENCE) {
-sl->er.error_count = 0;
+sl->er.error_count = ATOMIC_VAR_INIT(0);
 }
 
 /* make sure none of those slices overlap */
@@ -2786,7 +2786,8 @@ int ff_h264_execute_decode_slices(H264Context *h)
 h->mb_y  = sl->mb_y;
 if (CONFIG_ERROR_RESILIENCE) {
 for (i = 1; i < context_count; i++)
-h->slice_ctx[0].er.error_count += 
h->slice_ctx[i].er.error_count;
+atomic_fetch_add(>slice_ctx[0].er.error_count,
+ atomic_load(>slice_ctx[i].er.error_count));
 }
 
 if (h->postpone_filter) {
-- 
2.16.2

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


[FFmpeg-devel] [PATCH] avcodec/h264_slice: fix access to atomic error_count

2018-03-11 Thread Aman Gupta
From: Aman Gupta 

---
 libavcodec/h264_slice.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 90e05ed8f1..d0f38783ee 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -2762,7 +2762,7 @@ int ff_h264_execute_decode_slices(H264Context *h)
 
 sl = >slice_ctx[i];
 if (CONFIG_ERROR_RESILIENCE) {
-sl->er.error_count = 0;
+atomic_init(>er.error_count, 0);
 }
 
 /* make sure none of those slices overlap */
@@ -2786,7 +2786,7 @@ int ff_h264_execute_decode_slices(H264Context *h)
 h->mb_y  = sl->mb_y;
 if (CONFIG_ERROR_RESILIENCE) {
 for (i = 1; i < context_count; i++)
-h->slice_ctx[0].er.error_count += 
h->slice_ctx[i].er.error_count;
+atomic_fetch_add(>slice_ctx[0].er.error_count, 
atomic_load(>slice_ctx[i].er.error_count));
 }
 
 if (h->postpone_filter) {
-- 
2.14.2

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


[FFmpeg-devel] [PATCH 7/7] doc/indevs: Add example using cropping to capture part of a plane

2018-03-11 Thread Mark Thompson
---
 doc/indevs.texi | 8 
 1 file changed, 8 insertions(+)

diff --git a/doc/indevs.texi b/doc/indevs.texi
index 6951940a93..02d1cb3d86 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -462,6 +462,14 @@ Capture from CRTC ID 42 at 60fps, map the result to VAAPI, 
convert to NV12 and e
 ffmpeg -crtc_id 42 -framerate 60 -f kmsgrab -i - -vf 
'hwmap=derive_device=vaapi,scale_vaapi=w=1920:h=1080:format=nv12' -c:v 
h264_vaapi output.mp4
 @end example
 
+@item
+To capture only part of a plane the output can be cropped - this can be used 
to capture
+a single window, as long as it has a known absolute position.  For example, to 
capture
+and encode the middle quarter of a 1920x1080 plane:
+@example
+ffmpeg -f kmsgrab -i - -vf 
'hwmap=derive_device=vaapi,crop=960:540:480:270,scale_vaapi=format=nv12' -c:v 
h264_vaapi output.mp4
+@end example
+
 @end itemize
 
 @section libndi_newtek
-- 
2.16.1

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


[FFmpeg-devel] [PATCH 5/7] vf_crop: Add support for cropping hardware frames

2018-03-11 Thread Mark Thompson
Set the cropping fields in the AVFrame.
---
 libavfilter/vf_crop.c | 61 ---
 1 file changed, 43 insertions(+), 18 deletions(-)

diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c
index 0fdc4949e3..0b1b8a048b 100644
--- a/libavfilter/vf_crop.c
+++ b/libavfilter/vf_crop.c
@@ -98,9 +98,17 @@ static int query_formats(AVFilterContext *ctx)
 
 for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) {
 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
-if (!(desc->flags & (AV_PIX_FMT_FLAG_HWACCEL | 
AV_PIX_FMT_FLAG_BITSTREAM)) &&
-!((desc->log2_chroma_w || desc->log2_chroma_h) && !(desc->flags & 
AV_PIX_FMT_FLAG_PLANAR)) &&
-(ret = ff_add_format(, fmt)) < 0)
+if (desc->flags & AV_PIX_FMT_FLAG_BITSTREAM)
+continue;
+if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
+// Not usable if there is any subsampling but the format is
+// not planar (e.g. YUYV422).
+if ((desc->log2_chroma_w || desc->log2_chroma_h) &&
+!(desc->flags & AV_PIX_FMT_FLAG_PLANAR))
+continue;
+}
+ret = ff_add_format(, fmt);
+if (ret < 0)
 return ret;
 }
 
@@ -157,8 +165,14 @@ static int config_input(AVFilterLink *link)
 s->var_values[VAR_POS]   = NAN;
 
 av_image_fill_max_pixsteps(s->max_step, NULL, pix_desc);
-s->hsub = pix_desc->log2_chroma_w;
-s->vsub = pix_desc->log2_chroma_h;
+
+if (pix_desc->flags & AV_PIX_FMT_FLAG_HWACCEL) {
+s->hsub = 1;
+s->vsub = 1;
+} else {
+s->hsub = pix_desc->log2_chroma_w;
+s->vsub = pix_desc->log2_chroma_h;
+}
 
 if ((ret = av_expr_parse_and_eval(, (expr = s->w_expr),
   var_names, s->var_values,
@@ -285,22 +299,33 @@ static int filter_frame(AVFilterLink *link, AVFrame 
*frame)
 (int)s->var_values[VAR_N], s->var_values[VAR_T], 
s->var_values[VAR_POS],
 s->x, s->y, s->x+s->w, s->y+s->h);
 
-frame->data[0] += s->y * frame->linesize[0];
-frame->data[0] += s->x * s->max_step[0];
-
-if (!(desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & 
AV_PIX_FMT_FLAG_PSEUDOPAL)) {
-for (i = 1; i < 3; i ++) {
-if (frame->data[i]) {
-frame->data[i] += (s->y >> s->vsub) * frame->linesize[i];
-frame->data[i] += (s->x * s->max_step[i]) >> s->hsub;
+if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL) {
+frame->crop_top   += s->y;
+frame->crop_left  += s->x;
+frame->crop_bottom = frame->height - frame->crop_top - 
frame->crop_bottom - s->h;
+frame->crop_right  = frame->width  - frame->crop_left - 
frame->crop_right - s->w;
+
+} else {
+frame->width  = s->w;
+frame->height = s->h;
+
+frame->data[0] += s->y * frame->linesize[0];
+frame->data[0] += s->x * s->max_step[0];
+
+if (!(desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & 
AV_PIX_FMT_FLAG_PSEUDOPAL)) {
+for (i = 1; i < 3; i ++) {
+if (frame->data[i]) {
+frame->data[i] += (s->y >> s->vsub) * frame->linesize[i];
+frame->data[i] += (s->x * s->max_step[i]) >> s->hsub;
+}
 }
 }
-}
 
-/* alpha plane */
-if (frame->data[3]) {
-frame->data[3] += s->y * frame->linesize[3];
-frame->data[3] += s->x * s->max_step[3];
+/* alpha plane */
+if (frame->data[3]) {
+frame->data[3] += s->y * frame->linesize[3];
+frame->data[3] += s->x * s->max_step[3];
+}
 }
 
 return ff_filter_frame(link->dst->outputs[0], frame);
-- 
2.16.1

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


[FFmpeg-devel] [PATCH 4/7] hwcontext_opencl: Add support for mapping DRM objects to Beignet

2018-03-11 Thread Mark Thompson
Also use that to support mapping VAAPI to Beignet.
---
 configure|  16 +--
 libavutil/hwcontext_opencl.c | 264 +--
 2 files changed, 138 insertions(+), 142 deletions(-)

diff --git a/configure b/configure
index 5e38bdab17..5051fd1abf 100755
--- a/configure
+++ b/configure
@@ -2137,6 +2137,7 @@ HAVE_LIST="
 makeinfo_html
 opencl_d3d11
 opencl_drm_arm
+opencl_drm_beignet
 opencl_dxva2
 opencl_vaapi_beignet
 opencl_vaapi_intel_media
@@ -6223,9 +6224,15 @@ enabled vaapi &&
 check_cpp_condition "va/va.h" "VA_CHECK_VERSION(1, 0, 0)" &&
 enable vaapi_1
 
-if enabled_all opencl vaapi ; then
+if enabled_all opencl libdrm ; then
 check_type "CL/cl_intel.h" "clCreateImageFromFdINTEL_fn" &&
-enable opencl_vaapi_beignet
+enable opencl_drm_beignet
+check_func_headers "CL/cl_ext.h" clImportMemoryARM &&
+enable opencl_drm_arm
+fi
+
+if enabled_all opencl vaapi ; then
+enabled opencl_drm_beignet && enable opencl_vaapi_beignet
 if enabled libmfx ; then
 check_type "CL/cl.h CL/va_ext.h" 
"clCreateFromVA_APIMediaSurfaceINTEL_fn" &&
 enable opencl_vaapi_intel_media
@@ -6242,11 +6249,6 @@ if enabled_all opencl d3d11va ; then
 enable opencl_d3d11
 fi
 
-if enabled_all opencl libdrm ; then
-check_func_headers "CL/cl_ext.h" clImportMemoryARM &&
-enable opencl_drm_arm
-fi
-
 enabled vdpau &&
 check_cpp_condition vdpau/vdpau.h "defined 
VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
 disable vdpau
diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c
index a725a491e2..334f87344e 100644
--- a/libavutil/hwcontext_opencl.c
+++ b/libavutil/hwcontext_opencl.c
@@ -37,6 +37,12 @@
 #include "hwcontext_vaapi.h"
 #endif
 
+#if HAVE_OPENCL_DRM_BEIGNET
+#include 
+#include 
+#include "hwcontext_drm.h"
+#endif
+
 #if HAVE_OPENCL_VAAPI_INTEL_MEDIA
 #include 
 #include 
@@ -74,9 +80,9 @@ typedef struct OpenCLDeviceContext {
 cl_platform_id platform_id;
 
 // Platform/device-specific functions.
-#if HAVE_OPENCL_VAAPI_BEIGNET
-int vaapi_mapping_usable;
-clCreateImageFromFdINTEL_fn  clCreateImageFromFdINTEL;
+#if HAVE_OPENCL_DRM_BEIGNET
+int beignet_drm_mapping_usable;
+clCreateImageFromFdINTEL_fn clCreateImageFromFdINTEL;
 #endif
 
 #if HAVE_OPENCL_VAAPI_INTEL_MEDIA
@@ -685,19 +691,19 @@ static int opencl_device_init(AVHWDeviceContext *hwdev)
 }   \
 } while (0)
 
-#if HAVE_OPENCL_VAAPI_BEIGNET
+#if HAVE_OPENCL_DRM_BEIGNET
 {
 int fail = 0;
 
 CL_FUNC(clCreateImageFromFdINTEL,
-"Intel DRM to OpenCL image mapping");
+"Beignet DRM to OpenCL image mapping");
 
 if (fail) {
-av_log(hwdev, AV_LOG_WARNING, "VAAPI to OpenCL mapping "
-   "not usable.\n");
-priv->vaapi_mapping_usable = 0;
+av_log(hwdev, AV_LOG_WARNING, "Beignet DRM to OpenCL "
+   "mapping not usable.\n");
+priv->beignet_drm_mapping_usable = 0;
 } else {
-priv->vaapi_mapping_usable = 1;
+priv->beignet_drm_mapping_usable = 1;
 }
 }
 #endif
@@ -1187,7 +1193,8 @@ static int opencl_device_derive(AVHWDeviceContext *hwdev,
 int err;
 switch (src_ctx->type) {
 
-#if HAVE_OPENCL_VAAPI_BEIGNET
+#if HAVE_OPENCL_DRM_BEIGNET
+case AV_HWDEVICE_TYPE_DRM:
 case AV_HWDEVICE_TYPE_VAAPI:
 {
 // Surface mapping works via DRM PRIME fds with no special
@@ -2028,175 +2035,151 @@ fail:
 return err;
 }
 
-#if HAVE_OPENCL_VAAPI_BEIGNET
+#if HAVE_OPENCL_DRM_BEIGNET
 
-typedef struct VAAPItoOpenCLMapping {
-VAImage  va_image;
-VABufferInfo va_buffer_info;
+typedef struct DRMBeignetToOpenCLMapping {
+AVFrame  *drm_frame;
+AVDRMFrameDescriptor *drm_desc;
 
 AVOpenCLFrameDescriptor frame;
-} VAAPItoOpenCLMapping;
+} DRMBeignetToOpenCLMapping;
 
-static void opencl_unmap_from_vaapi(AVHWFramesContext *src_fc,
-HWMapDescriptor *hwmap)
+static void opencl_unmap_from_drm_beignet(AVHWFramesContext *dst_fc,
+  HWMapDescriptor *hwmap)
 {
-VAAPItoOpenCLMapping *mapping = hwmap->priv;
-AVVAAPIDeviceContext *src_dev = src_fc->device_ctx->hwctx;
-VASurfaceID surface_id;
-VAStatus vas;
+DRMBeignetToOpenCLMapping *mapping = hwmap->priv;
 cl_int cle;
 int i;
 
-surface_id = (VASurfaceID)(uintptr_t)hwmap->source->data[3];
-av_log(src_fc, AV_LOG_DEBUG, "Unmap VAAPI surface %#x from OpenCL.\n",
-   surface_id);
-
 for (i = 0; i < mapping->frame.nb_planes; i++) {
 cle = clReleaseMemObject(mapping->frame.planes[i]);
 if (cle != CL_SUCCESS) {
-av_log(src_fc, AV_LOG_ERROR, "Failed to release CL "
-   "buffer of plane %d of VA image %#x 

[FFmpeg-devel] [PATCH 6/7] vf_scale_vaapi: Apply cropping rectangle to input

2018-03-11 Thread Mark Thompson
---
 libavfilter/vf_scale_vaapi.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavfilter/vf_scale_vaapi.c b/libavfilter/vf_scale_vaapi.c
index c19e23ccd0..d6529d5235 100644
--- a/libavfilter/vf_scale_vaapi.c
+++ b/libavfilter/vf_scale_vaapi.c
@@ -100,13 +100,13 @@ static int scale_vaapi_filter_frame(AVFilterLink *inlink, 
AVFrame *input_frame)
 
 memset(, 0, sizeof(params));
 
-// If there were top/left cropping, it could be taken into
-// account here.
 input_region = (VARectangle) {
-.x  = 0,
-.y  = 0,
-.width  = input_frame->width,
-.height = input_frame->height,
+.x  = input_frame->crop_left,
+.y  = input_frame->crop_top,
+.width  = input_frame->width -
+ (input_frame->crop_left + input_frame->crop_right),
+.height = input_frame->height -
+ (input_frame->crop_top + input_frame->crop_bottom),
 };
 
 params.surface = input_surface;
-- 
2.16.1

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


[FFmpeg-devel] [PATCH 3/7] hwcontext_vaapi: Pass correct read/write flags when exporting surfaces

2018-03-11 Thread Mark Thompson
---
 libavutil/hwcontext_vaapi.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index 15f1c4d1c0..8e4bef9f1b 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -1094,15 +1094,20 @@ static int vaapi_map_to_drm_esh(AVHWFramesContext 
*hwfc, AVFrame *dst,
 VAStatus vas;
 VADRMPRIMESurfaceDescriptor va_desc;
 AVDRMFrameDescriptor *drm_desc = NULL;
+uint32_t export_flags;
 int err, i, j;
 
 surface_id = (VASurfaceID)(uintptr_t)src->data[3];
 
+export_flags = VA_EXPORT_SURFACE_SEPARATE_LAYERS;
+if (flags & AV_HWFRAME_MAP_READ)
+export_flags |= VA_EXPORT_SURFACE_READ_ONLY;
+if (flags & AV_HWFRAME_MAP_WRITE)
+export_flags |= VA_EXPORT_SURFACE_WRITE_ONLY;
+
 vas = vaExportSurfaceHandle(hwctx->display, surface_id,
 VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2,
-VA_EXPORT_SURFACE_READ_ONLY |
-VA_EXPORT_SURFACE_SEPARATE_LAYERS,
-_desc);
+export_flags, _desc);
 if (vas != VA_STATUS_SUCCESS) {
 if (vas == VA_STATUS_ERROR_UNIMPLEMENTED)
 return AVERROR(ENOSYS);
-- 
2.16.1

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


[FFmpeg-devel] [PATCH 2/7] hwcontext_vaapi: Add support for legacy DRM mapping

2018-03-11 Thread Mark Thompson
The old vaAcquireBufferHandle() API works in fewer cases and provides
less information than the current vaExportSurfaceHandle(), but it exists
on older versions and is already used by the OpenCL code.  This probably
doesn't have much use directly, but it will be used to replace the ad-hoc
OpenCL code in a following patch.
---
 libavutil/hwcontext_vaapi.c | 191 +---
 1 file changed, 179 insertions(+), 12 deletions(-)

diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index 99f76b9169..15f1c4d1c0 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -1073,8 +1073,9 @@ static int vaapi_map_from_drm(AVHWFramesContext *src_fc, 
AVFrame *dst,
 return 0;
 }
 
-static void vaapi_unmap_to_drm(AVHWFramesContext *dst_fc,
-   HWMapDescriptor *hwmap)
+#if VA_CHECK_VERSION(1, 1, 0)
+static void vaapi_unmap_to_drm_esh(AVHWFramesContext *hwfc,
+   HWMapDescriptor *hwmap)
 {
 AVDRMFrameDescriptor *drm_desc = hwmap->priv;
 int i;
@@ -1085,10 +1086,9 @@ static void vaapi_unmap_to_drm(AVHWFramesContext *dst_fc,
 av_freep(_desc);
 }
 
-static int vaapi_map_to_drm(AVHWFramesContext *hwfc, AVFrame *dst,
-const AVFrame *src, int flags)
+static int vaapi_map_to_drm_esh(AVHWFramesContext *hwfc, AVFrame *dst,
+const AVFrame *src, int flags)
 {
-#if VA_CHECK_VERSION(1, 1, 0)
 AVVAAPIDeviceContext *hwctx = hwfc->device_ctx->hwctx;
 VASurfaceID surface_id;
 VAStatus vas;
@@ -1140,7 +1140,7 @@ static int vaapi_map_to_drm(AVHWFramesContext *hwfc, 
AVFrame *dst,
 }
 
 err = ff_hwframe_map_create(src->hw_frames_ctx, dst, src,
-_unmap_to_drm, drm_desc);
+_unmap_to_drm_esh, drm_desc);
 if (err < 0)
 goto fail;
 
@@ -1155,15 +1155,182 @@ fail:
 close(va_desc.objects[i].fd);
 av_freep(_desc);
 return err;
-#else
-// Older versions without vaExportSurfaceHandle() are not supported -
-// in theory this is possible with a combination of vaDeriveImage()
-// and vaAcquireBufferHandle(), but it doesn't carry enough metadata
-// to actually use the result in a generic way.
-return AVERROR(ENOSYS);
+}
 #endif
+
+typedef struct VAAPIDRMImageBufferMapping {
+VAImage  image;
+VABufferInfo buffer_info;
+
+AVDRMFrameDescriptor drm_desc;
+} VAAPIDRMImageBufferMapping;
+
+static void vaapi_unmap_to_drm_abh(AVHWFramesContext *hwfc,
+  HWMapDescriptor *hwmap)
+{
+AVVAAPIDeviceContext *hwctx = hwfc->device_ctx->hwctx;
+VAAPIDRMImageBufferMapping *mapping = hwmap->priv;
+VASurfaceID surface_id;
+VAStatus vas;
+
+surface_id = (VASurfaceID)(uintptr_t)hwmap->source->data[3];
+av_log(hwfc, AV_LOG_DEBUG, "Unmap VAAPI surface %#x from DRM.\n",
+   surface_id);
+
+// DRM PRIME file descriptors are closed by vaReleaseBufferHandle(),
+// so we shouldn't close them separately.
+
+vas = vaReleaseBufferHandle(hwctx->display, mapping->image.buf);
+if (vas != VA_STATUS_SUCCESS) {
+av_log(hwfc, AV_LOG_ERROR, "Failed to release buffer "
+   "handle of image %#x (derived from surface %#x): "
+   "%d (%s).\n", mapping->image.buf, surface_id,
+   vas, vaErrorStr(vas));
+}
+
+vas = vaDestroyImage(hwctx->display, mapping->image.image_id);
+if (vas != VA_STATUS_SUCCESS) {
+av_log(hwfc, AV_LOG_ERROR, "Failed to destroy image "
+   "derived from surface %#x: %d (%s).\n",
+   surface_id, vas, vaErrorStr(vas));
+}
+
+av_free(mapping);
 }
+
+static int vaapi_map_to_drm_abh(AVHWFramesContext *hwfc, AVFrame *dst,
+const AVFrame *src, int flags)
+{
+AVVAAPIDeviceContext *hwctx = hwfc->device_ctx->hwctx;
+VAAPIDRMImageBufferMapping *mapping = NULL;
+VASurfaceID surface_id;
+VAStatus vas;
+int err, i, p;
+
+surface_id = (VASurfaceID)(uintptr_t)src->data[3];
+av_log(hwfc, AV_LOG_DEBUG, "Map VAAPI surface %#x to DRM.\n",
+   surface_id);
+
+mapping = av_mallocz(sizeof(*mapping));
+if (!mapping)
+return AVERROR(ENOMEM);
+
+vas = vaDeriveImage(hwctx->display, surface_id,
+>image);
+if (vas != VA_STATUS_SUCCESS) {
+av_log(hwfc, AV_LOG_ERROR, "Failed to derive image from "
+   "surface %#x: %d (%s).\n",
+   surface_id, vas, vaErrorStr(vas));
+err = AVERROR(EIO);
+goto fail;
+}
+
+for (i = 0; i < FF_ARRAY_ELEMS(vaapi_drm_format_map); i++) {
+if (vaapi_drm_format_map[i].va_fourcc ==
+mapping->image.format.fourcc)
+break;
+}
+if (i >= FF_ARRAY_ELEMS(vaapi_drm_format_map)) {
+av_log(hwfc, AV_LOG_ERROR, "No matching DRM format for "
+   

[FFmpeg-devel] [PATCH 1/7] hwcontext_vaapi: Fix condition for DRM device derivation

2018-03-11 Thread Mark Thompson
vaGetDisplayDRM() is required for this code to work, libdrm is not.
---
 libavutil/hwcontext_vaapi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index af9a136ef0..99f76b9169 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -1324,7 +1324,7 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, 
const char *device,
 static int vaapi_device_derive(AVHWDeviceContext *ctx,
AVHWDeviceContext *src_ctx, int flags)
 {
-#if CONFIG_LIBDRM
+#if HAVE_VAAPI_DRM
 if (src_ctx->type == AV_HWDEVICE_TYPE_DRM) {
 AVDRMDeviceContext *src_hwctx = src_ctx->hwctx;
 VADisplay *display;
-- 
2.16.1

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


Re: [FFmpeg-devel] [PATCH] avfilter/vf_overlay: add show property/command

2018-03-11 Thread Lou Logan
On Sun, Mar 11, 2018, at 2:16 PM, Bodecs Bela wrote:
>
> I have found the info about it.

For others who may be curious:
https://ffmpeg.org/ffmpeg-filters.html#Timeline-editing

See supported filters with:
ffmpeg -filters

Todo: Mention which filters support timeline in filters.texi.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/vf_overlay: add show property/command

2018-03-11 Thread Bodecs Bela



2018.03.11. 23:09 keltezéssel, Bodecs Bela írta:



2018.03.11. 23:04 keltezéssel, Nicolas George írta:

Bodecs Bela (2018-03-11):
I frequently use overlay video filter. Sometimes it is needed to 
dinamically

hide/show the ovelaid video. (e.g during live streaming).
Currently the only possibility to hide the overlaid video is to 
position it

to off site area of the visible region.
This patch creates a new, explicit property to controll 
hiding/showing the

overlaid video.
'show' property may be an expression, similary to x and y.
The new 'show' property is controlable by command, also. So its 
value can be

adjusted dinamically during live sessions by zmq filters.
To be compatible with existing stuff, its default value is "1".

Please review this patch and consider putting this patch into the 
official

ffmpeg source tree.

Looks like a duplicate of the timeline editing feature, already
supported by overlay.

sorry I was not aware of it. Where can I read about it?



Regards,



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


best regards,

bb

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


I have found the info about it.

thank you,

bb


I have found the info about it.

thank you,

bb


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


Re: [FFmpeg-devel] [PATCH] avfilter/vf_overlay: add show property/command

2018-03-11 Thread Bodecs Bela



2018.03.11. 23:04 keltezéssel, Nicolas George írta:

Bodecs Bela (2018-03-11):

I frequently use overlay video filter. Sometimes it is needed to dinamically
hide/show the ovelaid video. (e.g during live streaming).
Currently the only possibility to hide the overlaid video is to position it
to off site area of the visible region.
This patch creates a new, explicit property to controll hiding/showing the
overlaid video.
'show' property may be an expression, similary to x and y.
The new 'show' property is controlable by command, also. So its value can be
adjusted dinamically during live sessions by zmq filters.
To be compatible with existing stuff, its default value is "1".

Please review this patch and consider putting this patch into the official
ffmpeg source tree.

Looks like a duplicate of the timeline editing feature, already
supported by overlay.

sorry I was not aware of it. Where can I read about it?



Regards,



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


best regards,

bb

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


Re: [FFmpeg-devel] [PATCH] avfilter/vf_overlay: add show property/command

2018-03-11 Thread Nicolas George
Bodecs Bela (2018-03-11):
> I frequently use overlay video filter. Sometimes it is needed to dinamically
> hide/show the ovelaid video. (e.g during live streaming).
> Currently the only possibility to hide the overlaid video is to position it
> to off site area of the visible region.
> This patch creates a new, explicit property to controll hiding/showing the
> overlaid video.
> 'show' property may be an expression, similary to x and y.
> The new 'show' property is controlable by command, also. So its value can be
> adjusted dinamically during live sessions by zmq filters.
> To be compatible with existing stuff, its default value is "1".
> 
> Please review this patch and consider putting this patch into the official
> ffmpeg source tree.

Looks like a duplicate of the timeline editing feature, already
supported by overlay.

Regards,

-- 
  Nicolas George


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


[FFmpeg-devel] [PATCH] avfilter/vf_overlay: add show property/command

2018-03-11 Thread Bodecs Bela

Dear All,

I frequently use overlay video filter. Sometimes it is needed to 
dinamically hide/show the ovelaid video. (e.g during live streaming).
Currently the only possibility to hide the overlaid video is to position 
it to off site area of the visible region.
This patch creates a new, explicit property to controll hiding/showing 
the overlaid video.

'show' property may be an expression, similary to x and y.
The new 'show' property is controlable by command, also. So its value 
can be adjusted dinamically during live sessions by zmq filters.

To be compatible with existing stuff, its default value is "1".

Please review this patch and consider putting this patch into the 
official ffmpeg source tree.


Thank you in advance.


best regards,

Bela


>From 808053b373b1209bc4a56a5630ee9cbc71413ff6 Mon Sep 17 00:00:00 2001
From: Bela Bodecs 
Date: Sun, 11 Mar 2018 22:33:32 +0100
Subject: [PATCH] avfilter/vf_overlay: add show property/command

Currently the only possibility to hide the overlaid video is to position
it to off site area of the visible region. This patch creates a new,
explicit property to controll hiding/showing the overlaid video. 'show'
property may be an expression, similary to x and y. The new 'show'
property is controlable by command, also. To be compatible with existing
stuff, its default value is "1".

Signed-off-by: Bela Bodecs 
---
 doc/filters.texi | 16 ++--
 libavfilter/vf_overlay.c | 37 ++---
 2 files changed, 40 insertions(+), 13 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index bd93e0a..f9b623c 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -11615,11 +11615,16 @@ on the main video. Default value is "0" for both 
expressions. In case
 the expression is invalid, it is set to a huge value (meaning that the
 overlay will not be displayed within the output visible area).
 
+@item show
+Set the expression for controlling to show or hide the overlaid video.
+Default value is "1". Expression evaluating to 0 means to hide,
+any other value means to show. Internally the result normalized to 0 or 1.
+
 @item eof_action
 See @ref{framesync}.
 
 @item eval
-Set when the expressions for @option{x}, and @option{y} are evaluated.
+Set when the expressions for @option{x}, @option{y} and @option{show} are 
evaluated.
 
 It accepts the following values:
 @table @samp
@@ -11670,7 +11675,7 @@ Set format of alpha of the overlaid video, it can be 
@var{straight} or
 @var{premultiplied}. Default is @var{straight}.
 @end table
 
-The @option{x}, and @option{y} expressions can contain the following
+The @option{x}, @option{y} and @option{show} expressions can contain the 
following
 parameters.
 
 @table @option
@@ -11702,6 +11707,9 @@ the position in the file of the input frame, NAN if 
unknown
 @item t
 The timestamp, expressed in seconds. It's NAN if the input timestamp is 
unknown.
 
+@item show
+the computed value of @var{show} normalized to 0 or 1 according to wether 
overlaid video shown or hidden.
+
 @end table
 
 This filter also supports the @ref{framesync} options.
@@ -11730,6 +11738,10 @@ The command accepts the same syntax of the 
corresponding option.
 
 If the specified expression is not valid, it is kept at its current
 value.
+
+@item show
+Modify the expression to show or to hide the overlaid video.
+
 @end table
 
 @subsection Examples
diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index c6a6ac8..891db9e 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -52,6 +52,7 @@ static const char *const var_names[] = {
 "n",///< number of frame
 "pos",  ///< position in the file
 "t",///< timestamp expressed in seconds
+"show", ///< show/hide overlay
 NULL
 };
 
@@ -67,6 +68,7 @@ enum var_name {
 VAR_N,
 VAR_POS,
 VAR_T,
+VAR_SHOW,
 VAR_VARS_NB
 };
 
@@ -111,6 +113,7 @@ typedef struct OverlayContext {
 int format; ///< OverlayFormat
 int alpha_format;
 int eval_mode;  ///< EvalMode
+int show;   ///< show or hide overlay
 
 FFFrameSync fs;
 
@@ -120,9 +123,9 @@ typedef struct OverlayContext {
 const AVPixFmtDescriptor *main_desc; ///< format descriptor for main input
 
 double var_values[VAR_VARS_NB];
-char *x_expr, *y_expr;
+char *x_expr, *y_expr, *show_expr;
 
-AVExpr *x_pexpr, *y_pexpr;
+AVExpr *x_pexpr, *y_pexpr, *show_pexpr;
 
 void (*blend_image)(AVFilterContext *ctx, AVFrame *dst, const AVFrame 
*src, int x, int y);
 } OverlayContext;
@@ -134,6 +137,7 @@ static av_cold void uninit(AVFilterContext *ctx)
 ff_framesync_uninit(>fs);
 av_expr_free(s->x_pexpr); s->x_pexpr = NULL;
 av_expr_free(s->y_pexpr); s->y_pexpr = NULL;
+av_expr_free(s->show_pexpr); s->show_pexpr = NULL;
 }
 
 static inline int normalize_xy(double d, int chroma_sub)
@@ -153,6 +157,8 

[FFmpeg-devel] [PATCH] add convolution_opencl

2018-03-11 Thread Danil Iashchenko
---
 configure   |   1 +
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   1 +
 libavfilter/opencl/convolution.cl   |  42 
 libavfilter/opencl_source.h |   3 +
 libavfilter/vf_convolution_opencl.c | 464 
 6 files changed, 512 insertions(+)
 create mode 100644 libavfilter/opencl/convolution.cl
 create mode 100644 libavfilter/vf_convolution_opencl.c

diff --git a/configure b/configure
index 6916b45..7c79e20 100755
--- a/configure
+++ b/configure
@@ -3212,6 +3212,7 @@ bs2b_filter_deps="libbs2b"
 colormatrix_filter_deps="gpl"
 convolve_filter_deps="avcodec"
 convolve_filter_select="fft"
+convolution_opencl_filter_deps="opencl"
 coreimage_filter_deps="coreimage appkit"
 coreimage_filter_extralibs="-framework OpenGL"
 coreimagesrc_filter_deps="coreimage appkit"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 6a60836..d005934 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -156,6 +156,7 @@ OBJS-$(CONFIG_COLORLEVELS_FILTER)+= 
vf_colorlevels.o
 OBJS-$(CONFIG_COLORMATRIX_FILTER)+= vf_colormatrix.o
 OBJS-$(CONFIG_COLORSPACE_FILTER) += vf_colorspace.o colorspacedsp.o
 OBJS-$(CONFIG_CONVOLUTION_FILTER)+= vf_convolution.o
+OBJS-$(CONFIG_CONVOLUTION_OPENCL_FILTER) += vf_convolution_opencl.o 
opencl.o opencl/convolution.o
 OBJS-$(CONFIG_CONVOLVE_FILTER)   += vf_convolve.o framesync.o
 OBJS-$(CONFIG_COPY_FILTER)   += vf_copy.o
 OBJS-$(CONFIG_COREIMAGE_FILTER)  += vf_coreimage.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 9adb109..f2dc55e 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -166,6 +166,7 @@ static void register_all(void)
 REGISTER_FILTER(COLORMATRIX,colormatrix,vf);
 REGISTER_FILTER(COLORSPACE, colorspace, vf);
 REGISTER_FILTER(CONVOLUTION,convolution,vf);
+REGISTER_FILTER(CONVOLUTION_OPENCL, convolution_opencl, vf);
 REGISTER_FILTER(CONVOLVE,   convolve,   vf);
 REGISTER_FILTER(COPY,   copy,   vf);
 REGISTER_FILTER(COREIMAGE,  coreimage,  vf);
diff --git a/libavfilter/opencl/convolution.cl 
b/libavfilter/opencl/convolution.cl
new file mode 100644
index 000..d074d98
--- /dev/null
+++ b/libavfilter/opencl/convolution.cl
@@ -0,0 +1,42 @@
+/*
+ * 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
+ */
+
+__kernel void convolution_global(__write_only image2d_t dst,
+ __read_only  image2d_t src,
+ __constant int *coef_matrix_size,
+ __constant float *coef_matrix,
+ __constant float *div,
+ __constant float *bias)
+{
+const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE | 
CLK_FILTER_NEAREST);
+
+int2 loc = (int2)(get_global_id(0), get_global_id(1));
+
+float4 convPix = (float4)(0.0f, 0.0f, 0.0f, 0.0f);
+for (int i = 0; i < 4; i++) {
+for (int conv_i = -(coef_matrix_size[i] / 2); conv_i <= 
(coef_matrix_size[i] / 2); conv_i++) {
+for (int conv_j = -(coef_matrix_size[i] / 2); conv_j <= 
(coef_matrix_size[i] / 2); conv_j++) {
+float4 px = read_imagef(src, sampler, loc + (int2)(conv_j, 
conv_i));
+convPix[i] += px[i] * 
coef_matrix[(coef_matrix_size[i]*coef_matrix_size[i]*i)
++ (conv_i+(coef_matrix_size[i] / 2)) * 
coef_matrix_size[i] + (conv_j+(coef_matrix_size[i] / 2))];
+}
+}
+convPix[i] = convPix[i] * div[i] + bias[i];
+}
+write_imagef(dst, loc, convPix);
+}
diff --git a/libavfilter/opencl_source.h b/libavfilter/opencl_source.h
index 23cdfc6..3029f64 100644
--- a/libavfilter/opencl_source.h
+++ b/libavfilter/opencl_source.h
@@ -19,7 +19,10 @@
 #ifndef AVFILTER_OPENCL_SOURCE_H
 #define AVFILTER_OPENCL_SOURCE_H
 
+extern const char *ff_opencl_source_convolution;
 extern const char *ff_opencl_source_overlay;
 extern const char *ff_opencl_source_unsharp;
 
+
+
 #endif /* AVFILTER_OPENCL_SOURCE_H */
diff --git a/libavfilter/vf_convolution_opencl.c 

[FFmpeg-devel] [PATCH] libavfilter/vf_convolution_opencl.c: add opencl version of libavfilter/convolution.c filter

2018-03-11 Thread Danil Iashchenko
Hi there. Thank you for your advices. I implemented 4 matrix / 4 rdiv / 4 bias 
option for each plane of image, fixed mem-leaks, added error messages if the 
matrix is invalid.  

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


Re: [FFmpeg-devel] [PATCH] libavfilter/vf_convolution_opencl.c: add opencl version of libavfilter/convolution.c filter

2018-03-11 Thread Danil Iashchenko
Hi there. Thank you for your advices. 
I implemented 4 matrix / 4 rdiv / 4 bias support, fixed mem-leaks, 
add error messages if matrix is incorrect, removed local kernel.
 
Kind regards. Danil

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


Re: [FFmpeg-devel] [PATCH 7/8] cbs: Add a table of all supported codec IDs

2018-03-11 Thread Mark Thompson


On 11/03/18 19:04, James Almer wrote:
> On 3/11/2018 3:30 PM, Mark Thompson wrote:
>> Use it as the set of codec IDs supported by the trace_headers BSF.
>> ---
>>  configure  |  1 -
>>  libavcodec/cbs.c   | 13 +
>>  libavcodec/cbs.h   |  8 
>>  libavcodec/trace_headers_bsf.c |  9 +
>>  4 files changed, 22 insertions(+), 9 deletions(-)
>>
>> diff --git a/configure b/configure
>> index 5e38bdab17..95354611ff 100755
>> --- a/configure
>> +++ b/configure
>> @@ -2905,7 +2905,6 @@ h264_redundant_pps_bsf_select="cbs_h264"
>>  hevc_metadata_bsf_select="cbs_h265"
>>  mjpeg2jpeg_bsf_select="jpegtables"
>>  mpeg2_metadata_bsf_select="cbs_mpeg2"
>> -trace_headers_bsf_select="cbs_h264 cbs_h265 cbs_mpeg2"
> 
> It should at least select cbs, otherwise linking will fail if no other
> module using cbs is enabled.

Yes, it should.  Fixed locally.

>>  
>>  # external libraries
>>  aac_at_decoder_deps="audiotoolbox"
>> diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
>> index 62f60be437..897e0bb28e 100644
>> --- a/libavcodec/cbs.c
>> +++ b/libavcodec/cbs.c
>> @@ -40,6 +40,19 @@ static const CodedBitstreamType *cbs_type_table[] = {
>>  #endif
>>  };
>>  
>> +const enum AVCodecID ff_cbs_all_codec_ids[] = {
>> +#if CONFIG_CBS_H264
>> +AV_CODEC_ID_H264,
>> +#endif
>> +#if CONFIG_CBS_H265
>> +AV_CODEC_ID_H265,
>> +#endif
>> +#if CONFIG_CBS_MPEG2
>> +AV_CODEC_ID_MPEG2VIDEO,
>> +#endif
>> +AV_CODEC_ID_NONE
>> +};
>> +
>>  int ff_cbs_init(CodedBitstreamContext **ctx_ptr,
>>  enum AVCodecID codec_id, void *log_ctx)
>>  {
>> diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
>> index 396ff0faec..402eb39e00 100644
>> --- a/libavcodec/cbs.h
>> +++ b/libavcodec/cbs.h
>> @@ -201,6 +201,14 @@ typedef struct CodedBitstreamContext {
>>  } CodedBitstreamContext;
>>  
>>  
>> +/**
>> + * Table of all supported codec IDs.
>> + *
>> + * Terminated by AV_CODEC_ID_NONE.
>> + */
>> +extern const enum AVCodecID ff_cbs_all_codec_ids[];
>> +
>> +
>>  /**
>>   * Create and initialise a new context for the given codec.
>>   */
>> diff --git a/libavcodec/trace_headers_bsf.c b/libavcodec/trace_headers_bsf.c
>> index 93d04cb509..f742e36d77 100644
>> --- a/libavcodec/trace_headers_bsf.c
>> +++ b/libavcodec/trace_headers_bsf.c
>> @@ -109,18 +109,11 @@ static int trace_headers(AVBSFContext *bsf, AVPacket 
>> *out)
>>  return 0;
>>  }
>>  
>> -static const enum AVCodecID trace_headers_codec_ids[] = {
>> -AV_CODEC_ID_H264,
>> -AV_CODEC_ID_HEVC,
>> -AV_CODEC_ID_MPEG2VIDEO,
>> -AV_CODEC_ID_NONE,
>> -};
>> -
>>  const AVBitStreamFilter ff_trace_headers_bsf = {
>>  .name   = "trace_headers",
>>  .priv_data_size = sizeof(TraceHeadersContext),
>>  .init   = _headers_init,
>>  .close  = _headers_close,
>>  .filter = _headers,
>> -.codec_ids  = trace_headers_codec_ids,
>> +.codec_ids  = ff_cbs_all_codec_ids,
>>  };
>>
> 
> Should be ok assuming the bsf API is ok with a filter reporting only
> ID_NONE as supported codec (I don't think any filter currently does
> that, but i didn't check).

It is.  (And you correctly always get the "Codec 'h264' (27) is not supported 
by the bitstream filter ..." message when trying to use it in that case.)

Thanks,

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


Re: [FFmpeg-devel] [PATCH 6/8] h264_metadata: Remove unused fields

2018-03-11 Thread Hendrik Leppkes
On Sun, Mar 11, 2018 at 7:55 PM, James Almer  wrote:
> On 3/11/2018 3:30 PM, Mark Thompson wrote:
>> The SEI NAL is unused since 69062d0f9b6aef5d9d9b8c9c9b5cfb23037caddb,
>> while the AUD NAL is small and would more sensibly be on the stack.
>> ---
>>  libavcodec/h264_metadata_bsf.c | 12 +---
>>  1 file changed, 5 insertions(+), 7 deletions(-)
>>
>> diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
>> index d340c55990..760fe99c41 100644
>> --- a/libavcodec/h264_metadata_bsf.c
>> +++ b/libavcodec/h264_metadata_bsf.c
>> @@ -47,9 +47,6 @@ typedef struct H264MetadataContext {
>>
>>  int done_first_au;
>>
>> -H264RawAUD aud_nal;
>> -H264RawSEI sei_nal;
>> -
>>  int aud;
>>
>>  AVRational sample_aspect_ratio;
>> @@ -263,7 +260,9 @@ static int h264_metadata_filter(AVBSFContext *bsf, 
>> AVPacket *out)
>>  0x3ff, // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
>>  };
>>  int primary_pic_type_mask = 0xff;
>> -H264RawAUD *aud = >aud_nal;
>> +H264RawAUD aud = {
>> +.nal_unit_header.nal_unit_type = H264_NAL_AUD,
>> +};
>
> Afaik every other field is not zero initialized if you do this, unlike
> if you keep it in H264MetadataContext.
> Not sure if that may have some consequences or not here.
>

All other members are initialized with zero if you use any sort of
initializer syntax.

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


Re: [FFmpeg-devel] [PATCH 7/8] cbs: Add a table of all supported codec IDs

2018-03-11 Thread James Almer
On 3/11/2018 3:30 PM, Mark Thompson wrote:
> Use it as the set of codec IDs supported by the trace_headers BSF.
> ---
>  configure  |  1 -
>  libavcodec/cbs.c   | 13 +
>  libavcodec/cbs.h   |  8 
>  libavcodec/trace_headers_bsf.c |  9 +
>  4 files changed, 22 insertions(+), 9 deletions(-)
> 
> diff --git a/configure b/configure
> index 5e38bdab17..95354611ff 100755
> --- a/configure
> +++ b/configure
> @@ -2905,7 +2905,6 @@ h264_redundant_pps_bsf_select="cbs_h264"
>  hevc_metadata_bsf_select="cbs_h265"
>  mjpeg2jpeg_bsf_select="jpegtables"
>  mpeg2_metadata_bsf_select="cbs_mpeg2"
> -trace_headers_bsf_select="cbs_h264 cbs_h265 cbs_mpeg2"

It should at least select cbs, otherwise linking will fail if no other
module using cbs is enabled.

>  
>  # external libraries
>  aac_at_decoder_deps="audiotoolbox"
> diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
> index 62f60be437..897e0bb28e 100644
> --- a/libavcodec/cbs.c
> +++ b/libavcodec/cbs.c
> @@ -40,6 +40,19 @@ static const CodedBitstreamType *cbs_type_table[] = {
>  #endif
>  };
>  
> +const enum AVCodecID ff_cbs_all_codec_ids[] = {
> +#if CONFIG_CBS_H264
> +AV_CODEC_ID_H264,
> +#endif
> +#if CONFIG_CBS_H265
> +AV_CODEC_ID_H265,
> +#endif
> +#if CONFIG_CBS_MPEG2
> +AV_CODEC_ID_MPEG2VIDEO,
> +#endif
> +AV_CODEC_ID_NONE
> +};
> +
>  int ff_cbs_init(CodedBitstreamContext **ctx_ptr,
>  enum AVCodecID codec_id, void *log_ctx)
>  {
> diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
> index 396ff0faec..402eb39e00 100644
> --- a/libavcodec/cbs.h
> +++ b/libavcodec/cbs.h
> @@ -201,6 +201,14 @@ typedef struct CodedBitstreamContext {
>  } CodedBitstreamContext;
>  
>  
> +/**
> + * Table of all supported codec IDs.
> + *
> + * Terminated by AV_CODEC_ID_NONE.
> + */
> +extern const enum AVCodecID ff_cbs_all_codec_ids[];
> +
> +
>  /**
>   * Create and initialise a new context for the given codec.
>   */
> diff --git a/libavcodec/trace_headers_bsf.c b/libavcodec/trace_headers_bsf.c
> index 93d04cb509..f742e36d77 100644
> --- a/libavcodec/trace_headers_bsf.c
> +++ b/libavcodec/trace_headers_bsf.c
> @@ -109,18 +109,11 @@ static int trace_headers(AVBSFContext *bsf, AVPacket 
> *out)
>  return 0;
>  }
>  
> -static const enum AVCodecID trace_headers_codec_ids[] = {
> -AV_CODEC_ID_H264,
> -AV_CODEC_ID_HEVC,
> -AV_CODEC_ID_MPEG2VIDEO,
> -AV_CODEC_ID_NONE,
> -};
> -
>  const AVBitStreamFilter ff_trace_headers_bsf = {
>  .name   = "trace_headers",
>  .priv_data_size = sizeof(TraceHeadersContext),
>  .init   = _headers_init,
>  .close  = _headers_close,
>  .filter = _headers,
> -.codec_ids  = trace_headers_codec_ids,
> +.codec_ids  = ff_cbs_all_codec_ids,
>  };
> 

Should be ok assuming the bsf API is ok with a filter reporting only
ID_NONE as supported codec (I don't think any filter currently does
that, but i didn't check).
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 6/8] h264_metadata: Remove unused fields

2018-03-11 Thread James Almer
On 3/11/2018 4:02 PM, Mark Thompson wrote:
> On 11/03/18 18:55, James Almer wrote:
>> On 3/11/2018 3:30 PM, Mark Thompson wrote:
>>> The SEI NAL is unused since 69062d0f9b6aef5d9d9b8c9c9b5cfb23037caddb,
>>> while the AUD NAL is small and would more sensibly be on the stack.
>>> ---
>>>  libavcodec/h264_metadata_bsf.c | 12 +---
>>>  1 file changed, 5 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
>>> index d340c55990..760fe99c41 100644
>>> --- a/libavcodec/h264_metadata_bsf.c
>>> +++ b/libavcodec/h264_metadata_bsf.c
>>> @@ -47,9 +47,6 @@ typedef struct H264MetadataContext {
>>>  
>>>  int done_first_au;
>>>  
>>> -H264RawAUD aud_nal;
>>> -H264RawSEI sei_nal;
>>> -
>>>  int aud;
>>>  
>>>  AVRational sample_aspect_ratio;
>>> @@ -263,7 +260,9 @@ static int h264_metadata_filter(AVBSFContext *bsf, 
>>> AVPacket *out)
>>>  0x3ff, // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
>>>  };
>>>  int primary_pic_type_mask = 0xff;
>>> -H264RawAUD *aud = >aud_nal;
>>> +H264RawAUD aud = {
>>> +.nal_unit_header.nal_unit_type = H264_NAL_AUD,
>>> +};
>>
>> Afaik every other field is not zero initialized if you do this, unlike
>> if you keep it in H264MetadataContext.
>> Not sure if that may have some consequences or not here.
> 
> As long as one member is set the rest are are zero-initialised.
> 
> C11 §6.7.9, paragraph 19:
> "all subobjects that are not initialized explicitly shall be initialized 
> implicitly the same as
> objects that have static storage duration."
> 
> (This is why the "{ 0 }" syntax works, because it initialises the first 
> member to zero (whatever that is) and then the rest are implicitly zero as 
> well.)
> 
> - Mark

Good to know, thanks.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 6/8] h264_metadata: Remove unused fields

2018-03-11 Thread Mark Thompson
On 11/03/18 18:55, James Almer wrote:
> On 3/11/2018 3:30 PM, Mark Thompson wrote:
>> The SEI NAL is unused since 69062d0f9b6aef5d9d9b8c9c9b5cfb23037caddb,
>> while the AUD NAL is small and would more sensibly be on the stack.
>> ---
>>  libavcodec/h264_metadata_bsf.c | 12 +---
>>  1 file changed, 5 insertions(+), 7 deletions(-)
>>
>> diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
>> index d340c55990..760fe99c41 100644
>> --- a/libavcodec/h264_metadata_bsf.c
>> +++ b/libavcodec/h264_metadata_bsf.c
>> @@ -47,9 +47,6 @@ typedef struct H264MetadataContext {
>>  
>>  int done_first_au;
>>  
>> -H264RawAUD aud_nal;
>> -H264RawSEI sei_nal;
>> -
>>  int aud;
>>  
>>  AVRational sample_aspect_ratio;
>> @@ -263,7 +260,9 @@ static int h264_metadata_filter(AVBSFContext *bsf, 
>> AVPacket *out)
>>  0x3ff, // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
>>  };
>>  int primary_pic_type_mask = 0xff;
>> -H264RawAUD *aud = >aud_nal;
>> +H264RawAUD aud = {
>> +.nal_unit_header.nal_unit_type = H264_NAL_AUD,
>> +};
> 
> Afaik every other field is not zero initialized if you do this, unlike
> if you keep it in H264MetadataContext.
> Not sure if that may have some consequences or not here.

As long as one member is set the rest are are zero-initialised.

C11 §6.7.9, paragraph 19:
"all subobjects that are not initialized explicitly shall be initialized 
implicitly the same as
objects that have static storage duration."

(This is why the "{ 0 }" syntax works, because it initialises the first member 
to zero (whatever that is) and then the rest are implicitly zero as well.)

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


Re: [FFmpeg-devel] [PATCH 6/8] h264_metadata: Remove unused fields

2018-03-11 Thread James Almer
On 3/11/2018 3:30 PM, Mark Thompson wrote:
> The SEI NAL is unused since 69062d0f9b6aef5d9d9b8c9c9b5cfb23037caddb,
> while the AUD NAL is small and would more sensibly be on the stack.
> ---
>  libavcodec/h264_metadata_bsf.c | 12 +---
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
> index d340c55990..760fe99c41 100644
> --- a/libavcodec/h264_metadata_bsf.c
> +++ b/libavcodec/h264_metadata_bsf.c
> @@ -47,9 +47,6 @@ typedef struct H264MetadataContext {
>  
>  int done_first_au;
>  
> -H264RawAUD aud_nal;
> -H264RawSEI sei_nal;
> -
>  int aud;
>  
>  AVRational sample_aspect_ratio;
> @@ -263,7 +260,9 @@ static int h264_metadata_filter(AVBSFContext *bsf, 
> AVPacket *out)
>  0x3ff, // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
>  };
>  int primary_pic_type_mask = 0xff;
> -H264RawAUD *aud = >aud_nal;
> +H264RawAUD aud = {
> +.nal_unit_header.nal_unit_type = H264_NAL_AUD,
> +};

Afaik every other field is not zero initialized if you do this, unlike
if you keep it in H264MetadataContext.
Not sure if that may have some consequences or not here.

>  
>  for (i = 0; i < au->nb_units; i++) {
>  if (au->units[i].type == H264_NAL_SLICE ||
> @@ -286,11 +285,10 @@ static int h264_metadata_filter(AVBSFContext *bsf, 
> AVPacket *out)
>  goto fail;
>  }
>  
> -aud->nal_unit_header.nal_unit_type = H264_NAL_AUD;
> -aud->primary_pic_type = j;
> +aud.primary_pic_type = j;
>  
>  err = ff_cbs_insert_unit_content(ctx->cbc, au,
> - 0, H264_NAL_AUD, aud, NULL);
> + 0, H264_NAL_AUD, , NULL);
>  if (err < 0) {
>  av_log(bsf, AV_LOG_ERROR, "Failed to insert AUD.\n");
>  goto fail;
> 

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


Re: [FFmpeg-devel] [PATCH 4/6] avcodec/trace_headers: move the reference in the bsf internal buffer

2018-03-11 Thread James Almer
On 3/11/2018 3:32 PM, Mark Thompson wrote:
> On 11/03/18 17:58, James Almer wrote:
>> There's no need to allocate a new packet for it.
>>
>> Signed-off-by: James Almer 
>> ---
>>  libavcodec/trace_headers_bsf.c | 30 ++
>>  1 file changed, 14 insertions(+), 16 deletions(-)
>>
>> diff --git a/libavcodec/trace_headers_bsf.c b/libavcodec/trace_headers_bsf.c
>> index 93d04cb509..d59bc828a9 100644
>> --- a/libavcodec/trace_headers_bsf.c
>> +++ b/libavcodec/trace_headers_bsf.c
>> @@ -71,41 +71,39 @@ static int trace_headers(AVBSFContext *bsf, AVPacket 
>> *out)
>>  {
>>  TraceHeadersContext *ctx = bsf->priv_data;
>>  CodedBitstreamFragment au;
>> -AVPacket *in;
>>  char tmp[256] = { 0 };
>>  int err;
>>  
>> -err = ff_bsf_get_packet(bsf, );
>> +err = ff_bsf_get_packet_ref(bsf, out);
>>  if (err < 0)
>>  return err;
>>  
>> -if (in->flags & AV_PKT_FLAG_KEY)
>> +if (out->flags & AV_PKT_FLAG_KEY)
>>  av_strlcat(tmp, ", key frame", sizeof(tmp));
>> -if (in->flags & AV_PKT_FLAG_CORRUPT)
>> +if (out->flags & AV_PKT_FLAG_CORRUPT)
>>  av_strlcat(tmp, ", corrupt", sizeof(tmp));
>>  
>> -if (in->pts != AV_NOPTS_VALUE)
>> -av_strlcatf(tmp, sizeof(tmp), ", pts %"PRId64, in->pts);
>> +if (out->pts != AV_NOPTS_VALUE)
>> +av_strlcatf(tmp, sizeof(tmp), ", pts %"PRId64, out->pts);
>>  else
>>  av_strlcat(tmp, ", no pts", sizeof(tmp));
>> -if (in->dts != AV_NOPTS_VALUE)
>> -av_strlcatf(tmp, sizeof(tmp), ", dts %"PRId64, in->dts);
>> +if (out->dts != AV_NOPTS_VALUE)
>> +av_strlcatf(tmp, sizeof(tmp), ", dts %"PRId64, out->dts);
>>  else
>>  av_strlcat(tmp, ", no dts", sizeof(tmp));
>> -if (in->duration > 0)
>> -av_strlcatf(tmp, sizeof(tmp), ", duration %"PRId64, in->duration);
>> +if (out->duration > 0)
>> +av_strlcatf(tmp, sizeof(tmp), ", duration %"PRId64, out->duration);
>>  
>> -av_log(bsf, AV_LOG_INFO, "Packet: %d bytes%s.\n", in->size, tmp);
>> +av_log(bsf, AV_LOG_INFO, "Packet: %d bytes%s.\n", out->size, tmp);
>>  
>> -err = ff_cbs_read_packet(ctx->cbc, , in);
>> -if (err < 0)
>> +err = ff_cbs_read_packet(ctx->cbc, , out);
>> +if (err < 0) {
>> +av_packet_unref(out);
>>  return err;
>> +}
>>  
>>  ff_cbs_fragment_uninit(ctx->cbc, );
>>  
>> -av_packet_move_ref(out, in);
>> -av_packet_free();
>> -
>>  return 0;
>>  }
>>  
>>
> 
> Rename the packet to something like "pkt" throughout?  The "out" name looks 
> kindof weird after this change.
> 
> (That could probably apply to all of the patches, but this one makes the most 
> use of the packet.)
> 
> Whole series looks fine to me.

Changed in all patches and pushed. Thanks!

> 
> - Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] fate/hap : add test for hap encoding

2018-03-11 Thread Martin Vignali
2017-11-26 18:25 GMT+01:00 Martin Vignali :

> Hello,
>
> Patch in attach, add test for hap encoding (currently not cover) (patch
> 002)
> and move decoding tests to a separate file (patch 001)
>
> decoding can be test with
> make fate-hap SAMPLES=fate-suite/
>
> and encoding can be test with
> make fate-hapenc SAMPLES=fate-suite/
>
> Hap encoding need ffmpeg compile with libsnappy (--enable-libsnappy)
>
>
If noone is against,
i plan to apply this in few days.

In attach, updated patch (in order to apply it on master).

Martin


0003-fate-hap-move-decoding-test-to-a-separate-file.patch
Description: Binary data


0004-fate-hap-add-test-for-hap-encoding.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/8] cbs_h265: Use helper macro for maximum values of fixed-width elements

2018-03-11 Thread Mark Thompson
Apply the same logic as the previous patch to H.265.  There are no cases
which currently overflow here, but this is still more consistent.
---
 libavcodec/cbs_h265_syntax_template.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavcodec/cbs_h265_syntax_template.c 
b/libavcodec/cbs_h265_syntax_template.c
index dae7f2dd46..140c827c9d 100644
--- a/libavcodec/cbs_h265_syntax_template.c
+++ b/libavcodec/cbs_h265_syntax_template.c
@@ -665,7 +665,7 @@ static int FUNC(sps_scc_extension)(CodedBitstreamContext 
*ctx, RWContext *rw,
   : current->bit_depth_chroma_minus8 + 
8;
 for (i = 0; i <= 
current->sps_num_palette_predictor_initializer_minus1; i++)
 u(bit_depth, sps_palette_predictor_initializers[comp][i],
-  0, (1 << bit_depth) - 1);
+  0, MAX_UINT_BITS(bit_depth));
 }
 }
 }
@@ -827,7 +827,7 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext 
*rw,
 for (i = 0; i < current->num_long_term_ref_pics_sps; i++) {
 u(current->log2_max_pic_order_cnt_lsb_minus4 + 4,
   lt_ref_pic_poc_lsb_sps[i],
-  0, (1 << (current->log2_max_pic_order_cnt_lsb_minus4 + 4)) - 1);
+  0, MAX_UINT_BITS(current->log2_max_pic_order_cnt_lsb_minus4 + 
4));
 flag(used_by_curr_pic_lt_sps_flag[i]);
 }
 }
@@ -845,7 +845,7 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext 
*rw,
 flag(sps_multilayer_extension_flag);
 flag(sps_3d_extension_flag);
 flag(sps_scc_extension_flag);
-u(4, sps_extension_4bits, 0, (1 << 4) - 1);
+u(4, sps_extension_4bits, 0, MAX_UINT_BITS(4));
 }
 
 if (current->sps_range_extension_flag)
@@ -925,7 +925,7 @@ static int FUNC(pps_scc_extension)(CodedBitstreamContext 
*ctx, RWContext *rw,
   : 
current->chroma_bit_depth_entry_minus8 + 8;
 for (i = 0; i < 
current->pps_num_palette_predictor_initializer; i++)
 u(bit_depth, pps_palette_predictor_initializers[comp][i],
-  0, (1 << bit_depth) - 1);
+  0, MAX_UINT_BITS(bit_depth));
 }
 }
 }
@@ -1038,7 +1038,7 @@ static int FUNC(pps)(CodedBitstreamContext *ctx, 
RWContext *rw,
 flag(pps_multilayer_extension_flag);
 flag(pps_3d_extension_flag);
 flag(pps_scc_extension_flag);
-u(4, pps_extension_4bits, 0, (1 << 4) - 1);
+u(4, pps_extension_4bits, 0, MAX_UINT_BITS(4));
 }
 if (current->pps_range_extension_flag)
 CHECK(FUNC(pps_range_extension)(ctx, rw, current));
@@ -1274,7 +1274,7 @@ static int 
FUNC(slice_segment_header)(CodedBitstreamContext *ctx, RWContext *rw,
 const H265RawSTRefPicSet *rps;
 
 u(sps->log2_max_pic_order_cnt_lsb_minus4 + 4, 
slice_pic_order_cnt_lsb,
-  0, (1 << (sps->log2_max_pic_order_cnt_lsb_minus4 + 4)) - 1);
+  0, MAX_UINT_BITS(sps->log2_max_pic_order_cnt_lsb_minus4 + 4));
 
 flag(short_term_ref_pic_set_sps_flag);
 if (!current->short_term_ref_pic_set_sps_flag) {
@@ -1321,7 +1321,7 @@ static int 
FUNC(slice_segment_header)(CodedBitstreamContext *ctx, RWContext *rw,
 ++num_pic_total_curr;
 } else {
 u(sps->log2_max_pic_order_cnt_lsb_minus4 + 4, 
poc_lsb_lt[i],
-  0, (1 << (sps->log2_max_pic_order_cnt_lsb_minus4 + 
4)) - 1);
+  0, 
MAX_UINT_BITS(sps->log2_max_pic_order_cnt_lsb_minus4 + 4));
 flag(used_by_curr_pic_lt_flag[i]);
 if (current->used_by_curr_pic_lt_flag[i])
 ++num_pic_total_curr;
@@ -1487,7 +1487,7 @@ static int 
FUNC(slice_segment_header)(CodedBitstreamContext *ctx, RWContext *rw,
 ue(offset_len_minus1, 0, 31);
 for (i = 0; i < current->num_entry_point_offsets; i++)
 u(current->offset_len_minus1 + 1, entry_point_offset_minus1[i],
-  0, (1 << (current->offset_len_minus1 + 1)) - 1);
+  0, MAX_UINT_BITS(current->offset_len_minus1 + 1));
 }
 }
 
-- 
2.16.1

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


Re: [FFmpeg-devel] [PATCH] lavc: Add filter_units bitstream filter

2018-03-11 Thread Mark Thompson
On 08/03/18 04:01, James Almer wrote:
> On 3/6/2018 3:49 PM, Mark Thompson wrote:
>> This can remove units with types in or not in a given set from a stream.
>> For example, it can be used to remove all non-VCL NAL units from an H.264 or
>> H.265 stream.
>> ---
>> On 06/03/18 17:27, Hendrik Leppkes wrote:
>>> On Tue, Mar 6, 2018 at 3:51 PM, Eran Kornblau  
>>> wrote:
 Hi all,

 The attached patch adds a parameter that enables the user to choose which 
 AVC/HEVC NAL units to include in the output.
 The parameter is supplied as a bitmask in order to keep things simple.

 A short background on why we need it - in our transcoding process, we 
 partition the video in chunks, the chunks are
 transcoded in parallel and packaged in MPEG-TS container. The transcoded 
 TS chunks are then concatenated and
 packaged in MP4. These MP4 files are later repackaged on-the-fly to 
 various protocols (HLS/DASH etc.) using our
 JIT packager.
 For performance reasons (can get into more detail if anyone's 
 interested...), when packaging the MP4 to DASH/CENC,
 we configure the packager to assume that each AVC frame contains exactly 
 one NAL unit.
 The problem is that the transition through MPEG-TS adds additional NAL 
 units (NAL AUD before each frame + SPS/PPS
 before each key frame), and this assumption fails.
 Using the attached patch we can pass '-nal_types_mask 0x3e' which will 
 make ffmpeg output only VCL NALs in the stream.

>>>
>>> Having such logic in one single muxer is not something we really like
>>> around here. Next time someone needs something similar for another
>>> codec, you're stuck re-implementing it.
>>>
>>> To achieve the same effect, Mark Thompson quickly wipped up a
>>> Bitstream Filter using his CBS framework which achieves the same
>>> result. He'll be sending that patch to the mailing list in a while.
>> The suggested use-case would be '-bsf:v filter_units=pass_types=1-5' for 
>> H.264 or '-bsf:v filter_units=pass_types=0-31' for H.265.
>>
>> (Also note that filters already exist for some individual parts of this: 
>> h264_metadata can remove AUDs, extract_extradata can remove parameter sets.)
>>
>> - Mark
>>
>>
>>  libavcodec/Makefile|   1 +
>>  libavcodec/bitstream_filters.c |   1 +
>>  libavcodec/filter_units_bsf.c  | 250 
>> +
>>  3 files changed, 252 insertions(+)
>>  create mode 100644 libavcodec/filter_units_bsf.c
>>
> 
> Can you write some minimal documentation with the two above examples?

Done.

>> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
>> index b496f0d..b99bdce 100644
>> --- a/libavcodec/Makefile
>> +++ b/libavcodec/Makefile
>> @@ -1037,6 +1037,7 @@ OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += 
>> dump_extradata_bsf.o
>>  OBJS-$(CONFIG_DCA_CORE_BSF)   += dca_core_bsf.o
>>  OBJS-$(CONFIG_EXTRACT_EXTRADATA_BSF)  += extract_extradata_bsf.o\
>>   h2645_parse.o
>> +OBJS-$(CONFIG_FILTER_UNITS_BSF)   += filter_units_bsf.o
>>  OBJS-$(CONFIG_H264_METADATA_BSF)  += h264_metadata_bsf.o
>>  OBJS-$(CONFIG_H264_MP4TOANNEXB_BSF)   += h264_mp4toannexb_bsf.o
>>  OBJS-$(CONFIG_H264_REDUNDANT_PPS_BSF) += h264_redundant_pps_bsf.o
>> diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
>> index 338ef82..e1dc198 100644
>> --- a/libavcodec/bitstream_filters.c
>> +++ b/libavcodec/bitstream_filters.c
>> @@ -29,6 +29,7 @@ extern const AVBitStreamFilter ff_chomp_bsf;
>>  extern const AVBitStreamFilter ff_dump_extradata_bsf;
>>  extern const AVBitStreamFilter ff_dca_core_bsf;
>>  extern const AVBitStreamFilter ff_extract_extradata_bsf;
>> +extern const AVBitStreamFilter ff_filter_units_bsf;
>>  extern const AVBitStreamFilter ff_h264_metadata_bsf;
>>  extern const AVBitStreamFilter ff_h264_mp4toannexb_bsf;
>>  extern const AVBitStreamFilter ff_h264_redundant_pps_bsf;
>> diff --git a/libavcodec/filter_units_bsf.c b/libavcodec/filter_units_bsf.c
>> new file mode 100644
>> index 000..3126f17
>> --- /dev/null
>> +++ b/libavcodec/filter_units_bsf.c
>> @@ -0,0 +1,250 @@
>> +/*
>> + * 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 

[FFmpeg-devel] [PATCH 4/8] h264_metadata: Add support for A/53 closed captions

2018-03-11 Thread Mark Thompson
---
 libavcodec/h264_metadata_bsf.c | 121 +
 1 file changed, 121 insertions(+)

diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
index 36047887ca..d340c55990 100644
--- a/libavcodec/h264_metadata_bsf.c
+++ b/libavcodec/h264_metadata_bsf.c
@@ -77,6 +77,8 @@ typedef struct H264MetadataContext {
 int display_orientation;
 double rotate;
 int flip;
+
+int a53_cc;
 } H264MetadataContext;
 
 
@@ -225,6 +227,8 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket 
*out)
 int err, i, j, has_sps;
 uint8_t *displaymatrix_side_data = NULL;
 size_t displaymatrix_side_data_size = 0;
+uint8_t *a53_side_data = NULL;
+size_t a53_side_data_size = 0;
 
 err = ff_bsf_get_packet(bsf, );
 if (err < 0)
@@ -514,6 +518,104 @@ static int h264_metadata_filter(AVBSFContext *bsf, 
AVPacket *out)
 }
 }
 
+if (ctx->a53_cc == INSERT) {
+uint8_t *data;
+int size;
+
+data = av_packet_get_side_data(in, AV_PKT_DATA_A53_CC, );
+if (data) {
+H264RawSEIPayload payload = {
+.payload_type = H264_SEI_TYPE_USER_DATA_REGISTERED,
+};
+H264RawSEIUserDataRegistered *udr =
+_data_registered;
+
+av_log(bsf, AV_LOG_WARNING, "A53 CC insert: %d bytes.\n", size);
+
+udr->data_length = size + 10;
+udr->data_ref= av_buffer_alloc(udr->data_length);
+if (!udr->data_ref) {
+err = AVERROR(ENOMEM);
+goto fail;
+}
+udr->data = udr->data_ref->data;
+
+udr->itu_t_t35_country_code = 181;
+udr->data[0] = 0;
+udr->data[1] = 49;
+AV_WB32(udr->data + 2, MKBETAG('G', 'A', '9', '4'));
+udr->data[6] = 3;
+udr->data[7] = ((size / 3) & 0x1f) | 0x40;
+udr->data[8] = 0;
+memcpy(udr->data + 9, data, size);
+udr->data[size + 9] = 0xff;
+
+err = ff_cbs_h264_add_sei_message(ctx->cbc, au, );
+if (err < 0) {
+av_log(bsf, AV_LOG_ERROR, "Failed to add user data SEI "
+   "message to access unit.\n");
+av_buffer_unref(>data_ref);
+goto fail;
+}
+}
+
+} else if (ctx->a53_cc == REMOVE || ctx->a53_cc == EXTRACT) {
+for (i = 0; i < au->nb_units; i++) {
+H264RawSEI *sei;
+if (au->units[i].type != H264_NAL_SEI)
+continue;
+sei = au->units[i].content;
+
+for (j = 0; j < sei->payload_count; j++) {
+H264RawSEIUserDataRegistered *udr;
+uint32_t tag;
+uint8_t type_code, count;
+
+if (sei->payload[j].payload_type !=
+H264_SEI_TYPE_USER_DATA_REGISTERED)
+continue;
+udr = >payload[j].payload.user_data_registered;
+tag = AV_RB32(udr->data + 2);
+type_code = udr->data[6];
+if (tag != MKBETAG('G', 'A', '9', '4') || type_code != 3)
+continue;
+
+if (ctx->a53_cc == REMOVE) {
+err = ff_cbs_h264_delete_sei_message(ctx->cbc, au,
+ >units[i], j);
+if (err < 0) {
+av_log(bsf, AV_LOG_ERROR, "Failed to delete "
+   "A53 CC SEI message.\n");
+goto fail;
+}
+av_log(bsf, AV_LOG_WARNING, "A53 CC remove!.\n");
+
+--i;
+break;
+}
+
+// Extract.
+count = udr->data[7] & 0x1f;
+if (3 * count + 10 > udr->data_length) {
+av_log(bsf, AV_LOG_ERROR, "Invalid A/53 closed caption "
+   "data: count %d overflows length %zu.\n",
+   count, udr->data_length);
+continue;
+}
+
+av_log(bsf, AV_LOG_WARNING, "A53 CC extract: %zu bytes.\n", 
udr->data_length);
+
+err = av_reallocp(_side_data,
+  a53_side_data_size + 3 * count);
+if (err)
+goto fail;
+memcpy(a53_side_data + a53_side_data_size,
+   udr->data + 9, 3 * count);
+a53_side_data_size += 3 * count;
+}
+}
+}
+
 err = ff_cbs_write_packet(ctx->cbc, out, au);
 if (err < 0) {
 av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
@@ -535,6 +637,16 @@ static int h264_metadata_filter(AVBSFContext *bsf, 
AVPacket *out)
 }
 displaymatrix_side_data = NULL;
 }
+if (a53_side_data) {
+err = av_packet_add_side_data(out, 

[FFmpeg-devel] [PATCH 3/8] h264_metadata: Add support for display orientation SEI messages

2018-03-11 Thread Mark Thompson
---
 libavcodec/h264_metadata_bsf.c | 169 -
 1 file changed, 165 insertions(+), 4 deletions(-)

diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
index 466823cda6..36047887ca 100644
--- a/libavcodec/h264_metadata_bsf.c
+++ b/libavcodec/h264_metadata_bsf.c
@@ -17,6 +17,7 @@
  */
 
 #include "libavutil/avstring.h"
+#include "libavutil/display.h"
 #include "libavutil/common.h"
 #include "libavutil/opt.h"
 
@@ -30,6 +31,12 @@ enum {
 PASS,
 INSERT,
 REMOVE,
+EXTRACT,
+};
+
+enum {
+FLIP_HORIZONTAL = 1,
+FLIP_VERTICAL   = 2,
 };
 
 typedef struct H264MetadataContext {
@@ -38,6 +45,8 @@ typedef struct H264MetadataContext {
 CodedBitstreamContext *cbc;
 CodedBitstreamFragment access_unit;
 
+int done_first_au;
+
 H264RawAUD aud_nal;
 H264RawSEI sei_nal;
 
@@ -62,9 +71,12 @@ typedef struct H264MetadataContext {
 int crop_bottom;
 
 const char *sei_user_data;
-int sei_first_au;
 
 int delete_filler;
+
+int display_orientation;
+double rotate;
+int flip;
 } H264MetadataContext;
 
 
@@ -211,6 +223,8 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket 
*out)
 AVPacket *in = NULL;
 CodedBitstreamFragment *au = >access_unit;
 int err, i, j, has_sps;
+uint8_t *displaymatrix_side_data = NULL;
+size_t displaymatrix_side_data_size = 0;
 
 err = ff_bsf_get_packet(bsf, );
 if (err < 0)
@@ -292,15 +306,13 @@ static int h264_metadata_filter(AVBSFContext *bsf, 
AVPacket *out)
 
 // Only insert the SEI in access units containing SPSs, and also
 // unconditionally in the first access unit we ever see.
-if (ctx->sei_user_data && (has_sps || !ctx->sei_first_au)) {
+if (ctx->sei_user_data && (has_sps || !ctx->done_first_au)) {
 H264RawSEIPayload payload = {
 .payload_type = H264_SEI_TYPE_USER_DATA_UNREGISTERED,
 };
 H264RawSEIUserDataUnregistered *udu =
 _data_unregistered;
 
-ctx->sei_first_au = 1;
-
 for (i = j = 0; j < 32 && ctx->sei_user_data[i]; i++) {
 int c, v;
 c = ctx->sei_user_data[i];
@@ -387,6 +399,121 @@ static int h264_metadata_filter(AVBSFContext *bsf, 
AVPacket *out)
 }
 }
 
+if (ctx->display_orientation != PASS) {
+for (i = 0; i < au->nb_units; i++) {
+H264RawSEI *sei;
+if (au->units[i].type != H264_NAL_SEI)
+continue;
+sei = au->units[i].content;
+
+for (j = 0; j < sei->payload_count; j++) {
+H264RawSEIDisplayOrientation *disp;
+int32_t *matrix;
+
+if (sei->payload[j].payload_type !=
+H264_SEI_TYPE_DISPLAY_ORIENTATION)
+continue;
+disp = >payload[j].payload.display_orientation;
+
+if (ctx->display_orientation == REMOVE ||
+ctx->display_orientation == INSERT) {
+err = ff_cbs_h264_delete_sei_message(ctx->cbc, au,
+ >units[i], j);
+if (err < 0) {
+av_log(bsf, AV_LOG_ERROR, "Failed to delete "
+   "display orientation SEI message.\n");
+goto fail;
+}
+--i;
+break;
+}
+
+matrix = av_mallocz(9 * sizeof(int32_t));
+if (!matrix) {
+err = AVERROR(ENOMEM);
+goto fail;
+}
+
+av_display_rotation_set(matrix,
+disp->anticlockwise_rotation *
+180.0 / 65536.0);
+av_display_matrix_flip(matrix, disp->hor_flip, disp->ver_flip);
+
+displaymatrix_side_data  = (uint8_t*)matrix;
+displaymatrix_side_data_size = 9 * sizeof(int32_t);
+}
+}
+}
+if (ctx->display_orientation == INSERT) {
+H264RawSEIPayload payload = {
+.payload_type = H264_SEI_TYPE_DISPLAY_ORIENTATION,
+};
+H264RawSEIDisplayOrientation *disp =
+_orientation;
+uint8_t *data;
+int size;
+int write = 0;
+
+data = av_packet_get_side_data(in, AV_PKT_DATA_DISPLAYMATRIX, );
+if (data && size >= 9 * sizeof(int32_t)) {
+int32_t matrix[9];
+int hflip, vflip;
+double angle;
+
+memcpy(matrix, data, sizeof(matrix));
+
+hflip = vflip = 0;
+if (matrix[0] < 0 && matrix[4] > 0)
+hflip = 1;
+else if (matrix[0] > 0 && matrix[4] < 0)
+vflip = 1;
+av_display_matrix_flip(matrix, hflip, vflip);
+
+angle = av_display_rotation_get(matrix);
+
+if (!(angle >= -180.0 

[FFmpeg-devel] [PATCH 5/8] h264_metadata: Update documentation

2018-03-11 Thread Mark Thompson
Improve documentation for the delete_filler option, and add the
display_orientation and a53_cc options.
---
 doc/bitstream_filters.texi | 50 +-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index b7ea549322..c196a30095 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -155,7 +155,55 @@ For example, 
@samp{086f3693-b7b3-4f2c-9653-21492feee5b8+hello} will
 insert the string ``hello'' associated with the given UUID.
 
 @item delete_filler
-Deletes both filler NAL units and filler SEI messages.
+Delete all filler in the stream: both filler data NAL units and
+filler payload SEI messages.
+
+Note that HRD parameters may be invalid after this transformation -
+in particular, the CPB may overflow if cbr_flag is set and the removed
+filler data was required to maintain the CPB level.
+
+@item display_orientation
+Modify display orientation SEI messages.
+
+@table @samp
+@item insert
+Insert new display orientation messages, overwriting any currently in
+the stream.  The new value is taken from the packet side data, modified
+by the @option{rotate} and @option{flip} options.
+
+@item remove
+Remove all display orientation messages from the stream.
+
+@item extract
+Extract display orientation messages so that they are available as
+packet side data.
+@end table
+
+@item rotate
+Set the rotation angle in the display orientation data.  This is an
+anticlockwise rotation angle in degrees.
+@item flip
+Set the flip fields in the display orientation data.  This can be any
+combination of the flags:
+@table @samp
+@item horizontal
+@item vertical
+@end table
+
+@item a53_cc
+Modify A/53 closed caption data in SEI messages.
+
+@table @samp
+@item insert
+Insert closed captions taken from packet side data into the stream.
+
+@item remove
+Remove all closed caption data from the stream.
+
+@item extract
+Extract closed captions from the stream so that they are available as
+as packet side data.
+@end table
 
 @end table
 
-- 
2.16.1

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


[FFmpeg-devel] [PATCH 1/8] cbs_h264: Fix overflow in shifts

2018-03-11 Thread Mark Thompson
The type of the result of a shift operation is unaffected by the type of
the right operand, so some existing code overflows with undefined behaviour
when the element length is 32.  Add a helper macro to calculate the maximum
value correctly and then use it everywhere this pattern appears.

Found-by: Andreas Rheinhardt 
---
 libavcodec/cbs_h264_syntax_template.c | 22 +++---
 libavcodec/cbs_internal.h |  4 
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/libavcodec/cbs_h264_syntax_template.c 
b/libavcodec/cbs_h264_syntax_template.c
index f58dee8a25..b5cd0b2310 100644
--- a/libavcodec/cbs_h264_syntax_template.c
+++ b/libavcodec/cbs_h264_syntax_template.c
@@ -342,8 +342,8 @@ static int FUNC(sps_extension)(CodedBitstreamContext *ctx, 
RWContext *rw,
 flag(alpha_incr_flag);
 
 bits = current->bit_depth_aux_minus8 + 9;
-u(bits, alpha_opaque_value,  0, (1 << bits) - 1);
-u(bits, alpha_transparent_value, 0, (1 << bits) - 1);
+u(bits, alpha_opaque_value,  0, MAX_UINT_BITS(bits));
+u(bits, alpha_transparent_value, 0, MAX_UINT_BITS(bits));
 }
 
 flag(additional_extension_flag);
@@ -483,10 +483,10 @@ static int 
FUNC(sei_buffering_period)(CodedBitstreamContext *ctx, RWContext *rw,
 length = 
sps->vui.nal_hrd_parameters.initial_cpb_removal_delay_length_minus1 + 1;
 xu(length, initial_cpb_removal_delay[SchedSelIdx],
current->nal.initial_cpb_removal_delay[i],
-   0, (1 << (uint64_t)length) - 1);
+   1, MAX_UINT_BITS(length));
 xu(length, initial_cpb_removal_delay_offset[SchedSelIdx],
current->nal.initial_cpb_removal_delay_offset[i],
-   0, (1 << (uint64_t)length) - 1);
+   0, MAX_UINT_BITS(length));
 }
 }
 
@@ -495,10 +495,10 @@ static int 
FUNC(sei_buffering_period)(CodedBitstreamContext *ctx, RWContext *rw,
 length = 
sps->vui.vcl_hrd_parameters.initial_cpb_removal_delay_length_minus1 + 1;
 xu(length, initial_cpb_removal_delay[SchedSelIdx],
current->vcl.initial_cpb_removal_delay[i],
-   0, (1 << (uint64_t)length) - 1);
+   1, MAX_UINT_BITS(length));
 xu(length, initial_cpb_removal_delay_offset[SchedSelIdx],
current->vcl.initial_cpb_removal_delay_offset[i],
-   0, (1 << (uint64_t)length) - 1);
+   0, MAX_UINT_BITS(length));
 }
 }
 
@@ -548,7 +548,7 @@ static int FUNC(sei_pic_timestamp)(CodedBitstreamContext 
*ctx, RWContext *rw,
 
 if (time_offset_length > 0)
 u(time_offset_length, time_offset,
-  0, (1 << (uint64_t)time_offset_length) - 1);
+  0, MAX_UINT_BITS(time_offset_length));
 else
 infer(time_offset, 0);
 
@@ -600,9 +600,9 @@ static int FUNC(sei_pic_timing)(CodedBitstreamContext *ctx, 
RWContext *rw,
 }
 
 u(hrd->cpb_removal_delay_length_minus1 + 1, cpb_removal_delay,
-  0, (1 << (uint64_t)hrd->cpb_removal_delay_length_minus1) + 1);
+  0, MAX_UINT_BITS(hrd->cpb_removal_delay_length_minus1 + 1));
 u(hrd->dpb_output_delay_length_minus1 + 1, dpb_output_delay,
-  0, (1 << (uint64_t)hrd->dpb_output_delay_length_minus1) + 1);
+  0, MAX_UINT_BITS(hrd->dpb_output_delay_length_minus1 + 1));
 }
 
 if (sps->vui.pic_struct_present_flag) {
@@ -1123,7 +1123,7 @@ static int FUNC(slice_header)(CodedBitstreamContext *ctx, 
RWContext *rw,
 u(2, colour_plane_id, 0, 2);
 
 u(sps->log2_max_frame_num_minus4 + 4, frame_num,
-  0, (1 << (sps->log2_max_frame_num_minus4 + 4)) - 1);
+  0, MAX_UINT_BITS(sps->log2_max_frame_num_minus4 + 4));
 
 if (!sps->frame_mbs_only_flag) {
 flag(field_pic_flag);
@@ -1141,7 +1141,7 @@ static int FUNC(slice_header)(CodedBitstreamContext *ctx, 
RWContext *rw,
 
 if (sps->pic_order_cnt_type == 0) {
 u(sps->log2_max_pic_order_cnt_lsb_minus4 + 4, pic_order_cnt_lsb,
-  0, (1 << (sps->log2_max_pic_order_cnt_lsb_minus4 + 4)) - 1);
+  0, MAX_UINT_BITS(sps->log2_max_pic_order_cnt_lsb_minus4 + 4));
 if (pps->bottom_field_pic_order_in_frame_present_flag &&
 !current->field_pic_flag)
 se(delta_pic_order_cnt_bottom, INT32_MIN + 1, INT32_MAX);
diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
index 5674803472..be540e2a44 100644
--- a/libavcodec/cbs_internal.h
+++ b/libavcodec/cbs_internal.h
@@ -79,6 +79,10 @@ int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, 
PutBitContext *pbc,
   int width, const char *name, uint32_t value,
   uint32_t range_min, uint32_t range_max);
 
+// The largest value representable in N bits, suitable for use as
+// range_max in the above functions.
+#define MAX_UINT_BITS(length) ((UINT64_C(1) << (length)) - 1)
+
 
 extern const 

Re: [FFmpeg-devel] avcodec/hapqa_extract_bsf : add bsf filter for haqqa (to hapq or hapalpha only) conversion

2018-03-11 Thread James Almer
On 3/11/2018 3:20 PM, Martin Vignali wrote:
> 2018-03-11 18:45 GMT+01:00 James Almer :
> 
>> On 3/11/2018 2:08 PM, Martin Vignali wrote:
>>> Work for me, changed.
>>>
>>> New patchs in attach, with these changes.
>>
>> Please combine the last three patches (bsf, docs and changelog entry)
>> into a single one.
>>
> 
> Changed
> 
>>
>>> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
>>> index ff6c9f8b2c..80e54f9e6d 100644
>>> --- a/libavcodec/Makefile
>>> +++ b/libavcodec/Makefile
>>> @@ -1040,6 +1040,7 @@ OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) +=
>> dump_extradata_bsf.o
>>>  OBJS-$(CONFIG_DCA_CORE_BSF)   += dca_core_bsf.o
>>>  OBJS-$(CONFIG_EXTRACT_EXTRADATA_BSF)  += extract_extradata_bsf.o
>>   \
>>>   h2645_parse.o
>>> +OBJS-$(CONFIG_HAPQA_EXTRACT_BSF)  += hapqa_extract_bsf.o
>>
>> Missing hap.o
>>
> 
> Changed
> 
>>
>> Also, HAPQA goes after H264.
>>
> 
> Changed (also in bitstream_filters.c)
> 
> 
>>
>>>  OBJS-$(CONFIG_H264_METADATA_BSF)  += h264_metadata_bsf.o
>>>  OBJS-$(CONFIG_H264_MP4TOANNEXB_BSF)   += h264_mp4toannexb_bsf.o
>>>  OBJS-$(CONFIG_H264_REDUNDANT_PPS_BSF) += h264_redundant_pps_bsf.o
>>
>>> +
>>> +av_packet_move_ref(out, in);
>>> +out->data += start_section_size;
>>> +out->size = target_packet_size;
>>> +
>>> +ret = av_packet_copy_props(out, in);
>>
>> No need to call av_packet_copy_props(). You moved the reference from
>> "in" to "out" right before this, which includes all properties, so "in"
>> is now an empty packet and av_packet_copy_props() will just reset all
>> properties from "out".
>>
> 
> Thanks for the explanations
> Removed.
> 
> 
>>
>> You should add a new fate test using one of the existing samples to make
>> sure the output of this bsf is the expected one.
>>
>>
> I plan to add fate test later.
> I would like to apply the previous fate hap patch before.
> 
> New patchs in attach
> 
> Martin

Should be ok now.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 4/6] avcodec/trace_headers: move the reference in the bsf internal buffer

2018-03-11 Thread Mark Thompson
On 11/03/18 17:58, James Almer wrote:
> There's no need to allocate a new packet for it.
> 
> Signed-off-by: James Almer 
> ---
>  libavcodec/trace_headers_bsf.c | 30 ++
>  1 file changed, 14 insertions(+), 16 deletions(-)
> 
> diff --git a/libavcodec/trace_headers_bsf.c b/libavcodec/trace_headers_bsf.c
> index 93d04cb509..d59bc828a9 100644
> --- a/libavcodec/trace_headers_bsf.c
> +++ b/libavcodec/trace_headers_bsf.c
> @@ -71,41 +71,39 @@ static int trace_headers(AVBSFContext *bsf, AVPacket *out)
>  {
>  TraceHeadersContext *ctx = bsf->priv_data;
>  CodedBitstreamFragment au;
> -AVPacket *in;
>  char tmp[256] = { 0 };
>  int err;
>  
> -err = ff_bsf_get_packet(bsf, );
> +err = ff_bsf_get_packet_ref(bsf, out);
>  if (err < 0)
>  return err;
>  
> -if (in->flags & AV_PKT_FLAG_KEY)
> +if (out->flags & AV_PKT_FLAG_KEY)
>  av_strlcat(tmp, ", key frame", sizeof(tmp));
> -if (in->flags & AV_PKT_FLAG_CORRUPT)
> +if (out->flags & AV_PKT_FLAG_CORRUPT)
>  av_strlcat(tmp, ", corrupt", sizeof(tmp));
>  
> -if (in->pts != AV_NOPTS_VALUE)
> -av_strlcatf(tmp, sizeof(tmp), ", pts %"PRId64, in->pts);
> +if (out->pts != AV_NOPTS_VALUE)
> +av_strlcatf(tmp, sizeof(tmp), ", pts %"PRId64, out->pts);
>  else
>  av_strlcat(tmp, ", no pts", sizeof(tmp));
> -if (in->dts != AV_NOPTS_VALUE)
> -av_strlcatf(tmp, sizeof(tmp), ", dts %"PRId64, in->dts);
> +if (out->dts != AV_NOPTS_VALUE)
> +av_strlcatf(tmp, sizeof(tmp), ", dts %"PRId64, out->dts);
>  else
>  av_strlcat(tmp, ", no dts", sizeof(tmp));
> -if (in->duration > 0)
> -av_strlcatf(tmp, sizeof(tmp), ", duration %"PRId64, in->duration);
> +if (out->duration > 0)
> +av_strlcatf(tmp, sizeof(tmp), ", duration %"PRId64, out->duration);
>  
> -av_log(bsf, AV_LOG_INFO, "Packet: %d bytes%s.\n", in->size, tmp);
> +av_log(bsf, AV_LOG_INFO, "Packet: %d bytes%s.\n", out->size, tmp);
>  
> -err = ff_cbs_read_packet(ctx->cbc, , in);
> -if (err < 0)
> +err = ff_cbs_read_packet(ctx->cbc, , out);
> +if (err < 0) {
> +av_packet_unref(out);
>  return err;
> +}
>  
>  ff_cbs_fragment_uninit(ctx->cbc, );
>  
> -av_packet_move_ref(out, in);
> -av_packet_free();
> -
>  return 0;
>  }
>  
> 

Rename the packet to something like "pkt" throughout?  The "out" name looks 
kindof weird after this change.

(That could probably apply to all of the patches, but this one makes the most 
use of the packet.)

Whole series looks fine to me.

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


[FFmpeg-devel] [PATCH 8/8] lavc: Add filter_units bitstream filter

2018-03-11 Thread Mark Thompson
This can remove units with types in or not in a given set from a stream.
For example, it can be used to remove all non-VCL NAL units from an H.264 or
H.265 stream.
---
 doc/bitstream_filters.texi |  29 +
 libavcodec/Makefile|   1 +
 libavcodec/bitstream_filters.c |   1 +
 libavcodec/filter_units_bsf.c  | 253 +
 4 files changed, 284 insertions(+)
 create mode 100644 libavcodec/filter_units_bsf.c

diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index c196a30095..b6b4064c0c 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -93,6 +93,35 @@ When this option is enabled, the long-term headers are 
removed from the
 bitstream after extraction.
 @end table
 
+@section filter_units
+
+Remove units with types in or not in a given set from the stream.
+
+@table @option
+@item pass_types
+List of unit types or ranges of unit types to pass through while removing
+all others.  This is specified as a '|'-separated list of unit type values
+or ranges of values with '-'.
+
+@item remove_types
+Identical to @option{pass_types}, except the units in the given set
+removed and all others passed through.
+@end table
+
+Extradata is unchanged by this transformation, but note that if the stream
+contains inline parameter sets then the output may be unusable if they are
+removed.
+
+For example, to remove all non-VCL NAL units from an H.264 stream:
+@example
+ffmpeg -i INPUT -c:v copy -bsf:v 'filter_units=pass_types=1-5' OUTPUT
+@end example
+
+To remove all AUDs, SEI and filler from an H.265 stream:
+@example
+ffmpeg -i INPUT -c:v copy -bsf:v 'filter_units=remove_types=35|38-40' OUTPUT
+@end example
+
 @section h264_metadata
 
 Modify metadata embedded in an H.264 stream.
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index ff6c9f8b2c..22095544a4 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1040,6 +1040,7 @@ OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += 
dump_extradata_bsf.o
 OBJS-$(CONFIG_DCA_CORE_BSF)   += dca_core_bsf.o
 OBJS-$(CONFIG_EXTRACT_EXTRADATA_BSF)  += extract_extradata_bsf.o\
  h2645_parse.o
+OBJS-$(CONFIG_FILTER_UNITS_BSF)   += filter_units_bsf.o
 OBJS-$(CONFIG_H264_METADATA_BSF)  += h264_metadata_bsf.o
 OBJS-$(CONFIG_H264_MP4TOANNEXB_BSF)   += h264_mp4toannexb_bsf.o
 OBJS-$(CONFIG_H264_REDUNDANT_PPS_BSF) += h264_redundant_pps_bsf.o
diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index 338ef8251b..e1dc19871f 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -29,6 +29,7 @@ extern const AVBitStreamFilter ff_chomp_bsf;
 extern const AVBitStreamFilter ff_dump_extradata_bsf;
 extern const AVBitStreamFilter ff_dca_core_bsf;
 extern const AVBitStreamFilter ff_extract_extradata_bsf;
+extern const AVBitStreamFilter ff_filter_units_bsf;
 extern const AVBitStreamFilter ff_h264_metadata_bsf;
 extern const AVBitStreamFilter ff_h264_mp4toannexb_bsf;
 extern const AVBitStreamFilter ff_h264_redundant_pps_bsf;
diff --git a/libavcodec/filter_units_bsf.c b/libavcodec/filter_units_bsf.c
new file mode 100644
index 00..36b22ffc04
--- /dev/null
+++ b/libavcodec/filter_units_bsf.c
@@ -0,0 +1,253 @@
+/*
+ * 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 "libavutil/common.h"
+#include "libavutil/opt.h"
+
+#include "bsf.h"
+#include "cbs.h"
+
+
+typedef struct FilterUnitsContext {
+const AVClass *class;
+
+CodedBitstreamContext *cbc;
+CodedBitstreamFragment fragment;
+
+const char *pass_types;
+const char *remove_types;
+
+enum {
+NOOP,
+PASS,
+REMOVE,
+} mode;
+CodedBitstreamUnitType *type_list;
+int nb_types;
+} FilterUnitsContext;
+
+
+static int filter_units_make_type_list(const char *list_string,
+   CodedBitstreamUnitType **type_list,
+   int *nb_types)
+{
+CodedBitstreamUnitType *list = NULL;
+int pass, count;
+
+for (pass = 1; pass <= 2; pass++) {
+long value, range_start, range_end;
+const char *str;
+char *value_end;
+
+count = 0;
+

[FFmpeg-devel] [PATCH 6/8] h264_metadata: Remove unused fields

2018-03-11 Thread Mark Thompson
The SEI NAL is unused since 69062d0f9b6aef5d9d9b8c9c9b5cfb23037caddb,
while the AUD NAL is small and would more sensibly be on the stack.
---
 libavcodec/h264_metadata_bsf.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
index d340c55990..760fe99c41 100644
--- a/libavcodec/h264_metadata_bsf.c
+++ b/libavcodec/h264_metadata_bsf.c
@@ -47,9 +47,6 @@ typedef struct H264MetadataContext {
 
 int done_first_au;
 
-H264RawAUD aud_nal;
-H264RawSEI sei_nal;
-
 int aud;
 
 AVRational sample_aspect_ratio;
@@ -263,7 +260,9 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket 
*out)
 0x3ff, // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
 };
 int primary_pic_type_mask = 0xff;
-H264RawAUD *aud = >aud_nal;
+H264RawAUD aud = {
+.nal_unit_header.nal_unit_type = H264_NAL_AUD,
+};
 
 for (i = 0; i < au->nb_units; i++) {
 if (au->units[i].type == H264_NAL_SLICE ||
@@ -286,11 +285,10 @@ static int h264_metadata_filter(AVBSFContext *bsf, 
AVPacket *out)
 goto fail;
 }
 
-aud->nal_unit_header.nal_unit_type = H264_NAL_AUD;
-aud->primary_pic_type = j;
+aud.primary_pic_type = j;
 
 err = ff_cbs_insert_unit_content(ctx->cbc, au,
- 0, H264_NAL_AUD, aud, NULL);
+ 0, H264_NAL_AUD, , NULL);
 if (err < 0) {
 av_log(bsf, AV_LOG_ERROR, "Failed to insert AUD.\n");
 goto fail;
-- 
2.16.1

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


[FFmpeg-devel] [PATCH 7/8] cbs: Add a table of all supported codec IDs

2018-03-11 Thread Mark Thompson
Use it as the set of codec IDs supported by the trace_headers BSF.
---
 configure  |  1 -
 libavcodec/cbs.c   | 13 +
 libavcodec/cbs.h   |  8 
 libavcodec/trace_headers_bsf.c |  9 +
 4 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/configure b/configure
index 5e38bdab17..95354611ff 100755
--- a/configure
+++ b/configure
@@ -2905,7 +2905,6 @@ h264_redundant_pps_bsf_select="cbs_h264"
 hevc_metadata_bsf_select="cbs_h265"
 mjpeg2jpeg_bsf_select="jpegtables"
 mpeg2_metadata_bsf_select="cbs_mpeg2"
-trace_headers_bsf_select="cbs_h264 cbs_h265 cbs_mpeg2"
 
 # external libraries
 aac_at_decoder_deps="audiotoolbox"
diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 62f60be437..897e0bb28e 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -40,6 +40,19 @@ static const CodedBitstreamType *cbs_type_table[] = {
 #endif
 };
 
+const enum AVCodecID ff_cbs_all_codec_ids[] = {
+#if CONFIG_CBS_H264
+AV_CODEC_ID_H264,
+#endif
+#if CONFIG_CBS_H265
+AV_CODEC_ID_H265,
+#endif
+#if CONFIG_CBS_MPEG2
+AV_CODEC_ID_MPEG2VIDEO,
+#endif
+AV_CODEC_ID_NONE
+};
+
 int ff_cbs_init(CodedBitstreamContext **ctx_ptr,
 enum AVCodecID codec_id, void *log_ctx)
 {
diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
index 396ff0faec..402eb39e00 100644
--- a/libavcodec/cbs.h
+++ b/libavcodec/cbs.h
@@ -201,6 +201,14 @@ typedef struct CodedBitstreamContext {
 } CodedBitstreamContext;
 
 
+/**
+ * Table of all supported codec IDs.
+ *
+ * Terminated by AV_CODEC_ID_NONE.
+ */
+extern const enum AVCodecID ff_cbs_all_codec_ids[];
+
+
 /**
  * Create and initialise a new context for the given codec.
  */
diff --git a/libavcodec/trace_headers_bsf.c b/libavcodec/trace_headers_bsf.c
index 93d04cb509..f742e36d77 100644
--- a/libavcodec/trace_headers_bsf.c
+++ b/libavcodec/trace_headers_bsf.c
@@ -109,18 +109,11 @@ static int trace_headers(AVBSFContext *bsf, AVPacket *out)
 return 0;
 }
 
-static const enum AVCodecID trace_headers_codec_ids[] = {
-AV_CODEC_ID_H264,
-AV_CODEC_ID_HEVC,
-AV_CODEC_ID_MPEG2VIDEO,
-AV_CODEC_ID_NONE,
-};
-
 const AVBitStreamFilter ff_trace_headers_bsf = {
 .name   = "trace_headers",
 .priv_data_size = sizeof(TraceHeadersContext),
 .init   = _headers_init,
 .close  = _headers_close,
 .filter = _headers,
-.codec_ids  = trace_headers_codec_ids,
+.codec_ids  = ff_cbs_all_codec_ids,
 };
-- 
2.16.1

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


Re: [FFmpeg-devel] avcodec/hapqa_extract_bsf : add bsf filter for haqqa (to hapq or hapalpha only) conversion

2018-03-11 Thread Martin Vignali
2018-03-11 18:45 GMT+01:00 James Almer :

> On 3/11/2018 2:08 PM, Martin Vignali wrote:
> > Work for me, changed.
> >
> > New patchs in attach, with these changes.
>
> Please combine the last three patches (bsf, docs and changelog entry)
> into a single one.
>

Changed

>
> > diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> > index ff6c9f8b2c..80e54f9e6d 100644
> > --- a/libavcodec/Makefile
> > +++ b/libavcodec/Makefile
> > @@ -1040,6 +1040,7 @@ OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) +=
> dump_extradata_bsf.o
> >  OBJS-$(CONFIG_DCA_CORE_BSF)   += dca_core_bsf.o
> >  OBJS-$(CONFIG_EXTRACT_EXTRADATA_BSF)  += extract_extradata_bsf.o
>   \
> >   h2645_parse.o
> > +OBJS-$(CONFIG_HAPQA_EXTRACT_BSF)  += hapqa_extract_bsf.o
>
> Missing hap.o
>

Changed

>
> Also, HAPQA goes after H264.
>

Changed (also in bitstream_filters.c)


>
> >  OBJS-$(CONFIG_H264_METADATA_BSF)  += h264_metadata_bsf.o
> >  OBJS-$(CONFIG_H264_MP4TOANNEXB_BSF)   += h264_mp4toannexb_bsf.o
> >  OBJS-$(CONFIG_H264_REDUNDANT_PPS_BSF) += h264_redundant_pps_bsf.o
>
> > +
> > +av_packet_move_ref(out, in);
> > +out->data += start_section_size;
> > +out->size = target_packet_size;
> > +
> > +ret = av_packet_copy_props(out, in);
>
> No need to call av_packet_copy_props(). You moved the reference from
> "in" to "out" right before this, which includes all properties, so "in"
> is now an empty packet and av_packet_copy_props() will just reset all
> properties from "out".
>

Thanks for the explanations
Removed.


>
> You should add a new fate test using one of the existing samples to make
> sure the output of this bsf is the expected one.
>
>
I plan to add fate test later.
I would like to apply the previous fate hap patch before.

New patchs in attach

Martin


0001-avcodec-hap-move-parse_section_header-to-hap.c-in-or.patch
Description: Binary data


0002-avcodec-hapqa_extract_bsf-add-new-bsf-filter.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 6/6] avcodec/mov2textsub: move the reference in the bsf internal buffer

2018-03-11 Thread James Almer
There's no need to allocate a new packet for it.

Signed-off-by: James Almer 
---
 libavcodec/movsub_bsf.c | 26 +++---
 1 file changed, 7 insertions(+), 19 deletions(-)

diff --git a/libavcodec/movsub_bsf.c b/libavcodec/movsub_bsf.c
index 3cb1183cd8..4305186b9c 100644
--- a/libavcodec/movsub_bsf.c
+++ b/libavcodec/movsub_bsf.c
@@ -64,33 +64,21 @@ const AVBitStreamFilter ff_text2movsub_bsf = {
 
 static int mov2textsub(AVBSFContext *ctx, AVPacket *out)
 {
-AVPacket *in;
 int ret = 0;
 
-ret = ff_bsf_get_packet(ctx, );
+ret = ff_bsf_get_packet_ref(ctx, out);
 if (ret < 0)
 return ret;
 
-if (in->size < 2) {
-   ret = AVERROR_INVALIDDATA;
-   goto fail;
+if (out->size < 2) {
+   av_packet_unref(out);
+   return AVERROR_INVALIDDATA;
 }
 
-ret = av_new_packet(out, FFMIN(in->size - 2, AV_RB16(in->data)));
-if (ret < 0)
-goto fail;
-
-ret = av_packet_copy_props(out, in);
-if (ret < 0)
-goto fail;
-
-memcpy(out->data, in->data + 2, out->size);
+out->data += 2;
+out->size  = FFMIN(out->size - 2, AV_RB16(out->data));
 
-fail:
-if (ret < 0)
-av_packet_unref(out);
-av_packet_free();
-return ret;
+return 0;
 }
 
 const AVBitStreamFilter ff_mov2textsub_bsf = {
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 4/6] avcodec/trace_headers: move the reference in the bsf internal buffer

2018-03-11 Thread James Almer
There's no need to allocate a new packet for it.

Signed-off-by: James Almer 
---
 libavcodec/trace_headers_bsf.c | 30 ++
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/libavcodec/trace_headers_bsf.c b/libavcodec/trace_headers_bsf.c
index 93d04cb509..d59bc828a9 100644
--- a/libavcodec/trace_headers_bsf.c
+++ b/libavcodec/trace_headers_bsf.c
@@ -71,41 +71,39 @@ static int trace_headers(AVBSFContext *bsf, AVPacket *out)
 {
 TraceHeadersContext *ctx = bsf->priv_data;
 CodedBitstreamFragment au;
-AVPacket *in;
 char tmp[256] = { 0 };
 int err;
 
-err = ff_bsf_get_packet(bsf, );
+err = ff_bsf_get_packet_ref(bsf, out);
 if (err < 0)
 return err;
 
-if (in->flags & AV_PKT_FLAG_KEY)
+if (out->flags & AV_PKT_FLAG_KEY)
 av_strlcat(tmp, ", key frame", sizeof(tmp));
-if (in->flags & AV_PKT_FLAG_CORRUPT)
+if (out->flags & AV_PKT_FLAG_CORRUPT)
 av_strlcat(tmp, ", corrupt", sizeof(tmp));
 
-if (in->pts != AV_NOPTS_VALUE)
-av_strlcatf(tmp, sizeof(tmp), ", pts %"PRId64, in->pts);
+if (out->pts != AV_NOPTS_VALUE)
+av_strlcatf(tmp, sizeof(tmp), ", pts %"PRId64, out->pts);
 else
 av_strlcat(tmp, ", no pts", sizeof(tmp));
-if (in->dts != AV_NOPTS_VALUE)
-av_strlcatf(tmp, sizeof(tmp), ", dts %"PRId64, in->dts);
+if (out->dts != AV_NOPTS_VALUE)
+av_strlcatf(tmp, sizeof(tmp), ", dts %"PRId64, out->dts);
 else
 av_strlcat(tmp, ", no dts", sizeof(tmp));
-if (in->duration > 0)
-av_strlcatf(tmp, sizeof(tmp), ", duration %"PRId64, in->duration);
+if (out->duration > 0)
+av_strlcatf(tmp, sizeof(tmp), ", duration %"PRId64, out->duration);
 
-av_log(bsf, AV_LOG_INFO, "Packet: %d bytes%s.\n", in->size, tmp);
+av_log(bsf, AV_LOG_INFO, "Packet: %d bytes%s.\n", out->size, tmp);
 
-err = ff_cbs_read_packet(ctx->cbc, , in);
-if (err < 0)
+err = ff_cbs_read_packet(ctx->cbc, , out);
+if (err < 0) {
+av_packet_unref(out);
 return err;
+}
 
 ff_cbs_fragment_uninit(ctx->cbc, );
 
-av_packet_move_ref(out, in);
-av_packet_free();
-
 return 0;
 }
 
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 3/6] avcodec/remove_extradata: move the reference in the bsf internal buffer

2018-03-11 Thread James Almer
There's no need to allocate a new packet for it.

Signed-off-by: James Almer 
---
 libavcodec/remove_extradata_bsf.c | 16 ++--
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/libavcodec/remove_extradata_bsf.c 
b/libavcodec/remove_extradata_bsf.c
index a54bbdbacf..d44cc8be92 100644
--- a/libavcodec/remove_extradata_bsf.c
+++ b/libavcodec/remove_extradata_bsf.c
@@ -42,26 +42,22 @@ static int remove_extradata(AVBSFContext *ctx, AVPacket 
*out)
 {
 RemoveExtradataContext *s = ctx->priv_data;
 
-AVPacket *in;
 int ret;
 
-ret = ff_bsf_get_packet(ctx, );
+ret = ff_bsf_get_packet_ref(ctx, out);
 if (ret < 0)
 return ret;
 
 if (s->parser && s->parser->parser->split) {
 if (s->freq == REMOVE_FREQ_ALL ||
-(s->freq == REMOVE_FREQ_NONKEYFRAME && !(in->flags & 
AV_PKT_FLAG_KEY)) ||
-(s->freq == REMOVE_FREQ_KEYFRAME && in->flags & AV_PKT_FLAG_KEY)) {
-int i = s->parser->parser->split(s->avctx, in->data, in->size);
-in->data += i;
-in->size -= i;
+(s->freq == REMOVE_FREQ_NONKEYFRAME && !(out->flags & 
AV_PKT_FLAG_KEY)) ||
+(s->freq == REMOVE_FREQ_KEYFRAME && out->flags & AV_PKT_FLAG_KEY)) 
{
+int i = s->parser->parser->split(s->avctx, out->data, out->size);
+out->data += i;
+out->size -= i;
 }
 }
 
-av_packet_move_ref(out, in);
-av_packet_free();
-
 return 0;
 }
 
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 2/6] avcodec/extract_extradata: move the reference in the bsf internal buffer

2018-03-11 Thread James Almer
There's no need to allocate a new packet for it.

Signed-off-by: James Almer 
---
 libavcodec/extract_extradata_bsf.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/libavcodec/extract_extradata_bsf.c 
b/libavcodec/extract_extradata_bsf.c
index 64017b6fb7..711814576c 100644
--- a/libavcodec/extract_extradata_bsf.c
+++ b/libavcodec/extract_extradata_bsf.c
@@ -280,21 +280,20 @@ static int extract_extradata_init(AVBSFContext *ctx)
 static int extract_extradata_filter(AVBSFContext *ctx, AVPacket *out)
 {
 ExtractExtradataContext *s = ctx->priv_data;
-AVPacket *in;
 uint8_t *extradata = NULL;
 int extradata_size;
 int ret = 0;
 
-ret = ff_bsf_get_packet(ctx, );
+ret = ff_bsf_get_packet_ref(ctx, out);
 if (ret < 0)
 return ret;
 
-ret = s->extract(ctx, in, , _size);
+ret = s->extract(ctx, out, , _size);
 if (ret < 0)
 goto fail;
 
 if (extradata) {
-ret = av_packet_add_side_data(in, AV_PKT_DATA_NEW_EXTRADATA,
+ret = av_packet_add_side_data(out, AV_PKT_DATA_NEW_EXTRADATA,
   extradata, extradata_size);
 if (ret < 0) {
 av_freep();
@@ -302,10 +301,10 @@ static int extract_extradata_filter(AVBSFContext *ctx, 
AVPacket *out)
 }
 }
 
-av_packet_move_ref(out, in);
+return 0;
 
 fail:
-av_packet_free();
+av_packet_unref(out);
 return ret;
 }
 
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 5/6] avcodec/chomp: move the reference in the bsf internal buffer

2018-03-11 Thread James Almer
There's no need to allocate a new packet for it.

Signed-off-by: James Almer 
---
 libavcodec/chomp_bsf.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/libavcodec/chomp_bsf.c b/libavcodec/chomp_bsf.c
index cc94380535..0d29a9a1d9 100644
--- a/libavcodec/chomp_bsf.c
+++ b/libavcodec/chomp_bsf.c
@@ -25,18 +25,14 @@
 
 static int chomp_filter(AVBSFContext *ctx, AVPacket *out)
 {
-AVPacket *in;
 int ret;
 
-ret = ff_bsf_get_packet(ctx, );
+ret = ff_bsf_get_packet_ref(ctx, out);
 if (ret < 0)
 return ret;
 
-while (in->size > 0 && !in->data[in->size - 1])
-in->size--;
-
-av_packet_move_ref(out, in);
-av_packet_free();
+while (out->size > 0 && !out->data[out->size - 1])
+out->size--;
 
 return 0;
 }
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 1/6] avcodec/dca_core: move the reference in the bsf internal buffer

2018-03-11 Thread James Almer
There's no need to allocate a new packet for it.

Signed-off-by: James Almer 
---
 libavcodec/dca_core_bsf.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/libavcodec/dca_core_bsf.c b/libavcodec/dca_core_bsf.c
index 9edc0cfd61..cd3bc6fe99 100644
--- a/libavcodec/dca_core_bsf.c
+++ b/libavcodec/dca_core_bsf.c
@@ -26,16 +26,15 @@
 
 static int dca_core_filter(AVBSFContext *ctx, AVPacket *out)
 {
-AVPacket *in;
 GetByteContext gb;
 uint32_t syncword;
 int core_size = 0, ret;
 
-ret = ff_bsf_get_packet(ctx, );
+ret = ff_bsf_get_packet_ref(ctx, out);
 if (ret < 0)
 return ret;
 
-bytestream2_init(, in->data, in->size);
+bytestream2_init(, out->data, out->size);
 syncword = bytestream2_get_be32();
 bytestream2_skip(, 1);
 
@@ -45,9 +44,6 @@ static int dca_core_filter(AVBSFContext *ctx, AVPacket *out)
 break;
 }
 
-av_packet_move_ref(out, in);
-av_packet_free();
-
 if (core_size > 0 && core_size <= out->size) {
 out->size = core_size;
 }
-- 
2.16.2

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


Re: [FFmpeg-devel] avcodec/hapqa_extract_bsf : add bsf filter for haqqa (to hapq or hapalpha only) conversion

2018-03-11 Thread James Almer
On 3/11/2018 2:08 PM, Martin Vignali wrote:
> Work for me, changed.
> 
> New patchs in attach, with these changes.

Please combine the last three patches (bsf, docs and changelog entry)
into a single one.

> 
> Martin
> 

> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index ff6c9f8b2c..80e54f9e6d 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -1040,6 +1040,7 @@ OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += 
> dump_extradata_bsf.o
>  OBJS-$(CONFIG_DCA_CORE_BSF)   += dca_core_bsf.o
>  OBJS-$(CONFIG_EXTRACT_EXTRADATA_BSF)  += extract_extradata_bsf.o\
>   h2645_parse.o
> +OBJS-$(CONFIG_HAPQA_EXTRACT_BSF)  += hapqa_extract_bsf.o

Missing hap.o

Also, HAPQA goes after H264.

>  OBJS-$(CONFIG_H264_METADATA_BSF)  += h264_metadata_bsf.o
>  OBJS-$(CONFIG_H264_MP4TOANNEXB_BSF)   += h264_mp4toannexb_bsf.o
>  OBJS-$(CONFIG_H264_REDUNDANT_PPS_BSF) += h264_redundant_pps_bsf.o

> +
> +av_packet_move_ref(out, in);
> +out->data += start_section_size;
> +out->size = target_packet_size;
> +
> +ret = av_packet_copy_props(out, in);

No need to call av_packet_copy_props(). You moved the reference from
"in" to "out" right before this, which includes all properties, so "in"
is now an empty packet and av_packet_copy_props() will just reset all
properties from "out".

You should add a new fate test using one of the existing samples to make
sure the output of this bsf is the expected one.

> +if (ret < 0)
> +goto fail;

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


[FFmpeg-devel] [PATCH] ffprobe: fix infinite loop in subtitle decoding

2018-03-11 Thread Marton Balint
Fixes a regression since 2a88ebd096f3c748a2d99ed1b60b22879b3c567c which caused
an infinite loop in the subtitle decoding.

Fixes ticket #6796.

Signed-off-by: Marton Balint 
---
 fftools/ffprobe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 967adbe30c..d8032bfddf 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2275,7 +2275,8 @@ static av_always_inline int process_frame(WriterContext 
*w,
 break;
 
 case AVMEDIA_TYPE_SUBTITLE:
-ret = avcodec_decode_subtitle2(dec_ctx, , _frame, pkt);
+if (*packet_new || !pkt->data)
+ret = avcodec_decode_subtitle2(dec_ctx, , _frame, pkt);
 *packet_new = 0;
 break;
 default:
-- 
2.13.6

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


Re: [FFmpeg-devel] avcodec/hapqa_extract_bsf : add bsf filter for haqqa (to hapq or hapalpha only) conversion

2018-03-11 Thread Martin Vignali
Hello,

Thanks for the comments.

> +
> > +av_log(bsf, AV_LOG_DEBUG, "Texture to keep : %d.\n", ctx->texture);
>
> There's no point printing this on every packet. Either add an init()
> callback function and put it there, or remove it altogether since it's
> of dubious usefulness.
>

Removed.


>
>
> > +ret = av_new_packet(out, target_packet_size);
> > +if (ret < 0)
> > +goto fail;
> > +
> > +out_buf = out->data;
> > +bytestream_put_buffer(_buf, in->data + start_section_size,
> target_packet_size);
> > +
> > +ret = av_packet_copy_props(out, in);
> > +if (ret < 0)
> > +goto fail;
>
> Why not just do something like
>
> av_packet_move_ref(out, in);
>
> out->data += start_section_size;
> out->size  = target_packet_size;
>

Work for me, changed.

New patchs in attach, with these changes.

Martin


0001-avcodec-hap-move-parse_section_header-to-hap.c-in-or.patch
Description: Binary data


0002-avcodec-hapqa_extract_bsf-add-new-bsf-filter.patch
Description: Binary data


0003-doc-bsf-add-doc-for-new-hapqa_extract-bsf-filter.patch
Description: Binary data


0004-changelog-add-entry-for-hapqa-extract-bsf.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] h264_mp4toannexb_bsf: Fix start code size of parameter sets.

2018-03-11 Thread Yusuke Nakamura
2018-02-13 1:45 GMT+09:00 Yusuke Nakamura :

> Any parameter set shall have start code of at least 4 byte size.
> ---
>  libavcodec/h264_mp4toannexb_bsf.c| 22 +++---
>  tests/ref/fate/h264-bsf-mp4toannexb  |  2 +-
>  tests/ref/fate/h264_mp4toannexb_ticket2991   | 22 +++---
>  tests/ref/fate/h264_mp4toannexb_ticket5927   | 10 +-
>  tests/ref/fate/h264_mp4toannexb_ticket5927_2 | 10 +-
>  tests/ref/fate/segment-mp4-to-ts |  4 ++--
>  6 files changed, 35 insertions(+), 35 deletions(-)
>
> diff --git a/libavcodec/h264_mp4toannexb_bsf.c
> b/libavcodec/h264_mp4toannexb_bsf.c
> index 163d0f5..292d106 100644
> --- a/libavcodec/h264_mp4toannexb_bsf.c
> +++ b/libavcodec/h264_mp4toannexb_bsf.c
> @@ -39,21 +39,21 @@ typedef struct H264BSFContext {
>
>  static int alloc_and_copy(AVPacket *out,
>const uint8_t *sps_pps, uint32_t sps_pps_size,
> -  const uint8_t *in, uint32_t in_size)
> +  const uint8_t *in, uint32_t in_size, int ps)
>  {
>  uint32_t offset = out->size;
> -uint8_t nal_header_size = offset ? 3 : 4;
> +uint8_t start_code_size = offset == 0 || ps ? 4 : 3;
>  int err;
>
> -err = av_grow_packet(out, sps_pps_size + in_size + nal_header_size);
> +err = av_grow_packet(out, sps_pps_size + in_size + start_code_size);
>  if (err < 0)
>  return err;
>
>  if (sps_pps)
>  memcpy(out->data + offset, sps_pps, sps_pps_size);
> -memcpy(out->data + sps_pps_size + nal_header_size + offset, in,
> in_size);
> -if (!offset) {
> -AV_WB32(out->data + sps_pps_size, 1);
> +memcpy(out->data + sps_pps_size + start_code_size + offset, in,
> in_size);
> +if (start_code_size == 4) {
> +AV_WB32(out->data + offset + sps_pps_size, 1);
>  } else {
>  (out->data + offset + sps_pps_size)[0] =
>  (out->data + offset + sps_pps_size)[1] = 0;
> @@ -221,7 +221,7 @@ static int h264_mp4toannexb_filter(AVBSFContext *ctx,
> AVPacket *out)
>  if ((ret = alloc_and_copy(out,
>   ctx->par_out->extradata +
> s->sps_offset,
>   s->pps_offset != -1 ?
> s->pps_offset : ctx->par_out->extradata_size - s->sps_offset,
> - buf, nal_size)) < 0)
> + buf, nal_size, 1)) < 0)
>  goto fail;
>  s->idr_sps_seen = 1;
>  goto next_nal;
> @@ -239,21 +239,21 @@ static int h264_mp4toannexb_filter(AVBSFContext
> *ctx, AVPacket *out)
>  if (s->new_idr && unit_type == 5 && !s->idr_sps_seen &&
> !s->idr_pps_seen) {
>  if ((ret=alloc_and_copy(out,
> ctx->par_out->extradata,
> ctx->par_out->extradata_size,
> -   buf, nal_size)) < 0)
> +   buf, nal_size, 1)) < 0)
>  goto fail;
>  s->new_idr = 0;
>  /* if only SPS has been seen, also insert PPS */
>  } else if (s->new_idr && unit_type == 5 && s->idr_sps_seen &&
> !s->idr_pps_seen) {
>  if (s->pps_offset == -1) {
>  av_log(ctx, AV_LOG_WARNING, "PPS not present in the
> stream, nor in AVCC, stream may be unreadable\n");
> -if ((ret = alloc_and_copy(out, NULL, 0, buf, nal_size)) <
> 0)
> +if ((ret = alloc_and_copy(out, NULL, 0, buf, nal_size,
> 0)) < 0)
>  goto fail;
>  } else if ((ret = alloc_and_copy(out,
>  ctx->par_out->extradata +
> s->pps_offset, ctx->par_out->extradata_size - s->pps_offset,
> -buf, nal_size)) < 0)
> +buf, nal_size, 1)) < 0)
>  goto fail;
>  } else {
> -if ((ret=alloc_and_copy(out, NULL, 0, buf, nal_size)) < 0)
> +if ((ret=alloc_and_copy(out, NULL, 0, buf, nal_size,
> unit_type == 7 || unit_type == 8)) < 0)
>  goto fail;
>  if (!s->new_idr && unit_type == 1) {
>  s->new_idr = 1;
> diff --git a/tests/ref/fate/h264-bsf-mp4toannexb
> b/tests/ref/fate/h264-bsf-mp4toannexb
> index 2049f39..7cd086a 100644
> --- a/tests/ref/fate/h264-bsf-mp4toannexb
> +++ b/tests/ref/fate/h264-bsf-mp4toannexb
> @@ -1 +1 @@
> -5f04c27cc6ee8625fe2405fb0f7da9a3
> +f340e7ca9a46d437af4e96f6c8de221c
> diff --git a/tests/ref/fate/h264_mp4toannexb_ticket2991
> b/tests/ref/fate/h264_mp4toannexb_ticket2991
> index 76bdf3c..3245ef4 100644
> --- a/tests/ref/fate/h264_mp4toannexb_ticket2991
> +++ b/tests/ref/fate/h264_mp4toannexb_ticket2991
> @@ -1,12 +1,12 @@
> -05d66e60ab22ee004720e0051af0fe74 *tests/data/fate/h264_mp4toann
> exb_ticket2991.h264
> -1985815 

Re: [FFmpeg-devel] [PATCH] lavf/rtsp: fix the type of the timeout option.

2018-03-11 Thread wm4
On Sun, 11 Mar 2018 14:49:37 +0100
Michael Niedermayer  wrote:

> On Sun, Mar 11, 2018 at 03:03:06AM +0100, wm4 wrote:
> > On Sat, 10 Mar 2018 20:37:20 +0100
> > Nicolas George  wrote:
> >   
> > > A timeout is a duration of time, therefore the correct type for it
> > > is AV_OPT_TYPE_DURATION. It has the benefit of offering a better
> > > user interface, with units specification.
> > > Unfortunately, ff46124b0df17a1d35249e09ae8eae9a61f16e04 was pushed
> > > before that mistake could be corrected.
> > > 
> > > Signed-off-by: Nicolas George 
> > > ---
> > >  libavformat/rtsp.c | 5 +++--
> > >  libavformat/rtsp.h | 4 
> > >  2 files changed, 7 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> > > index ceb770a3a4..1fbdcfcedd 100644
> > > --- a/libavformat/rtsp.c
> > > +++ b/libavformat/rtsp.c
> > > @@ -98,7 +98,7 @@ const AVOption ff_rtsp_options[] = {
> > >  { "timeout", "set maximum timeout (in seconds) to wait for incoming 
> > > connections (-1 is infinite, imply flag listen) (deprecated, use 
> > > listen_timeout)", OFFSET(initial_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, 
> > > INT_MIN, INT_MAX, DEC },
> > >  { "stimeout", "set timeout (in microseconds) of socket TCP I/O 
> > > operations", OFFSET(stimeout), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, 
> > > INT_MAX, DEC },
> > >  #else
> > > -{ "timeout", "set timeout (in microseconds) of socket TCP I/O 
> > > operations", OFFSET(stimeout), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, 
> > > INT_MAX, DEC },
> > > +{ "timeout", "set timeout of socket TCP I/O operations", 
> > > OFFSET(stimeout), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, INT64_MAX, DEC },
> > >  #endif
> > >  COMMON_OPTS(),
> > >  { "user_agent", "override User-Agent header", OFFSET(user_agent), 
> > > AV_OPT_TYPE_STRING, {.str = LIBAVFORMAT_IDENT}, 0, 0, DEC },
> > > @@ -1818,7 +1818,8 @@ redirect:
> > >  /* open the tcp connection */
> > >  ff_url_join(tcpname, sizeof(tcpname), lower_rtsp_proto, NULL,
> > >  host, port,
> > > -"?timeout=%d", rt->stimeout);
> > > +/* cast necessary until FF_API_OLD_RTSP_OPTIONS 
> > > removed */
> > > +"?timeout=%"PRId64, (int64_t)rt->stimeout);
> > >  if ((ret = ffurl_open_whitelist(>rtsp_hd, tcpname, 
> > > AVIO_FLAG_READ_WRITE,
> > > >interrupt_callback, NULL, 
> > > s->protocol_whitelist, s->protocol_blacklist, NULL)) < 0) {
> > >  err = ret;
> > > diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h
> > > index 9a7f366b39..1524962e1b 100644
> > > --- a/libavformat/rtsp.h
> > > +++ b/libavformat/rtsp.h
> > > @@ -395,7 +395,11 @@ typedef struct RTSPState {
> > >  /**
> > >   * timeout of socket i/o operations.
> > >   */
> > > +#if FF_API_OLD_RTSP_OPTIONS
> > >  int stimeout;
> > > +#else
> > > +int64_t stimeout;
> > > +#endif
> > >  
> > >  /**
> > >   * Size of RTP packet reordering queue.  
> 
> I have been asked to comment on this patch
> 
> 
> > 
> > On IRC I was asked to explain my NACK:
> > 
> > The whole point of ff46124b0df17a1d35249e09ae8eae9a61f16e04 was to
> > harmonize the timeout options with that of other protocols. In
> > particular, http/tcp (the most used network protocol of them all) uses
> > an AV_OPT_TYPE_INT "timeout" option, using microseconds.
> >   
> 
> > AV_OPT_TYPE_DURATION parses the time in seconds, so this is
> > incompatible. It's incompatible on both CLI and API, because the API
> > usually requires you to pass all options as string in AVDictionary
> > entries (this is how dispatching general options to underlying
> > protocols work, and it's impossible to access the options for sub
> > protocols directly).  
> 
> If we look at the last release:
> git grep '"timeout"' release/3.4 libavformat/rtsp.c
> release/3.4:libavformat/rtsp.c:{ "timeout", "set maximum timeout (in 
> seconds) to wait for incoming connections (-1 is infinite, imply flag 
> listen)", OFFSET(initial_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, 
> INT_MAX, DEC },
>   
> ^^
> That in fact the timeout parameter of rtsp.c was in seconds already
> 
> 
> > 
> > Thus your change negates the whole point of the previous change, which
> > is why I'm rejecting it. Reverting others patches after the discussion
> > of it was done and everything finalized isn't exactly how team work
> > works either.
> > 
> > You have 2 choices:
> > - change all timeout options to AV_OPT_TYPE_DURATION (after a
> >   deprecation period)
> > - drop the patch  
> 
> Let me summarize it
> IIRC nicolas was against your patch
> you are against nicolas patch
> 
> neither of these patches move us toward a consistent and compatible
> AV_OPT_TYPE_DURATION based timeout interface.
> 
> "timeout" as it is currently, is not 

Re: [FFmpeg-devel] avcodec/hapqa_extract_bsf : add bsf filter for haqqa (to hapq or hapalpha only) conversion

2018-03-11 Thread James Almer
On 3/11/2018 10:47 AM, Martin Vignali wrote:
> Hello
> 
> New patchs in attach :
> - check texture type, for rgb or alpha keep (don't assume first texture is
> rgb and second texture is alpha)
> - change options, to use "color" or "alpha".
> - Translate french comments
> - add changelog entry
> 
> Not entirely sure, of the options part of the bsf filter.
> 
> Comments welcome
> 
> Martin

> +static int hapqa_extract(AVBSFContext *bsf, AVPacket *out)
> +{
> +HapqaExtractContext *ctx = bsf->priv_data;
> +GetByteContext gbc;
> +int section_size;
> +enum HapSectionType section_type;
> +int start_section_size;
> +int target_packet_size = 0;
> +AVPacket *in;
> +int ret = 0;
> +uint8_t *out_buf;
> +
> +av_log(bsf, AV_LOG_DEBUG, "Texture to keep : %d.\n", ctx->texture);

There's no point printing this on every packet. Either add an init()
callback function and put it there, or remove it altogether since it's
of dubious usefulness.

> +
> +ret = ff_bsf_get_packet(bsf, );
> +if (ret < 0)
> +return ret;
> +
> +bytestream2_init(, in->data, in->size);
> +ret = ff_hap_parse_section_header(, _size, _type);
> +if (ret != 0)
> +goto fail;
> +
> +if ((section_type & 0x0F) != 0x0D) {
> +av_log(bsf, AV_LOG_ERROR, "Invalid section type for HAPQA %#04x.\n", 
> section_type & 0x0F);
> +goto fail;
> +}
> +
> +start_section_size = 4;
> +
> +bytestream2_seek(, start_section_size, SEEK_SET);/* go to start of 
> the first texture */
> +
> +ret = ff_hap_parse_section_header(, _size, _type);
> +if (ret != 0)
> +goto fail;
> +
> +target_packet_size = section_size + 4;
> +
> +if (check_texture(ctx, section_type) == 0) { /* the texture is not the 
> one to keep */
> +start_section_size += 4 + section_size;
> +bytestream2_seek(, start_section_size, SEEK_SET);/* go to start 
> of the second texture */
> +ret = ff_hap_parse_section_header(, _size, 
> _type);
> +if (ret != 0)
> +goto fail;
> +
> +target_packet_size = section_size + 4;
> +
> +if (check_texture(ctx, section_type) == 0){ /* the second texture is 
> not the one to keep */
> +av_log(bsf, AV_LOG_ERROR, "No valid texture found.\n");
> +goto fail;
> +}
> +}
> +


> +ret = av_new_packet(out, target_packet_size);
> +if (ret < 0)
> +goto fail;
> +
> +out_buf = out->data;
> +bytestream_put_buffer(_buf, in->data + start_section_size, 
> target_packet_size);
> +
> +ret = av_packet_copy_props(out, in);
> +if (ret < 0)
> +goto fail;

Why not just do something like

av_packet_move_ref(out, in);

out->data += start_section_size;
out->size  = target_packet_size;

(Untested)

You're not assembling any complex data structure using separate parts of
the input packet, so no need to reallocate the entire buffer for this.
It will be faster this way.
See dca_core_bsf for another example of this.

> +
> +fail:
> +if (ret < 0)
> +av_packet_unref(out);
> +av_packet_free();
> +return ret;
> +}
> +
> +static const enum AVCodecID codec_ids[] = {
> +AV_CODEC_ID_HAP, AV_CODEC_ID_NONE,
> +};
> +
> +#define OFFSET(x) offsetof(HapqaExtractContext, x)
> +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
> +static const AVOption options[] = {
> +{ "texture", "texture to keep", OFFSET(texture), AV_OPT_TYPE_INT, { .i64 
> = 0 }, 0, 1, FLAGS,  "texture" },
> +{ "color", "keep HapQ texture", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 
> 0, 0, FLAGS, "texture" },
> +{ "alpha", "keep HapAlphaOnly texture", 0, AV_OPT_TYPE_CONST, { .i64 
> = 1 }, 0, 0, FLAGS, "texture" },
> +{ NULL },
> +};
> +
> +static const AVClass hapqa_extract_class = {
> +.class_name = "hapqa_extract_bsf",
> +.item_name  = av_default_item_name,
> +.option = options,
> +.version= LIBAVUTIL_VERSION_MAJOR,
> +};
> +
> +const AVBitStreamFilter ff_hapqa_extract_bsf = {
> +.name   = "hapqa_extract",
> +.filter = hapqa_extract,
> +.priv_data_size = sizeof(HapqaExtractContext),
> +.priv_class = _extract_class,
> +.codec_ids  = codec_ids,
> +};
> -- 
> 2.14.3 (Apple Git-98)
> 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] avcodec/hapqa_extract_bsf : add bsf filter for haqqa (to hapq or hapalpha only) conversion

2018-03-11 Thread Martin Vignali
Hello

New patchs in attach :
- check texture type, for rgb or alpha keep (don't assume first texture is
rgb and second texture is alpha)
- change options, to use "color" or "alpha".
- Translate french comments
- add changelog entry

Not entirely sure, of the options part of the bsf filter.

Comments welcome

Martin


0001-avcodec-hap-move-parse_section_header-to-hap.c-in-or.patch
Description: Binary data


0002-avcodec-hapqa_extract_bsf-add-new-bsf-filter.patch
Description: Binary data


0003-doc-bsf-add-doc-for-new-hapqa_extract-bsf-filter.patch
Description: Binary data


0004-changelog-add-entry-for-hapqa-extract-bsf.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavf/rtsp: fix the type of the timeout option.

2018-03-11 Thread Michael Niedermayer
On Sun, Mar 11, 2018 at 03:03:06AM +0100, wm4 wrote:
> On Sat, 10 Mar 2018 20:37:20 +0100
> Nicolas George  wrote:
> 
> > A timeout is a duration of time, therefore the correct type for it
> > is AV_OPT_TYPE_DURATION. It has the benefit of offering a better
> > user interface, with units specification.
> > Unfortunately, ff46124b0df17a1d35249e09ae8eae9a61f16e04 was pushed
> > before that mistake could be corrected.
> > 
> > Signed-off-by: Nicolas George 
> > ---
> >  libavformat/rtsp.c | 5 +++--
> >  libavformat/rtsp.h | 4 
> >  2 files changed, 7 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> > index ceb770a3a4..1fbdcfcedd 100644
> > --- a/libavformat/rtsp.c
> > +++ b/libavformat/rtsp.c
> > @@ -98,7 +98,7 @@ const AVOption ff_rtsp_options[] = {
> >  { "timeout", "set maximum timeout (in seconds) to wait for incoming 
> > connections (-1 is infinite, imply flag listen) (deprecated, use 
> > listen_timeout)", OFFSET(initial_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, 
> > INT_MIN, INT_MAX, DEC },
> >  { "stimeout", "set timeout (in microseconds) of socket TCP I/O 
> > operations", OFFSET(stimeout), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, 
> > INT_MAX, DEC },
> >  #else
> > -{ "timeout", "set timeout (in microseconds) of socket TCP I/O 
> > operations", OFFSET(stimeout), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, 
> > INT_MAX, DEC },
> > +{ "timeout", "set timeout of socket TCP I/O operations", 
> > OFFSET(stimeout), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, INT64_MAX, DEC },
> >  #endif
> >  COMMON_OPTS(),
> >  { "user_agent", "override User-Agent header", OFFSET(user_agent), 
> > AV_OPT_TYPE_STRING, {.str = LIBAVFORMAT_IDENT}, 0, 0, DEC },
> > @@ -1818,7 +1818,8 @@ redirect:
> >  /* open the tcp connection */
> >  ff_url_join(tcpname, sizeof(tcpname), lower_rtsp_proto, NULL,
> >  host, port,
> > -"?timeout=%d", rt->stimeout);
> > +/* cast necessary until FF_API_OLD_RTSP_OPTIONS 
> > removed */
> > +"?timeout=%"PRId64, (int64_t)rt->stimeout);
> >  if ((ret = ffurl_open_whitelist(>rtsp_hd, tcpname, 
> > AVIO_FLAG_READ_WRITE,
> > >interrupt_callback, NULL, 
> > s->protocol_whitelist, s->protocol_blacklist, NULL)) < 0) {
> >  err = ret;
> > diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h
> > index 9a7f366b39..1524962e1b 100644
> > --- a/libavformat/rtsp.h
> > +++ b/libavformat/rtsp.h
> > @@ -395,7 +395,11 @@ typedef struct RTSPState {
> >  /**
> >   * timeout of socket i/o operations.
> >   */
> > +#if FF_API_OLD_RTSP_OPTIONS
> >  int stimeout;
> > +#else
> > +int64_t stimeout;
> > +#endif
> >  
> >  /**
> >   * Size of RTP packet reordering queue.

I have been asked to comment on this patch


> 
> On IRC I was asked to explain my NACK:
> 
> The whole point of ff46124b0df17a1d35249e09ae8eae9a61f16e04 was to
> harmonize the timeout options with that of other protocols. In
> particular, http/tcp (the most used network protocol of them all) uses
> an AV_OPT_TYPE_INT "timeout" option, using microseconds.
> 

> AV_OPT_TYPE_DURATION parses the time in seconds, so this is
> incompatible. It's incompatible on both CLI and API, because the API
> usually requires you to pass all options as string in AVDictionary
> entries (this is how dispatching general options to underlying
> protocols work, and it's impossible to access the options for sub
> protocols directly).

If we look at the last release:
git grep '"timeout"' release/3.4 libavformat/rtsp.c
release/3.4:libavformat/rtsp.c:{ "timeout", "set maximum timeout (in 
seconds) to wait for incoming connections (-1 is infinite, imply flag listen)", 
OFFSET(initial_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, DEC },
  ^^
That in fact the timeout parameter of rtsp.c was in seconds already


> 
> Thus your change negates the whole point of the previous change, which
> is why I'm rejecting it. Reverting others patches after the discussion
> of it was done and everything finalized isn't exactly how team work
> works either.
> 
> You have 2 choices:
> - change all timeout options to AV_OPT_TYPE_DURATION (after a
>   deprecation period)
> - drop the patch

Let me summarize it
IIRC nicolas was against your patch
you are against nicolas patch

neither of these patches move us toward a consistent and compatible
AV_OPT_TYPE_DURATION based timeout interface.

"timeout" as it is currently, is not consistent, it is not in seconds
in many cases and we cant just change it everywhere as it would break 
compatibility.
What we need is a new parameter with a new name that then will be
consistently be in AV_OPT_TYPE_DURATION (seconds). And then deprecate 
all the old parameters
I wanted to work on this but didnt had time yet.

I think we 

Re: [FFmpeg-devel] [PATCH] avcodec/arm/hevcdsp_sao : add NEON optimization for sao

2018-03-11 Thread Yingming Fan

> On 11 Mar 2018, at 8:54 PM, Carl Eugen Hoyos  wrote:
> 
> 2018-03-08 8:03 GMT+01:00 Yingming Fan :
>> From: Meng Wang 
> 
>> +stride_dst /= sizeof(uint8_t);
>> +stride_src /= sizeof(uint8_t);
> 
> FFmpeg requires sizeof(uint8_t) to be 1, please simplify
> your patch accordingly.
> 
> Why is the wrapper function needed?

We use wrapper because codes in wrapper no need to be written with assembly, C 
codes more readable.

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

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


Re: [FFmpeg-devel] [PATCH] avcodec/arm/hevcdsp_sao : add NEON optimization for sao

2018-03-11 Thread Carl Eugen Hoyos
2018-03-08 8:03 GMT+01:00 Yingming Fan :
> From: Meng Wang 

> +stride_dst /= sizeof(uint8_t);
> +stride_src /= sizeof(uint8_t);

FFmpeg requires sizeof(uint8_t) to be 1, please simplify
your patch accordingly.

Why is the wrapper function needed?

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


Re: [FFmpeg-devel] avformat/mov : add support for read/write Adobe Alpha Udta

2018-03-11 Thread Martin Vignali
> > +av_log(c->fc, AV_LOG_ERROR,
> > +   "unknown value for ALFA udta (%llu)\n", alpha_val);
>
> the %llu looks wrong for the type
>
>
>
New patch in attach replacing %llu with %"PRIu64

Martin


0001-avformat-mov-add-support-for-Adobe-Alpha-metadata.patch
Description: Binary data


0002-avformat-movenc-add-support-for-writing-alpha-metada.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] fate/mov : add test for ffprobe and alpha metadata

2018-03-11 Thread Martin Vignali
Hello,

Patch in attach add test for adobe alpha metadata in mov file

Sample can be found here :
https://we.tl/d4AIvKE3wV

and need to be put inside ./fate-suite/mov

can be test with :
make fate-mov SAMPLES=fate-suite


Need to be apply after patch in discussion :
avformat/mov : add support for read/write Adobe Alpha Udta


Martin


0003-fate-mov-add-test-for-ffprobe-and-alpha-metadata.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] GSoC

2018-03-11 Thread Mark Thompson
On 11/03/18 04:36, Dylan Fernando wrote:
> On Thu, Mar 8, 2018 at 8:57 AM, Mark Thompson  wrote:
> 
>> On 07/03/18 03:56, Dylan Fernando wrote:
>>> Thanks, it works now
>>>
>>> Would trying to implement an OpenCL version of vf_fade be a good idea
>> for a
>>> qualification task, or would it be a better idea to try a different
>> filter?
>>
>> That sounds like a sensible choice to me, though if you haven't written a
>> filter before you might find it helpful to write something simpler first to
>> understand how it fits together (for example: vflip, which has trivial
>> processing parts but still needs the surrounding boilerplate).
>>
>> - Mark
>>
>> (PS: be aware that top-posting is generally frowned upon on this mailing
>> list.)
>>
>>
>>> On Wed, Mar 7, 2018 at 1:20 AM, Mark Thompson  wrote:
>>>
 On 06/03/18 12:37, Dylan Fernando wrote:
> Hi,
>
> I am Dylan Fernando. I am a Computer Science student from Australia. I
>> am
> new to FFmpeg and I wish to apply for GSoC this year.
> I would like to do the Video filtering with OpenCL project and I have a
 few
> questions. Would trying to implement an opencl version of vf_fade be a
 good
> idea for the qualification task, or would I be better off using a
 different
> filter?
>
> Also, I’m having a bit of trouble with running unsharp_opencl. I tried
> running:
> ffmpeg -hide_banner -nostats -v verbose -init_hw_device opencl=ocl:0.1
> -filter_hw_device ocl -i space.mpg -filter_complex unsharp_opencl
 output.mp4
>
> but I got the error:
> [AVHWDeviceContext @ 0x7fdac050c700] 0.1: Apple / Intel(R) Iris(TM)
> Graphics 6100
> [mpeg @ 0x7fdac3132600] max_analyze_duration 500 reached at 5005000
> microseconds st:0
> Input #0, mpeg, from 'space.mpg':
>   Duration: 00:00:21.99, start: 0.387500, bitrate: 6108 kb/s
> Stream #0:0[0x1e0]: Video: mpeg2video (Main), 1 reference frame,
> yuv420p(tv, bt470bg, bottom first, left), 720x480 [SAR 8:9 DAR 4:3],
>> 6000
> kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
> Stream mapping:
>   Stream #0:0 (mpeg2video) -> unsharp_opencl
>   unsharp_opencl -> Stream #0:0 (mpeg4)
> Press [q] to stop, [?] for help
> [graph 0 input from stream 0:0 @ 0x7fdac0418800] w:720 h:480
 pixfmt:yuv420p
> tb:1/9 fr:3/1001 sar:8/9 sws_param:flags=2
> [auto_scaler_0 @ 0x7fdac05232c0] w:iw h:ih flags:'bilinear' interl:0
> [Parsed_unsharp_opencl_0 @ 0x7fdac0715a80] auto-inserting filter
> 'auto_scaler_0' between the filter 'graph 0 input from stream 0:0' and
 the
> filter 'Parsed_unsharp_opencl_0'
> Impossible to convert between the formats supported by the filter
>> 'graph
 0
> input from stream 0:0' and the filter 'auto_scaler_0'
> Error reinitializing filters!
> Failed to inject frame into filter network: Function not implemented
> Error while processing the decoded data for stream #0:0
> Conversion failed!
>
> How do I correctly run unsharp_opencl? Should I be running it on a
> different video file?

 It's intended to be used in filter graphs where much of the activity is
 already happening on the GPU, so the input and output are in the
 AV_PIX_FMT_OPENCL format which contains GPU-side OpenCL images.

 If you want to use it standalone then you need hwupload and hwdownload
 filters to move the frames between the CPU and GPU.  For your example,
>> it
 should work with:

 ffmpeg -init_hw_device opencl=ocl:0.1 -filter_hw_device ocl -i space.mpg
 -filter_complex hwupload,unsharp_opencl,hwdownload output.mp4

 (There are constraints on what formats can be used and therefore
>> suitable
 files (or required format conversions), but I believe a normal yuv420p
 video like this should work in all cases.)

 - Mark
>>
> 
> Thanks.
> 
> How is AV_PIX_FMT_OPENCL formatted? When using read_imagef(), does xyzw
> correspond to RGBA respectively, or to YUV? Would I have to account for
> different formats? If so, how do I check the format of the input?

See libavutil/hwcontext_opencl.c and in particular the functions 
opencl_get_buffer(), opencl_pool_alloc() and opencl_get_plane_format() for the 
code creating the AV_PIX_FMT_OPENCL images.

It tries to support all formats which are representable as OpenCL images, so 
the component values are dependent on what the format of the underlying image 
is.  What can actually be represented does depends a bit on the implementation 
- for example, CL_R channel order is needed for all planar YUV images, and 
CL_RG is needed as well for NV12 and P010 support.  The data_type is always 
UNORM_INT8 or UNORM_INT16 (depending on depth, intermediate depths like 10-bit 
require are treated as UNORM_INT16 and require an MSB-packed format like P010 
rather than an LSB-packed format like YUV420P), so it should always be read as 
a 

Re: [FFmpeg-devel] Type mismatch in ADPCM

2018-03-11 Thread Carl Eugen Hoyos
2018-03-11 11:27 GMT+01:00 Carlo Bramini :
> Hello,
> I see. I expected that adding that could be considered out of the coding 
> guidelines.

You misunderstand:
The issue is not (afaict) the coding guidelines but the fact that the
change would mean we claim a compatibility that we cannot guarantee.

> However, what about the patch attached for fixing the declaration
> of ff_adpcm_afc_coeffs[2][16]?

This would revert 10542491, a relatively recent change: Maybe Paul,
the author, wants to comment. Do you think the code gets more
readable?

Please do not top-post here, Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] Type mismatch in ADPCM

2018-03-11 Thread Carlo Bramini
Hello,
I see. I expected that adding that could be considered out of the coding 
guidelines.
However, what about the patch attached for fixing the declaration of 
ff_adpcm_afc_coeffs[2][16]?
Although it works because the binary values are the same, this is wrong, 
independently by the fact that you are compiling for plain C or C++.

Sincerely.


> Il 10 marzo 2018 alle 20.38 Carl Eugen Hoyos  ha scritto:
> 
> 2018-03-10 15:02 GMT+01:00 Carlo Bramini :
> 
> > I noticed this thing because I compiled those sources with a more robust 
> > syntax check, by using C++ rather that plain C. At pratical level, nothing 
> > changed, except for the .h files that required to use the extern "C" 
> > keyword. I was wondering if you could evaulate the chance to add this 
> > feature to the include files.
> > It could be done directly by using some #ifdef/#endif, or perhaps by doing 
> > something like this, somewhere in a common file:
> > 
> > #ifdef __cplusplus
> > 
> > #define FFMPEG_EXTERN_C_BEGIN extern "C" {
> > 
> > #define FFMPEG_EXTERN_C_END }
> > 
> > #else
> > 
> > #define FFMPEG_EXTERN_C_BEGIN
> > 
> > #define FFMPEG_EXTERN_C_END
> > 
> > #endif
> 
> In addition to what was said:
> We cannot commit above because we would not test it
> and we cannot guarantee that it will always work: We
> provide C headers, if you want to use them in a C++
> project, it is your responsibility to make sure it works,
> not ours.
> 
> Carl Eugen
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/wmalosslessdec: Reset num_saved_bits on error path

2018-03-11 Thread Paul B Mahol
On 3/11/18, Michael Niedermayer  wrote:
> Fixes: NULL pointer dereference
> Fixes: poc-201803.wav
> Found-by: GwanYeong Kim 
>
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/wmalosslessdec.c | 1 +
>  1 file changed, 1 insertion(+)
>

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