[FFmpeg-devel] [PATCH] ffprobe: Initialize coded_width/height

2018-01-18 Thread Zhong Li
coded_width/height are unnitialized and will be overwritten by
dec_ctx->width/height in avcodec_open2()

This fixes tiket #6958.

Signed-off-by: Zhong Li 
---
 fftools/ffprobe.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 0e7a771..233760d 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2512,10 +2512,12 @@ static int show_stream(WriterContext *w, 
AVFormatContext *fmt_ctx, int stream_id
 case AVMEDIA_TYPE_VIDEO:
 print_int("width",par->width);
 print_int("height",   par->height);
+#if FF_API_LAVF_AVCTX
 if (dec_ctx) {
 print_int("coded_width",  dec_ctx->coded_width);
 print_int("coded_height", dec_ctx->coded_height);
 }
+#endif
 print_int("has_b_frames", par->video_delay);
 sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
 if (sar.den) {
@@ -2912,6 +2914,10 @@ static int open_input_file(InputFile *ifile, const char 
*filename)
 
 ist->dec_ctx->pkt_timebase = stream->time_base;
 ist->dec_ctx->framerate = stream->avg_frame_rate;
+#if FF_API_LAVF_AVCTX
+ist->dec_ctx->coded_width = stream->codec->coded_width;
+ist->dec_ctx->coded_height = stream->codec->coded_height;
+#endif
 
 if (avcodec_open2(ist->dec_ctx, codec, &opts) < 0) {
 av_log(NULL, AV_LOG_WARNING, "Could not open codec for input 
stream %d\n",
-- 
1.8.3.1

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


Re: [FFmpeg-devel] [PATCH] avfilter/drawtext - implement fix_bounds

2018-01-18 Thread Gyan Doshi


On 1/11/2018 7:12 PM, Gyan Doshi wrote:
The no-op commit e496c45 from Libav introduced an option which allowed 
the user to relocate text to fit within the frame if it was going out of 
bounds.


For some reason, when the merge commit b479e01 was applied, the option 
was added but the code fragment which implemented it, was not. So the 
option was dead on arrival, and has remained impotent (since Feb 2012).


Attached patch implements option. Text styling elements like shadow or 
box are also kept within bounds. Default value changed to false so that 
filter outcome doesn't change in existing scripts.


Regards,
Gyan


Ping. Unless text needs to be rescaled as well, this patch is ready for 
review.


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


[FFmpeg-devel] [PATCH] avcodec/vp9_parser: parse size and colorspace values from frame headers

2018-01-18 Thread James Almer
Improves remuxing support when vp9 decoder is not compiled in.

Signed-off-by: James Almer 
---
 libavcodec/vp9_parser.c | 98 -
 1 file changed, 97 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vp9_parser.c b/libavcodec/vp9_parser.c
index 9531f34a32..b059477747 100644
--- a/libavcodec/vp9_parser.c
+++ b/libavcodec/vp9_parser.c
@@ -23,15 +23,69 @@
 
 #include "libavutil/intreadwrite.h"
 #include "libavcodec/get_bits.h"
+#include "libavcodec/internal.h"
 #include "parser.h"
 
+#define VP9_SYNCCODE 0x498342
+
+static int read_colorspace_details(AVCodecParserContext *ctx, AVCodecContext 
*avctx,
+   GetBitContext *gb)
+{
+static const enum AVColorSpace colorspaces[8] = {
+AVCOL_SPC_UNSPECIFIED, AVCOL_SPC_BT470BG, AVCOL_SPC_BT709, 
AVCOL_SPC_SMPTE170M,
+AVCOL_SPC_SMPTE240M, AVCOL_SPC_BT2020_NCL, AVCOL_SPC_RESERVED, 
AVCOL_SPC_RGB,
+};
+int bits = avctx->profile <= 1 ? 0 : 1 + get_bits1(gb); // 0:8, 1:10, 2:12
+
+avctx->colorspace = colorspaces[get_bits(gb, 3)];
+if (avctx->colorspace == AVCOL_SPC_RGB) { // RGB = profile 1
+static const enum AVPixelFormat pix_fmt_rgb[3] = {
+AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12
+};
+if (avctx->profile & 1) {
+if (get_bits1(gb)) // reserved bit
+return AVERROR_INVALIDDATA;
+} else
+return AVERROR_INVALIDDATA;
+avctx->color_range = AVCOL_RANGE_JPEG;
+ctx->format = pix_fmt_rgb[bits];
+} else {
+static const enum AVPixelFormat pix_fmt_for_ss[3][2 /* v */][2 /* h 
*/] = {
+{ { AV_PIX_FMT_YUV444P,   AV_PIX_FMT_YUV422P },
+  { AV_PIX_FMT_YUV440P,   AV_PIX_FMT_YUV420P } },
+{ { AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV422P10 },
+  { AV_PIX_FMT_YUV440P10, AV_PIX_FMT_YUV420P10 } },
+{ { AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV422P12 },
+  { AV_PIX_FMT_YUV440P12, AV_PIX_FMT_YUV420P12 } }
+};
+avctx->color_range = get_bits1(gb) ? AVCOL_RANGE_JPEG : 
AVCOL_RANGE_MPEG;
+if (avctx->profile & 1) {
+int ss_h, ss_v, format;
+
+ss_h = get_bits1(gb);
+ss_v = get_bits1(gb);
+format = pix_fmt_for_ss[bits][ss_v][ss_h];
+if (format == AV_PIX_FMT_YUV420P)
+// YUV 4:2:0 not supported in profiles 1 and 3
+return AVERROR_INVALIDDATA;
+else if (get_bits1(gb)) // color details reserved bit
+return AVERROR_INVALIDDATA;
+ctx->format = format;
+} else {
+ctx->format = pix_fmt_for_ss[bits][1][1];
+}
+}
+
+return 0;
+}
+
 static int parse(AVCodecParserContext *ctx,
  AVCodecContext *avctx,
  const uint8_t **out_data, int *out_size,
  const uint8_t *data, int size)
 {
 GetBitContext gb;
-int res, profile, keyframe;
+int res, profile, keyframe, invisible, errorres;
 
 *out_data = data;
 *out_size = size;
@@ -42,21 +96,63 @@ static int parse(AVCodecParserContext *ctx,
 profile  = get_bits1(&gb);
 profile |= get_bits1(&gb) << 1;
 if (profile == 3) profile += get_bits1(&gb);
+if (profile > 3)
+return size;
 
 if (get_bits1(&gb)) {
 keyframe = 0;
+skip_bits(&gb, 3);
 } else {
 keyframe  = !get_bits1(&gb);
 }
 
+invisible = !get_bits1(&gb);
+errorres  = get_bits1(&gb);
+
 if (!keyframe) {
+int intraonly = invisible ? get_bits1(&gb) : 0;
+if (!errorres)
+skip_bits(&gb, 2);
+if (intraonly) {
+if (get_bits_long(&gb, 24) != VP9_SYNCCODE) // synccode
+return size;
+avctx->profile = profile;
+if (profile >= 1) {
+if ((read_colorspace_details(ctx, avctx, &gb)) < 0)
+return size;
+} else {
+ctx->format= AV_PIX_FMT_YUV420P;
+avctx->colorspace  = AVCOL_SPC_BT470BG;
+avctx->color_range = AVCOL_RANGE_MPEG;
+}
+skip_bits(&gb, 8); // refreshrefmask
+ctx->width  = get_bits(&gb, 16) + 1;
+ctx->height = get_bits(&gb, 16) + 1;
+if (get_bits1(&gb)) // display size
+skip_bits(&gb, 32);
+}
+
 ctx->pict_type = AV_PICTURE_TYPE_P;
 ctx->key_frame = 0;
 } else {
+if (get_bits_long(&gb, 24) != VP9_SYNCCODE) // synccode
+return size;
+avctx->profile = profile;
+if (read_colorspace_details(ctx, avctx, &gb) < 0)
+return size;
+ctx->width  = get_bits(&gb, 16) + 1;
+ctx->height = get_bits(&gb, 16) + 1;
+if (get_bits1(&gb)) // display size
+skip_bits(&gb, 32);
+
 ctx->pict_type = AV_PICTURE_TYPE_I;
 ctx->key_frame = 1;
 }
 

Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Dont write stream info for agroup

2018-01-18 Thread 刘歧

> On 19 Jan 2018, at 11:18, Jeyapal, Karthick  wrote:
> 
> 
> 
> On 1/19/18 8:42 AM, Brendan McGrath wrote:
>> Thanks Karthick - I can confirm that your patch does solve the issue.
> Thanks for the confirmation.
>> 
>> However - I noticed your patch does not include HEVC. I believe this format 
>> is now supported in HLS (and that several players including iOS 11 now 
>> provide support).
> Yes, I just supported H264 since I was working on it. But that patch is 
> modular enough to easily extend CODECS tag support for HEVC. 
> Maybe somebody can add the HEVC support in CODECS tag later :)
Can you add it into the patch, so that will be perfect :D
>> 
>> On 19/01/18 00:41, Jeyapal, Karthick wrote:
>>> On 1/18/18 6:53 PM, Brendan McGrath wrote:
 I tried your suggestion and it still didn't work. So I took another look 
 at the spec and it looks like what was originally there was correct (as 
 seen in the below example):
 https://tools.ietf.org/html/rfc8216#section-8.6
 
 In that example - english-audio.m3u8 appears in both a MEDIA and 
 STREAM-INF entry with the STREAM-INF entry including an AUDIO tag that 
 references back to itself.
 
 So I believe this patch can be dropped.
 
 What I did discover was that it worked when I added a CODECS tag to the 
 STREAM-INF variant of the audio stream. The spec just says:
 Every EXT-X-STREAM-INF tag SHOULD include a CODECS attribute
 
 So I guess this is a bug in iOS.
>>> I agree. But, there is a patch available 
>>> https://patchwork.ffmpeg.org/patch/7000/ to add CODECS tag. 
>>> You could check if applying that patch solves your issue. 
 On 18/01/18 21:59, Dixit, Vishwanath wrote:
> On 1/18/18 2:39 PM, Brendan McGrath wrote:
>> When using an 'agroup' within var_stream_map - the audio stream is
>> being added to the master playlist file as both an audio rendition
>> and an individual stream (with an AUDIO reference back to itself).
>> 
>> This patch ensures an audio rendition does not also appear within
>> the stream info list.
>> 
>> What follows is an example of the command to create this issue and
>> the contents of the master playlist before and after this patch is
>> applied:
>> 
>> ffmpeg -i in.ts -b:a:0 128k -b:v:0 1800k -b:v:1 1024k -map 0:a \
>> -map 0:v -map 0:v -f hls -var_stream_map "a:0,agroup:audio_0 "\
>> "v:0,agroup:audio_0 v:1,agroup:audio_0" -master_pl_name \
>> tv_hls.m3u8 tv_hls_%v.m3u8
>> 
>> Before:
>>  #EXTM3U
>>  #EXT-X-VERSION:3
>>  
>> #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
>>  #EXT-X-STREAM-INF:BANDWIDTH=140800,AUDIO="group_audio_0"
>>  tv_hls_0.m3u8
>> 
>>  
>> #EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
>>  tv_hls_1.m3u8
>> 
>>  
>> #EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
>>  tv_hls_2.m3u8
>> 
>> After:
>>  #EXTM3U
>>  #EXT-X-VERSION:3
>>  
>> #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
>>  
>> #EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
>>  tv_hls_1.m3u8
>> 
>>  
>> #EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
>>  tv_hls_2.m3u8
>> 
>> Signed-off-by: Brendan McGrath 
>> ---
>> 
> Some use cases may need audio only variant streams. Ex: when bandwidth is 
> too low. Also, I think the playback issue you are seeing, is because of 
> AUDIO referencing back to itself, but, not because of audio only variant 
> stream. So, instead of completely removing the audio only variant 
> streams, you can just remove the self-referencing attribute (AUDIO=) from 
> the #EXT-X-STREAM-INF tag’s attribute list, for the audio only variant 
> streams.
> #EXTM3U
> #EXT-X-VERSION:3
> #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
> #EXT-X-STREAM-INF:BANDWIDTH=140800
> tv_hls_0.m3u8
> 
> #EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
> tv_hls_1.m3u8
> 
> #EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
> tv_hls_2.m3u8
> 
> 
>> Pre-patch - the hls stream I was testing would not play on the iOS 
>> devices I was testing with.
>> 
>> With the patch applied - they now play the stream
>> 
>>  libavformat/hlsenc.c | 3 +++
>>  1 file changed, 3 insertions(+)
>> 
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index e36120c..a75853b 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -1172,6 +1172,9 @@ static int create_master_playlist(AVFormatContext 
>> *s,
>>  for (i = 0; i < hls-

Re: [FFmpeg-devel] [PATCH V2 2/2] Don't overwrite previously setup dimensions for all codecs

2018-01-18 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Carl Eugen Hoyos
> Sent: Thursday, January 18, 2018 5:26 PM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH V2 2/2] Don't overwrite previously setup
> dimensions for all codecs
> 
> 2018-01-18 6:03 GMT+01:00 Zhong Li :
> > Currently a hacky way is used for some specific codecs such as
> > H264/VP6F/DXV
> 
> > (and "lowres" case is broken now).
> 
> How can I reproduce this?

Just infer from the code. The logic is different between H264/VP6F/DXV and 
non-H264/VP6F/DXV if lowres is enable.
(Maybe there is somewhere else to handle H264/VP6F/DXV lowres cases and make it 
work as expectation?)
Please correct me if I am wrong and I am happy to update the commit message.
BTW, there is a typo in the patch (lowles->lowres). Fixed locally but forgot to 
submit : (. 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] lavc: Add coded_w/h to AVCodecParameters

2018-01-18 Thread Li, Zhong
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of James Almer
> Sent: Thursday, January 18, 2018 1:15 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH 1/2] lavc: Add coded_w/h to
> AVCodecParameters
> 
> On 1/18/2018 2:03 AM, Zhong Li wrote:
> > coded_width/height may be different from width/height sometimes
> 
> > (e.g, crop or lowres cases).
> 
> Which is why it's not a field that belongs to AVCodecParameters.
> 
> Codec level cropping has nothing to do with containers. Same with lowres,
> which is an internal feature, and scheduled for removal.

Got it. How about fixing ticket #6958 as below? 

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 0e7a771..233760d 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2512,10 +2512,12 @@ static int show_stream(WriterContext *w, 
AVFormatContext *fmt_ctx, int stream_id
 case AVMEDIA_TYPE_VIDEO:
 print_int("width",par->width);
 print_int("height",   par->height);
+#if FF_API_LAVF_AVCTX
 if (dec_ctx) {
 print_int("coded_width",  dec_ctx->coded_width);
 print_int("coded_height", dec_ctx->coded_height);
 }
+#endif
 print_int("has_b_frames", par->video_delay);
 sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
 if (sar.den) {
@@ -2912,6 +2914,10 @@ static int open_input_file(InputFile *ifile, const char 
*filename)

 ist->dec_ctx->pkt_timebase = stream->time_base;
 ist->dec_ctx->framerate = stream->avg_frame_rate;
+#if FF_API_LAVF_AVCTX
+ist->dec_ctx->coded_width = stream->codec->coded_width;
+ist->dec_ctx->coded_height = stream->codec->coded_height;
+#endif

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


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Dont write stream info for agroup

2018-01-18 Thread Jeyapal, Karthick


On 1/19/18 8:42 AM, Brendan McGrath wrote:
> Thanks Karthick - I can confirm that your patch does solve the issue.
Thanks for the confirmation.
>
> However - I noticed your patch does not include HEVC. I believe this format 
> is now supported in HLS (and that several players including iOS 11 now 
> provide support).
Yes, I just supported H264 since I was working on it. But that patch is modular 
enough to easily extend CODECS tag support for HEVC. 
Maybe somebody can add the HEVC support in CODECS tag later :)
>
> On 19/01/18 00:41, Jeyapal, Karthick wrote:
>> On 1/18/18 6:53 PM, Brendan McGrath wrote:
>>> I tried your suggestion and it still didn't work. So I took another look at 
>>> the spec and it looks like what was originally there was correct (as seen 
>>> in the below example):
>>> https://tools.ietf.org/html/rfc8216#section-8.6
>>>
>>> In that example - english-audio.m3u8 appears in both a MEDIA and STREAM-INF 
>>> entry with the STREAM-INF entry including an AUDIO tag that references back 
>>> to itself.
>>>
>>> So I believe this patch can be dropped.
>>>
>>> What I did discover was that it worked when I added a CODECS tag to the 
>>> STREAM-INF variant of the audio stream. The spec just says:
>>> Every EXT-X-STREAM-INF tag SHOULD include a CODECS attribute
>>>
>>> So I guess this is a bug in iOS.
>> I agree. But, there is a patch available 
>> https://patchwork.ffmpeg.org/patch/7000/ to add CODECS tag. 
>> You could check if applying that patch solves your issue. 
>>> On 18/01/18 21:59, Dixit, Vishwanath wrote:
 On 1/18/18 2:39 PM, Brendan McGrath wrote:
> When using an 'agroup' within var_stream_map - the audio stream is
> being added to the master playlist file as both an audio rendition
> and an individual stream (with an AUDIO reference back to itself).
>
> This patch ensures an audio rendition does not also appear within
> the stream info list.
>
> What follows is an example of the command to create this issue and
> the contents of the master playlist before and after this patch is
> applied:
>
> ffmpeg -i in.ts -b:a:0 128k -b:v:0 1800k -b:v:1 1024k -map 0:a \
> -map 0:v -map 0:v -f hls -var_stream_map "a:0,agroup:audio_0 "\
> "v:0,agroup:audio_0 v:1,agroup:audio_0" -master_pl_name \
> tv_hls.m3u8 tv_hls_%v.m3u8
>
> Before:
>   #EXTM3U
>   #EXT-X-VERSION:3
>   
> #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
>   #EXT-X-STREAM-INF:BANDWIDTH=140800,AUDIO="group_audio_0"
>   tv_hls_0.m3u8
>
>   
> #EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
>   tv_hls_1.m3u8
>
>   
> #EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
>   tv_hls_2.m3u8
>
> After:
>   #EXTM3U
>   #EXT-X-VERSION:3
>   
> #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
>   
> #EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
>   tv_hls_1.m3u8
>
>   
> #EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
>   tv_hls_2.m3u8
>
> Signed-off-by: Brendan McGrath 
> ---
>
 Some use cases may need audio only variant streams. Ex: when bandwidth is 
 too low. Also, I think the playback issue you are seeing, is because of 
 AUDIO referencing back to itself, but, not because of audio only variant 
 stream. So, instead of completely removing the audio only variant streams, 
 you can just remove the self-referencing attribute (AUDIO=) from the 
 #EXT-X-STREAM-INF tag’s attribute list, for the audio only variant streams.
 #EXTM3U
 #EXT-X-VERSION:3
 #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
 #EXT-X-STREAM-INF:BANDWIDTH=140800
 tv_hls_0.m3u8

 #EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
 tv_hls_1.m3u8

 #EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
 tv_hls_2.m3u8


> Pre-patch - the hls stream I was testing would not play on the iOS 
> devices I was testing with.
>
> With the patch applied - they now play the stream
>
>   libavformat/hlsenc.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index e36120c..a75853b 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1172,6 +1172,9 @@ static int create_master_playlist(AVFormatContext 
> *s,
>   for (i = 0; i < hls->nb_varstreams; i++) {
>   vs = &(hls->var_streams[i]);
>   +if (!vs->has_video && !vs->has_subtitle && vs->agroup)
> +continue;
> +
>   m3u8_name_size = strlen(vs->m3u8_name) + 1;
>  

Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Dont write stream info for agroup

2018-01-18 Thread Brendan McGrath

Thanks Karthick - I can confirm that your patch does solve the issue.

However - I noticed your patch does not include HEVC. I believe this 
format is now supported in HLS (and that several players including iOS 
11 now provide support).


On 19/01/18 00:41, Jeyapal, Karthick wrote:

On 1/18/18 6:53 PM, Brendan McGrath wrote:

I tried your suggestion and it still didn't work. So I took another look at the 
spec and it looks like what was originally there was correct (as seen in the 
below example):
https://tools.ietf.org/html/rfc8216#section-8.6

In that example - english-audio.m3u8 appears in both a MEDIA and STREAM-INF 
entry with the STREAM-INF entry including an AUDIO tag that references back to 
itself.

So I believe this patch can be dropped.

What I did discover was that it worked when I added a CODECS tag to the 
STREAM-INF variant of the audio stream. The spec just says:
Every EXT-X-STREAM-INF tag SHOULD include a CODECS attribute

So I guess this is a bug in iOS.

I agree. But, there is a patch 
availablehttps://patchwork.ffmpeg.org/patch/7000/  to add CODECS tag.
You could check if applying that patch solves your issue.

On 18/01/18 21:59, Dixit, Vishwanath wrote:

On 1/18/18 2:39 PM, Brendan McGrath wrote:

When using an 'agroup' within var_stream_map - the audio stream is
being added to the master playlist file as both an audio rendition
and an individual stream (with an AUDIO reference back to itself).

This patch ensures an audio rendition does not also appear within
the stream info list.

What follows is an example of the command to create this issue and
the contents of the master playlist before and after this patch is
applied:

ffmpeg -i in.ts -b:a:0 128k -b:v:0 1800k -b:v:1 1024k -map 0:a \
-map 0:v -map 0:v -f hls -var_stream_map "a:0,agroup:audio_0 "\
"v:0,agroup:audio_0 v:1,agroup:audio_0" -master_pl_name \
tv_hls.m3u8 tv_hls_%v.m3u8

Before:
   #EXTM3U
   #EXT-X-VERSION:3
   
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
   #EXT-X-STREAM-INF:BANDWIDTH=140800,AUDIO="group_audio_0"
   tv_hls_0.m3u8

   
#EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
   tv_hls_1.m3u8

   
#EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
   tv_hls_2.m3u8

After:
   #EXTM3U
   #EXT-X-VERSION:3
   
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
   
#EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
   tv_hls_1.m3u8

   
#EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
   tv_hls_2.m3u8

Signed-off-by: Brendan McGrath
---


Some use cases may need audio only variant streams. Ex: when bandwidth is too 
low. Also, I think the playback issue you are seeing, is because of AUDIO 
referencing back to itself, but, not because of audio only variant stream. So, 
instead of completely removing the audio only variant streams, you can just 
remove the self-referencing attribute (AUDIO=) from the #EXT-X-STREAM-INF tag’s 
attribute list, for the audio only variant streams.
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=140800
tv_hls_0.m3u8

#EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
tv_hls_1.m3u8

#EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
tv_hls_2.m3u8



Pre-patch - the hls stream I was testing would not play on the iOS devices I 
was testing with.

With the patch applied - they now play the stream

   libavformat/hlsenc.c | 3 +++
   1 file changed, 3 insertions(+)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index e36120c..a75853b 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1172,6 +1172,9 @@ static int create_master_playlist(AVFormatContext *s,
   for (i = 0; i < hls->nb_varstreams; i++) {
   vs = &(hls->var_streams[i]);
   +if (!vs->has_video && !vs->has_subtitle && vs->agroup)
+continue;
+
   m3u8_name_size = strlen(vs->m3u8_name) + 1;
   m3u8_rel_name = av_malloc(m3u8_name_size);
   if (!m3u8_rel_name) {

___
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 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 2/2] example/vaapi_transcode: Add a VA-API transcode example.

2018-01-18 Thread Mark Thompson
On 11/01/18 07:07, Jun Zhao wrote:
> From b76a2f790814df326d7d93c54b14b3c8e74ab759 Mon Sep 17 00:00:00 2001
> From: Jun Zhao 
> Date: Thu, 11 Jan 2018 15:00:30 +0800
> Subject: [PATCH 2/2] example/vaapi_transcode: Add a VA-API transcode example.
> 
> Add VA-API transcoding example, useage like:
> ./vaapi_transcode input_stream h264_vaapi output_stream
> 
> Signed-off-by: Jun Zhao 
> Signed-off-by: Liu, Kaixuan 
> ---
>  configure  |   2 +
>  doc/examples/Makefile  |   1 +
>  doc/examples/vaapi_transcode.c | 256 
> +
>  3 files changed, 259 insertions(+)
>  create mode 100644 doc/examples/vaapi_transcode.c
> 
> diff --git a/configure b/configure
> index b8985ba542..6d08c0fbbb 100755
> --- a/configure
> +++ b/configure
> @@ -1526,6 +1526,7 @@ EXAMPLE_LIST="
>  transcode_aac_example
>  transcoding_example
>  vaapi_encode_example
> +vaapi_transcode_example
>  "
>  
>  EXTERNAL_AUTODETECT_LIBRARY_LIST="
> @@ -3319,6 +3320,7 @@ scaling_video_example_deps="avutil swscale"
>  transcode_aac_example_deps="avcodec avformat swresample"
>  transcoding_example_deps="avfilter avcodec avformat avutil"
>  vaapi_encode_example_deps="avcodec avutil"
> +vaapi_transcode_example_deps="avcodec avformat avutil"
>  
>  # EXTRALIBS_LIST
>  cpu_init_extralibs="pthreads_extralibs"
> diff --git a/doc/examples/Makefile b/doc/examples/Makefile
> index da5af36532..928ff306b3 100644
> --- a/doc/examples/Makefile
> +++ b/doc/examples/Makefile
> @@ -20,6 +20,7 @@ EXAMPLES-$(CONFIG_SCALING_VIDEO_EXAMPLE) += 
> scaling_video
>  EXAMPLES-$(CONFIG_TRANSCODE_AAC_EXAMPLE) += transcode_aac
>  EXAMPLES-$(CONFIG_TRANSCODING_EXAMPLE)   += transcoding
>  EXAMPLES-$(CONFIG_VAAPI_ENCODE_EXAMPLE)  += vaapi_encode
> +EXAMPLES-$(CONFIG_VAAPI_TRANSCODE_EXAMPLE)   += vaapi_transcode
>  
>  EXAMPLES   := $(EXAMPLES-yes:%=doc/examples/%$(PROGSSUF)$(EXESUF))
>  EXAMPLES_G := $(EXAMPLES-yes:%=doc/examples/%$(PROGSSUF)_g$(EXESUF))
> diff --git a/doc/examples/vaapi_transcode.c b/doc/examples/vaapi_transcode.c
> new file mode 100644
> index 00..b92a387f2f
> --- /dev/null
> +++ b/doc/examples/vaapi_transcode.c
> @@ -0,0 +1,256 @@
> +/*
> + * Video Acceleration API (video transcoding) transcode sample
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +/**
> + * @file
> + * Intel VAAPI-accelerated transcoding example.
> + *
> + * @example vaapi_transcode.c
> + * This example shows how to do VAAPI-accelerated transcoding.
> + * Usage: vaapi_transcode input_stream h264_vaapi output_stream
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +static AVFormatContext *ifmt_ctx = NULL;
> +static AVBufferRef *hw_device_ctx = NULL;
> +static AVCodecContext *decoder_ctx = NULL, *encoder_ctx = NULL;
> +static int video_stream = -1;
> +static FILE *fout;
> +static int initialized = 0;
> +
> +static enum AVPixelFormat get_vaapi_format(AVCodecContext *ctx,
> +   const enum AVPixelFormat 
> *pix_fmts)
> +{
> +const enum AVPixelFormat *p;
> +
> +for (p = pix_fmts; *p != -1; p++) {

AV_PIX_FMT_NONE would be clearer than -1 here.

> +if (*p == AV_PIX_FMT_VAAPI)
> +return *p;
> +}
> +
> +fprintf(stderr, "Failed to get vaapi pix format\n");

Maybe something like "Unable to decode this file using VAAPI", since that's 
what it actually means (the decoder didn't offer the VAAPI output format).

> +return AV_PIX_FMT_NONE;
> +}
> +
> +static int open_input_file(const char *filename)
> +{
> +int ret;
> +AVCodec *decoder = NULL;
> +AVStream *video = NULL;
> +
> +if ((ret = avformat_open_input(&ifmt_ctx, filename, NULL, NULL)) < 0) {
> +fprintf(stderr, "Cannot open input file '%s', Error code: %s\n",
> +filename, av_err2str(ret));
> +return ret;
> +}
> +
> +if ((ret = avformat_find_stream_info(ifmt_ctx, NULL)) < 0) {
> +fprintf(stderr, "Cannot find input stream information. Error code: 
> %s\n",
> +av_err2str(ret));
> +return ret;
> +}
> +
> +ret = av_find_best_stream(ifmt_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, 
> 

Re: [FFmpeg-devel] [PATCH] lavfi/vf_scale_vaapi: set output SAR

2018-01-18 Thread Mark Thompson
On 13/01/18 01:08, Rodger Combs wrote:
> ---
>  libavfilter/vf_scale_vaapi.c | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/libavfilter/vf_scale_vaapi.c b/libavfilter/vf_scale_vaapi.c
> index 22e928c..4bead5a 100644
> --- a/libavfilter/vf_scale_vaapi.c
> +++ b/libavfilter/vf_scale_vaapi.c
> @@ -240,6 +240,11 @@ static int scale_vaapi_config_output(AVFilterLink 
> *outlink)
>  goto fail;
>  }
>  
> +if (inlink->sample_aspect_ratio.num)
> +outlink->sample_aspect_ratio = av_mul_q((AVRational){outlink->h * 
> inlink->w, outlink->w * inlink->h}, inlink->sample_aspect_ratio);
> +else
> +outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
> +
>  av_freep(&hwconfig);
>  av_hwframe_constraints_free(&constraints);
>  return 0;
> 

Tested, LGTM.

Thanks,

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


Re: [FFmpeg-devel] [PATCH] Fix float-cast-overflow undefined behavior in matroskadec

2018-01-18 Thread Niki Bowe
In the file the fuzzer produced the frame rate is incredibly small
(7.29112e-304).
I thought %e (or %g if you prefer) produced the most appropriate and
readable log message.
Also happy to just remove the frame rate from the log if you prefer?

On Thu, Jan 18, 2018 at 4:02 PM, Carl Eugen Hoyos 
wrote:

> 2018-01-19 0:21 GMT+01:00 Nikolas Bowe :
>
> > +  av_log(matroska->ctx, AV_LOG_WARNING,
> > + "Invalid frame rate %e. Cannot calculate
> default duration.\n",
> > + track->video.frame_rate);
>
> We currently have one ocurence of "%e" in the whole codebase
> and it is usually not compiled: Can you use %f here or would that
> be a disadvantage?
>
> Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>



-- 

Nikolas Bowe |  SWE |  nb...@google.com |  408-565-5137
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH V3 2/6] lavfi: use common VPP infrastructure for vf_scale_vaapi.

2018-01-18 Thread Mark Thompson
On 19/01/18 00:41, Jun Zhao wrote:
> On 2018/1/19 8:25, Mark Thompson wrote:
>> On 18/01/18 05:18, Jun Zhao wrote:
>>> From d157fdbffebd07066b1a857398e1067615f908b3 Mon Sep 17 00:00:00 2001
>>> From: Jun Zhao 
>>> Date: Mon, 8 Jan 2018 16:02:35 +0800
>>> Subject: [PATCH V3 2/6] lavfi: use common VPP infrastructure for
>>>  vf_scale_vaapi.
>>>
>>> Use the common VPP infrastructure re-work vf_scale_vaapi.
>>>
>>> Signed-off-by: Jun Zhao 
>>> ---
>>>  libavfilter/Makefile |   2 +-
>>>  libavfilter/vf_scale_vaapi.c | 353 
>>> +--
>>>  2 files changed, 41 insertions(+), 314 deletions(-)
>>>
>>> ...
>>>  
>>>  static av_cold int scale_vaapi_init(AVFilterContext *avctx)
>>>  {
>>> -ScaleVAAPIContext *ctx = avctx->priv;
>>> +VAAPIVPPContext *vpp_ctx = avctx->priv;
>>> +ScaleVAAPIContext *ctx   = (ScaleVAAPIContext *)vpp_ctx->priv_data;
>> The extra indirection means this is reading ctx before it's set.  E.g. try:
>>
>> $ gdb --args ./ffmpeg_g -y -hwaccel vaapi -hwaccel_device 
>> /dev/dri/renderD129 -hwaccel_output_format vaapi -i input.mp4 -vf 
>> 'scale_vaapi=format=invalid' -f null -
>> ...
>> Thread 1 "ffmpeg_g" received signal SIGSEGV, Segmentation fault.
>> 0x56927515 in format_line (avcl=0x5843b950, level=16, 
>> fmt=0x56984f69 "Invalid output format.\n", vl=0x7fffcfb0, 
>> part=0x7fffbf20, print_prefix=0x5708c708 , 
>> type=0x7fffbb18) at src/libavutil/log.c:258
>> 258 AVClass** parent = *(AVClass ***) (((uint8_t *) avcl) +
>> (gdb) bt
>> #0  0x56927515 in format_line (avcl=0x5843b950, level=16, 
>> fmt=0x56984f69 "Invalid output format.\n", vl=0x7fffcfb0, 
>> part=0x7fffbf20, print_prefix=0x5708c708 , 
>> type=0x7fffbb18) at src/libavutil/log.c:258
>> #1  0x569278da in av_log_default_callback (ptr=0x5843b950, 
>> level=16, fmt=0x56984f69 "Invalid output format.\n", vl=0x7fffcfb0) 
>> at src/libavutil/log.c:320
>> #2  0x56927d05 in av_vlog (avcl=0x5843b950, level=16, 
>> fmt=0x56984f69 "Invalid output format.\n", vl=0x7fffcfb0) at 
>> src/libavutil/log.c:377
>> #3  0x56927cc4 in av_log (avcl=0x5843b950, level=16, 
>> fmt=0x56984f69 "Invalid output format.\n") at src/libavutil/log.c:369
>> #4  0x55844bac in scale_vaapi_init (avctx=0x5836ad80) at 
>> src/libavfilter/vf_scale_vaapi.c:151
>>
>>
>> I still think having VAAPIVPPContext as the first element of 
>> ScaleVAAPIContext would be cleaner.
>>
> This issue have been fix in local, if we put VAAPIVPPContext as the
> first element of ScaleVAAPIContex, I can't find a way to reuse VPP
> common APP.
> 
> e,g, for: scale_vaapi_vpp_config_input, need to implement as: (the first
> version )
> 
>  
>  static int scale_vaapi_config_input(AVFilterLink *inlink)
>  {
>  AVFilterContext *avctx = inlink->dst;
>  ScaleVAAPIContext *ctx = avctx->priv;
> VAAPIVPPContext *vpp_ctx = ctx->vpp_ctx;  return 
> vaapi_vpp_config_input(inlink, vpp_ctx);
>  } 

No, you don't need this function - it's completely equivalent to calling 
ff_vaapi_vpp_context_input() directly in what you currently have, because 
avctx->priv is a pointer to both the ScaleVAAPIContext and its first member 
which is the VAAPIVPPContext.

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


Re: [FFmpeg-devel] [PATCH V3 4/6] lavfi: add ProcAmp(color balance) vaapi video filter.

2018-01-18 Thread Jun Zhao


On 2018/1/19 8:33, Mark Thompson wrote:
> On 18/01/18 05:18, Jun Zhao wrote:
>> From 795fc41a83c23ff461fef1870a003d77b070084f Mon Sep 17 00:00:00 2001
>> From: Jun Zhao 
>> Date: Mon, 8 Jan 2018 16:12:41 +0800
>> Subject: [PATCH V3 4/6] lavfi: add ProcAmp(color balance) vaapi video filter.
>>
>> add ProcAmp(color balance) vaapi video filter, use the option
>> like -vf "procamp_vaapi=b=10:h=120:c=2.8:s=3.7" to set
>> brightness/hue/contrast/saturation.
>>
>> Signed-off-by: Yun Zhou 
>> Signed-off-by: Jun Zhao 
>> ---
>>  configure  |   1 +
>>  libavfilter/Makefile   |   1 +
>>  libavfilter/allfilters.c   |   1 +
>>  libavfilter/vf_procamp_vaapi.c | 227 
>> +
>>  4 files changed, 230 insertions(+)
>>  create mode 100644 libavfilter/vf_procamp_vaapi.c
>>
>> diff --git a/configure b/configure
>> index 5d533621ae..12fb34a202 100755
>> --- a/configure
>> +++ b/configure
>> @@ -3245,6 +3245,7 @@ perspective_filter_deps="gpl"
>>  phase_filter_deps="gpl"
>>  pp7_filter_deps="gpl"
>>  pp_filter_deps="gpl postproc"
>> +procamp_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer"
>>  program_opencl_filter_deps="opencl"
>>  pullup_filter_deps="gpl"
>>  removelogo_filter_deps="avcodec avformat swscale"
>> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
>> index bbc97a0831..43d0dd36e6 100644
>> --- a/libavfilter/Makefile
>> +++ b/libavfilter/Makefile
>> @@ -275,6 +275,7 @@ OBJS-$(CONFIG_PP_FILTER) += vf_pp.o
>>  OBJS-$(CONFIG_PP7_FILTER)+= vf_pp7.o
>>  OBJS-$(CONFIG_PREMULTIPLY_FILTER)+= vf_premultiply.o framesync.o
>>  OBJS-$(CONFIG_PREWITT_FILTER)+= vf_convolution.o
>> +OBJS-$(CONFIG_PROCAMP_VAAPI_FILTER)  += vf_procamp_vaapi.o 
>> vaapi_vpp.o
>>  OBJS-$(CONFIG_PROGRAM_OPENCL_FILTER) += vf_program_opencl.o 
>> opencl.o framesync.o
>>  OBJS-$(CONFIG_PSEUDOCOLOR_FILTER)+= vf_pseudocolor.o
>>  OBJS-$(CONFIG_PSNR_FILTER)   += vf_psnr.o framesync.o
>> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
>> index 42516bbdf9..63550628e5 100644
>> --- a/libavfilter/allfilters.c
>> +++ b/libavfilter/allfilters.c
>> @@ -284,6 +284,7 @@ static void register_all(void)
>>  REGISTER_FILTER(PP7,pp7,vf);
>>  REGISTER_FILTER(PREMULTIPLY,premultiply,vf);
>>  REGISTER_FILTER(PREWITT,prewitt,vf);
>> +REGISTER_FILTER(PROCAMP_VAAPI,  procamp_vaapi,  vf);
>>  REGISTER_FILTER(PROGRAM_OPENCL, program_opencl, vf);
>>  REGISTER_FILTER(PSEUDOCOLOR,pseudocolor,vf);
>>  REGISTER_FILTER(PSNR,   psnr,   vf);
>> diff --git a/libavfilter/vf_procamp_vaapi.c b/libavfilter/vf_procamp_vaapi.c
>> new file mode 100644
>> index 00..2d6c45366f
>> --- /dev/null
>> +++ b/libavfilter/vf_procamp_vaapi.c
>> @@ -0,0 +1,227 @@
>> +/*
>> + * 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/avassert.h"
>> +#include "libavutil/mem.h"
>> +#include "libavutil/opt.h"
>> +#include "libavutil/pixdesc.h"
>> +
>> +#include "avfilter.h"
>> +#include "formats.h"
>> +#include "internal.h"
>> +#include "vaapi_vpp.h"
>> +
>> +typedef struct ProcampVAAPIContext {
>> +float bright;
>> +float hue;
>> +float saturation;
>> +float contrast;
>> +} ProcampVAAPIContext;
>> +
>> +static int procamp_vaapi_build_filter_params(AVFilterContext *avctx)
>> +{
>> +VAAPIVPPContext *vpp_ctx = avctx->priv;
>> +ProcampVAAPIContext *ctx = vpp_ctx->priv;
>> +VAStatus vas;
>> +VAProcFilterParameterBufferColorBalance procamp_params[4];
>> +VAProcFilterCapColorBalance procamp_caps[VAProcColorBalanceCount];
>> +int num_caps;
>> +
>> +memset(&procamp_params, 0, sizeof(procamp_params));
>> +memset(&procamp_caps, 0, sizeof(procamp_caps));
>> +
>> +num_caps = VAProcColorBalanceCount;
>> +vas = vaQueryVideoProcFilterCaps(vpp_ctx->hwctx->display, 
>> vpp_ctx->va_context,
>> + VAProcFilterColorBalance, 
>> &procamp_caps, &num_caps);
>> +
>> +if (vas != VA_STATUS_SUCCESS) {
>> +av_log(avctx, AV_LOG_ERR

Re: [FFmpeg-devel] [PATCH V3 2/6] lavfi: use common VPP infrastructure for vf_scale_vaapi.

2018-01-18 Thread Jun Zhao


On 2018/1/19 8:25, Mark Thompson wrote:
> On 18/01/18 05:18, Jun Zhao wrote:
>> From d157fdbffebd07066b1a857398e1067615f908b3 Mon Sep 17 00:00:00 2001
>> From: Jun Zhao 
>> Date: Mon, 8 Jan 2018 16:02:35 +0800
>> Subject: [PATCH V3 2/6] lavfi: use common VPP infrastructure for
>>  vf_scale_vaapi.
>>
>> Use the common VPP infrastructure re-work vf_scale_vaapi.
>>
>> Signed-off-by: Jun Zhao 
>> ---
>>  libavfilter/Makefile |   2 +-
>>  libavfilter/vf_scale_vaapi.c | 353 
>> +--
>>  2 files changed, 41 insertions(+), 314 deletions(-)
>>
>> ...
>>  
>>  static av_cold int scale_vaapi_init(AVFilterContext *avctx)
>>  {
>> -ScaleVAAPIContext *ctx = avctx->priv;
>> +VAAPIVPPContext *vpp_ctx = avctx->priv;
>> +ScaleVAAPIContext *ctx   = (ScaleVAAPIContext *)vpp_ctx->priv_data;
> The extra indirection means this is reading ctx before it's set.  E.g. try:
>
> $ gdb --args ./ffmpeg_g -y -hwaccel vaapi -hwaccel_device /dev/dri/renderD129 
> -hwaccel_output_format vaapi -i input.mp4 -vf 'scale_vaapi=format=invalid' -f 
> null -
> ...
> Thread 1 "ffmpeg_g" received signal SIGSEGV, Segmentation fault.
> 0x56927515 in format_line (avcl=0x5843b950, level=16, 
> fmt=0x56984f69 "Invalid output format.\n", vl=0x7fffcfb0, 
> part=0x7fffbf20, print_prefix=0x5708c708 , 
> type=0x7fffbb18) at src/libavutil/log.c:258
> 258 AVClass** parent = *(AVClass ***) (((uint8_t *) avcl) +
> (gdb) bt
> #0  0x56927515 in format_line (avcl=0x5843b950, level=16, 
> fmt=0x56984f69 "Invalid output format.\n", vl=0x7fffcfb0, 
> part=0x7fffbf20, print_prefix=0x5708c708 , 
> type=0x7fffbb18) at src/libavutil/log.c:258
> #1  0x569278da in av_log_default_callback (ptr=0x5843b950, 
> level=16, fmt=0x56984f69 "Invalid output format.\n", vl=0x7fffcfb0) 
> at src/libavutil/log.c:320
> #2  0x56927d05 in av_vlog (avcl=0x5843b950, level=16, 
> fmt=0x56984f69 "Invalid output format.\n", vl=0x7fffcfb0) at 
> src/libavutil/log.c:377
> #3  0x56927cc4 in av_log (avcl=0x5843b950, level=16, 
> fmt=0x56984f69 "Invalid output format.\n") at src/libavutil/log.c:369
> #4  0x55844bac in scale_vaapi_init (avctx=0x5836ad80) at 
> src/libavfilter/vf_scale_vaapi.c:151
>
>
> I still think having VAAPIVPPContext as the first element of 
> ScaleVAAPIContext would be cleaner.
>
This issue have been fix in local, if we put VAAPIVPPContext as the
first element of ScaleVAAPIContex, I can't find a way to reuse VPP
common APP.

e,g, for: scale_vaapi_vpp_config_input, need to implement as: (the first
version )

 
 static int scale_vaapi_config_input(AVFilterLink *inlink)
 {
 AVFilterContext *avctx = inlink->dst;
 ScaleVAAPIContext *ctx = avctx->priv;
VAAPIVPPContext *vpp_ctx = ctx->vpp_ctx;  return vaapi_vpp_config_input(inlink, 
vpp_ctx);
 } 


And I don't like this part, and I think if we use a common part
(VAAPIVPPContext) + a specific part like (ScaleVPPContext), we can get
more clean abstract.
>>  
>> -ctx->va_config  = VA_INVALID_ID;
>> -ctx->va_context = VA_INVALID_ID;
>> -ctx->valid_ids  = 1;
>> +vaapi_vpp_ctx_init(vpp_ctx);
>> +vpp_ctx->pipeline_uninit = vaapi_vpp_pipeline_uninit;
>>  
>>  if (ctx->output_format_string) {
>> -ctx->output_format = av_get_pix_fmt(ctx->output_format_string);
>> -if (ctx->output_format == AV_PIX_FMT_NONE) {
>> +vpp_ctx->output_format = av_get_pix_fmt(ctx->output_format_string);
>> +if (vpp_ctx->output_format == AV_PIX_FMT_NONE) {
>>  av_log(ctx, AV_LOG_ERROR, "Invalid output format.\n");
>>  return AVERROR(EINVAL);
>>  }
>>  } else {
>>  // Use the input format once that is configured.
>> -ctx->output_format = AV_PIX_FMT_NONE;
>> +vpp_ctx->output_format = AV_PIX_FMT_NONE;
>>  }
>>  
>>  return 0;
>>  }
>>  
>> -static av_cold void scale_vaapi_uninit(AVFilterContext *avctx)
>> -{
>> -ScaleVAAPIContext *ctx = avctx->priv;
>> -
>> -if (ctx->valid_ids)
>> -scale_vaapi_pipeline_uninit(ctx);
>> -
>> -av_buffer_unref(&ctx->input_frames_ref);
>> -av_buffer_unref(&ctx->output_frames_ref);
>> -av_buffer_unref(&ctx->device_ref);
>> -}
>> -
>> -
>> -#define OFFSET(x) offsetof(ScaleVAAPIContext, x)
>> +#define OFFSET(x) (offsetof(VAAPIVPPContext, priv_data) + \
>> +   offsetof(ScaleVAAPIContext, x))
>>  #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
>>  static const AVOption scale_vaapi_options[] = {
>>  { "w", "Output video width",
>> @@ -441,19 +172,14 @@ static const AVOption scale_vaapi_options[] = {
>>  { NULL },
>>  };
>>  
>> -static const AVClass scale_vaapi_class = {
>> -.class_name = "scale_vaapi",
>> -.item_name  = av_default_item_name,
>> -.option = scale_vaapi_options,
>> -.version= LIBAVUTIL_VERSION_INT,
>> -};
>> 

Re: [FFmpeg-devel] [PATCH V3 4/6] lavfi: add ProcAmp(color balance) vaapi video filter.

2018-01-18 Thread Mark Thompson
On 18/01/18 05:18, Jun Zhao wrote:
> 
> From 795fc41a83c23ff461fef1870a003d77b070084f Mon Sep 17 00:00:00 2001
> From: Jun Zhao 
> Date: Mon, 8 Jan 2018 16:12:41 +0800
> Subject: [PATCH V3 4/6] lavfi: add ProcAmp(color balance) vaapi video filter.
> 
> add ProcAmp(color balance) vaapi video filter, use the option
> like -vf "procamp_vaapi=b=10:h=120:c=2.8:s=3.7" to set
> brightness/hue/contrast/saturation.
> 
> Signed-off-by: Yun Zhou 
> Signed-off-by: Jun Zhao 
> ---
>  configure  |   1 +
>  libavfilter/Makefile   |   1 +
>  libavfilter/allfilters.c   |   1 +
>  libavfilter/vf_procamp_vaapi.c | 227 
> +
>  4 files changed, 230 insertions(+)
>  create mode 100644 libavfilter/vf_procamp_vaapi.c
> 
> diff --git a/configure b/configure
> index 5d533621ae..12fb34a202 100755
> --- a/configure
> +++ b/configure
> @@ -3245,6 +3245,7 @@ perspective_filter_deps="gpl"
>  phase_filter_deps="gpl"
>  pp7_filter_deps="gpl"
>  pp_filter_deps="gpl postproc"
> +procamp_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer"
>  program_opencl_filter_deps="opencl"
>  pullup_filter_deps="gpl"
>  removelogo_filter_deps="avcodec avformat swscale"
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index bbc97a0831..43d0dd36e6 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -275,6 +275,7 @@ OBJS-$(CONFIG_PP_FILTER) += vf_pp.o
>  OBJS-$(CONFIG_PP7_FILTER)+= vf_pp7.o
>  OBJS-$(CONFIG_PREMULTIPLY_FILTER)+= vf_premultiply.o framesync.o
>  OBJS-$(CONFIG_PREWITT_FILTER)+= vf_convolution.o
> +OBJS-$(CONFIG_PROCAMP_VAAPI_FILTER)  += vf_procamp_vaapi.o 
> vaapi_vpp.o
>  OBJS-$(CONFIG_PROGRAM_OPENCL_FILTER) += vf_program_opencl.o opencl.o 
> framesync.o
>  OBJS-$(CONFIG_PSEUDOCOLOR_FILTER)+= vf_pseudocolor.o
>  OBJS-$(CONFIG_PSNR_FILTER)   += vf_psnr.o framesync.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index 42516bbdf9..63550628e5 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -284,6 +284,7 @@ static void register_all(void)
>  REGISTER_FILTER(PP7,pp7,vf);
>  REGISTER_FILTER(PREMULTIPLY,premultiply,vf);
>  REGISTER_FILTER(PREWITT,prewitt,vf);
> +REGISTER_FILTER(PROCAMP_VAAPI,  procamp_vaapi,  vf);
>  REGISTER_FILTER(PROGRAM_OPENCL, program_opencl, vf);
>  REGISTER_FILTER(PSEUDOCOLOR,pseudocolor,vf);
>  REGISTER_FILTER(PSNR,   psnr,   vf);
> diff --git a/libavfilter/vf_procamp_vaapi.c b/libavfilter/vf_procamp_vaapi.c
> new file mode 100644
> index 00..2d6c45366f
> --- /dev/null
> +++ b/libavfilter/vf_procamp_vaapi.c
> @@ -0,0 +1,227 @@
> +/*
> + * 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/avassert.h"
> +#include "libavutil/mem.h"
> +#include "libavutil/opt.h"
> +#include "libavutil/pixdesc.h"
> +
> +#include "avfilter.h"
> +#include "formats.h"
> +#include "internal.h"
> +#include "vaapi_vpp.h"
> +
> +typedef struct ProcampVAAPIContext {
> +float bright;
> +float hue;
> +float saturation;
> +float contrast;
> +} ProcampVAAPIContext;
> +
> +static int procamp_vaapi_build_filter_params(AVFilterContext *avctx)
> +{
> +VAAPIVPPContext *vpp_ctx = avctx->priv;
> +ProcampVAAPIContext *ctx = vpp_ctx->priv;
> +VAStatus vas;
> +VAProcFilterParameterBufferColorBalance procamp_params[4];
> +VAProcFilterCapColorBalance procamp_caps[VAProcColorBalanceCount];
> +int num_caps;
> +
> +memset(&procamp_params, 0, sizeof(procamp_params));
> +memset(&procamp_caps, 0, sizeof(procamp_caps));
> +
> +num_caps = VAProcColorBalanceCount;
> +vas = vaQueryVideoProcFilterCaps(vpp_ctx->hwctx->display, 
> vpp_ctx->va_context,
> + VAProcFilterColorBalance, 
> &procamp_caps, &num_caps);
> +
> +if (vas != VA_STATUS_SUCCESS) {
> +av_log(avctx, AV_LOG_ERROR, "Failed to query procamp "
> +   "filter caps: %d (%s).\n", vas, vaErrorStr(vas));
> +return AVERROR(EIO);
> +}
> +
> +procamp_

Re: [FFmpeg-devel] [PATCH V3 2/6] lavfi: use common VPP infrastructure for vf_scale_vaapi.

2018-01-18 Thread Mark Thompson
On 18/01/18 05:18, Jun Zhao wrote:
> 
> From d157fdbffebd07066b1a857398e1067615f908b3 Mon Sep 17 00:00:00 2001
> From: Jun Zhao 
> Date: Mon, 8 Jan 2018 16:02:35 +0800
> Subject: [PATCH V3 2/6] lavfi: use common VPP infrastructure for
>  vf_scale_vaapi.
> 
> Use the common VPP infrastructure re-work vf_scale_vaapi.
> 
> Signed-off-by: Jun Zhao 
> ---
>  libavfilter/Makefile |   2 +-
>  libavfilter/vf_scale_vaapi.c | 353 
> +--
>  2 files changed, 41 insertions(+), 314 deletions(-)
> 
> ...
>  
>  static av_cold int scale_vaapi_init(AVFilterContext *avctx)
>  {
> -ScaleVAAPIContext *ctx = avctx->priv;
> +VAAPIVPPContext *vpp_ctx = avctx->priv;
> +ScaleVAAPIContext *ctx   = (ScaleVAAPIContext *)vpp_ctx->priv_data;

The extra indirection means this is reading ctx before it's set.  E.g. try:

$ gdb --args ./ffmpeg_g -y -hwaccel vaapi -hwaccel_device /dev/dri/renderD129 
-hwaccel_output_format vaapi -i input.mp4 -vf 'scale_vaapi=format=invalid' -f 
null -
...
Thread 1 "ffmpeg_g" received signal SIGSEGV, Segmentation fault.
0x56927515 in format_line (avcl=0x5843b950, level=16, 
fmt=0x56984f69 "Invalid output format.\n", vl=0x7fffcfb0, 
part=0x7fffbf20, print_prefix=0x5708c708 , 
type=0x7fffbb18) at src/libavutil/log.c:258
258 AVClass** parent = *(AVClass ***) (((uint8_t *) avcl) +
(gdb) bt
#0  0x56927515 in format_line (avcl=0x5843b950, level=16, 
fmt=0x56984f69 "Invalid output format.\n", vl=0x7fffcfb0, 
part=0x7fffbf20, print_prefix=0x5708c708 , 
type=0x7fffbb18) at src/libavutil/log.c:258
#1  0x569278da in av_log_default_callback (ptr=0x5843b950, 
level=16, fmt=0x56984f69 "Invalid output format.\n", vl=0x7fffcfb0) at 
src/libavutil/log.c:320
#2  0x56927d05 in av_vlog (avcl=0x5843b950, level=16, 
fmt=0x56984f69 "Invalid output format.\n", vl=0x7fffcfb0) at 
src/libavutil/log.c:377
#3  0x56927cc4 in av_log (avcl=0x5843b950, level=16, 
fmt=0x56984f69 "Invalid output format.\n") at src/libavutil/log.c:369
#4  0x55844bac in scale_vaapi_init (avctx=0x5836ad80) at 
src/libavfilter/vf_scale_vaapi.c:151


I still think having VAAPIVPPContext as the first element of ScaleVAAPIContext 
would be cleaner.


>  
> -ctx->va_config  = VA_INVALID_ID;
> -ctx->va_context = VA_INVALID_ID;
> -ctx->valid_ids  = 1;
> +vaapi_vpp_ctx_init(vpp_ctx);
> +vpp_ctx->pipeline_uninit = vaapi_vpp_pipeline_uninit;
>  
>  if (ctx->output_format_string) {
> -ctx->output_format = av_get_pix_fmt(ctx->output_format_string);
> -if (ctx->output_format == AV_PIX_FMT_NONE) {
> +vpp_ctx->output_format = av_get_pix_fmt(ctx->output_format_string);
> +if (vpp_ctx->output_format == AV_PIX_FMT_NONE) {
>  av_log(ctx, AV_LOG_ERROR, "Invalid output format.\n");
>  return AVERROR(EINVAL);
>  }
>  } else {
>  // Use the input format once that is configured.
> -ctx->output_format = AV_PIX_FMT_NONE;
> +vpp_ctx->output_format = AV_PIX_FMT_NONE;
>  }
>  
>  return 0;
>  }
>  
> -static av_cold void scale_vaapi_uninit(AVFilterContext *avctx)
> -{
> -ScaleVAAPIContext *ctx = avctx->priv;
> -
> -if (ctx->valid_ids)
> -scale_vaapi_pipeline_uninit(ctx);
> -
> -av_buffer_unref(&ctx->input_frames_ref);
> -av_buffer_unref(&ctx->output_frames_ref);
> -av_buffer_unref(&ctx->device_ref);
> -}
> -
> -
> -#define OFFSET(x) offsetof(ScaleVAAPIContext, x)
> +#define OFFSET(x) (offsetof(VAAPIVPPContext, priv_data) + \
> +   offsetof(ScaleVAAPIContext, x))
>  #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
>  static const AVOption scale_vaapi_options[] = {
>  { "w", "Output video width",
> @@ -441,19 +172,14 @@ static const AVOption scale_vaapi_options[] = {
>  { NULL },
>  };
>  
> -static const AVClass scale_vaapi_class = {
> -.class_name = "scale_vaapi",
> -.item_name  = av_default_item_name,
> -.option = scale_vaapi_options,
> -.version= LIBAVUTIL_VERSION_INT,
> -};
> +AVFILTER_DEFINE_CLASS(scale_vaapi);
>  
>  static const AVFilterPad scale_vaapi_inputs[] = {
>  {
>  .name = "default",
>  .type = AVMEDIA_TYPE_VIDEO,
>  .filter_frame = &scale_vaapi_filter_frame,
> -.config_props = &scale_vaapi_config_input,
> +.config_props = &vaapi_vpp_config_input,
>  },
>  { NULL }
>  };
> @@ -470,10 +196,11 @@ static const AVFilterPad scale_vaapi_outputs[] = {
>  AVFilter ff_vf_scale_vaapi = {
>  .name  = "scale_vaapi",
>  .description   = NULL_IF_CONFIG_SMALL("Scale to/from VAAPI surfaces."),
> -.priv_size = sizeof(ScaleVAAPIContext),
> +.priv_size = (sizeof(VAAPIVPPContext) +
> +  sizeof(ScaleVAAPIContext)),
>  .init  = &scale_vaapi_init,
> 

Re: [FFmpeg-devel] [PATCH V3 1/6] lavfi: VAAPI VPP common infrastructure.

2018-01-18 Thread Mark Thompson
On 18/01/18 05:18, Jun Zhao wrote:
> 
> V3: - Fix the error handle in vaapi_vpp.
>     - Fix the build issue and remove the duplicated header file
> - Add a entry to Changelog for procamp_vaapi filter.
>  
> V2: - Fix the resource leak in procamp/misc VPP filter.
>     - Re-work the common VAAPIVPPContext and specific VPP context part
> like VAAPIVPPContext+ScaleVAAPIContext, borrowing the idea from
> vaapi_encode.
>     - misc vpp part need to refactoring, and I don't have good idea
> about the file name for vf_misc_vaapi.c, sadly.
> 
> 
> From 826e2c10bbe107fd494912ce72aa166db49ac9db Mon Sep 17 00:00:00 2001
> From: Jun Zhao 
> Date: Mon, 8 Jan 2018 15:56:43 +0800
> Subject: [PATCH V3 1/6] lavfi: VAAPI VPP common infrastructure.
> 
> Re-work the VA-API common infrastructure.
> 
> Signed-off-by: Jun Zhao 
> ---
>  libavfilter/vaapi_vpp.c | 377 
> 
>  libavfilter/vaapi_vpp.h |  88 +++
>  2 files changed, 465 insertions(+)
>  create mode 100644 libavfilter/vaapi_vpp.c
>  create mode 100644 libavfilter/vaapi_vpp.h
> 
> diff --git a/libavfilter/vaapi_vpp.c b/libavfilter/vaapi_vpp.c
> new file mode 100644
> index 00..95ee38ca10
> --- /dev/null
> +++ b/libavfilter/vaapi_vpp.c
> @@ -0,0 +1,377 @@
> +/*
> + * 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/avassert.h"
> +#include "libavutil/pixdesc.h"
> +#include "formats.h"
> +
> +#include "vaapi_vpp.h"
> +
> +int vaapi_vpp_query_formats(AVFilterContext *avctx)
> +{
> +enum AVPixelFormat pix_fmts[] = {
> +AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE,
> +};
> +int err;
> +
> +if ((err = ff_formats_ref(ff_make_format_list(pix_fmts),
> +  &avctx->inputs[0]->out_formats)) < 0)
> +return err;
> +if ((err = ff_formats_ref(ff_make_format_list(pix_fmts),
> +  &avctx->outputs[0]->in_formats)) < 0)
> +return err;
> +
> +return 0;
> +}
> +
> +void vaapi_vpp_pipeline_uninit(AVFilterContext *avctx)
> +{
> +VAAPIVPPContext *ctx   = avctx->priv;
> +int i;
> +for (i = 0; i < ctx->nb_filter_buffers; i++) {
> +if (ctx->filter_buffers[i] != VA_INVALID_ID) {
> +vaDestroyBuffer(ctx->hwctx->display, ctx->filter_buffers[i]);
> +ctx->filter_buffers[i] = VA_INVALID_ID;
> +}
> +}
> +ctx->nb_filter_buffers = 0;
> +
> +if (ctx->va_context != VA_INVALID_ID) {
> +vaDestroyContext(ctx->hwctx->display, ctx->va_context);
> +ctx->va_context = VA_INVALID_ID;
> +}
> +
> +if (ctx->va_config != VA_INVALID_ID) {
> +vaDestroyConfig(ctx->hwctx->display, ctx->va_config);
> +ctx->va_config = VA_INVALID_ID;
> +}
> +
> +av_buffer_unref(&ctx->output_frames_ref);
> +av_buffer_unref(&ctx->device_ref);
> +ctx->hwctx = NULL;
> +}
> +
> +int vaapi_vpp_config_input(AVFilterLink *inlink)
> +{
> +AVFilterContext *avctx = inlink->dst;
> +VAAPIVPPContext *ctx   = avctx->priv;
> +
> +if (ctx->pipeline_uninit)
> +ctx->pipeline_uninit(avctx);
> +
> +if (!inlink->hw_frames_ctx) {
> +av_log(avctx, AV_LOG_ERROR, "A hardware frames reference is "
> +   "required to associate the processing device.\n");
> +return AVERROR(EINVAL);
> +}
> +
> +ctx->input_frames_ref = av_buffer_ref(inlink->hw_frames_ctx);
> +if (!ctx->input_frames_ref) {
> +av_log(avctx, AV_LOG_ERROR, "A input frames reference create "
> +   "failed.\n");
> +return AVERROR(ENOMEM);
> +}
> +ctx->input_frames = (AVHWFramesContext*)ctx->input_frames_ref->data;
> +
> +return 0;
> +}
> +
> +int vaapi_vpp_config_output(AVFilterLink *outlink)
> +{
> +AVFilterContext *avctx = outlink->src;
> +VAAPIVPPContext *ctx   = avctx->priv;
> +AVVAAPIHWConfig *hwconfig = NULL;
> +AVHWFramesConstraints *constraints = NULL;
> +AVVAAPIFramesContext *va_frames;
> +VAStatus vas;
> +int err, i;
> +
> +if (ctx->pipeline_uninit)
> +ctx->pipeline_uninit(avctx);
> +
> +if (!ctx->output_width)
> +ctx->output_width  = avctx->inputs[0]->w;
> +if (!ctx->output_height)
> +

Re: [FFmpeg-devel] [PATCH] ffmpeg: Ignore SIGPIPE

2018-01-18 Thread Mark Thompson
On 19/01/18 00:08, Carl Eugen Hoyos wrote:
> 2018-01-19 0:42 GMT+01:00 Mark Thompson :
> 
>> To offer this suggestion in a more concrete form.
> 
> Works as expected here except for printing an error which
> may be intended.

Yes, that's intended.  Data may have been lost unexpectedly (as with any I/O 
error), so I believe the user should be informed.

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


Re: [FFmpeg-devel] [PATCH] ffmpeg: Ignore SIGPIPE

2018-01-18 Thread Carl Eugen Hoyos
2018-01-19 0:42 GMT+01:00 Mark Thompson :

> To offer this suggestion in a more concrete form.

Works as expected here except for printing an error which
may be intended.

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


Re: [FFmpeg-devel] [PATCH] Fix float-cast-overflow undefined behavior in matroskadec

2018-01-18 Thread Carl Eugen Hoyos
2018-01-19 0:21 GMT+01:00 Nikolas Bowe :

> +  av_log(matroska->ctx, AV_LOG_WARNING,
> + "Invalid frame rate %e. Cannot calculate default 
> duration.\n",
> + track->video.frame_rate);

We currently have one ocurence of "%e" in the whole codebase
and it is usually not compiled: Can you use %f here or would that
be a disadvantage?

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


Re: [FFmpeg-devel] [PATCH 1/3] Add muxing/demuxing of RMHD

2018-01-18 Thread Michael Niedermayer
On Thu, Jan 18, 2018 at 07:39:07PM +0100, Thilo Borgmann wrote:
> This time including the patch...

>  fftools/ffmpeg.c |   28 +++
>  fftools/ffmpeg_opt.c |2 
>  libavformat/Makefile |2 
>  libavformat/allformats.c |1 
>  libavformat/rm.c |1 
>  libavformat/rm.h |7 
>  libavformat/rmdec.c  |   96 +--
>  libavformat/rmenc.c  |  395 
> ++-
>  libavformat/utils.c  |5 
>  9 files changed, 438 insertions(+), 99 deletions(-)
> b65cfa6fc05b6199324118ef1b40d9737cd70272  
> 0001-Add-muxing-demuxing-of-RMHD.patch
> From aaeaf7721ba5e9afd79ee13dbb9cc7c3226027b3 Mon Sep 17 00:00:00 2001
> From: Thilo Borgmann 
> Date: Wed, 17 Jan 2018 23:09:03 +0100
> Subject: [PATCH 1/3] Add muxing/demuxing of RMHD

This is missing AV_CODEC_ID_RV60

src/libavformat/rm.c:37:7: error: ‘AV_CODEC_ID_RV60’ undeclared here (not in a 
function)
 { AV_CODEC_ID_RV60,   MKTAG('R','V','6','0') },
   ^
make: *** [libavformat/rm.o] Error 1
make: *** Waiting for unfinished jobs
src/libavformat/rmenc.c: In function ‘rv10_write_header’:
src/libavformat/rmenc.c:189:48: error: ‘AV_CODEC_ID_RV60’ undeclared (first use 
in this function)
   stream->par->codec_id == AV_CODEC_ID_RV60) {
^
src/libavformat/rmenc.c:189:48: note: each undeclared identifier is reported 
only once for each function it appears in
src/libavformat/rmenc.c: In function ‘rm_write_video’:
src/libavformat/rmenc.c:538:34: error: ‘AV_CODEC_ID_RV60’ undeclared (first use 
in this function)
 stream->par->codec_id == AV_CODEC_ID_RV60) {
  ^
src/libavformat/rmenc.c: At top level:
src/libavformat/rmenc.c:723:20: error: ‘AV_CODEC_ID_RV60’ undeclared here (not 
in a function)
 .video_codec   = AV_CODEC_ID_RV60,
^
make: *** [libavformat/rmenc.o] Error 1

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

If you drop bombs on a foreign country and kill a hundred thousand
innocent people, expect your government to call the consequence
"unprovoked inhuman terrorist attacks" and use it to justify dropping
more bombs and killing more people. The technology changed, the idea is old.


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


[FFmpeg-devel] [PATCH] ffmpeg: Ignore SIGPIPE

2018-01-18 Thread Mark Thompson
On systems which deliver SIGPIPE (Unices), a broken pipe will currently
result in the immediate termination of the ffmpeg process (the default
disposition as required by POSIX).  This is undesirable, because while
the broken pipe is likely fatal to useful cleanup of whatever component
is writing to it, there might be other components which can do useful
cleanup - for example, a muxer on another stream may still need to write
indexes to complete a file.  Therefore, set the signal disposition for
SIGPIPE to ignore the signal - the call which caused the signal will
fail with EPIPE and the error will be propagated upwards like any other
I/O failure on a single stream.
---
On 18/01/18 15:55, Mark Thompson wrote:
> On 18/01/18 14:49, Dave Rice wrote:
>> Thread bump.
>>
>>> On Jan 11, 2018, at 5:51 PM, Nicolas George  wrote:
>>>
>>> Moritz Barsnick (2018-01-11):
 This patch doesn't change the handling of SIGTERM
>>>
>>> You should have read SIGPIPE, obviously.
>>>
 Is SIGPIPE an interactive signal?
>>>
>>> Of course not.
>>>
Anything on the other side of output
 file(name) "-" or "pipe:N" may terminate for some reason.
>>>
>>> Yes, that is exactly what SIGPIPE is for.
>>>
 This patch does NOT try to ignore anything. ffmpeg won't keep running
 due to ignoring of SIGPIPE, it will terminate more cleanly due to
 handling it. The former is not desired. (But yes, shall handing to
 enforce ignoring it would allow that.)
>>>
>>> It will terminate less cleanly than if you do the right thing with
>>> SIGPIPE.
>>
>> This patch has been working for me and ffmpeg terminates cleanly with 
>> SIGPIPE with a valid output (moov atom written with mov or cues/seekhead 
>> written with mkv). Not sure if I understand well the disadvantage of this 
>> patch.
> 
> Making SIGPIPE have an effect like this seems highly dubious to me, but I 
> admit that since it always killed the process before it feels like an 
> improvement.
> 
> Changing it to ignore the signal (set it to SIG_IGN) instead sounds like a 
> safer option?  I think that would move the code to having the same behaviour 
> on Unices as on Windows, since Windows has no SIGPIPE.

To offer this suggestion in a more concrete form.


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

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 528849a2c6..918eb353aa 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -406,6 +406,9 @@ void term_init(void)
 #ifdef SIGXCPU
 signal(SIGXCPU, sigterm_handler);
 #endif
+#ifdef SIGPIPE
+signal(SIGPIPE, SIG_IGN); /* Broken pipe (POSIX). */
+#endif
 #if HAVE_SETCONSOLECTRLHANDLER
 SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, TRUE);
 #endif
-- 
2.11.0
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v1 1/3] avcodec: v4l2_m2m: fix races around freeing data on close

2018-01-18 Thread Michael Niedermayer
On Thu, Jan 18, 2018 at 09:24:20AM +0100, Jorge Ramirez-Ortiz wrote:
> On 01/09/2018 11:56 PM, Jorge Ramirez-Ortiz wrote:
> >From: Mark Thompson 
> >
> >Refcount all of the context information. This also fixes a potential
> >segmentation fault when accessing freed memory  (buffer returned after
> >the codec has been closed).
> 
> just a follow up on the patchset (patches 1 to 3)
> any feedback? shall I resend?

Who is the maintainer of this code ?
noone is listed for it MAINTAINERS

if someone volunteers to maintain it and there are no objections
then that person would get git write access and could push patches
and then bugfixes wont be stuck so long ...

If someone wants to volunteer in that sense, then please send a patch
for the MAINTAINER file


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

The educated differ from the uneducated as much as the living from the
dead. -- Aristotle 


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


[FFmpeg-devel] [PATCH] Fix float-cast-overflow undefined behavior in matroskadec

2018-01-18 Thread Nikolas Bowe
---
 libavformat/matroskadec.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 496499b553..cd9e1f56c2 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2096,8 +2096,16 @@ static int matroska_parse_tracks(AVFormatContext *s)
 }
 
 if (track->type == MATROSKA_TRACK_TYPE_VIDEO) {
-if (!track->default_duration && track->video.frame_rate > 0)
-track->default_duration = 10 / track->video.frame_rate;
+if (!track->default_duration && track->video.frame_rate > 0) {
+double default_duration = 10 / track->video.frame_rate;
+if (default_duration > UINT64_MAX || default_duration < 0) {
+  av_log(matroska->ctx, AV_LOG_WARNING,
+ "Invalid frame rate %e. Cannot calculate default 
duration.\n",
+ track->video.frame_rate);
+} else {
+  track->default_duration = default_duration;
+}
+}
 if (track->video.display_width == -1)
 track->video.display_width = track->video.pixel_width;
 if (track->video.display_height == -1)
-- 
2.16.0.rc1.238.g530d649a79-goog

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


[FFmpeg-devel] [PATCH 5/5] x86inc: Drop cpuflags_slowctz

2018-01-18 Thread Henrik Gramner
---
 libavutil/x86/x86inc.asm | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavutil/x86/x86inc.asm b/libavutil/x86/x86inc.asm
index 438863042f..5044ee86f0 100644
--- a/libavutil/x86/x86inc.asm
+++ b/libavutil/x86/x86inc.asm
@@ -827,9 +827,8 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, jge, 
jng, jnge, ja, jae,
 
 %assign cpuflags_cache32  (1<<21)
 %assign cpuflags_cache64  (1<<22)
-%assign cpuflags_slowctz  (1<<23)
-%assign cpuflags_aligned  (1<<24) ; not a cpu feature, but a function variant
-%assign cpuflags_atom (1<<25)
+%assign cpuflags_aligned  (1<<23) ; not a cpu feature, but a function variant
+%assign cpuflags_atom (1<<24)
 
 ; Returns a boolean value expressing whether or not the specified cpuflag is 
enabled.
 %definecpuflag(x) (cpuflags & (cpuflags_ %+ x)) ^ (cpuflags_ %+ x)) - 
1) >> 31) & 1)
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 4/5] x86inc: Correctly set mmreg variables

2018-01-18 Thread Henrik Gramner
---
 libavutil/x86/x86inc.asm | 87 
 1 file changed, 36 insertions(+), 51 deletions(-)

diff --git a/libavutil/x86/x86inc.asm b/libavutil/x86/x86inc.asm
index de048f863d..438863042f 100644
--- a/libavutil/x86/x86inc.asm
+++ b/libavutil/x86/x86inc.asm
@@ -1,7 +1,7 @@
 ;*
 ;* x86inc.asm: x264asm abstraction layer
 ;*
-;* Copyright (C) 2005-2017 x264 project
+;* Copyright (C) 2005-2018 x264 project
 ;*
 ;* Authors: Loren Merritt 
 ;*  Henrik Gramner 
@@ -892,6 +892,36 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, 
jge, jng, jnge, ja, jae,
 %undef %1%2
 %endmacro
 
+%macro DEFINE_MMREGS 1 ; mmtype
+%assign %%prev_mmregs 0
+%ifdef num_mmregs
+%assign %%prev_mmregs num_mmregs
+%endif
+
+%assign num_mmregs 8
+%if ARCH_X86_64 && mmsize >= 16
+%assign num_mmregs 16
+%if cpuflag(avx512) || mmsize == 64
+%assign num_mmregs 32
+%endif
+%endif
+
+%assign %%i 0
+%rep num_mmregs
+CAT_XDEFINE m, %%i, %1 %+ %%i
+CAT_XDEFINE nn%1, %%i, %%i
+%assign %%i %%i+1
+%endrep
+%if %%prev_mmregs > num_mmregs
+%rep %%prev_mmregs - num_mmregs
+CAT_UNDEF m, %%i
+CAT_UNDEF nn %+ mmtype, %%i
+%assign %%i %%i+1
+%endrep
+%endif
+%xdefine mmtype %1
+%endmacro
+
 ; Prefer registers 16-31 over 0-15 to avoid having to use vzeroupper
 %macro AVX512_MM_PERMUTATION 0-1 0 ; start_reg
 %if ARCH_X86_64 && cpuflag(avx512)
@@ -908,23 +938,12 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, 
jge, jng, jnge, ja, jae,
 %assign avx_enabled 0
 %define RESET_MM_PERMUTATION INIT_MMX %1
 %define mmsize 8
-%define num_mmregs 8
 %define mova movq
 %define movu movq
 %define movh movd
 %define movnta movntq
-%assign %%i 0
-%rep 8
-CAT_XDEFINE m, %%i, mm %+ %%i
-CAT_XDEFINE nnmm, %%i, %%i
-%assign %%i %%i+1
-%endrep
-%rep 24
-CAT_UNDEF m, %%i
-CAT_UNDEF nnmm, %%i
-%assign %%i %%i+1
-%endrep
 INIT_CPUFLAGS %1
+DEFINE_MMREGS mm
 %endmacro
 
 %macro INIT_XMM 0-1+
@@ -936,22 +955,9 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, 
jge, jng, jnge, ja, jae,
 %define movh movq
 %define movnta movntdq
 INIT_CPUFLAGS %1
-%define num_mmregs 8
-%if ARCH_X86_64
-%define num_mmregs 16
-%if cpuflag(avx512)
-%define num_mmregs 32
-%endif
-%endif
-%assign %%i 0
-%rep num_mmregs
-CAT_XDEFINE m, %%i, xmm %+ %%i
-CAT_XDEFINE nnxmm, %%i, %%i
-%assign %%i %%i+1
-%endrep
+DEFINE_MMREGS xmm
 %if WIN64
-; Swap callee-saved registers with volatile registers
-AVX512_MM_PERMUTATION 6
+AVX512_MM_PERMUTATION 6 ; Swap callee-saved registers with volatile 
registers
 %endif
 %endmacro
 
@@ -964,19 +970,7 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, 
jge, jng, jnge, ja, jae,
 %undef movh
 %define movnta movntdq
 INIT_CPUFLAGS %1
-%define num_mmregs 8
-%if ARCH_X86_64
-%define num_mmregs 16
-%if cpuflag(avx512)
-%define num_mmregs 32
-%endif
-%endif
-%assign %%i 0
-%rep num_mmregs
-CAT_XDEFINE m, %%i, ymm %+ %%i
-CAT_XDEFINE nnymm, %%i, %%i
-%assign %%i %%i+1
-%endrep
+DEFINE_MMREGS ymm
 AVX512_MM_PERMUTATION
 %endmacro
 
@@ -984,21 +978,12 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, 
jge, jng, jnge, ja, jae,
 %assign avx_enabled 1
 %define RESET_MM_PERMUTATION INIT_ZMM %1
 %define mmsize 64
-%define num_mmregs 8
-%if ARCH_X86_64
-%define num_mmregs 32
-%endif
 %define mova movdqa
 %define movu movdqu
 %undef movh
 %define movnta movntdq
-%assign %%i 0
-%rep num_mmregs
-CAT_XDEFINE m, %%i, zmm %+ %%i
-CAT_XDEFINE nnzmm, %%i, %%i
-%assign %%i %%i+1
-%endrep
 INIT_CPUFLAGS %1
+DEFINE_MMREGS zmm
 AVX512_MM_PERMUTATION
 %endmacro
 
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 1/5] x86inc: Enable AVX emulation for floating-point pseudo-instructions

2018-01-18 Thread Henrik Gramner
There are 32 pseudo-instructions for each floating-point comparison
instruction, but only 8 of them are actually valid in legacy-encoded mode.
The remaining 24 requires the use of VEX-encoded (v-prefixed) instructions
and can therefore be disregarded for this purpose.
---
 libavutil/x86/x86inc.asm | 32 
 1 file changed, 32 insertions(+)

diff --git a/libavutil/x86/x86inc.asm b/libavutil/x86/x86inc.asm
index 196374c348..3b43dbc2e0 100644
--- a/libavutil/x86/x86inc.asm
+++ b/libavutil/x86/x86inc.asm
@@ -1297,10 +1297,42 @@ AVX_INSTR blendpd, sse4, 1, 1, 0
 AVX_INSTR blendps, sse4, 1, 1, 0
 AVX_INSTR blendvpd, sse4 ; can't be emulated
 AVX_INSTR blendvps, sse4 ; can't be emulated
+AVX_INSTR cmpeqpd, sse2, 1, 0, 1
+AVX_INSTR cmpeqps, sse, 1, 0, 1
+AVX_INSTR cmpeqsd, sse2, 1, 0, 0
+AVX_INSTR cmpeqss, sse, 1, 0, 0
+AVX_INSTR cmplepd, sse2, 1, 0, 0
+AVX_INSTR cmpleps, sse, 1, 0, 0
+AVX_INSTR cmplesd, sse2, 1, 0, 0
+AVX_INSTR cmpless, sse, 1, 0, 0
+AVX_INSTR cmpltpd, sse2, 1, 0, 0
+AVX_INSTR cmpltps, sse, 1, 0, 0
+AVX_INSTR cmpltsd, sse2, 1, 0, 0
+AVX_INSTR cmpltss, sse, 1, 0, 0
+AVX_INSTR cmpneqpd, sse2, 1, 0, 1
+AVX_INSTR cmpneqps, sse, 1, 0, 1
+AVX_INSTR cmpneqsd, sse2, 1, 0, 0
+AVX_INSTR cmpneqss, sse, 1, 0, 0
+AVX_INSTR cmpnlepd, sse2, 1, 0, 0
+AVX_INSTR cmpnleps, sse, 1, 0, 0
+AVX_INSTR cmpnlesd, sse2, 1, 0, 0
+AVX_INSTR cmpnless, sse, 1, 0, 0
+AVX_INSTR cmpnltpd, sse2, 1, 0, 0
+AVX_INSTR cmpnltps, sse, 1, 0, 0
+AVX_INSTR cmpnltsd, sse2, 1, 0, 0
+AVX_INSTR cmpnltss, sse, 1, 0, 0
+AVX_INSTR cmpordpd, sse2 1, 0, 1
+AVX_INSTR cmpordps, sse 1, 0, 1
+AVX_INSTR cmpordsd, sse2 1, 0, 0
+AVX_INSTR cmpordss, sse 1, 0, 0
 AVX_INSTR cmppd, sse2, 1, 1, 0
 AVX_INSTR cmpps, sse, 1, 1, 0
 AVX_INSTR cmpsd, sse2, 1, 1, 0
 AVX_INSTR cmpss, sse, 1, 1, 0
+AVX_INSTR cmpunordpd, sse2, 1, 0, 1
+AVX_INSTR cmpunordps, sse, 1, 0, 1
+AVX_INSTR cmpunordsd, sse2, 1, 0, 0
+AVX_INSTR cmpunordss, sse, 1, 0, 0
 AVX_INSTR comisd, sse2
 AVX_INSTR comiss, sse
 AVX_INSTR cvtdq2pd, sse2
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 2/5] x86inc: Use .rdata instead of .rodata on Windows

2018-01-18 Thread Henrik Gramner
The standard section for read-only data on Windows is .rdata. Nasm will
flag non-standard sections as executable by default which isn't ideal.
---
 libavutil/x86/x86inc.asm | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavutil/x86/x86inc.asm b/libavutil/x86/x86inc.asm
index 3b43dbc2e0..57cd4d80de 100644
--- a/libavutil/x86/x86inc.asm
+++ b/libavutil/x86/x86inc.asm
@@ -90,6 +90,10 @@
 SECTION .text
 %elifidn __OUTPUT_FORMAT__,coff
 SECTION .text
+%elifidn __OUTPUT_FORMAT__,win32
+SECTION .rdata align=%1
+%elif WIN64
+SECTION .rdata align=%1
 %else
 SECTION .rodata align=%1
 %endif
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 3/5] x86inc: Support creating global symbols from local labels

2018-01-18 Thread Henrik Gramner
On ELF platforms such symbols needs to be flagged as functions with the
correct visibility to please certain linkers in some scenarios.
---
 libavutil/x86/x86inc.asm | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/libavutil/x86/x86inc.asm b/libavutil/x86/x86inc.asm
index 57cd4d80de..de048f863d 100644
--- a/libavutil/x86/x86inc.asm
+++ b/libavutil/x86/x86inc.asm
@@ -4,9 +4,9 @@
 ;* Copyright (C) 2005-2017 x264 project
 ;*
 ;* Authors: Loren Merritt 
+;*  Henrik Gramner 
 ;*  Anton Mitrofanov 
 ;*  Fiona Glaser 
-;*  Henrik Gramner 
 ;*
 ;* Permission to use, copy, modify, and/or distribute this software for any
 ;* purpose with or without fee is hereby granted, provided that the above
@@ -743,6 +743,16 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, 
jge, jng, jnge, ja, jae,
 %endif
 %endmacro
 
+; Create a global symbol from a local label with the correct name mangling and 
type
+%macro cglobal_label 1
+%if FORMAT_ELF
+global current_function %+ %1:function hidden
+%else
+global current_function %+ %1
+%endif
+%1:
+%endmacro
+
 %macro cextern 1
 %xdefine %1 mangle(private_prefix %+ _ %+ %1)
 CAT_XDEFINE cglobaled_, %1, 1
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 0/5] x86inc: Sync changes from x264

2018-01-18 Thread Henrik Gramner
Henrik Gramner (5):
  x86inc: Enable AVX emulation for floating-point pseudo-instructions
  x86inc: Use .rdata instead of .rodata on Windows
  x86inc: Support creating global symbols from local labels
  x86inc: Correctly set mmreg variables
  x86inc: Drop cpuflags_slowctz

 libavutil/x86/x86inc.asm | 140 ---
 1 file changed, 85 insertions(+), 55 deletions(-)

-- 
2.11.0

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


[FFmpeg-devel] [PATCH]lavc/svq3: Do not write into const memory

2018-01-18 Thread Carl Eugen Hoyos
Hi!

Attached patch fixes a warning, I suspect it makes the code more correct.

Please comment, Carl Eugen
From 0460da037b91bbc4d0fbca3b756f5c7d345c Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Thu, 18 Jan 2018 23:31:48 +0100
Subject: [PATCH] lavc/svq3: Do not write into memory defined as const.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fixes a warning on ppc:
libavcodec/svq3.c:1055:21: warning: passing argument 1 of ‘av_write_bswap32’ discards 'const' qualifier from pointer target type
---
 libavcodec/svq3.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index a937b2f..fc17081 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -1048,12 +1048,12 @@ static int svq3_decode_slice_header(AVCodecContext *avctx)
 }
 memcpy(s->slice_buf, s->gb.buffer + s->gb.index / 8, slice_bytes);
 
-init_get_bits(&s->gb_slice, s->slice_buf, slice_bits);
-
 if (s->watermark_key) {
-uint32_t header = AV_RL32(&s->gb_slice.buffer[1]);
-AV_WL32(&s->gb_slice.buffer[1], header ^ s->watermark_key);
+uint32_t header = AV_RL32(&s->slice_buf[1]);
+AV_WL32(&s->slice_buf[1], header ^ s->watermark_key);
 }
+init_get_bits(&s->gb_slice, s->slice_buf, slice_bits);
+
 if (length > 0) {
 memmove(s->slice_buf, &s->slice_buf[slice_length], length - 1);
 }
-- 
1.7.10.4

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


Re: [FFmpeg-devel] [PATCHv2 4/4] avfilter/vf_framerate: add SIMD functions for frame blending

2018-01-18 Thread James Almer
On 1/18/2018 6:16 PM, James Almer wrote:
> On 1/18/2018 6:06 PM, Marton Balint wrote:
>> Blend function speedups on x86_64 Core i5 4460:
>>
>> ffmpeg -f lavfi -i allyuv -vf framerate=60:threads=1 -f null none
>>
>> C: 447548411 decicycles in Blend,2048 runs,  0 skips
>> SSSE3: 130020087 decicycles in Blend,2048 runs,  0 skips
>> AVX2:  128508221 decicycles in Blend,2048 runs,  0 skips
>>
>> ffmpeg -f lavfi -i allyuv -vf format=yuv420p12,framerate=60:threads=1 -f 
>> null none
>>
>> C: 228932745 decicycles in Blend,2048 runs,  0 skips
>> SSE4:  123357781 decicycles in Blend,2048 runs,  0 skips
>> AVX2:  121215353 decicycles in Blend,2048 runs,  0 skips
>>
>> Signed-off-by: Marton Balint 
>> ---
>>  libavfilter/vf_framerate.c   |  24 ++-
>>  libavfilter/x86/Makefile |   1 +
>>  libavfilter/x86/vf_framerate.asm | 136 
>> +++
>>  3 files changed, 158 insertions(+), 3 deletions(-)
>>  create mode 100644 libavfilter/x86/vf_framerate.asm
>>
>> diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c
>> index d315ef5d09..6a3b85910f 100644
>> --- a/libavfilter/vf_framerate.c
>> +++ b/libavfilter/vf_framerate.c
>> @@ -29,11 +29,13 @@
>>  #define DEBUG
>>  
>>  #include "libavutil/avassert.h"
>> +#include "libavutil/cpu.h"
>>  #include "libavutil/imgutils.h"
>>  #include "libavutil/internal.h"
>>  #include "libavutil/opt.h"
>>  #include "libavutil/pixdesc.h"
>>  #include "libavutil/pixelutils.h"
>> +#include "libavutil/x86/cpu.h"
>>  
>>  #include "avfilter.h"
>>  #include "internal.h"
>> @@ -246,7 +248,7 @@ static int blend_frames(AVFilterContext *ctx, int 
>> interpolate)
>>  av_frame_copy_props(s->work, s->f0);
>>  
>>  ff_dlog(ctx, "blend_frames() INTERPOLATE to create work frame\n");
>> -ctx->internal->execute(ctx, filter_slice, &td, NULL, 
>> FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
>> +ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(FFMAX(1, 
>> outlink->h >> 2), ff_filter_get_nb_threads(ctx)));
>>  return 1;
>>  }
>>  return 0;
>> @@ -347,6 +349,11 @@ static void blend_frames_c(BLEND_FUNC_PARAMS)
>>  }
>>  }
>>  
>> +void ff_blend_frames_ssse3(BLEND_FUNC_PARAMS);
>> +void ff_blend_frames_avx2(BLEND_FUNC_PARAMS);
>> +void ff_blend_frames16_sse4(BLEND_FUNC_PARAMS);
>> +void ff_blend_frames16_avx2(BLEND_FUNC_PARAMS);
>> +
>>  static void blend_frames16_c(BLEND_FUNC_PARAMS)
>>  {
>>  int line, pixel;
>> @@ -371,6 +378,7 @@ static int config_input(AVFilterLink *inlink)
>>  AVFilterContext *ctx = inlink->dst;
>>  FrameRateContext *s = ctx->priv;
>>  const AVPixFmtDescriptor *pix_desc = 
>> av_pix_fmt_desc_get(inlink->format);
>> +int cpu_flags = av_get_cpu_flags();
>>  int plane;
>>  
>>  for (plane = 0; plane < 4; plane++) {
>> @@ -389,10 +397,20 @@ static int config_input(AVFilterLink *inlink)
>>  
>>  if (s->bitdepth == 8) {
>>  s->blend_factor_max = 1 << BLEND_FACTOR_DEPTH8;
>> -s->blend = blend_frames_c;
>> +if (ARCH_X86 && EXTERNAL_AVX2_FAST(cpu_flags))
>> +s->blend = ff_blend_frames_avx2;
>> +else if (ARCH_X86 && EXTERNAL_SSSE3(cpu_flags))
>> +s->blend = ff_blend_frames_ssse3;
>> +else
>> +s->blend = blend_frames_c;
>>  } else {
>>  s->blend_factor_max = 1 << BLEND_FACTOR_DEPTH16;
>> -s->blend = blend_frames16_c;
>> +if (ARCH_X86 && EXTERNAL_AVX2_FAST(cpu_flags))
>> +s->blend = ff_blend_frames16_avx2;
>> +else if (ARCH_X86 && EXTERNAL_SSE4(cpu_flags))
>> +s->blend = ff_blend_frames16_sse4;
>> +else
>> +s->blend = blend_frames16_c;
> 
> The simd function pointer initialization and the respective prototypes
> should be in a separate file in the x86 folder. In here you should only
> have something like
> 
> if (ARCH_X86)
> ff_blend_frames_init_x86(s);

On second thought, seeing this is the framerate filter, a more correct
name would be ff_framerate_init_x86(). Blend may not be the only
function the filter could optimize with assembly in the future.

> 
> Then the corresponding pointer initialization inside that function. The
> prototype for ff_blend_frames_init_x86() should be in a new header.
> 
> See how vf_blend (and many other filters) do.
> 
>>  }
>>  
>>  return 0;

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


Re: [FFmpeg-devel] [PATCHv2 4/4] avfilter/vf_framerate: add SIMD functions for frame blending

2018-01-18 Thread Martin Vignali
> +
> +
> +%if HAVE_AVX2_EXTERNAL
> +
> +INIT_YMM avx2
> +BLEND_FRAMES
> +
> +INIT_YMM avx2
>

Don't think it's necessary to repeat INIT_YMM avx2.


> +BLEND_FRAMES16
> +
> +%endif
> --


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


Re: [FFmpeg-devel] [PATCHv2 4/4] avfilter/vf_framerate: add SIMD functions for frame blending

2018-01-18 Thread James Almer
On 1/18/2018 6:06 PM, Marton Balint wrote:
> Blend function speedups on x86_64 Core i5 4460:
> 
> ffmpeg -f lavfi -i allyuv -vf framerate=60:threads=1 -f null none
> 
> C: 447548411 decicycles in Blend,2048 runs,  0 skips
> SSSE3: 130020087 decicycles in Blend,2048 runs,  0 skips
> AVX2:  128508221 decicycles in Blend,2048 runs,  0 skips
> 
> ffmpeg -f lavfi -i allyuv -vf format=yuv420p12,framerate=60:threads=1 -f null 
> none
> 
> C: 228932745 decicycles in Blend,2048 runs,  0 skips
> SSE4:  123357781 decicycles in Blend,2048 runs,  0 skips
> AVX2:  121215353 decicycles in Blend,2048 runs,  0 skips
> 
> Signed-off-by: Marton Balint 
> ---
>  libavfilter/vf_framerate.c   |  24 ++-
>  libavfilter/x86/Makefile |   1 +
>  libavfilter/x86/vf_framerate.asm | 136 
> +++
>  3 files changed, 158 insertions(+), 3 deletions(-)
>  create mode 100644 libavfilter/x86/vf_framerate.asm
> 
> diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c
> index d315ef5d09..6a3b85910f 100644
> --- a/libavfilter/vf_framerate.c
> +++ b/libavfilter/vf_framerate.c
> @@ -29,11 +29,13 @@
>  #define DEBUG
>  
>  #include "libavutil/avassert.h"
> +#include "libavutil/cpu.h"
>  #include "libavutil/imgutils.h"
>  #include "libavutil/internal.h"
>  #include "libavutil/opt.h"
>  #include "libavutil/pixdesc.h"
>  #include "libavutil/pixelutils.h"
> +#include "libavutil/x86/cpu.h"
>  
>  #include "avfilter.h"
>  #include "internal.h"
> @@ -246,7 +248,7 @@ static int blend_frames(AVFilterContext *ctx, int 
> interpolate)
>  av_frame_copy_props(s->work, s->f0);
>  
>  ff_dlog(ctx, "blend_frames() INTERPOLATE to create work frame\n");
> -ctx->internal->execute(ctx, filter_slice, &td, NULL, 
> FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
> +ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(FFMAX(1, 
> outlink->h >> 2), ff_filter_get_nb_threads(ctx)));
>  return 1;
>  }
>  return 0;
> @@ -347,6 +349,11 @@ static void blend_frames_c(BLEND_FUNC_PARAMS)
>  }
>  }
>  
> +void ff_blend_frames_ssse3(BLEND_FUNC_PARAMS);
> +void ff_blend_frames_avx2(BLEND_FUNC_PARAMS);
> +void ff_blend_frames16_sse4(BLEND_FUNC_PARAMS);
> +void ff_blend_frames16_avx2(BLEND_FUNC_PARAMS);
> +
>  static void blend_frames16_c(BLEND_FUNC_PARAMS)
>  {
>  int line, pixel;
> @@ -371,6 +378,7 @@ static int config_input(AVFilterLink *inlink)
>  AVFilterContext *ctx = inlink->dst;
>  FrameRateContext *s = ctx->priv;
>  const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
> +int cpu_flags = av_get_cpu_flags();
>  int plane;
>  
>  for (plane = 0; plane < 4; plane++) {
> @@ -389,10 +397,20 @@ static int config_input(AVFilterLink *inlink)
>  
>  if (s->bitdepth == 8) {
>  s->blend_factor_max = 1 << BLEND_FACTOR_DEPTH8;
> -s->blend = blend_frames_c;
> +if (ARCH_X86 && EXTERNAL_AVX2_FAST(cpu_flags))
> +s->blend = ff_blend_frames_avx2;
> +else if (ARCH_X86 && EXTERNAL_SSSE3(cpu_flags))
> +s->blend = ff_blend_frames_ssse3;
> +else
> +s->blend = blend_frames_c;
>  } else {
>  s->blend_factor_max = 1 << BLEND_FACTOR_DEPTH16;
> -s->blend = blend_frames16_c;
> +if (ARCH_X86 && EXTERNAL_AVX2_FAST(cpu_flags))
> +s->blend = ff_blend_frames16_avx2;
> +else if (ARCH_X86 && EXTERNAL_SSE4(cpu_flags))
> +s->blend = ff_blend_frames16_sse4;
> +else
> +s->blend = blend_frames16_c;

The simd function pointer initialization and the respective prototypes
should be in a separate file in the x86 folder. In here you should only
have something like

if (ARCH_X86)
ff_blend_frames_init_x86(s);

Then the corresponding pointer initialization inside that function. The
prototype for ff_blend_frames_init_x86() should be in a new header.

See how vf_blend (and many other filters) do.

>  }
>  
>  return 0;
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCHv2 4/4] avfilter/vf_framerate: add SIMD functions for frame blending

2018-01-18 Thread Marton Balint
Blend function speedups on x86_64 Core i5 4460:

ffmpeg -f lavfi -i allyuv -vf framerate=60:threads=1 -f null none

C: 447548411 decicycles in Blend,2048 runs,  0 skips
SSSE3: 130020087 decicycles in Blend,2048 runs,  0 skips
AVX2:  128508221 decicycles in Blend,2048 runs,  0 skips

ffmpeg -f lavfi -i allyuv -vf format=yuv420p12,framerate=60:threads=1 -f null 
none

C: 228932745 decicycles in Blend,2048 runs,  0 skips
SSE4:  123357781 decicycles in Blend,2048 runs,  0 skips
AVX2:  121215353 decicycles in Blend,2048 runs,  0 skips

Signed-off-by: Marton Balint 
---
 libavfilter/vf_framerate.c   |  24 ++-
 libavfilter/x86/Makefile |   1 +
 libavfilter/x86/vf_framerate.asm | 136 +++
 3 files changed, 158 insertions(+), 3 deletions(-)
 create mode 100644 libavfilter/x86/vf_framerate.asm

diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c
index d315ef5d09..6a3b85910f 100644
--- a/libavfilter/vf_framerate.c
+++ b/libavfilter/vf_framerate.c
@@ -29,11 +29,13 @@
 #define DEBUG
 
 #include "libavutil/avassert.h"
+#include "libavutil/cpu.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/pixelutils.h"
+#include "libavutil/x86/cpu.h"
 
 #include "avfilter.h"
 #include "internal.h"
@@ -246,7 +248,7 @@ static int blend_frames(AVFilterContext *ctx, int 
interpolate)
 av_frame_copy_props(s->work, s->f0);
 
 ff_dlog(ctx, "blend_frames() INTERPOLATE to create work frame\n");
-ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(outlink->h, 
ff_filter_get_nb_threads(ctx)));
+ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(FFMAX(1, 
outlink->h >> 2), ff_filter_get_nb_threads(ctx)));
 return 1;
 }
 return 0;
@@ -347,6 +349,11 @@ static void blend_frames_c(BLEND_FUNC_PARAMS)
 }
 }
 
+void ff_blend_frames_ssse3(BLEND_FUNC_PARAMS);
+void ff_blend_frames_avx2(BLEND_FUNC_PARAMS);
+void ff_blend_frames16_sse4(BLEND_FUNC_PARAMS);
+void ff_blend_frames16_avx2(BLEND_FUNC_PARAMS);
+
 static void blend_frames16_c(BLEND_FUNC_PARAMS)
 {
 int line, pixel;
@@ -371,6 +378,7 @@ static int config_input(AVFilterLink *inlink)
 AVFilterContext *ctx = inlink->dst;
 FrameRateContext *s = ctx->priv;
 const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
+int cpu_flags = av_get_cpu_flags();
 int plane;
 
 for (plane = 0; plane < 4; plane++) {
@@ -389,10 +397,20 @@ static int config_input(AVFilterLink *inlink)
 
 if (s->bitdepth == 8) {
 s->blend_factor_max = 1 << BLEND_FACTOR_DEPTH8;
-s->blend = blend_frames_c;
+if (ARCH_X86 && EXTERNAL_AVX2_FAST(cpu_flags))
+s->blend = ff_blend_frames_avx2;
+else if (ARCH_X86 && EXTERNAL_SSSE3(cpu_flags))
+s->blend = ff_blend_frames_ssse3;
+else
+s->blend = blend_frames_c;
 } else {
 s->blend_factor_max = 1 << BLEND_FACTOR_DEPTH16;
-s->blend = blend_frames16_c;
+if (ARCH_X86 && EXTERNAL_AVX2_FAST(cpu_flags))
+s->blend = ff_blend_frames16_avx2;
+else if (ARCH_X86 && EXTERNAL_SSE4(cpu_flags))
+s->blend = ff_blend_frames16_sse4;
+else
+s->blend = blend_frames16_c;
 }
 
 return 0;
diff --git a/libavfilter/x86/Makefile b/libavfilter/x86/Makefile
index 2fc5c62644..07fc0f9486 100644
--- a/libavfilter/x86/Makefile
+++ b/libavfilter/x86/Makefile
@@ -31,6 +31,7 @@ X86ASM-OBJS-$(CONFIG_AFIR_FILTER)+= x86/af_afir.o
 X86ASM-OBJS-$(CONFIG_BLEND_FILTER)   += x86/vf_blend.o
 X86ASM-OBJS-$(CONFIG_BWDIF_FILTER)   += x86/vf_bwdif.o
 X86ASM-OBJS-$(CONFIG_COLORSPACE_FILTER)  += x86/colorspacedsp.o
+X86ASM-OBJS-$(CONFIG_FRAMERATE_FILTER)   += x86/vf_framerate.o
 X86ASM-OBJS-$(CONFIG_FSPP_FILTER)+= x86/vf_fspp.o
 X86ASM-OBJS-$(CONFIG_GRADFUN_FILTER) += x86/vf_gradfun.o
 X86ASM-OBJS-$(CONFIG_HFLIP_FILTER)   += x86/vf_hflip.o
diff --git a/libavfilter/x86/vf_framerate.asm b/libavfilter/x86/vf_framerate.asm
new file mode 100644
index 00..34dcff7891
--- /dev/null
+++ b/libavfilter/x86/vf_framerate.asm
@@ -0,0 +1,136 @@
+;*
+;* x86-optimized functions for framerate filter
+;*
+;* Copyright (C) 2018 Marton Balint
+;*
+;* Based on vf_blend.asm, Copyright (C) 2015 Paul B Mahol
+;*
+;* 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
+

Re: [FFmpeg-devel] [PATCH 4/4] avfilter/vf_framerate: add SIMD functions for frame blending

2018-01-18 Thread Marton Balint


On Thu, 18 Jan 2018, Carl Eugen Hoyos wrote:


2018-01-18 1:03 GMT+01:00 Marton Balint :

Blend function speedups on x86_64 Core i5 4460:

ffmpeg -f lavfi -i allyuv -vf framerate=60:threads=1 -f null none

C: 447548411 decicycles in Blend,2048 runs,  0 skips
SSSE3: 130020087 decicycles in Blend,2048 runs,  0 skips
AVX2:  128508221 decicycles in Blend,2048 runs,  0 skips

ffmpeg -f lavfi -i allyuv -vf format=yuv420p12,framerate=60:threads=1 -f null 
none

C: 228932745 decicycles in Blend,2048 runs,  0 skips
SSE4:  123357781 decicycles in Blend,2048 runs,  0 skips
AVX2:  121215353 decicycles in Blend,2048 runs,  0 skips


Is the avx2 version really useful?


Well, it _is_ faster, even if the speedup is not significant. The ASM code 
is almost the same, so almost no maitenance burden is invovled in keeping 
both.


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


[FFmpeg-devel] [PATCH]lavf/swfdec: Reduce score when auto-detecting swf files

2018-01-18 Thread Carl Eugen Hoyos
Hi!

The probe score for swf files (with uncompressed headers) is currently
very high after testing a little more than 24bit, attached patch
reduces the score.

Please comment, Carl Eugen
From 561cb5cea0ead726c747edea7d1c3e8c768eac81 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Thu, 18 Jan 2018 21:25:49 +0100
Subject: [PATCH] lavf/swfdec: Reduce score when auto-detecting swf files.

Only a little more than 24bit are tested.
---
 libavformat/swfdec.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c
index 57b619f..da58755 100644
--- a/libavformat/swfdec.c
+++ b/libavformat/swfdec.c
@@ -95,7 +95,7 @@ static int swf_probe(AVProbeData *p)
 if (p->buf[3] >= 20 || xmax < 16 || ymax < 16)
 return AVPROBE_SCORE_MAX / 4;
 
-return AVPROBE_SCORE_MAX;
+return AVPROBE_SCORE_MAX / 2;
 }
 
 #if CONFIG_ZLIB
-- 
1.7.10.4

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


Re: [FFmpeg-devel] [PATCH 2/3] Add codec wrapper for librv11

2018-01-18 Thread James Almer
On 1/18/2018 3:37 PM, Thilo Borgmann wrote:
> From 0386c9e0a4c2ea1579378807ff5a7a04c508c50e Mon Sep 17 00:00:00 2001
> From: Thilo Borgmann 
> Date: Wed, 17 Jan 2018 23:13:53 +0100
> Subject: [PATCH 2/3] Add codec wrapper for librv11
> 
> ---
>  MAINTAINERS |   1 +
>  configure   |   8 +
>  libavcodec/Makefile |   2 +
>  libavcodec/allcodecs.c  |   2 +
>  libavcodec/avcodec.h|   1 +
>  libavcodec/codec_desc.c |   7 +
>  libavcodec/librv11.h|  55 
>  libavcodec/librv11dec.c | 367 
>  libavcodec/librv11enc.c | 735 
> 
>  libavcodec/version.h|   2 +-
>  10 files changed, 1179 insertions(+), 1 deletion(-)
>  create mode 100644 libavcodec/librv11.h
>  create mode 100644 libavcodec/librv11dec.c
>  create mode 100644 libavcodec/librv11enc.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index e583926..0067986 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -192,6 +192,7 @@ Codecs:
>libkvazaar.c  Arttu Ylä-Outinen
>libopenjpeg.c Jaikrishnan Menon
>libopenjpegenc.c  Michael Bradshaw
> +  librv11*  Thilo Borgmann, Qiang Luo
>libtheoraenc.cDavid Conrad
>libvorbis.c   David Conrad
>libvpx*   James Zern
> diff --git a/configure b/configure
> index 5d53362..1c27852 100755
> --- a/configure
> +++ b/configure
> @@ -250,6 +250,8 @@ External library support:
>--enable-librsvg enable SVG rasterization via librsvg [no]
>--enable-librubberband   enable rubberband needed for rubberband filter 
> [no]
>--enable-librtmp enable RTMP[E] support via librtmp [no]
> +  --disable-librv11dec enable RV11 decoding via rv11 [autodetect]
> +  --disable-librv11enc enable RV11 encoding via rv11 [autodetect]

Single librv11 entry, please.

>--enable-libshineenable fixed-point MP3 encoding via libshine [no]
>--enable-libsmbclientenable Samba protocol via libsmbclient [no]
>--enable-libsnappy   enable Snappy compression, needed for hap 
> encoding [no]
> @@ -1535,6 +1537,8 @@ EXTERNAL_AUTODETECT_LIBRARY_LIST="
>  bzlib
>  coreimage
>  iconv
> +librv11enc
> +librv11dec

This needs to be in EXTERNAL_LIBRARY_LIST, not in
EXTERNAL_AUTODETECT_LIBRARY_LIST. Also as i said above as a single entry.

>  libxcb
>  libxcb_shm
>  libxcb_shape
> @@ -2959,6 +2963,8 @@ libopus_decoder_deps="libopus"
>  libopus_encoder_deps="libopus"
>  libopus_encoder_select="audio_frame_queue"
>  librsvg_decoder_deps="librsvg"
> +librv11dec_decoder_deps="librv11dec"
> +librv11enc_encoder_deps="librv11enc"

librv11_decoder_deps="librv11"
librv11_encoder_deps="librv11"

>  libshine_encoder_deps="libshine"
>  libshine_encoder_select="audio_frame_queue"
>  libspeex_decoder_deps="libspeex"
> @@ -5890,6 +5896,8 @@ enabled libpulse  && require_pkg_config 
> libpulse libpulse pulse/pulseaud
>  enabled librsvg   && require_pkg_config librsvg librsvg-2.0 
> librsvg-2.0/librsvg/rsvg.h rsvg_handle_render_cairo
>  enabled librtmp   && require_pkg_config librtmp librtmp 
> librtmp/rtmp.h RTMP_Socket
>  enabled librubberband && require_pkg_config librubberband "rubberband >= 
> 1.8.1" rubberband/rubberband-c.h rubberband_new -lstdc++ && append 
> librubberband_extralibs "-lstdc++"
> +enabled librv11enc&& require_pkg_config librv11 librv11 
> librv11_sdk.h fpinit
> +enabled librv11dec&& require_pkg_config librv11 librv11 
> librv11_sdk.h fpinit

As is, these checks are not really enabling either of these two modules,
but a currently nonexistant one called librv11.

The only reason it worked like this is because you had them in the
autodetect list above.

enabled librv11   && require_pkg_config librv11 librv11
librv11_sdk.h fpinit

>  enabled libshine  && require_pkg_config libshine shine 
> shine/layer3.h shine_encode_buffer
>  enabled libsmbclient  && { check_pkg_config libsmbclient smbclient 
> libsmbclient.h smbc_init ||
> require libsmbclient libsmbclient.h smbc_init 
> -lsmbclient; }
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index cfacd6b..2e32815 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -948,6 +948,8 @@ OBJS-$(CONFIG_LIBOPUS_DECODER)+= libopusdec.o 
> libopus.o \
>   vorbis_data.o
>  OBJS-$(CONFIG_LIBOPUS_ENCODER)+= libopusenc.o libopus.o \
>   vorbis_data.o
> +OBJS-$(CONFIG_LIBRV11DEC_DECODER) += librv11dec.o
> +OBJS-$(CONFIG_LIBRV11ENC_ENCODER) += librv11enc.o

OBJS-$(CONFIG_LIBRV11_DECODER)+= librv11dec.o
OBJS-$(CONFIG_LIBRV11_ENCODER)+= librv11enc.o

>  OBJS-$(CONFIG_LIBSHINE_ENCODER)

Re: [FFmpeg-devel] [PATCH 2/3] Add codec wrapper for librv11

2018-01-18 Thread Carl Eugen Hoyos
2018-01-18 19:37 GMT+01:00 Thilo Borgmann :

Needs non-free (and therefore cannot be auto-detected).
And please link at compile-time unless there are no
visible symbols except the lookup function.

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


Re: [FFmpeg-devel] [PATCH 1/3] Add muxing/demuxing of RMHD

2018-01-18 Thread Carl Eugen Hoyos
2018-01-18 19:39 GMT+01:00 Thilo Borgmann :
> This time including the patch...

Why do you add a new demuxer?
Isn't it sufficient to add the new descriptor (with AV_RB32()) to the
existing probe function?

Please split this patch:
From a (very) quick look, I saw:
Demuxing MLTI, muxing aac, muxing RV30 and friends, some
fixes wrt version (all apart from RV60).
Please add a few comments where it currently says "unknown".
I suspect no new muxer should be added (but I may miss something).

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


Re: [FFmpeg-devel] [PATCH 0/3] Codec wrapper for librv11 and RMHD muxer/demuxer

2018-01-18 Thread Thilo Borgmann
Am 18.01.18 um 19:36 schrieb Thilo Borgmann:
> Realnetworks released Linux libraries for their encoder/decoder of RealVideo 
> 11 (RV60) [1].

[1] http://www.rmhd.io

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


Re: [FFmpeg-devel] [PATCH 1/3] Add muxing/demuxing of RMHD

2018-01-18 Thread Thilo Borgmann
This time including the patch...
From aaeaf7721ba5e9afd79ee13dbb9cc7c3226027b3 Mon Sep 17 00:00:00 2001
From: Thilo Borgmann 
Date: Wed, 17 Jan 2018 23:09:03 +0100
Subject: [PATCH 1/3] Add muxing/demuxing of RMHD

---
 fftools/ffmpeg.c |  28 +++-
 fftools/ffmpeg_opt.c |   2 +-
 libavformat/Makefile |   2 +
 libavformat/allformats.c |   1 +
 libavformat/rm.c |   1 +
 libavformat/rm.h |   7 +
 libavformat/rmdec.c  |  96 +---
 libavformat/rmenc.c  | 395 ++-
 libavformat/utils.c  |   5 +-
 9 files changed, 438 insertions(+), 99 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 528849a..9bd5724 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1296,7 +1296,18 @@ static void do_video_out(OutputFile *of,
 if (pkt.pts == AV_NOPTS_VALUE && !(enc->codec->capabilities & 
AV_CODEC_CAP_DELAY))
 pkt.pts = ost->sync_opts;
 
-av_packet_rescale_ts(&pkt, enc->time_base, ost->mux_timebase);
+if(enc->codec->id == AV_CODEC_ID_RV60) {
+AVRational rm_time_base = {1, 1000};
+if (pkt.pts != AV_NOPTS_VALUE)
+pkt.pts = av_rescale_q(pkt.pts, enc->time_base, 
ost->mux_timebase);
+if (pkt.dts != AV_NOPTS_VALUE && av_cmp_q(rm_time_base, 
ost->mux_timebase)) {
+pkt.dts = av_rescale_q(pkt.dts, enc->time_base, 
ost->mux_timebase);
+pkt.dts = av_rescale_q(pkt.dts, rm_time_base, 
enc->time_base);
+}
+pkt.pts = pkt.dts;
+} else {
+av_packet_rescale_ts(&pkt, enc->time_base, ost->mux_timebase);
+}
 
 if (debug_ts) {
 av_log(NULL, AV_LOG_INFO, "encoder -> type:video "
@@ -1940,7 +1951,20 @@ static void flush_encoders(void)
 av_packet_unref(&pkt);
 continue;
 }
-av_packet_rescale_ts(&pkt, enc->time_base, ost->mux_timebase);
+
+if(enc->codec->id == AV_CODEC_ID_RV60) {
+AVRational rm_time_base = {1, 1000};
+if (pkt.pts != AV_NOPTS_VALUE)
+pkt.pts = av_rescale_q(pkt.pts, enc->time_base, 
ost->mux_timebase);
+if (pkt.dts != AV_NOPTS_VALUE && av_cmp_q(rm_time_base, 
ost->mux_timebase)) {
+pkt.dts = av_rescale_q(pkt.dts, enc->time_base, 
ost->mux_timebase);
+pkt.dts = av_rescale_q(pkt.dts, rm_time_base, 
enc->time_base);
+}
+pkt.pts = pkt.dts;
+} else {
+av_packet_rescale_ts(&pkt, enc->time_base, 
ost->mux_timebase);
+}
+
 pkt_size = pkt.size;
 output_packet(of, &pkt, ost, 0);
 if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO && 
vstats_filename) {
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 92199b3..0036468 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1747,7 +1747,7 @@ static OutputStream *new_video_stream(OptionsContext *o, 
AVFormatContext *oc, in
  ost->logfile_prefix ? ost->logfile_prefix :
DEFAULT_PASS_LOGFILENAME_PREFIX,
  i);
-if (!strcmp(ost->enc->name, "libx264")) {
+if (!strcmp(ost->enc->name, "libx264") || !strcmp(ost->enc->name, 
"librv11enc")) {
 av_dict_set(&ost->encoder_opts, "stats", logfilename, 
AV_DICT_DONT_OVERWRITE);
 } else {
 if (video_enc->flags & AV_CODEC_FLAG_PASS2) {
diff --git a/libavformat/Makefile b/libavformat/Makefile
index de0de92..3a8d0a2 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -414,6 +414,8 @@ OBJS-$(CONFIG_REDSPARK_DEMUXER)  += redspark.o
 OBJS-$(CONFIG_RL2_DEMUXER)   += rl2.o
 OBJS-$(CONFIG_RM_DEMUXER)+= rmdec.o rm.o rmsipr.o
 OBJS-$(CONFIG_RM_MUXER)  += rmenc.o rm.o
+OBJS-$(CONFIG_RMHD_DEMUXER)  += rmdec.o rm.o rmsipr.o
+OBJS-$(CONFIG_RMHD_MUXER)+= rmenc.o rm.o
 OBJS-$(CONFIG_ROQ_DEMUXER)   += idroqdec.o
 OBJS-$(CONFIG_ROQ_MUXER) += idroqenc.o rawenc.o
 OBJS-$(CONFIG_RSD_DEMUXER)   += rsd.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index ec84096..141ccd2 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -266,6 +266,7 @@ static void register_all(void)
 REGISTER_DEMUXER (REDSPARK, redspark);
 REGISTER_DEMUXER (RL2,  rl2);
 REGISTER_MUXDEMUX(RM,   rm);
+REGISTER_MUXDEMUX(RMHD, rmhd);
 REGISTER_MUXDEMUX(ROQ,  roq);
 REGISTER_DEMUXER (RPL,  rpl);
 REGISTER_DEMUXER (RSD,  rsd);
diff --git a/libavformat/rm.c b/li

[FFmpeg-devel] [PATCH 3/3] Add docs and Changelog

2018-01-18 Thread Thilo Borgmann

From 933e314a2571f0e57ec078b87dc4990a4fe213f1 Mon Sep 17 00:00:00 2001
From: Thilo Borgmann 
Date: Wed, 17 Jan 2018 23:14:16 +0100
Subject: [PATCH 3/3] Add docs and Changelog

---
 Changelog |  2 ++
 doc/encoders.texi | 92 +++
 doc/general.texi  |  7 +
 3 files changed, 101 insertions(+)

diff --git a/Changelog b/Changelog
index 61075b3..7eebf5f 100644
--- a/Changelog
+++ b/Changelog
@@ -38,6 +38,8 @@ version :
 - Removed the ffserver program
 - Removed the ffmenc and ffmdec muxer and demuxer
 - VideoToolbox HEVC encoder and hwaccel
+- RMHD Muxer/Demuxer
+- RealVideo 11 support via librv11
 
 
 version 3.4:
diff --git a/doc/encoders.texi b/doc/encoders.texi
index 6a410a8..ccdaba5 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1452,6 +1452,98 @@ Set maximum NAL size in bytes.
 Allow skipping frames to hit the target bitrate if set to 1.
 @end table
 
+@section librv11
+
+RealVideo 11 (RV60) codec wrapper.
+
+Requires the presence of the librv11 SDK headers and
+libraries during configuration. The library is detected using
+@command{pkg-config}.
+
+For more information about the library see
+@url{http://www.rmhd.io/}.
+
+@subsection Options
+
+The following FFmpeg global options affect the configurations of the
+librv11 encoder.
+
+@table @option
+@item b
+Set the bitrate (as a number of bits per second).
+
+@item is_lossprotect
+Enable loss protection feature
+
+@item output_width
+Video encoded frame output width
+
+@item output_height
+Video encoded frame output height
+
+@item rc_strategy
+Which ratecontrol method to be used (default: bitrate)
+
+@table @samp
+@item bitrate
+@item quality
+@end table
+
+@item complexity
+Encoding complexity (default: medium)
+
+@table @samp
+@item verylow
+@item low
+@item medium
+@item high
+@end table
+
+@item framerate
+Max frame rate value
+
+@item resize_quality
+Video encoded frame resize quality (default: 1),
+
+@table @samp
+@item high
+@item fast
+@end table
+
+@item video_mode
+Motion quality (default: 50)
+
+@table @samp
+@item normal
+@item sharp
+@item smooth
+@end table
+
+@item max_keyint
+Max keyframe interval (default: 5),
+
+@item max_latency
+Max video latency on start (default: 4.0)
+
+@item vbrquality
+Vbr quality value (default: 60)
+
+@item passlogfile
+Filename for 2 pass encoding stats (default: rv11passstats.log)
+
+@item pon
+Picture order number (default: 0)
+
+@item vbr_opt (default: false)
+Vbr enabled
+
+@table @samp
+@item true
+@item false
+@end table
+
+@end table
+
 @section libtheora
 
 libtheora Theora encoder wrapper.
diff --git a/doc/general.texi b/doc/general.texi
index 3b73e31..a5b7aa9 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -237,6 +237,12 @@ Create an @code{AMF/} directory in the system include path.
 Copy the contents of @code{AMF/amf/public/include/} into that directory.
 Then configure FFmpeg with @code{--enable-amf}.
 
+@section RealVideo11 (RV60)
+
+FFmpeg can make use of the RV11 codec libraries for encoding and decoding.
+
+Go to @url{http://www.rmhd.io/} and download the SDK installer.
+
 
 @chapter Supported File Formats, Codecs or Features
 
@@ -510,6 +516,7 @@ library:
 @item REDCODE R3D   @tab   @tab X
 @tab File format used by RED Digital cameras, contains JPEG 2000 frames 
and PCM audio.
 @item RealMedia @tab X @tab X
+@item RealMedia HD  @tab X @tab X
 @item Redirector@tab   @tab X
 @item RedSpark  @tab   @tab X
 @item Renderware TeXture Dictionary @tab   @tab X
-- 
2.9.3

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


[FFmpeg-devel] [PATCH 2/3] Add codec wrapper for librv11

2018-01-18 Thread Thilo Borgmann
From 0386c9e0a4c2ea1579378807ff5a7a04c508c50e Mon Sep 17 00:00:00 2001
From: Thilo Borgmann 
Date: Wed, 17 Jan 2018 23:13:53 +0100
Subject: [PATCH 2/3] Add codec wrapper for librv11

---
 MAINTAINERS |   1 +
 configure   |   8 +
 libavcodec/Makefile |   2 +
 libavcodec/allcodecs.c  |   2 +
 libavcodec/avcodec.h|   1 +
 libavcodec/codec_desc.c |   7 +
 libavcodec/librv11.h|  55 
 libavcodec/librv11dec.c | 367 
 libavcodec/librv11enc.c | 735 
 libavcodec/version.h|   2 +-
 10 files changed, 1179 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/librv11.h
 create mode 100644 libavcodec/librv11dec.c
 create mode 100644 libavcodec/librv11enc.c

diff --git a/MAINTAINERS b/MAINTAINERS
index e583926..0067986 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -192,6 +192,7 @@ Codecs:
   libkvazaar.c  Arttu Ylä-Outinen
   libopenjpeg.c Jaikrishnan Menon
   libopenjpegenc.c  Michael Bradshaw
+  librv11*  Thilo Borgmann, Qiang Luo
   libtheoraenc.cDavid Conrad
   libvorbis.c   David Conrad
   libvpx*   James Zern
diff --git a/configure b/configure
index 5d53362..1c27852 100755
--- a/configure
+++ b/configure
@@ -250,6 +250,8 @@ External library support:
   --enable-librsvg enable SVG rasterization via librsvg [no]
   --enable-librubberband   enable rubberband needed for rubberband filter [no]
   --enable-librtmp enable RTMP[E] support via librtmp [no]
+  --disable-librv11dec enable RV11 decoding via rv11 [autodetect]
+  --disable-librv11enc enable RV11 encoding via rv11 [autodetect]
   --enable-libshineenable fixed-point MP3 encoding via libshine [no]
   --enable-libsmbclientenable Samba protocol via libsmbclient [no]
   --enable-libsnappy   enable Snappy compression, needed for hap encoding 
[no]
@@ -1535,6 +1537,8 @@ EXTERNAL_AUTODETECT_LIBRARY_LIST="
 bzlib
 coreimage
 iconv
+librv11enc
+librv11dec
 libxcb
 libxcb_shm
 libxcb_shape
@@ -2959,6 +2963,8 @@ libopus_decoder_deps="libopus"
 libopus_encoder_deps="libopus"
 libopus_encoder_select="audio_frame_queue"
 librsvg_decoder_deps="librsvg"
+librv11dec_decoder_deps="librv11dec"
+librv11enc_encoder_deps="librv11enc"
 libshine_encoder_deps="libshine"
 libshine_encoder_select="audio_frame_queue"
 libspeex_decoder_deps="libspeex"
@@ -5890,6 +5896,8 @@ enabled libpulse  && require_pkg_config libpulse 
libpulse pulse/pulseaud
 enabled librsvg   && require_pkg_config librsvg librsvg-2.0 
librsvg-2.0/librsvg/rsvg.h rsvg_handle_render_cairo
 enabled librtmp   && require_pkg_config librtmp librtmp librtmp/rtmp.h 
RTMP_Socket
 enabled librubberband && require_pkg_config librubberband "rubberband >= 
1.8.1" rubberband/rubberband-c.h rubberband_new -lstdc++ && append 
librubberband_extralibs "-lstdc++"
+enabled librv11enc&& require_pkg_config librv11 librv11 librv11_sdk.h 
fpinit
+enabled librv11dec&& require_pkg_config librv11 librv11 librv11_sdk.h 
fpinit
 enabled libshine  && require_pkg_config libshine shine shine/layer3.h 
shine_encode_buffer
 enabled libsmbclient  && { check_pkg_config libsmbclient smbclient 
libsmbclient.h smbc_init ||
require libsmbclient libsmbclient.h smbc_init 
-lsmbclient; }
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index cfacd6b..2e32815 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -948,6 +948,8 @@ OBJS-$(CONFIG_LIBOPUS_DECODER)+= libopusdec.o 
libopus.o \
  vorbis_data.o
 OBJS-$(CONFIG_LIBOPUS_ENCODER)+= libopusenc.o libopus.o \
  vorbis_data.o
+OBJS-$(CONFIG_LIBRV11DEC_DECODER) += librv11dec.o
+OBJS-$(CONFIG_LIBRV11ENC_ENCODER) += librv11enc.o
 OBJS-$(CONFIG_LIBSHINE_ENCODER)   += libshine.o
 OBJS-$(CONFIG_LIBSPEEX_DECODER)   += libspeexdec.o
 OBJS-$(CONFIG_LIBSPEEX_ENCODER)   += libspeexenc.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index ed1e7ab..8eb8610 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -548,6 +548,8 @@ static void register_all(void)
 REGISTER_ENCDEC (LIBOPENJPEG,   libopenjpeg);
 REGISTER_ENCDEC (LIBOPUS,   libopus);
 REGISTER_DECODER(LIBRSVG,   librsvg);
+REGISTER_DECODER(LIBRV11DEC,librv11dec);
+REGISTER_ENCODER(LIBRV11ENC,librv11enc);
 REGISTER_ENCODER(LIBSHINE,  libshine);
 REGISTER_ENCDEC (LIBSPEEX,  libspeex);
 REGISTER_ENCODER(LIBTHEORA, libtheora);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 8fbbc79..b7c1fa1 100644
--- a/libavcodec/avcodec.h
+

[FFmpeg-devel] [PATCH 1/3] Add muxing/demuxing of RMHD

2018-01-18 Thread Thilo Borgmann

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


[FFmpeg-devel] [PATCH 0/3] Codec wrapper for librv11 and RMHD muxer/demuxer

2018-01-18 Thread Thilo Borgmann
Hi,

Realnetworks released Linux libraries for their encoder/decoder of RealVideo 11 
(RV60) [1].
This is a joint approach to add a codec wrapper and suport muxing/demuxing of 
the latest real format version (RMHD).

I'd especially appreciate feedback on the handling of the PTS/DTS which IMHO is 
not what I think it should look like - there are non-monotonous pts returned 
and I think changes to ffmpeg.c are unnecessary. I could not be of much help 
with that yet and hope for some hints from someone who knows that stuff better 
than me.

When linking the binaries I got a "warning: multiple common of 'fpinit'". Not 
sure if there is something wrong with what I did in configure/make or if it is 
caused by the declaration in the installed header alone.

I split it up in separate patches for easier review only, non-functional if 
applied separately. Will be stashed after review or split in a sane way.

The codec comes in two separate binaries for en/decoding, so I did the same 
split in the code. I will add tests to FATE after review. If we'd prefer to 
have a sample for that which is not synthetic, I might ask them to forge a real 
small-sized sample for us to add to the fate-suite. I already tested 
successfully with private real-world test samples not created by this patchset.

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


Re: [FFmpeg-devel] [PATCH] add dumpwave filter

2018-01-18 Thread Dmytro Humeniuk

> On 18 Jan 2018, at 08:56, Tobias Rapp  wrote:
> 
> On 15.01.2018 13:48, Dmytro Humeniuk wrote:
>>> On 15 Jan 2018, at 09:14, Tobias Rapp  wrote:
>>> 
>>> On 13.01.2018 23:52, Дмитрий Гуменюк wrote:
 Hi,
> On 13 Jan 2018, at 01:37, Дмитрий Гуменюк  
> wrote:
> 
> Hi
> 
>> On 12 Jan 2018, at 13:32, Дмитрий Гуменюк  
>> wrote:
>> 
>>> On 12 Jan 2018, at 13:17, Tobias Rapp  wrote:
>>> 
>>> On 12.01.2018 12:16, Дмитрий Гуменюк wrote:
 Hi
> On 11 Jan 2018, at 09:20, Tobias Rapp  wrote:
> 
> On 10.01.2018 18:18, Kyle Swanson wrote:
>> Hi,
>> For this to be a part of libavfilter the output needs to be more 
>> generic
>> than the just the Soundcloud format. If we want this to be generally 
>> useful
>> it should probably just output an array of floats between 0.0 and 
>> 1.0. The
>> consumer of this data (JS library, or whatever) can use this in 
>> whatever
>> way it wants.
> 
> I agree. If the BWF Peak Envelope output which was suggested in the 
> other thread does not match your demands and filter implementation is 
> actually necessary I would prefer if the filter would attach the RMS 
> value(s) as frame metadata instead of directly dumping to file. Frame 
> metadata can then be re-
 RMS values may be counted for several frames or only for a half of a 
 frame
> used by other filters or dumped into file by using the existing 
> "ametadata" filter.
> 
> This would be similar to:
> 
> ffmpeg -i input-file -f null -filter:a 
> "asetnsamples=22050,astats=metadata=on,ametadata=print:file=stats-file.dat"
>  /dev/null
 I like this idea, but won’t asetnsamples affect performance by 
 creating fifo queue? And it may require some effort to parse long 
 output
>>> 
>>> I added asetnsamples to define the audio frame size (interval of values 
>>> from astats). You can reduce the number of lines printed by ametadata 
>>> by using the "key=lavfi.astats.foo" option.
>> I used asetnsamples as well, and I measured performance while 
>> transcoding - it appears to be slight slower
> I think output is now more generic and I got rid of long switch/case, 
> thanks for support
 Here is most recent patch, seems like all comments are addressed, did I 
 miss something?
>>> 
>>> I still would prefer to have the value attached as frame metadata, then 
>>> dumped into file via the existing "ametadata" filter. Even better would be 
>>> to integrate the statistic value (if missing) into the "astats" filter.
>>> 
>>> If your concern is the output format of "ametadata" then some output format 
>>> extension (CSV/JSON) needs to be discussed for ametadata/metadata.
>>> 
>>> If your concern is performance then please add some numbers. In my tests 
>>> using an approx. 5 minutes input WAV file (48kHz, stereo) the run with 
>>> "asetnsamples" was considerably faster than the run without (1.7s vs. 13.9s)
>> Hi
>> As I mentioned previously adding metadata to each frame is not possible
>> as value may be counted for several frames or only for a half of a frame
>> I used 2 hours long 48kHz mp3 
>> https://s3-eu-west-1.amazonaws.com/balamii/SynthSystemSystersJAN2018.mp3
>> For this purposes I set up CentOS AWS EC2 nano instance
>> Then I transcoded it while filtering like following (just to recreate real 
>> situation):
>> 1. -filter:a 
>> "asetnsamples=192197,astats=metadata=on,ametadata=print:file=stats-file.dat" 
>> out.mp3
>> 2. -filter:a "dumpwave=n=192197:f=-" out.mp3
>> Results:
>> 1. 244810550046 nanoseconds
>> 2. 87494286740 nanoseconds
>> One of the possible use cases - to set up 2 chains of asetnsamples->metadata 
>> - for example:
>> "asetnsamples=192197,astats=metadata=on,ametadata=print:file=stats-file.dat,asetnsamples=22050,astats=metadata=on,ametadata=print:file=stats-file1.dat”
>>  for sure it will affect performance
>> Comparing with "dumpwave=n=192197:f=out1,dumpwave=n= 22050:f=out2"
> 
> Sorry, I misunderstood your concerns regarding asetnsamples filter 
> performance. The numbers I provided have been for
> 
> "asetnsamples=22050,astats=metadata=on,ametadata=print:file=stats-file.dat"
> 
> versus
> 
> "astats=metadata=on,ametadata=print:file=stats-file.dat"
> 
> When comparing astats+ametadata versus dumpwave it is obvious that a 
> specialized filter which only calculates one statistic value is faster than a 
> filter that calculates multiple statistics. But still my opinion is that if 
> the dumpwave filter is to be added to the codebase it should be more generic 
> (i.e. output frame metadata similar to the psnr/ssim filters for video).

Actually current output(normalised float values in range 0...1) was proposed by 
Kyle as more generic.
> 
> Regards,
> Tobias
> 
> ___

Re: [FFmpeg-devel] [PATCH] ffmpeg.c: use sigterm_handler with sigpipe

2018-01-18 Thread Mark Thompson
On 18/01/18 16:02, Carl Eugen Hoyos wrote:
> 2018-01-18 16:55 GMT+01:00 Mark Thompson :
> 
>> Setting the termination option in the ffmpeg program or not shouldn't
>> make a difference to the behaviour inside the muxer
> 
> How did you test this?

The signal is received by a write call deep inside lavf, and it runs the signal 
handler which sets the termination option but doesn't actually act on it 
immediately.  The signal handler returns and the write call returns EPIPE, 
which then has to be handled correctly by all callers up the stack before the 
ffmpeg program even gets a chance to check the termination option at all.

From a little bit of testing with named pipes ignoring the signal does appear 
to have the right effect (fails in one muxer and closes the other cleanly), so 
I think that's probably the right answer.

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


Re: [FFmpeg-devel] [PATCH] add dumpwave filter

2018-01-18 Thread Dmytro Humeniuk

> On 18 Jan 2018, at 00:13, Moritz Barsnick  wrote:
> 
>> --- a/doc/filters.texi
>> +++ b/doc/filters.texi
>> @@ -680,13 +680,13 @@ select RIAA.
>> @item cd
>> select Compact Disc (CD).
>> @item 50fm
>> -select 50??s (FM).
>> +select 50??s (FM).
>> @item 75fm
>> -select 75??s (FM).
>> +select 75??s (FM).
>> @item 50kf
>> -select 50??s (FM-KF).
>> +select 50??s (FM-KF).
>> @item 75kf
>> -select 75??s (FM-KF).
>> +select 75??s (FM-KF).
>> @end table
>> @end table
> 
> Please review your own patches carefully. As you can see here, your
> editor is changing other sections due to some charset options or so.
> Please make sure that doesn't happen.
> 
Sorry, I will pay more attention reviewing patches
>> +The default value is @var{1800}
> 
> You probably don't need to add markup to "1800" (and is it really a
> @val? not @code?), especially:
> 
>> +Samples count per value per channel, default 128
> 
> as you didn't do that here either.
> 
>> +@item f, file
>> +Path to a file ``-'' is a shorthand
>> +for standard output.
> 
> There needs to be a comma or perios after "Path to a file".
> Furthermore, you don't need to wrap your lines so short.
> 
> 
>> more details but also more artifacts, while higher values make the image 
>> smoother
>> -but also blurrier. Default value is @code{0} ??? PSNR optimal.
>> +but also blurrier. Default value is @code{0} ??? PSNR optimal.
> 
> Your editor also changed this.
> 
>> +static const AVOption dumpwave_options[] = {
>> +{ "w", "set number of data values",  OFFSET(width), AV_OPT_TYPE_INT,  
>> {.i64 = 1800}, 1, INT_MAX, FLAGS },
>> +{ "width", "set number of data values",  OFFSET(width), 
>> AV_OPT_TYPE_INT,  {.i64 = 1800}, 1, INT_MAX, FLAGS },
>> +{ "n", "set number of samples per value per channel",  
>> OFFSET(nb_samples), AV_OPT_TYPE_INT64,  {.i64 = 128}, 1, INT64_MAX, FLAGS },
>> +{ "nb_samples", "set number of samples per value per channel",  
>> OFFSET(nb_samples), AV_OPT_TYPE_INT64,  {.i64 = 128}, 1, INT64_MAX, FLAGS },
>> +{ "f", "set dump file", OFFSET(filename), AV_OPT_TYPE_STRING, { .str = 
>> NULL }, 0, 0, FLAGS },
>> +{ "file", "set dump file", OFFSET(filename), AV_OPT_TYPE_STRING, { .str 
>> = NULL }, 0, 0, FLAGS },
> 
I’m not sure what is maximum line length limit
> Cosmetic: I suggest aligning these with some whitespace, which makes it
> easier to recognize the duplicated options.
> 
>> +dumpwave->values = av_malloc(dumpwave->width * sizeof(float));
>> +if (!dumpwave->values)
>> +return AVERROR(ENOMEM);
>> +memset(dumpwave->values, 0, dumpwave->width * sizeof(float));
> 
> av_mallocz()?
> 
>> +static inline void RMS(DumpWaveContext *dumpwave, const float sample)
> ^^^ I believe capitals are not desired here (but may be 
> wrong)
> 
>> +if (sample != 0)
> 
> 0.f
Thanks
> 
> Moritz
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



0001-avfilter-add-dumpwave-filter.patch
Description: Binary data


smime.p7s
Description: S/MIME cryptographic signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: use sigterm_handler with sigpipe

2018-01-18 Thread Mark Thompson
On 18/01/18 15:58, Nicolas George wrote:
> Mark Thompson (2018-01-18):
>> Changing it to ignore the signal (set it to SIG_IGN) instead sounds
>> like a safer option?
> 
> Yes, I think it would be somewhat safer. And it can be done without
> modification to FFmpeg.

To clarify: I was definitely proposing that the change be made in the ffmpeg 
program.  The appearance of SIGPIPE is a surprise to many people, and keeping 
the default disposition here does cause ffmpeg to behave significantly 
differently on Unix and Windows without any obvious reason why to those not 
familiar with it.

> What is missing, though, is better control on error conditions: when
> muxing in one output fails, choosing the behaviour for other outputs
> (continue, abort, close cleanly).

Sure.  That can be independent of any change to signal behaviour, though.

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


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: use sigterm_handler with sigpipe

2018-01-18 Thread wm4
On Thu, 18 Jan 2018 16:30:22 +0100
Carl Eugen Hoyos  wrote:

> 2018-01-18 16:27 GMT+01:00 Nicolas George :
> > Carl Eugen Hoyos (2018-01-18):  
> >> Could you please tell us which cases get broken?  
> >
> > I cannot.  
> 
> Ok.
> 
> So we both agree that FFmpeg should get rid of
> Vincent as fast as possible.

Please cease your uncalled for childish attacks against me.

I'm really having trouble what outraged you this time, just like I did
last time.

Maybe we should try to enforce the Code of Conduct for once?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [RFC] [PATCH] hls: export range of currently available segments

2018-01-18 Thread wm4
The intention is to:
1. let API users know whether a HLS stream is live
2. let API users know about the safe seek range

This is supposed to avoid Bad things happening when seeking outside of
range.

There are lots of problems with this patch:
- the API consists of adding yet another set of obscure format specific
  fields to an already huge struct
- determination of the first timestamp is fishy
- is it actually safe to seek to the very first segment?
- the range is only updated when the playlist is reloaded, but it could
  happen that the user accesses the fields while not having read any
  packets for a while, so the fields can be easily stale
- same when enabling/disabling streams (which happens by setting public
  fields, and the hls code only knows about this when reading a new
  packet or when seeking)

I'm open for ideas.

Also this change is untested (other than that it compiles).
---
 libavformat/avformat.h | 36 
 libavformat/hls.c  | 37 +
 libavformat/options.c  |  3 +++
 3 files changed, 76 insertions(+)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index b0387214c5..eb1b6b4a68 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1898,6 +1898,42 @@ typedef struct AVFormatContext {
  * - decoding: set by user
  */
 int max_streams;
+
+/**
+ * If this is set to 1, this is a live stream. Typically it will be
+ * unseekable, or allow seeking within a time window only.
+ *
+ * If this is set to 0, it is unknown what kind of stream this is. For
+ * specific protocols (such as HLS), it will indicate that it is
+ * definitely a static stream.
+ *
+ * Other values are reserved for the future, but if used will also indicate
+ * some kind of seek-restricted stream.
+ *
+ * - encoding: unused
+ * - decoding: set by libavformat
+ */
+int is_live_stream;
+
+/**
+ * If this field and available_range_end are set to a value other than
+ * AV_NOPTS_VALUE, they indicate the currently available media range in
+ * AV_TIME_BASE fractional seconds. This is supported by specific network
+ * protocols only, such as HLS. Generally this means you can seek within
+ * this range.
+ *
+ * - encoding: unused
+ * - decoding: set by libavformat
+ */
+int64_t available_range_start;
+
+/**
+ * See available_range_start field.
+ *
+ * - encoding: unused
+ * - decoding: set by libavformat
+ */
+int64_t available_range_end;
 } AVFormatContext;
 
 #if FF_API_FORMAT_GET_SET
diff --git a/libavformat/hls.c b/libavformat/hls.c
index 950cc4c3bd..557b185f4b 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -215,6 +215,8 @@ typedef struct HLSContext {
 AVIOContext *playlist_pb;
 } HLSContext;
 
+static int playlist_needed(struct playlist *pls);
+
 static int read_chomp_line(AVIOContext *s, char *buf, int maxlen)
 {
 int len = ff_get_line(s, buf, maxlen);
@@ -707,6 +709,40 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, 
const char *url,
 return ret;
 }
 
+static void update_available_range(HLSContext *c)
+{
+int n, i;
+
+c->ctx->available_range_start = AV_NOPTS_VALUE;
+c->ctx->available_range_end = AV_NOPTS_VALUE;
+c->ctx->is_live_stream = 0;
+
+for (n = 0; n < c->n_playlists; n++) {
+struct playlist *pls = c->playlists[n];
+int64_t ts;
+
+if (!playlist_needed(pls) || !pls->n_segments)
+continue;
+
+// Not sure where to get the actual start timestamp - might require
+// waiting until the first packet for every active stream on pls is 
read.
+ts = c->first_timestamp == AV_NOPTS_VALUE ? 0 : c->first_timestamp;
+if (c->ctx->available_range_start == AV_NOPTS_VALUE ||
+c->ctx->available_range_start < ts)
+c->ctx->available_range_start = ts;
+
+for (i = 0; 0 < pls->n_segments; i++)
+ts += pls->segments[i]->duration;
+
+if (c->ctx->available_range_end == AV_NOPTS_VALUE ||
+c->ctx->available_range_end > ts)
+c->ctx->available_range_end = ts;
+
+if (!pls->finished)
+c->ctx->is_live_stream = 1;
+}
+}
+
 static int parse_playlist(HLSContext *c, const char *url,
   struct playlist *pls, AVIOContext *in)
 {
@@ -930,6 +966,7 @@ fail:
 av_free(new_url);
 if (close_in)
 ff_format_io_close(c->ctx, &in);
+update_available_range(c);
 return ret;
 }
 
diff --git a/libavformat/options.c b/libavformat/options.c
index 9371c72667..875f81341e 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -138,6 +138,9 @@ static void avformat_get_context_defaults(AVFormatContext 
*s)
 s->io_open  = io_open_default;
 s->io_close = io_close_default;
 
+s->available_range_start = AV_NOPTS_VALUE;
+s->available_range_end = AV_NOPTS_VALUE;
+

Re: [FFmpeg-devel] [PATCH] ffmpeg.c: use sigterm_handler with sigpipe

2018-01-18 Thread Carl Eugen Hoyos
2018-01-18 16:55 GMT+01:00 Mark Thompson :

> Setting the termination option in the ffmpeg program or not shouldn't
> make a difference to the behaviour inside the muxer

How did you test this?

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


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: use sigterm_handler with sigpipe

2018-01-18 Thread Nicolas George
Mark Thompson (2018-01-18):
> Changing it to ignore the signal (set it to SIG_IGN) instead sounds
> like a safer option?

Yes, I think it would be somewhat safer. And it can be done without
modification to FFmpeg.

What is missing, though, is better control on error conditions: when
muxing in one output fails, choosing the behaviour for other outputs
(continue, abort, close cleanly).

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: use sigterm_handler with sigpipe

2018-01-18 Thread Mark Thompson
On 18/01/18 14:49, Dave Rice wrote:
> Thread bump.
> 
>> On Jan 11, 2018, at 5:51 PM, Nicolas George  wrote:
>>
>> Moritz Barsnick (2018-01-11):
>>> This patch doesn't change the handling of SIGTERM
>>
>> You should have read SIGPIPE, obviously.
>>
>>> Is SIGPIPE an interactive signal?
>>
>> Of course not.
>>
>>> Anything on the other side of output
>>> file(name) "-" or "pipe:N" may terminate for some reason.
>>
>> Yes, that is exactly what SIGPIPE is for.
>>
>>> This patch does NOT try to ignore anything. ffmpeg won't keep running
>>> due to ignoring of SIGPIPE, it will terminate more cleanly due to
>>> handling it. The former is not desired. (But yes, shall handing to
>>> enforce ignoring it would allow that.)
>>
>> It will terminate less cleanly than if you do the right thing with
>> SIGPIPE.
> 
> This patch has been working for me and ffmpeg terminates cleanly with SIGPIPE 
> with a valid output (moov atom written with mov or cues/seekhead written with 
> mkv). Not sure if I understand well the disadvantage of this patch.

Making SIGPIPE have an effect like this seems highly dubious to me, but I admit 
that since it always killed the process before it feels like an improvement.

Changing it to ignore the signal (set it to SIG_IGN) instead sounds like a 
safer option?  I think that would move the code to having the same behaviour on 
Unices as on Windows, since Windows has no SIGPIPE.

Setting the termination option in the ffmpeg program or not shouldn't make a 
difference to the behaviour inside the muxer - the failing call is still going 
to return and the error propagated to its caller like it is already on Windows, 
so that handling has to work anyway.  If there is a case where a subsequent 
call causes problems which are somehow different between Unix/Windows such that 
ignoring the signal does not make them act similarly then that is a bug which 
should be fixed.

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


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: use sigterm_handler with sigpipe

2018-01-18 Thread Nicolas George
Carl Eugen Hoyos (2018-01-18):
> We have disagreed in the past about pkg-config,
> you don't want me to test FFmpeg on less common
> systems, fine.

This is untrue. I have offered you help to find a work-flow to test
FFmpeg on less common systems while playing nice with pkg-config, but
you never accepted.

> Now you are again behaving childishly, be it because
> you don't like a patch, be it because you are in a
> bad mood.

Neither. Let me explain one last time.

Unix signals are an abomination, their behaviour is barely portable,
made mostly of undefined or implementation-defined behaviours, with a
lot of strange corner cases. They are also a very fragile edifice, with
some signals playing a very subtle but absolutely necessary role in the
correct workings of the system.

Programming with Unix signals should be reserved to very skilled
programmers. I usually do not even trust myself to touch them, except in
the simplest of cases; yet, if I say so myself, I think when it comes to
Unix system programming, I am rather ahead here.

I would not oppose a patch from a skilled Unix programmer who explains
the details of the behaviour changes and why they are good. But if
somebody just copy-paste a bit of code that looks vaguely similar and
says "I do not know what I am doing but it seems to fix my particular
use case", then I oppose. It would make things worse.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: use sigterm_handler with sigpipe

2018-01-18 Thread Paul B Mahol
On 1/18/18, Nicolas George  wrote:
> Carl Eugen Hoyos (2018-01-18):
>> Could you please tell us which cases get broken?
>
> I cannot. But these are Unix signals: there are.

Just ignore Nicolas, he doesn't know any better.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: use sigterm_handler with sigpipe

2018-01-18 Thread Carl Eugen Hoyos
2018-01-18 16:27 GMT+01:00 Nicolas George :
> Carl Eugen Hoyos (2018-01-18):
>> Could you please tell us which cases get broken?
>
> I cannot.

Ok.

So we both agree that FFmpeg should get rid of
Vincent as fast as possible.

We have disagreed in the past about pkg-config,
you don't want me to test FFmpeg on less common
systems, fine.

Now you are again behaving childishly, be it because
you don't like a patch, be it because you are in a
bad mood.

How do you expect we find more support for our common goal?

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


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: use sigterm_handler with sigpipe

2018-01-18 Thread Nicolas George
Carl Eugen Hoyos (2018-01-18):
> Could you please tell us which cases get broken?

I cannot. But these are Unix signals: there are.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: use sigterm_handler with sigpipe

2018-01-18 Thread Carl Eugen Hoyos
2018-01-18 16:19 GMT+01:00 Nicolas George :
> Carl Eugen Hoyos (2018-01-18):
>> The OP has created a very easy to reproduce case where
>> FFmpeg unexpectedly doesn't close its output files, and
>> a patch that fixes this (broken) behaviour.
>
> And the OP neglected to check that the patch does not
> break other cases.

Could you please tell us which cases get broken?

>> Why do you believe there is an indefinitely running process
>> involved?
>
> You misread.

Then please explain, I am not a native speaker.

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


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: use sigterm_handler with sigpipe

2018-01-18 Thread Nicolas George
Carl Eugen Hoyos (2018-01-18):
> The OP has created a very easy to reproduce case where
> FFmpeg unexpectedly doesn't close its output files, and
> a patch that fixes this (broken) behaviour.

And the OP neglected to check that the patch does not break other cases.

> Why do you believe there is an indefinitely running process
> involved?

You misread.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: use sigterm_handler with sigpipe

2018-01-18 Thread Carl Eugen Hoyos
2018-01-18 16:05 GMT+01:00 Nicolas George :
> Carl Eugen Hoyos (2018-01-18):
>> Would you like to elaborate?
>
> Of course, provided somebody is interested.
>
> Issuing the following command:
>
> trap "" SIGPIPE
>
> will ignore SIGPIPE in the shell and all subsequent programs started
> from it.

> It will achieve exactly the result of this patch

Dave's patch and your shell command above behave differently here.

> in a much cleaner way, without impacting others users.

It now terminates with an error message instead of succeeding.
Why is that cleaner?

>> Maybe you could explain the drawbacks?
>
> No, I cannot. I only know they exist, because signals on Unix are like
> that. In this instance, I consider the burden of the proof to be on the
> person who proposes the patch.
>
> Still, there is always the fact that it changes the behaviour in a
> significant way, possibly resulting in process running indefinitely
> where they were stopping previously.

Why do you think so?

The OP has created a very easy to reproduce case where
FFmpeg unexpectedly doesn't close its output files, and
a patch that fixes this (broken) behaviour.
Why do you believe there is an indefinitely running process
involved?

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


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: use sigterm_handler with sigpipe

2018-01-18 Thread Nicolas George
Carl Eugen Hoyos (2018-01-18):
> Would you like to elaborate?

Of course, provided somebody is interested.

Issuing the following command:

trap "" SIGPIPE

will ignore SIGPIPE in the shell and all subsequent programs started
from it. It will achieve exactly the result of this patch, in a much
cleaner way, without impacting others users.

> Maybe you could explain the drawbacks?

No, I cannot. I only know they exist, because signals on Unix are like
that. In this instance, I consider the burden of the proof to be on the
person who proposes the patch.

Still, there is always the fact that it changes the behaviour in a
significant way, possibly resulting in process running indefinitely
where they were stopping previously.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: use sigterm_handler with sigpipe

2018-01-18 Thread Carl Eugen Hoyos
2018-01-18 15:54 GMT+01:00 Nicolas George :

> The same result can be achieved with the shell

Would you like to elaborate?

> without the corresponding drawbacks.

Maybe you could explain the drawbacks?
Exiting FFmpeg without closing output files seems like a
major drawback to me, independently of the output format.

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


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: use sigterm_handler with sigpipe

2018-01-18 Thread wm4
On Thu, 18 Jan 2018 15:54:46 +0100
Nicolas George  wrote:

> Dave Rice (2018-01-18):
> > Not sure if I understand well the disadvantage of this patch.  
> 
> When dealing with Unix signals, "not sure if I understand" means
> "don't".

Well, he's asking you why.

If you refuse to explain, I don't think your opposition against the
patch has to count.

> The same result can be achieved with the shell, without the
> corresponding drawbacks.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: use sigterm_handler with sigpipe

2018-01-18 Thread Nicolas George
Dave Rice (2018-01-18):
> Not sure if I understand well the disadvantage of this patch.

When dealing with Unix signals, "not sure if I understand" means
"don't".

The same result can be achieved with the shell, without the
corresponding drawbacks.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: use sigterm_handler with sigpipe

2018-01-18 Thread Dave Rice
Thread bump.

> On Jan 11, 2018, at 5:51 PM, Nicolas George  wrote:
> 
> Moritz Barsnick (2018-01-11):
>> This patch doesn't change the handling of SIGTERM
> 
> You should have read SIGPIPE, obviously.
> 
>> Is SIGPIPE an interactive signal?
> 
> Of course not.
> 
>>  Anything on the other side of output
>> file(name) "-" or "pipe:N" may terminate for some reason.
> 
> Yes, that is exactly what SIGPIPE is for.
> 
>> This patch does NOT try to ignore anything. ffmpeg won't keep running
>> due to ignoring of SIGPIPE, it will terminate more cleanly due to
>> handling it. The former is not desired. (But yes, shall handing to
>> enforce ignoring it would allow that.)
> 
> It will terminate less cleanly than if you do the right thing with
> SIGPIPE.

This patch has been working for me and ffmpeg terminates cleanly with SIGPIPE 
with a valid output (moov atom written with mov or cues/seekhead written with 
mkv). Not sure if I understand well the disadvantage of this patch.
Dave Rice

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


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Dont write stream info for agroup

2018-01-18 Thread Jeyapal, Karthick


On 1/18/18 6:53 PM, Brendan McGrath wrote:
> I tried your suggestion and it still didn't work. So I took another look at 
> the spec and it looks like what was originally there was correct (as seen in 
> the below example):
> https://tools.ietf.org/html/rfc8216#section-8.6
>
> In that example - english-audio.m3u8 appears in both a MEDIA and STREAM-INF 
> entry with the STREAM-INF entry including an AUDIO tag that references back 
> to itself.
>
> So I believe this patch can be dropped.
>
> What I did discover was that it worked when I added a CODECS tag to the 
> STREAM-INF variant of the audio stream. The spec just says:
> Every EXT-X-STREAM-INF tag SHOULD include a CODECS attribute
>
> So I guess this is a bug in iOS.
I agree. But, there is a patch available 
https://patchwork.ffmpeg.org/patch/7000/ to add CODECS tag. 
You could check if applying that patch solves your issue. 
>
> On 18/01/18 21:59, Dixit, Vishwanath wrote:
>>
>> On 1/18/18 2:39 PM, Brendan McGrath wrote:
>>> When using an 'agroup' within var_stream_map - the audio stream is
>>> being added to the master playlist file as both an audio rendition
>>> and an individual stream (with an AUDIO reference back to itself).
>>>
>>> This patch ensures an audio rendition does not also appear within
>>> the stream info list.
>>>
>>> What follows is an example of the command to create this issue and
>>> the contents of the master playlist before and after this patch is
>>> applied:
>>>
>>> ffmpeg -i in.ts -b:a:0 128k -b:v:0 1800k -b:v:1 1024k -map 0:a \
>>> -map 0:v -map 0:v -f hls -var_stream_map "a:0,agroup:audio_0 "\
>>> "v:0,agroup:audio_0 v:1,agroup:audio_0" -master_pl_name \
>>> tv_hls.m3u8 tv_hls_%v.m3u8
>>>
>>> Before:
>>>   #EXTM3U
>>>   #EXT-X-VERSION:3
>>>   
>>> #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
>>>   #EXT-X-STREAM-INF:BANDWIDTH=140800,AUDIO="group_audio_0"
>>>   tv_hls_0.m3u8
>>>
>>>   
>>> #EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
>>>   tv_hls_1.m3u8
>>>
>>>   
>>> #EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
>>>   tv_hls_2.m3u8
>>>
>>> After:
>>>   #EXTM3U
>>>   #EXT-X-VERSION:3
>>>   
>>> #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
>>>   
>>> #EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
>>>   tv_hls_1.m3u8
>>>
>>>   
>>> #EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
>>>   tv_hls_2.m3u8
>>>
>>> Signed-off-by: Brendan McGrath 
>>> ---
>>>
>> Some use cases may need audio only variant streams. Ex: when bandwidth is 
>> too low. Also, I think the playback issue you are seeing, is because of 
>> AUDIO referencing back to itself, but, not because of audio only variant 
>> stream. So, instead of completely removing the audio only variant streams, 
>> you can just remove the self-referencing attribute (AUDIO=) from the 
>> #EXT-X-STREAM-INF tag’s attribute list, for the audio only variant streams.
>> #EXTM3U
>> #EXT-X-VERSION:3
>> #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
>> #EXT-X-STREAM-INF:BANDWIDTH=140800
>> tv_hls_0.m3u8
>>
>> #EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
>> tv_hls_1.m3u8
>>
>> #EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
>> tv_hls_2.m3u8
>>
>>
>>> Pre-patch - the hls stream I was testing would not play on the iOS devices 
>>> I was testing with.
>>>
>>> With the patch applied - they now play the stream
>>>
>>>   libavformat/hlsenc.c | 3 +++
>>>   1 file changed, 3 insertions(+)
>>>
>>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>>> index e36120c..a75853b 100644
>>> --- a/libavformat/hlsenc.c
>>> +++ b/libavformat/hlsenc.c
>>> @@ -1172,6 +1172,9 @@ static int create_master_playlist(AVFormatContext *s,
>>>   for (i = 0; i < hls->nb_varstreams; i++) {
>>>   vs = &(hls->var_streams[i]);
>>>   +if (!vs->has_video && !vs->has_subtitle && vs->agroup)
>>> +continue;
>>> +
>>>   m3u8_name_size = strlen(vs->m3u8_name) + 1;
>>>   m3u8_rel_name = av_malloc(m3u8_name_size);
>>>   if (!m3u8_rel_name) { 
>>
>>
>> ___
>> 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 mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Dont write stream info for agroup

2018-01-18 Thread Brendan McGrath
I tried your suggestion and it still didn't work. So I took another look 
at the spec and it looks like what was originally there was correct (as 
seen in the below example):

https://tools.ietf.org/html/rfc8216#section-8.6

In that example - english-audio.m3u8 appears in both a MEDIA and 
STREAM-INF entry with the STREAM-INF entry including an AUDIO tag that 
references back to itself.


So I believe this patch can be dropped.

What I did discover was that it worked when I added a CODECS tag to the 
STREAM-INF variant of the audio stream. The spec just says:

Every EXT-X-STREAM-INF tag SHOULD include a CODECS attribute

So I guess this is a bug in iOS.

On 18/01/18 21:59, Dixit, Vishwanath wrote:


On 1/18/18 2:39 PM, Brendan McGrath wrote:

When using an 'agroup' within var_stream_map - the audio stream is
being added to the master playlist file as both an audio rendition
and an individual stream (with an AUDIO reference back to itself).

This patch ensures an audio rendition does not also appear within
the stream info list.

What follows is an example of the command to create this issue and
the contents of the master playlist before and after this patch is
applied:

ffmpeg -i in.ts -b:a:0 128k -b:v:0 1800k -b:v:1 1024k -map 0:a \
-map 0:v -map 0:v -f hls -var_stream_map "a:0,agroup:audio_0 "\
"v:0,agroup:audio_0 v:1,agroup:audio_0" -master_pl_name \
tv_hls.m3u8 tv_hls_%v.m3u8

Before:
  #EXTM3U
  #EXT-X-VERSION:3
  
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
  #EXT-X-STREAM-INF:BANDWIDTH=140800,AUDIO="group_audio_0"
  tv_hls_0.m3u8

  #EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
  tv_hls_1.m3u8

  #EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
  tv_hls_2.m3u8

After:
  #EXTM3U
  #EXT-X-VERSION:3
  
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
  #EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
  tv_hls_1.m3u8

  #EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
  tv_hls_2.m3u8

Signed-off-by: Brendan McGrath 
---


Some use cases may need audio only variant streams. Ex: when bandwidth is too 
low. Also, I think the playback issue you are seeing, is because of AUDIO 
referencing back to itself, but, not because of audio only variant stream. So, 
instead of completely removing the audio only variant streams, you can just 
remove the self-referencing attribute (AUDIO=) from the #EXT-X-STREAM-INF tag’s 
attribute list, for the audio only variant streams.
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=140800
tv_hls_0.m3u8

#EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
tv_hls_1.m3u8

#EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
tv_hls_2.m3u8



Pre-patch - the hls stream I was testing would not play on the iOS devices I 
was testing with.

With the patch applied - they now play the stream

  libavformat/hlsenc.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index e36120c..a75853b 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1172,6 +1172,9 @@ static int create_master_playlist(AVFormatContext *s,
  for (i = 0; i < hls->nb_varstreams; i++) {
  vs = &(hls->var_streams[i]);
  
+if (!vs->has_video && !vs->has_subtitle && vs->agroup)

+continue;
+
  m3u8_name_size = strlen(vs->m3u8_name) + 1;
  m3u8_rel_name = av_malloc(m3u8_name_size);
  if (!m3u8_rel_name) {



___
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 4/4] avfilter/vf_framerate: add SIMD functions for frame blending

2018-01-18 Thread Martin Vignali
>  if (s->bitdepth == 8) {
>  s->blend_factor_max = 1 << BLEND_FACTOR_DEPTH8;
> -s->blend = blend_frames_c;
> +if (ARCH_X86 && EXTERNAL_AVX2(cpu_flags))
> +s->blend = ff_blend_frames_avx2;
>

I think it's :
if (EXTERNAL_AVX2_FAST(cpu_flags)


> +else if (ARCH_X86 && EXTERNAL_SSSE3(cpu_flags))
> +s->blend = ff_blend_frames_ssse3;
> +else
> +s->blend = blend_frames_c;
>  } else {
>  s->blend_factor_max = 1 << BLEND_FACTOR_DEPTH16;
> -s->blend = blend_frames16_c;
> +if (ARCH_X86 && EXTERNAL_AVX2(cpu_flags))
> +s->blend = ff_blend_frames16_avx2;
>

same here

+else if (ARCH_X86 && EXTERNAL_SSE4(cpu_flags))
> +s->blend = ff_blend_frames16_sse4;
> +else
> +s->blend = blend_frames16_c;
>  }
>
>
+
> +
> +INIT_XMM ssse3
> +BLEND_FRAMES
> +
> +INIT_YMM avx2
> +BLEND_FRAMES
>

Probably need
%if HAVE_AVX2_EXTERNAL

%end if (around INIT_YMM avx2)


> +
> +INIT_XMM sse4
> +BLEND_FRAMES16
> +
> +INIT_YMM avx2
> +BLEND_FRAMES16
> --
>
>
Martin
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] RTMPS to FFM

2018-01-18 Thread Timo Rothenpieler

Am 18.01.2018 um 03:38 schrieb Gonzalo Martinez:

Hi I have a client written in C++ that use a Hardware Encoder called Cedar
and Stream the Video and Audio to my RTMPS server but now I need to change
that to Stream locally to a ffserver.

The problem that I have when modify the URL from rtmps to
http://localhost:8090/feed1.ffm is an error in DTS. Specially this.

I/HipcamCameraJNI(  786): sending video pts=880919, dts=9223372036854775808
I/ffmpeg  (  786): Application provided invalid, non monotonically
increasing dts to muxer in stream 0: 800821 >= 800821
E/HipcamCameraJNI(  786): Error while writing video frame: Invalid argument

I need to contract someone to help with this bug, I have an environment
with the build and the code and you can test with me in the camera that is
android based.

Please let me know if someone can take this job or if you need more details
about the error.

Thanks


ffserver was dropped from the codebase as it was long unmaintained, same 
with its associated formats like ffm.

It's highly unlikely you are going to find any kind of support for it.



smime.p7s
Description: S/MIME Cryptographic Signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Dont write stream info for agroup

2018-01-18 Thread Dixit, Vishwanath


On 1/18/18 2:39 PM, Brendan McGrath wrote:
> When using an 'agroup' within var_stream_map - the audio stream is
> being added to the master playlist file as both an audio rendition
> and an individual stream (with an AUDIO reference back to itself).
>
> This patch ensures an audio rendition does not also appear within
> the stream info list.
>
> What follows is an example of the command to create this issue and
> the contents of the master playlist before and after this patch is
> applied:
>
> ffmpeg -i in.ts -b:a:0 128k -b:v:0 1800k -b:v:1 1024k -map 0:a \
> -map 0:v -map 0:v -f hls -var_stream_map "a:0,agroup:audio_0 "\
> "v:0,agroup:audio_0 v:1,agroup:audio_0" -master_pl_name \
> tv_hls.m3u8 tv_hls_%v.m3u8
>
> Before:
>  #EXTM3U
>  #EXT-X-VERSION:3
>  
> #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
>  #EXT-X-STREAM-INF:BANDWIDTH=140800,AUDIO="group_audio_0"
>  tv_hls_0.m3u8
>
>  
> #EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
>  tv_hls_1.m3u8
>
>  
> #EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
>  tv_hls_2.m3u8
>
> After:
>  #EXTM3U
>  #EXT-X-VERSION:3
>  
> #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
>  
> #EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
>  tv_hls_1.m3u8
>
>  
> #EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
>  tv_hls_2.m3u8
>
> Signed-off-by: Brendan McGrath 
> ---
>
Some use cases may need audio only variant streams. Ex: when bandwidth is too 
low. Also, I think the playback issue you are seeing, is because of AUDIO 
referencing back to itself, but, not because of audio only variant stream. So, 
instead of completely removing the audio only variant streams, you can just 
remove the self-referencing attribute (AUDIO=) from the #EXT-X-STREAM-INF tag’s 
attribute list, for the audio only variant streams.
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=140800
tv_hls_0.m3u8

#EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
tv_hls_1.m3u8

#EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
tv_hls_2.m3u8


> Pre-patch - the hls stream I was testing would not play on the iOS devices I 
> was testing with.
>
> With the patch applied - they now play the stream
>
>  libavformat/hlsenc.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index e36120c..a75853b 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1172,6 +1172,9 @@ static int create_master_playlist(AVFormatContext *s,
>  for (i = 0; i < hls->nb_varstreams; i++) {
>  vs = &(hls->var_streams[i]);
>  
> +if (!vs->has_video && !vs->has_subtitle && vs->agroup)
> +continue;
> +
>  m3u8_name_size = strlen(vs->m3u8_name) + 1;
>  m3u8_rel_name = av_malloc(m3u8_name_size);
>  if (!m3u8_rel_name) {



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


Re: [FFmpeg-devel] [PATCH 1/2] lavc: Add coded_w/h to AVCodecParameters

2018-01-18 Thread Hendrik Leppkes
On Thu, Jan 18, 2018 at 6:14 AM, James Almer  wrote:
> On 1/18/2018 2:03 AM, Zhong Li wrote:
>> coded_width/height may be different from width/height sometimes
>
>> (e.g, crop or lowres cases).
>
> Which is why it's not a field that belongs to AVCodecParameters.
>
> Codec level cropping has nothing to do with containers. Same with
> lowres, which is an internal feature, and scheduled for removal.

Indeed, the coded w/h are technical details internal to a codec, and
not relevant as a codec parameter.

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


[FFmpeg-devel] [PATCH] dashdec: Only free url string if being reused

2018-01-18 Thread Brendan McGrath
If no representation bandwidth value is set, the url value returned
by get_content_url is corrupt (as the memory has been freed).

This change ensures the url string is not freed unless it is about
to be reused

Signed-off-by: Brendan McGrath 
---
 libavformat/dashdec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 2492f1d..83980b9 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -482,9 +482,11 @@ static char *get_content_url(xmlNodePtr *baseurl_nodes,
 return NULL;
 }
 av_strlcpy(tmp_str, url, sizeof(tmp_str));
-av_free(url);
 }
 if (rep_bandwidth_val && tmp_str[0] != '\0') {
+if (url) {
+av_free(url);
+}
 url = av_strireplace(tmp_str, "$Bandwidth$", (const 
char*)rep_bandwidth_val);
 if (!url) {
 return NULL;
-- 
2.7.4

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


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: Dont write stream info for agroup

2018-01-18 Thread 刘歧


> On 18 Jan 2018, at 17:09, Brendan McGrath  wrote:
> 
> When using an 'agroup' within var_stream_map - the audio stream is
> being added to the master playlist file as both an audio rendition
> and an individual stream (with an AUDIO reference back to itself).
https://patchwork.ffmpeg.org/patch/7229/

Can this patch pass your test case?
> 
> This patch ensures an audio rendition does not also appear within
> the stream info list.
> 
> What follows is an example of the command to create this issue and
> the contents of the master playlist before and after this patch is
> applied:
> 
> ffmpeg -i in.ts -b:a:0 128k -b:v:0 1800k -b:v:1 1024k -map 0:a \
> -map 0:v -map 0:v -f hls -var_stream_map "a:0,agroup:audio_0 "\
> "v:0,agroup:audio_0 v:1,agroup:audio_0" -master_pl_name \
> tv_hls.m3u8 tv_hls_%v.m3u8
> 
> Before:
> #EXTM3U
> #EXT-X-VERSION:3
> #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
> #EXT-X-STREAM-INF:BANDWIDTH=140800,AUDIO="group_audio_0"
> tv_hls_0.m3u8
> 
> #EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
> tv_hls_1.m3u8
> 
> #EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
> tv_hls_2.m3u8
> 
> After:
> #EXTM3U
> #EXT-X-VERSION:3
> #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
> #EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
> tv_hls_1.m3u8
> 
> #EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
> tv_hls_2.m3u8
> 
> Signed-off-by: Brendan McGrath 
> ---
> 
> Pre-patch - the hls stream I was testing would not play on the iOS devices I 
> was testing with.
> 
> With the patch applied - they now play the stream
> 
> libavformat/hlsenc.c | 3 +++
> 1 file changed, 3 insertions(+)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index e36120c..a75853b 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1172,6 +1172,9 @@ static int create_master_playlist(AVFormatContext *s,
> for (i = 0; i < hls->nb_varstreams; i++) {
> vs = &(hls->var_streams[i]);
> 
> +if (!vs->has_video && !vs->has_subtitle && vs->agroup)
> +continue;
> +
> m3u8_name_size = strlen(vs->m3u8_name) + 1;
> m3u8_rel_name = av_malloc(m3u8_name_size);
> if (!m3u8_rel_name) {
> -- 
> 2.7.4
> 
> ___
> 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 V2 2/2] Don't overwrite previously setup dimensions for all codecs

2018-01-18 Thread Carl Eugen Hoyos
2018-01-18 6:03 GMT+01:00 Zhong Li :
> Currently a hacky way is used for some specific codecs such as
> H264/VP6F/DXV

> (and "lowres" case is broken now).

How can I reproduce this?

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


Re: [FFmpeg-devel] [PATCH 4/4] avfilter/vf_framerate: add SIMD functions for frame blending

2018-01-18 Thread Carl Eugen Hoyos
2018-01-18 1:03 GMT+01:00 Marton Balint :
> Blend function speedups on x86_64 Core i5 4460:
>
> ffmpeg -f lavfi -i allyuv -vf framerate=60:threads=1 -f null none
>
> C: 447548411 decicycles in Blend,2048 runs,  0 skips
> SSSE3: 130020087 decicycles in Blend,2048 runs,  0 skips
> AVX2:  128508221 decicycles in Blend,2048 runs,  0 skips
>
> ffmpeg -f lavfi -i allyuv -vf format=yuv420p12,framerate=60:threads=1 -f null 
> none
>
> C: 228932745 decicycles in Blend,2048 runs,  0 skips
> SSE4:  123357781 decicycles in Blend,2048 runs,  0 skips
> AVX2:  121215353 decicycles in Blend,2048 runs,  0 skips

Is the avx2 version really useful?

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


[FFmpeg-devel] [PATCH] avformat/hlsenc: Dont write stream info for agroup

2018-01-18 Thread Brendan McGrath
When using an 'agroup' within var_stream_map - the audio stream is
being added to the master playlist file as both an audio rendition
and an individual stream (with an AUDIO reference back to itself).

This patch ensures an audio rendition does not also appear within
the stream info list.

What follows is an example of the command to create this issue and
the contents of the master playlist before and after this patch is
applied:

ffmpeg -i in.ts -b:a:0 128k -b:v:0 1800k -b:v:1 1024k -map 0:a \
-map 0:v -map 0:v -f hls -var_stream_map "a:0,agroup:audio_0 "\
"v:0,agroup:audio_0 v:1,agroup:audio_0" -master_pl_name \
tv_hls.m3u8 tv_hls_%v.m3u8

Before:
 #EXTM3U
 #EXT-X-VERSION:3
 
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
 #EXT-X-STREAM-INF:BANDWIDTH=140800,AUDIO="group_audio_0"
 tv_hls_0.m3u8

 #EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
 tv_hls_1.m3u8

 #EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
 tv_hls_2.m3u8

After:
 #EXTM3U
 #EXT-X-VERSION:3
 
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_audio_0",NAME="audio_0",DEFAULT=YES,URI="tv_hls_0.m3u8"
 #EXT-X-STREAM-INF:BANDWIDTH=2120800,RESOLUTION=1920x1080,AUDIO="group_audio_0"
 tv_hls_1.m3u8

 #EXT-X-STREAM-INF:BANDWIDTH=1267200,RESOLUTION=1920x1080,AUDIO="group_audio_0"
 tv_hls_2.m3u8

Signed-off-by: Brendan McGrath 
---

Pre-patch - the hls stream I was testing would not play on the iOS devices I 
was testing with.

With the patch applied - they now play the stream

 libavformat/hlsenc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index e36120c..a75853b 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1172,6 +1172,9 @@ static int create_master_playlist(AVFormatContext *s,
 for (i = 0; i < hls->nb_varstreams; i++) {
 vs = &(hls->var_streams[i]);
 
+if (!vs->has_video && !vs->has_subtitle && vs->agroup)
+continue;
+
 m3u8_name_size = strlen(vs->m3u8_name) + 1;
 m3u8_rel_name = av_malloc(m3u8_name_size);
 if (!m3u8_rel_name) {
-- 
2.7.4

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


Re: [FFmpeg-devel] [PATCH v1 1/3] avcodec: v4l2_m2m: fix races around freeing data on close

2018-01-18 Thread Jorge Ramirez-Ortiz

On 01/09/2018 11:56 PM, Jorge Ramirez-Ortiz wrote:

From: Mark Thompson 

Refcount all of the context information. This also fixes a potential
segmentation fault when accessing freed memory  (buffer returned after
the codec has been closed).


just a follow up on the patchset (patches 1 to 3)
any feedback? shall I resend?

thanks!


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