Re: [FFmpeg-devel] [PATCH 1/2] vaapi_h264: Add named options for setting profile and level

2017-11-30 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Moritz Barsnick
> Sent: Thursday, November 30, 2017 10:33 PM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH 1/2] vaapi_h264: Add named options for
> setting profile and level
> 
> On Thu, Nov 30, 2017 at 08:52:21 +, Li, Zhong wrote:
> > > +{ LEVEL("6",   60) },
> > > +{ LEVEL("6.1", 61) },
> > > +{ LEVEL("6.2", 62) },
> >
> > IIRC, level 5.2 is the maximum level of H264?
> 
> Higher levels were introduced in 2016. Edition V12 of H.264 lists 6,
> 6.1 and 6.2 in Annex A, Table A-1. It basically lists the same thing as
> Wikipedia:
> https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Levels

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


Re: [FFmpeg-devel] [PATCH 2/2] vaapi_h265: Add named options for setting profile and level

2017-11-30 Thread Song, Ruiling


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of
> Hendrik Leppkes
> Sent: Thursday, November 30, 2017 6:12 PM
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH 2/2] vaapi_h265: Add named options for
> setting profile and level
> 
> On Thu, Nov 30, 2017 at 10:40 AM, Li, Zhong  wrote:
> >> -Original Message-
> >> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> >> Of Mark Thompson
> >> Sent: Thursday, November 30, 2017 7:30 AM
> >> To: ffmpeg-devel@ffmpeg.org
> >> Subject: [FFmpeg-devel] [PATCH 2/2] vaapi_h265: Add named options for
> >> setting profile and level
> >>
> >> Also fixes the default, which previously contained a nonsense value.
> >> ---
> >> On 29/11/17 03:51, Li, Zhong wrote:
> >> >> On 28/11/17 07:46, Ruiling Song wrote:
> >> >>> Signed-off-by: Ruiling Song 
> >> >>> ---
> >> >>>  libavcodec/vaapi_encode_h265.c | 2 +-
> >> >>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >> >>>
> >> >>> diff --git a/libavcodec/vaapi_encode_h265.c
> >> >>> b/libavcodec/vaapi_encode_h265.c index 3ae92a7..32b8bc6 100644
> >> >>> --- a/libavcodec/vaapi_encode_h265.c
> >> >>> +++ b/libavcodec/vaapi_encode_h265.c
> >> >>> @@ -219,7 +219,7 @@ static int
> >> >> vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
> >> >>>  .general_non_packed_constraint_flag = 1,
> >> >>>  .general_frame_only_constraint_flag = 1,
> >> >>>
> >> >>> -.general_level_idc = avctx->level,
> >> >>> +.general_level_idc = avctx->level * 3,
> >> >>>  };
> >> >>>
> >> >>> vps->profile_tier_level.general_profile_compatibility_flag[avctx->pr
> >> >>> vps->of
> >> >>> ile & 31] = 1;
> >> >>>
> >> >>>
> >> >> The documentation has always said "profile and level set the values
> >> >> of general_profile_idc and general_level_idc respectively"
> >> >> () - the code
> >> >> disagreed for a while, but that was made consistent in
> >> >> 00179664bccd1dd6fa0d1c40db453528757bf6f7.
> >> >>
> >> >> Why do you want to change it to be general_level_idc / 3 instead?
> >> >
> >> > As HEVC spec, "general_level_idc and sub_layer_level_idc[ i ] shall be
> >> > set equal to a value of 30 times the level number specified in Table 
> >> > A.4."
> >> > And use the tool "mediainfo" to check the encoded bitstream, it show the
> >> level is 1.7 if set the option "-level" to be 51.
> >> >
> >> > Maybe the documentation
> >> (()) also needs to
> >> be changed?
> >>
> >> Hmm, right - the default is wrong, so you get a nonsense value there.
> >>
> >> How about we fix that and add named constants to make it clearer, like 
> >> this?
> >
> > I think it is a good idea, except one situation:
> > Suppose user set the level to be 41, they may want an encoded bitstream with
> level 4.1, right?
> > But actually the output level is 1.4 (using mediainfo to check this), 
> > currently we
> are forcing them to set the option to be 4.1 or 123, right?
> > Haven't verify your patch, just infer from the code.
> 
> 
> But 41 is never 4.1 for HEVC, so using a scheme that was basically
> "invented" doesn't seem right (probably as a carry-over from H264).
> When decoding, avctx->level contains 123, not 41, for example, or for
> a closer match, NVENC accepts -profile:v 123 or -profile:v 4.1, but
> not 41.
> I think its more important to stay consistent here (both to the HEVC
> spec and other HEVC encoders), instead of catering to an imaginary
> value that is never actually used in relation to HEVC.

I agree with you on this. It would be better if we can keep consistent here.
For this level information, if user want to set level to 5.1 in hevc.
They can do as: "-level 5.1" or "-level 153". I tried Mark's patch, it works as 
expected.

- Ruiling

> 
> - Hendrik
> ___
> 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][RFC] avutil/reverse: make ff_reverse shared

2017-11-30 Thread Steven Liu
2017-12-01 9:19 GMT+08:00 James Almer :
> Signed-off-by: James Almer 
> ---
> Pros:
> Removes duplicate arrays and ugly c file including c files
>
> Cons:
> Makes the array in libavutil effectively part of the ABI.
> Might not be worth doing for 256 bytes
>
>
> Something like this was probably sent before, so i guess it
> will be rejected again.
>
>  libavcodec/Makefile  |  2 +-
>  libavcodec/asvdec.c  |  4 ++--
>  libavcodec/asvenc.c  |  4 ++--
>  libavcodec/dcaenc.c  |  2 +-
>  libavcodec/dsd.c |  4 ++--
>  libavcodec/dsddec.c  |  2 +-
>  libavcodec/dstdec.c  |  2 +-
>  libavcodec/indeo2.c  |  2 +-
>  libavcodec/ivi.c |  6 +++---
>  libavcodec/mathops.h |  8 
>  libavcodec/mpeg12dec.c   |  4 ++--
>  libavcodec/pcm.c |  8 
>  libavcodec/reverse.c |  1 -
>  libavcodec/s302m.c   | 36 ++--
>  libavcodec/s302menc.c| 36 ++--
>  libavcodec/tiff.c| 10 +-
>  libavcodec/webp.c|  4 ++--
>  libavcodec/wnv1.c|  4 ++--
>  libavcodec/xbmdec.c  |  4 ++--
>  libavcodec/xbmenc.c  |  2 +-
>  libavdevice/Makefile |  1 -
>  libavdevice/decklink_dec.cpp |  2 +-
>  libavdevice/reverse.c|  1 -
>  libavutil/eval.c |  2 +-
>  libavutil/reverse.c  |  3 ++-
>  libavutil/reverse.h  |  3 ++-
>  26 files changed, 78 insertions(+), 79 deletions(-)
>  delete mode 100644 libavcodec/reverse.c
>  delete mode 100644 libavdevice/reverse.c
>
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index ab7893f560..6942b2c926 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -129,7 +129,7 @@ OBJS-$(CONFIG_QSVENC)  += qsvenc.o
>  OBJS-$(CONFIG_RANGECODER)  += rangecoder.o
>  OBJS-$(CONFIG_RDFT)+= rdft.o
>  OBJS-$(CONFIG_RV34DSP) += rv34dsp.o
> -OBJS-$(CONFIG_SHARED)  += log2_tab.o reverse.o
> +OBJS-$(CONFIG_SHARED)  += log2_tab.o
>  OBJS-$(CONFIG_SINEWIN) += sinewin.o sinewin_fixed.o
>  OBJS-$(CONFIG_SNAPPY)  += snappy.o
>  OBJS-$(CONFIG_STARTCODE)   += startcode.o
> diff --git a/libavcodec/asvdec.c b/libavcodec/asvdec.c
> index 9a11446f52..11d1564db3 100644
> --- a/libavcodec/asvdec.c
> +++ b/libavcodec/asvdec.c
> @@ -71,7 +71,7 @@ static av_cold void init_vlcs(ASV1Context *a)
>  // FIXME write a reversed bitstream reader to avoid the double reverse
>  static inline int asv2_get_bits(GetBitContext *gb, int n)
>  {
> -return ff_reverse[get_bits(gb, n) << (8 - n)];
> +return avpriv_reverse[get_bits(gb, n) << (8 - n)];
>  }
>
>  static inline int asv1_get_level(GetBitContext *gb)
> @@ -229,7 +229,7 @@ static int decode_frame(AVCodecContext *avctx, void 
> *data, int *got_frame,
>  } else {
>  int i;
>  for (i = 0; i < buf_size; i++)
> -a->bitstream_buffer[i] = ff_reverse[buf[i]];
> +a->bitstream_buffer[i] = avpriv_reverse[buf[i]];
>  }
>
>  init_get_bits(>gb, a->bitstream_buffer, buf_size * 8);
> diff --git a/libavcodec/asvenc.c b/libavcodec/asvenc.c
> index c4eca2a13d..7ed932c934 100644
> --- a/libavcodec/asvenc.c
> +++ b/libavcodec/asvenc.c
> @@ -37,7 +37,7 @@
>
>  static inline void asv2_put_bits(PutBitContext *pb, int n, int v)
>  {
> -put_bits(pb, n, ff_reverse[v << (8 - n)]);
> +put_bits(pb, n, avpriv_reverse[v << (8 - n)]);
>  }
>
>  static inline void asv1_put_level(PutBitContext *pb, int level)
> @@ -306,7 +306,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket 
> *pkt,
>  } else {
>  int i;
>  for (i = 0; i < 4 * size; i++)
> -pkt->data[i] = ff_reverse[pkt->data[i]];
> +pkt->data[i] = avpriv_reverse[pkt->data[i]];
>  }
>
>  pkt->size   = size * 4;
> diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c
> index dd601ffae0..b111fe98ba 100644
> --- a/libavcodec/dcaenc.c
> +++ b/libavcodec/dcaenc.c
> @@ -446,7 +446,7 @@ static void fft(const int32_t in[2 * 256], cplx32 
> out[256])
>  }
>  /* post-rotation */
>  for (i = 0; i < 256; i++) {
> -int b = ff_reverse[i];
> +int b = avpriv_reverse[i];
>  rout[i].re = mul32(buf[b].re, cos_t(4 * i))
> - mul32(buf[b].im, sin_t(4 * i));
>  rout[i].im = mul32(buf[b].im, cos_t(4 * i))
> diff --git a/libavcodec/dsd.c b/libavcodec/dsd.c
> index 9104f38476..2233adf349 100644
> --- a/libavcodec/dsd.c
> +++ b/libavcodec/dsd.c
> @@ -63,11 +63,11 @@ void ff_dsd2pcm_translate(DSDContext* s, size_t samples, 
> int lsbf,
>  pos = s->pos;
>
>  while (samples-- > 0) {
> -s->buf[pos] = lsbf ? ff_reverse[*src] : *src;
> +s->buf[pos] = lsbf ? avpriv_reverse[*src] : *src;
>  src += src_stride;

Re: [FFmpeg-devel] [ogg] Respect AVERROR codes returned by ogg header parsing.

2017-11-30 Thread Michael Niedermayer
On Thu, Nov 30, 2017 at 12:19:10PM -0800, Dale Curtis wrote:
> On Wed, Nov 29, 2017 at 5:58 PM, Michael Niedermayer  > wrote:
> 
> >
> > AV_EF_EXPLODE appears to be a possibility, yes
> > in general demuxers should try to extract as much as possible from a
> > file and not give up if some broken packet is found
> >
> 
> I don't think this is a good idea; some of these errors seem fairly fatal
> to the overall process. I think instead it's better to write off the sample
> you have as being invalid. That said, I defer to your judgement here, so
> I've produced both versions of the patch and leave it to your decision.
> Chrome is now always using AV_EF_EXPLODE, so either works for our usage.

Ive taken a deeper look as this doesnt sound right

I dont see anything really wrong with the file

it seems what happens is that theres a data packet in one stream that
preceeds the headers on the other streams, technically that data packet
likely contains the video headers so its kind of a header too.

The demuxer stops header parsing prematurly due to this.
from there on it gets confused reading the same header twice
while it determines the duration of the file which triggers the error

There are a few differnt ways to fix this, iam not sure which is the
simplest but i dont think the demuxer should fail in this case

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

"Nothing to hide" only works if the folks in power share the values of
you and everyone you know entirely and always will -- Tom Scott



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


[FFmpeg-devel] [PATCH][RFC] avutil/reverse: make ff_reverse shared

2017-11-30 Thread James Almer
Signed-off-by: James Almer 
---
Pros:
Removes duplicate arrays and ugly c file including c files

Cons:
Makes the array in libavutil effectively part of the ABI.
Might not be worth doing for 256 bytes


Something like this was probably sent before, so i guess it
will be rejected again.

 libavcodec/Makefile  |  2 +-
 libavcodec/asvdec.c  |  4 ++--
 libavcodec/asvenc.c  |  4 ++--
 libavcodec/dcaenc.c  |  2 +-
 libavcodec/dsd.c |  4 ++--
 libavcodec/dsddec.c  |  2 +-
 libavcodec/dstdec.c  |  2 +-
 libavcodec/indeo2.c  |  2 +-
 libavcodec/ivi.c |  6 +++---
 libavcodec/mathops.h |  8 
 libavcodec/mpeg12dec.c   |  4 ++--
 libavcodec/pcm.c |  8 
 libavcodec/reverse.c |  1 -
 libavcodec/s302m.c   | 36 ++--
 libavcodec/s302menc.c| 36 ++--
 libavcodec/tiff.c| 10 +-
 libavcodec/webp.c|  4 ++--
 libavcodec/wnv1.c|  4 ++--
 libavcodec/xbmdec.c  |  4 ++--
 libavcodec/xbmenc.c  |  2 +-
 libavdevice/Makefile |  1 -
 libavdevice/decklink_dec.cpp |  2 +-
 libavdevice/reverse.c|  1 -
 libavutil/eval.c |  2 +-
 libavutil/reverse.c  |  3 ++-
 libavutil/reverse.h  |  3 ++-
 26 files changed, 78 insertions(+), 79 deletions(-)
 delete mode 100644 libavcodec/reverse.c
 delete mode 100644 libavdevice/reverse.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index ab7893f560..6942b2c926 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -129,7 +129,7 @@ OBJS-$(CONFIG_QSVENC)  += qsvenc.o
 OBJS-$(CONFIG_RANGECODER)  += rangecoder.o
 OBJS-$(CONFIG_RDFT)+= rdft.o
 OBJS-$(CONFIG_RV34DSP) += rv34dsp.o
-OBJS-$(CONFIG_SHARED)  += log2_tab.o reverse.o
+OBJS-$(CONFIG_SHARED)  += log2_tab.o
 OBJS-$(CONFIG_SINEWIN) += sinewin.o sinewin_fixed.o
 OBJS-$(CONFIG_SNAPPY)  += snappy.o
 OBJS-$(CONFIG_STARTCODE)   += startcode.o
diff --git a/libavcodec/asvdec.c b/libavcodec/asvdec.c
index 9a11446f52..11d1564db3 100644
--- a/libavcodec/asvdec.c
+++ b/libavcodec/asvdec.c
@@ -71,7 +71,7 @@ static av_cold void init_vlcs(ASV1Context *a)
 // FIXME write a reversed bitstream reader to avoid the double reverse
 static inline int asv2_get_bits(GetBitContext *gb, int n)
 {
-return ff_reverse[get_bits(gb, n) << (8 - n)];
+return avpriv_reverse[get_bits(gb, n) << (8 - n)];
 }
 
 static inline int asv1_get_level(GetBitContext *gb)
@@ -229,7 +229,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, 
int *got_frame,
 } else {
 int i;
 for (i = 0; i < buf_size; i++)
-a->bitstream_buffer[i] = ff_reverse[buf[i]];
+a->bitstream_buffer[i] = avpriv_reverse[buf[i]];
 }
 
 init_get_bits(>gb, a->bitstream_buffer, buf_size * 8);
diff --git a/libavcodec/asvenc.c b/libavcodec/asvenc.c
index c4eca2a13d..7ed932c934 100644
--- a/libavcodec/asvenc.c
+++ b/libavcodec/asvenc.c
@@ -37,7 +37,7 @@
 
 static inline void asv2_put_bits(PutBitContext *pb, int n, int v)
 {
-put_bits(pb, n, ff_reverse[v << (8 - n)]);
+put_bits(pb, n, avpriv_reverse[v << (8 - n)]);
 }
 
 static inline void asv1_put_level(PutBitContext *pb, int level)
@@ -306,7 +306,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket 
*pkt,
 } else {
 int i;
 for (i = 0; i < 4 * size; i++)
-pkt->data[i] = ff_reverse[pkt->data[i]];
+pkt->data[i] = avpriv_reverse[pkt->data[i]];
 }
 
 pkt->size   = size * 4;
diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c
index dd601ffae0..b111fe98ba 100644
--- a/libavcodec/dcaenc.c
+++ b/libavcodec/dcaenc.c
@@ -446,7 +446,7 @@ static void fft(const int32_t in[2 * 256], cplx32 out[256])
 }
 /* post-rotation */
 for (i = 0; i < 256; i++) {
-int b = ff_reverse[i];
+int b = avpriv_reverse[i];
 rout[i].re = mul32(buf[b].re, cos_t(4 * i))
- mul32(buf[b].im, sin_t(4 * i));
 rout[i].im = mul32(buf[b].im, cos_t(4 * i))
diff --git a/libavcodec/dsd.c b/libavcodec/dsd.c
index 9104f38476..2233adf349 100644
--- a/libavcodec/dsd.c
+++ b/libavcodec/dsd.c
@@ -63,11 +63,11 @@ void ff_dsd2pcm_translate(DSDContext* s, size_t samples, 
int lsbf,
 pos = s->pos;
 
 while (samples-- > 0) {
-s->buf[pos] = lsbf ? ff_reverse[*src] : *src;
+s->buf[pos] = lsbf ? avpriv_reverse[*src] : *src;
 src += src_stride;
 
 p = s->buf + ((pos - CTABLES) & FIFOMASK);
-*p = ff_reverse[*p];
+*p = avpriv_reverse[*p];
 
 sum = 0.0;
 for (i = 0; i < CTABLES; i++) {
diff --git a/libavcodec/dsddec.c b/libavcodec/dsddec.c
index 2c5c357acc..3974bdeeb2 100644
--- a/libavcodec/dsddec.c

[FFmpeg-devel] ffplay: use AV_PKT_FLAG_DISPOSABLE in frame drop logic

2017-11-30 Thread John Stebbins
Fix parenthesis in conditional
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 6/6] ffplay: use AV_PKT_FLAG_DISPOSABLE in frame drop logic

2017-11-30 Thread John Stebbins
---
 fftools/ffplay.c | 21 -
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 10a917194d..152d220cdb 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -198,6 +198,8 @@ typedef struct Decoder {
 int64_t next_pts;
 AVRational next_pts_tb;
 SDL_Thread *decoder_tid;
+int drop_disposable;
+int frame_drops_disposable;
 } Decoder;
 
 typedef struct VideoState {
@@ -660,10 +662,16 @@ static int decoder_decode_frame(Decoder *d, AVFrame 
*frame, AVSubtitle *sub) {
 ret = got_frame ? 0 : (pkt.data ? AVERROR(EAGAIN) : 
AVERROR_EOF);
 }
 } else {
-if (avcodec_send_packet(d->avctx, ) == AVERROR(EAGAIN)) {
-av_log(d->avctx, AV_LOG_ERROR, "Receive_frame and 
send_packet both returned EAGAIN, which is an API violation.\n");
-d->packet_pending = 1;
-av_packet_move_ref(>pkt, );
+if (d->avctx->codec_type == AVMEDIA_TYPE_VIDEO &&
+d->drop_disposable &&
+(pkt.flags & AV_PKT_FLAG_DISPOSABLE)) {
+d->frame_drops_disposable++;
+} else {
+if (avcodec_send_packet(d->avctx, ) == 
AVERROR(EAGAIN)) {
+av_log(d->avctx, AV_LOG_ERROR, "Receive_frame and 
send_packet both returned EAGAIN, which is an API violation.\n");
+d->packet_pending = 1;
+av_packet_move_ref(>pkt, );
+}
 }
 }
 av_packet_unref();
@@ -1622,6 +1630,7 @@ retry:
 frame_queue_next(>pictq);
 goto retry;
 }
+is->viddec.drop_disposable = 0;
 }
 
 if (is->subtitle_st) {
@@ -1699,7 +1708,8 @@ display:
get_master_clock(is),
(is->audio_st && is->video_st) ? "A-V" : (is->video_st ? 
"M-V" : (is->audio_st ? "M-A" : "   ")),
av_diff,
-   is->frame_drops_early + is->frame_drops_late,
+   is->frame_drops_early + is->frame_drops_late +
+   is->viddec.frame_drops_disposable,
aqsize / 1024,
vqsize / 1024,
sqsize,
@@ -1767,6 +1777,7 @@ static int get_video_frame(VideoState *is, AVFrame *frame)
 is->frame_drops_early++;
 av_frame_unref(frame);
 got_picture = 0;
+is->viddec.drop_disposable = 1;
 }
 }
 }
-- 
2.14.3

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


[FFmpeg-devel] [PATCH 5/6] lavf/mov: fix disposable flags in mov_fix_index

2017-11-30 Thread John Stebbins
Merges ctts_data into mov_index_entries.  This allows a considerable
amount of code simplification.
---
 libavformat/isom.h |   1 +
 libavformat/mov.c  | 312 ++---
 2 files changed, 130 insertions(+), 183 deletions(-)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index 646b31ccc7..8fee8f4f53 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -138,6 +138,7 @@ typedef struct MOVIndexRange {
 } MOVIndexRange;
 
 typedef struct MOVIndexEntry {
+int ctts;
 #define MOVINDEX_DISPOSABLE 0x01
 int8_t  flags;
 } MOVIndexEntry;
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 2bb81d8f01..0370ce6098 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -76,6 +76,8 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, 
MOVAtom atom);
 static int mov_read_mfra(MOVContext *c, AVIOContext *f);
 static int64_t add_ctts_entry(MOVStts** ctts_data, unsigned int* ctts_count, 
unsigned int* allocated_size,
   int count, int duration);
+static int64_t add_mov_index_entry(MOVStreamContext *sc, int ctts,
+   uint8_t flags);
 
 static int mov_metadata_track_or_disc_number(MOVContext *c, AVIOContext *pb,
  unsigned len, const char *key)
@@ -3064,9 +3066,9 @@ static int get_edit_list_entry(MOVContext *mov,
  * Find the closest previous frame to the timestamp_pts, in e_old index
  * entries. Searching for just any frame / just key frames can be controlled by
  * last argument 'flag'.
- * Note that if ctts_data is not NULL, we will always search for a key frame
- * irrespective of the value of 'flag'. If we don't find any keyframe, we will
- * return the first frame of the video.
+ * Note that if mov_index_entries is not NULL, we will always search for a
+ * key frame irrespective of the value of 'flag'. If we don't find any
+ * keyframe, we will return the first frame of the video.
  *
  * Here the timestamp_pts is considered to be a presentation timestamp and
  * the timestamp of index entries are considered to be decoding timestamps.
@@ -3074,27 +3076,23 @@ static int get_edit_list_entry(MOVContext *mov,
  * Returns 0 if successful in finding a frame, else returns -1.
  * Places the found index corresponding output arg.
  *
- * If ctts_old is not NULL, then refines the searched entry by searching
- * backwards from the found timestamp, to find the frame with correct PTS.
- *
- * Places the found ctts_index and ctts_sample in corresponding output args.
+ * If mov_index_entries is not NULL, then refines the searched entry by
+ * searching backwards from the found timestamp, to find the frame with
+ * correct PTS.
  */
 static int find_prev_closest_index(AVStream *st,
AVIndexEntry *e_old,
int nb_old,
-   MOVStts* ctts_data,
-   int64_t ctts_count,
+   MOVIndexEntry *mov_index_entries,
+   int64_t nb_mov_index_entries,
int64_t timestamp_pts,
int flag,
-   int64_t* index,
-   int64_t* ctts_index,
-   int64_t* ctts_sample)
+   int64_t* index)
 {
 MOVStreamContext *msc = st->priv_data;
 AVIndexEntry *e_keep = st->index_entries;
 int nb_keep = st->nb_index_entries;
 int64_t i = 0;
-int64_t index_ctts_count;
 
 av_assert0(index);
 
@@ -3122,39 +3120,16 @@ static int find_prev_closest_index(AVStream *st,
 
 // If we have CTTS then refine the search, by searching backwards over PTS
 // computed by adding corresponding CTTS durations to index timestamps.
-if (ctts_data && *index >= 0) {
-av_assert0(ctts_index);
-av_assert0(ctts_sample);
-// Find out the ctts_index for the found frame.
-*ctts_index = 0;
-*ctts_sample = 0;
-for (index_ctts_count = 0; index_ctts_count < *index; 
index_ctts_count++) {
-if (*ctts_index < ctts_count) {
-(*ctts_sample)++;
-if (ctts_data[*ctts_index].count == *ctts_sample) {
-(*ctts_index)++;
-*ctts_sample = 0;
-}
-}
-}
-
-while (*index >= 0 && (*ctts_index) >= 0) {
+if (mov_index_entries && *index >= 0 && *index < nb_mov_index_entries) {
+while (*index >= 0) {
 // Find a "key frame" with PTS <= timestamp_pts (So that we can 
decode B-frames correctly).
 // No need to add dts_shift to the timestamp here becase 
timestamp_pts has already been
 // compensated by dts_shift above.
-if ((e_old[*index].timestamp + ctts_data[*ctts_index].duration) <= 
timestamp_pts &&
+   

[FFmpeg-devel] [PATCH 4/6] lavf/mov: set AV_PKT_FLAG_DISPOSABLE from sdtp box

2017-11-30 Thread John Stebbins
---
 libavformat/isom.h  | 10 ++
 libavformat/mov.c   | 92 ++---
 libavformat/utils.c |  3 +-
 3 files changed, 99 insertions(+), 6 deletions(-)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index 65676fb0f5..646b31ccc7 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -137,11 +137,19 @@ typedef struct MOVIndexRange {
 int64_t end;
 } MOVIndexRange;
 
+typedef struct MOVIndexEntry {
+#define MOVINDEX_DISPOSABLE 0x01
+int8_t  flags;
+} MOVIndexEntry;
+
 typedef struct MOVStreamContext {
 AVIOContext *pb;
 int pb_is_copied;
 int ffindex;  ///< AVStream index
 int next_chunk;
+MOVIndexEntry * mov_index_entries;
+int nb_mov_index_entries;
+unsigned int mov_index_allocated_size;
 unsigned int chunk_count;
 int64_t *chunk_offsets;
 unsigned int stts_count;
@@ -166,6 +174,8 @@ typedef struct MOVStreamContext {
 int keyframe_absent;
 unsigned int keyframe_count;
 int *keyframes;
+unsigned int frame_deps_count;
+int *frame_deps;
 int time_scale;
 int64_t time_offset;  ///< time offset of the edit list entries
 int current_sample;
diff --git a/libavformat/mov.c b/libavformat/mov.c
index f7fab98dd8..2bb81d8f01 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2682,6 +2682,43 @@ static int mov_read_stps(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 return 0;
 }
 
+static int mov_read_sdtp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+{
+AVStream *st;
+MOVStreamContext *sc;
+unsigned int i, entries;
+
+if (c->fc->nb_streams < 1)
+return 0;
+st = c->fc->streams[c->fc->nb_streams-1];
+sc = st->priv_data;
+
+if (atom.size < 8)
+return 0;
+
+avio_r8(pb); /* version */
+avio_rb24(pb); /* flags */
+
+entries = atom.size - 4;
+sc->frame_deps_count = 0;
+sc->frame_deps = av_malloc_array(entries, sizeof(*sc->frame_deps));
+
+if (!sc->frame_deps)
+return AVERROR(ENOMEM);
+
+for (i = 0; i < entries && !pb->eof_reached; i++) {
+sc->frame_deps[i] = avio_r8(pb);
+}
+
+sc->frame_deps_count = i;
+
+if (pb->eof_reached)
+return AVERROR_EOF;
+
+
+return 0;
+}
+
 static int mov_read_stss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
 AVStream *st;
@@ -3638,15 +3675,40 @@ static void mov_build_index(MOVContext *mov, AVStream 
*st)
 
 if (!sc->sample_count || st->nb_index_entries)
 return;
-if (sc->sample_count >= UINT_MAX / sizeof(*st->index_entries) - 
st->nb_index_entries)
+if (sc->sample_count >= UINT_MAX / sizeof(*st->index_entries))
 return;
-if (av_reallocp_array(>index_entries,
-  st->nb_index_entries + sc->sample_count,
+if (av_reallocp_array(>index_entries, sc->sample_count,
   sizeof(*st->index_entries)) < 0) {
 st->nb_index_entries = 0;
 return;
 }
-st->index_entries_allocated_size = (st->nb_index_entries + 
sc->sample_count) * sizeof(*st->index_entries);
+st->index_entries_allocated_size = sc->sample_count *
+   sizeof(*st->index_entries);
+
+// realloc mov_index_entries if needed for frame dependencies
+// or if it already exists for ctts
+if (sc->frame_deps || sc->mov_index_entries) {
+// make mov_index_entries the same number of entries as
+// index_entries
+if (av_reallocp_array(>mov_index_entries,
+  sc->sample_count,
+  sizeof(*sc->mov_index_entries)) < 0) {
+sc->nb_mov_index_entries = 0;
+return;
+}
+sc->mov_index_allocated_size = sc->sample_count *
+   sizeof(*sc->mov_index_entries);
+
+if (sc->sample_count > sc->nb_mov_index_entries)
+// In case there were samples without ctts entries, ensure they
+// get zero valued entries. This ensures clips which mix boxes
+// with and without ctts entries don't pickup uninitialized
+// data.
+memset(sc->mov_index_entries + sc->nb_mov_index_entries, 0,
+   (sc->sample_count - sc->nb_mov_index_entries) *
+   sizeof(*sc->mov_index_entries));
+sc->nb_mov_index_entries = sc->sample_count;
+}
 
 if (ctts_data_old) {
 // Expand ctts entries such that we have a 1-1 mapping with samples
@@ -3689,10 +3751,14 @@ static void mov_build_index(MOVContext *mov, AVStream 
*st)
 
 for (j = 0; j < sc->stsc_data[stsc_index].count; j++) {
 int keyframe = 0;
+int disposable = 0;
 if (current_sample >= sc->sample_count) {
 av_log(mov->fc, 

[FFmpeg-devel] lavf/mov: set AV_PKT_FLAG_DISPOSABLE from sdtp box

2017-11-30 Thread John Stebbins
Rebase to resolve conflicts.

These 2 patches should be merged before commit.  They are separated to
make reviewing easier.  Patch 4 alone does not account for edit list
fix-ups.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] lavc/libx265: mark disposable frames

2017-11-30 Thread John Stebbins
Remove redundant sliceType check.  It is only needed if using x265 2.4
or below where sliceType BREF is never set.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 3/6] lavc/libx265: mark disposable frames

2017-11-30 Thread John Stebbins
Used by movenc to fill sdtp box
---
 libavcodec/libx265.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 4456e300f2..c137fe4ae1 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -329,6 +329,9 @@ FF_DISABLE_DEPRECATION_WARNINGS
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
+if (x265pic_out.sliceType == X265_TYPE_B)
+pkt->flags |= AV_PKT_FLAG_DISPOSABLE;
+
 *got_packet = 1;
 return 0;
 }
-- 
2.14.3

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


Re: [FFmpeg-devel] AMD external header

2017-11-30 Thread Marton Balint


On Wed, 29 Nov 2017, Mironov, Mikhail wrote:


-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
Of Paul B Mahol
Sent: November 29, 2017 10:16 AM
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] AMD external header

On 11/29/17, Carl Eugen Hoyos  wrote:

2017-11-29 15:58 GMT+01:00 wm4 :


Well, don't worry too much. People like him are, as some would say,
toxic members of the community. Frequent drama and flame wars

happen.

(And here's where I wished ffmpeg were a properly managed project.)


Look who's talking!

Given that you started a fork of FFmpeg repeating ancient lies and
stating you don't support FFmpeg anymore:
Why do you post here?


Because he like to argue with toxic people like you.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Hi,
This conversation is very entertaining but leads us nowhere.
May I suggest to go down to business of enabling HW encoders by default?
Yesterday Mark submitted the initial implementation and I really want
to thank him for his mentoring and participation - it was very useful.
The submission doesn't have AMD header so AMD encoder is off in any default 
build.
I counted responses to my posts and found six people are for the default 
enabling
of HW blocks one way or another: by including headers or pulling them out
automatically using git (I guess via submodules?).
Two people want to remove external headers and disable default HW acceleration.
Question is: how to move forward on practical terms? I really don’t know how 
this team makes such decisions.
Or maybe it is impasse case and  all want to keep things the way they are today?


The project has a voting system which was used in the past for issues 
where no consensus was reached. A voting however is a tedious process 
which usually leaves a few frustrated people on the losing side, so I'd 
say that is a last resort.


An alternative solution to adding AMD or removing Nvidia headers might be 
to simply disable the Nvidia hwaccel autodetection, and require the user 
to explicitly enable it. That seems mostly fair to me, and keeps the 
current status of the headers.


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


Re: [FFmpeg-devel] [PATCH] configure: Fix dependencies of aac_at decoder.

2017-11-30 Thread James Almer
On 11/30/2017 7:58 PM, Jacob Trimble wrote:
> Signed-off-by: Jacob Trimble 
> ---
>  configure | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/configure b/configure
> index 1fa16e9dba..d05388638d 100755
> --- a/configure
> +++ b/configure
> @@ -2890,6 +2890,7 @@ trace_headers_bsf_select="cbs_h264 cbs_h265 cbs_mpeg2"
>  
>  # external libraries
>  aac_at_decoder_deps="audiotoolbox"
> +aac_at_decoder_select="aac_adtstoasc_bsf"
>  ac3_at_decoder_deps="audiotoolbox"
>  ac3_at_decoder_select="ac3_parser"
>  adpcm_ima_qt_at_decoder_deps="audiotoolbox"
> 

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


Re: [FFmpeg-devel] [PATCH] hls: fix baseurl missing last char

2017-11-30 Thread Steven Liu
2017-12-01 0:31 GMT+08:00 Robert Nagy :
> ---
>  libavformat/hlsenc.c | 9 +
>  1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index cdfbf45823..394c7130ac 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1921,14 +1921,7 @@ static int hls_write_header(AVFormatContext *s)
>  }
>
>  if (hls->baseurl) {
> -int baseurl_len;
> -baseurl_len = strlen(hls->baseurl);
> -vs->baseurl = av_malloc(baseurl_len);
> -if (!vs->baseurl) {
> -ret = AVERROR(ENOMEM);
> -goto fail;
> -}
> -av_strlcpy(vs->baseurl, hls->baseurl, baseurl_len);
> +vs->baseurl = av_strdup(hls->baseurl);
Check the result.


Thanks
>  }
>
>  if ((hls->flags & HLS_SINGLE_FILE) && (hls->segment_type ==
> SEGMENT_TYPE_FMP4)) {
> --
> 2.15.0
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] libavcodec/hevc_filter: support for all skip_loop_filter levels

2017-11-30 Thread Stefan _
Hi,

Attached patch adds full support for skip_loop_filter (all levels) to 
the hevc decoder.

I'm not too sure about the implementation of "nonref", since this email 
(http://ffmpeg.org/pipermail/ffmpeg-devel/2015-July/176116.html) 
mentions looking at nal_unit_type and temporal_id instead. Some help 
would be appreciated.

The 'make fate' test suite passed.

From 3e2f7152e3dab1f6cfe7c7e14f2ba1cee519978c Mon Sep 17 00:00:00 2001
From: sfan5 
Date: Thu, 30 Nov 2017 23:58:02 +0100
Subject: [PATCH] libavcodec/hevc_filter: support for all skip_loop_filter
 levels.

Continues where commit 52c75d486ed5f75cbb79e5dbd07b7aef24f3071f left off.
---
 doc/decoders.texi|  7 ---
 libavcodec/hevc_filter.c | 12 +++-
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/doc/decoders.texi b/doc/decoders.texi
index d149d2bea5..a9510bdf02 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -25,13 +25,6 @@ enabled decoders.
 A description of some of the currently available video decoders
 follows.
 
-@section hevc
-
-HEVC / H.265 decoder.
-
-Note: the @option{skip_loop_filter} option has effect only at level
-@code{all}.
-
 @section rawvideo
 
 Raw video decoder.
diff --git a/libavcodec/hevc_filter.c b/libavcodec/hevc_filter.c
index b53f4cc721..17ec59619f 100644
--- a/libavcodec/hevc_filter.c
+++ b/libavcodec/hevc_filter.c
@@ -842,7 +842,17 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0,
 void ff_hevc_hls_filter(HEVCContext *s, int x, int y, int ctb_size)
 {
 int x_end = x >= s->ps.sps->width  - ctb_size;
-if (s->avctx->skip_loop_filter < AVDISCARD_ALL)
+int deblock = 1;
+if (s->avctx->skip_loop_filter >= AVDISCARD_ALL ||
+(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY && !IS_IDR(s)) ||
+(s->avctx->skip_loop_filter >= AVDISCARD_NONINTRA &&
+ s->sh.slice_type != HEVC_SLICE_I) ||
+(s->avctx->skip_loop_filter >= AVDISCARD_BIDIR &&
+ s->sh.slice_type == HEVC_SLICE_B) ||
+(s->avctx->skip_loop_filter >= AVDISCARD_NONREF &&
+ ff_hevc_frame_nb_refs(s) == 0))
+deblock = 0;
+if (deblock)
 deblocking_filter_CTB(s, x, y);
 if (s->ps.sps->sao_enabled) {
 int y_end = y >= s->ps.sps->height - ctb_size;
-- 
2.15.0

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


[FFmpeg-devel] [PATCH] libavformat/segment: strftime date sub-directories

2017-11-30 Thread James Courtier-Dutton

From b6a6f6d577e562c09c7cc1fc0befd2d73a9c0f32 Mon Sep 17 00:00:00 2001
From: James Courtier-Dutton 
Date: Thu, 30 Nov 2017 22:56:04 +
Subject: [PATCH] libavformat/segment: strftime date sub-directories

Automatically create sub-directories if needed based on date.
E.g.
ffmpeg ... -timelimit 2147483647 -f segment -strftime 1 -segment_time 10 "%Y/%m/%d/%Y-%m-%d_%H-%M-%S.mkv"
---
 libavformat/segment.c | 48 
 1 file changed, 48 insertions(+)

diff --git a/libavformat/segment.c b/libavformat/segment.c
index 81d3f1d..f8484bf 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -186,6 +186,39 @@ static int segment_mux_init(AVFormatContext *s)
 return 0;
 }
 
+static int mkdir_p(const char *path) {
+int ret = 0;
+char *temp = av_strdup(path);
+char *pos = temp;
+char tmp_ch = '\0';
+
+if (!path || !temp) {
+return -1;
+}
+
+if (!strncmp(temp, "/", 1) || !strncmp(temp, "\\", 1)) {
+pos++;
+} else if (!strncmp(temp, "./", 2) || !strncmp(temp, ".\\", 2)) {
+pos += 2;
+}
+
+for ( ; *pos != '\0'; ++pos) {
+if (*pos == '/' || *pos == '\\') {
+tmp_ch = *pos;
+*pos = '\0';
+ret = mkdir(temp, 0755);
+*pos = tmp_ch;
+}
+}
+
+if ((*(pos - 1) != '/') || (*(pos - 1) != '\\')) {
+ret = mkdir(temp, 0755);
+}
+
+av_free(temp);
+return ret;
+}
+
 static int set_segment_filename(AVFormatContext *s)
 {
 SegmentContext *seg = s->priv_data;
@@ -198,12 +231,27 @@ static int set_segment_filename(AVFormatContext *s)
 if (seg->use_strftime) {
 time_t now0;
 struct tm *tm, tmpbuf;
+const char *dir;
+char *fn_copy;
 time();
 tm = localtime_r(, );
 if (!strftime(oc->filename, sizeof(oc->filename), s->filename, tm)) {
 av_log(oc, AV_LOG_ERROR, "Could not get segment filename with strftime\n");
 return AVERROR(EINVAL);
 }
+/* Automatically create directories if needed */
+/* E.g. %Y/%m/%d/%Y-%m-%d_%H-%M-%S.mkv */
+fn_copy = av_strdup(oc->filename);
+if (!fn_copy) {
+return AVERROR(ENOMEM);
+}
+dir = av_dirname(fn_copy);
+if (mkdir_p(dir) == -1 && errno != EEXIST) {
+av_log(oc, AV_LOG_ERROR, "Could not create directory %s with use_localtime_mkdir\n", dir);
+av_free(fn_copy);
+return AVERROR(errno);
+}
+av_free(fn_copy);
 } else if (av_get_frame_filename(oc->filename, sizeof(oc->filename),
  s->filename, seg->segment_idx) < 0) {
 av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s'\n", s->filename);
-- 
2.7.4

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


[FFmpeg-devel] [PATCH] configure: Fix dependencies of aac_at decoder.

2017-11-30 Thread Jacob Trimble
Signed-off-by: Jacob Trimble 
---
 configure | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configure b/configure
index 1fa16e9dba..d05388638d 100755
--- a/configure
+++ b/configure
@@ -2890,6 +2890,7 @@ trace_headers_bsf_select="cbs_h264 cbs_h265 cbs_mpeg2"
 
 # external libraries
 aac_at_decoder_deps="audiotoolbox"
+aac_at_decoder_select="aac_adtstoasc_bsf"
 ac3_at_decoder_deps="audiotoolbox"
 ac3_at_decoder_select="ac3_parser"
 adpcm_ima_qt_at_decoder_deps="audiotoolbox"
-- 
2.15.0.531.g2ccb3012c9-goog

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


[FFmpeg-devel] [PATCH 2/3] avcodec/j2kenc: Fix out of array access in encode_cblk()

2017-11-30 Thread Michael Niedermayer
Fixes: 4427/clusterfuzz-testcase-minimized-5106919271301120

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

diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 32c7fddb74..78ec88a694 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -690,7 +690,8 @@ static void encode_cblk(Jpeg2000EncoderContext *s, 
Jpeg2000T1Context *t1, Jpeg20
 cblk->npasses = passno;
 cblk->ninclpasses = passno;
 
-cblk->passes[passno-1].rate = ff_mqc_flush_to(>mqc, 
cblk->passes[passno-1].flushed, >passes[passno-1].flushed_len);
+if (passno)
+cblk->passes[passno-1].rate = ff_mqc_flush_to(>mqc, 
cblk->passes[passno-1].flushed, >passes[passno-1].flushed_len);
 }
 
 /* tier-2 routines: */
-- 
2.15.0

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


[FFmpeg-devel] [PATCH 1/3] avcodec/hevcdsp_template: Fix undefined shift in put_hevc_epel_bi_w_h()

2017-11-30 Thread Michael Niedermayer
Fixes: runtime error: left shift of negative value -127
Fixes: 4397/clusterfuzz-testcase-minimized-4779061080489984

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

diff --git a/libavcodec/hevcdsp_template.c b/libavcodec/hevcdsp_template.c
index 46a0da2045..0623cfad89 100644
--- a/libavcodec/hevcdsp_template.c
+++ b/libavcodec/hevcdsp_template.c
@@ -1355,7 +1355,7 @@ static void FUNC(put_hevc_epel_bi_w_h)(uint8_t *_dst, 
ptrdiff_t _dststride, uint
 for (y = 0; y < height; y++) {
 for (x = 0; x < width; x++)
 dst[x] = av_clip_pixel(((EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) * 
wx1 + src2[x] * wx0 +
-((ox0 + ox1 + 1) << log2Wd)) >> (log2Wd + 
1));
+((ox0 + ox1 + 1) * (1 << log2Wd))) >> 
(log2Wd + 1));
 src  += srcstride;
 dst  += dststride;
 src2 += MAX_PB_SIZE;
-- 
2.15.0

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


[FFmpeg-devel] [PATCH 3/3] avcodec/jpeg2000: Only allocate Jpeg2000Pass for the encoder

2017-11-30 Thread Michael Niedermayer
Reduces memory needed.
Fixes: OOM
Fixes: 4427/clusterfuzz-testcase-minimized-5106919271301120

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/j2kenc.c   | 4 +++-
 libavcodec/jpeg2000.c | 1 +
 libavcodec/jpeg2000.h | 2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 78ec88a694..3e542af3c6 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -941,7 +941,9 @@ static int encode_tile(Jpeg2000EncoderContext *s, 
Jpeg2000Tile *tile, int tileno
 }
 if (!prec->cblk[cblkno].data)
 prec->cblk[cblkno].data = av_malloc(1 + 8192);
-if (!prec->cblk[cblkno].data)
+if (!prec->cblk[cblkno].passes)
+prec->cblk[cblkno].passes = 
av_malloc_array(JPEG2000_MAX_PASSES, sizeof (*prec->cblk[cblkno].passes));
+if (!prec->cblk[cblkno].data || 
!prec->cblk[cblkno].passes)
 return AVERROR(ENOMEM);
 encode_cblk(s, , prec->cblk + cblkno, tile, xx1 - 
xx0, yy1 - yy0,
 bandpos, codsty->nreslevels - reslevelno - 
1);
diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
index 8551cf8d6c..5f3965047f 100644
--- a/libavcodec/jpeg2000.c
+++ b/libavcodec/jpeg2000.c
@@ -606,6 +606,7 @@ void ff_jpeg2000_cleanup(Jpeg2000Component *comp, 
Jpeg2000CodingStyle *codsty)
 for (cblkno = 0; cblkno < nb_code_blocks; cblkno ++) {
 Jpeg2000Cblk *cblk = >cblk[cblkno];
 av_freep(>data);
+av_freep(>passes);
 }
 av_freep(>cblk);
 }
diff --git a/libavcodec/jpeg2000.h b/libavcodec/jpeg2000.h
index eaf7faf342..752feae96b 100644
--- a/libavcodec/jpeg2000.h
+++ b/libavcodec/jpeg2000.h
@@ -173,7 +173,7 @@ typedef struct Jpeg2000Cblk {
 int nb_terminations;
 int nb_terminationsinc;
 int data_start[JPEG2000_MAX_PASSES];
-Jpeg2000Pass passes[JPEG2000_MAX_PASSES];
+Jpeg2000Pass *passes;
 int coord[2][2]; // border coordinates {{x0, x1}, {y0, y1}}
 } Jpeg2000Cblk; // code block
 
-- 
2.15.0

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


Re: [FFmpeg-devel] [PATCH] lavf/mov: fix huge alloc in mov_read_ctts

2017-11-30 Thread Michael Niedermayer
On Sun, Nov 26, 2017 at 07:32:30AM -0800, John Stebbins wrote:
> An invalid file may cause huge alloc.  Delay expansion of ctts entries
> until the number of samples is known in mov_build_index.
> 
> Found-by: zhao dongzhuo, AD-lab of Venustech
> ---
>  libavformat/mov.c | 31 +++
>  1 file changed, 27 insertions(+), 4 deletions(-)

will apply

thanks

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

The worst form of inequality is to try to make unequal things equal.
-- Aristotle


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


[FFmpeg-devel] [PATCH] avcodec/nvdec: Fix capability check with old drivers.

2017-11-30 Thread Jacob Trimble
Copied the check from cuviddec.c (*_cuvid decoders) to allow the
capability check to be optional for older drivers.

Signed-off-by: Jacob Trimble 
---
 libavcodec/nvdec.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
index c7a02ff40f..e9e6ea0f8b 100644
--- a/libavcodec/nvdec.c
+++ b/libavcodec/nvdec.c
@@ -91,6 +91,18 @@ static int nvdec_test_capabilities(NVDECDecoder *decoder,
 caps.eChromaFormat   = params->ChromaFormat;
 caps.nBitDepthMinus8 = params->bitDepthMinus8;
 
+if (!decoder->cvdl->cuvidGetDecoderCaps) {
+av_log(logctx, AV_LOG_WARNING, "Used Nvidia driver is too old to 
perform a capability check.\n");
+av_log(logctx, AV_LOG_WARNING, "The minimum required version is "
+#if defined(_WIN32) || defined(__CYGWIN__)
+"378.66"
+#else
+"378.13"
+#endif
+". Continuing blind.\n");
+return 0;
+}
+
 err = decoder->cvdl->cuvidGetDecoderCaps();
 if (err != CUDA_SUCCESS) {
 av_log(logctx, AV_LOG_ERROR, "Failed querying decoder capabilities\n");
-- 
2.15.0.531.g2ccb3012c9-goog

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


Re: [FFmpeg-devel] [ogg] Respect AVERROR codes returned by ogg header parsing.

2017-11-30 Thread Dale Curtis
On Wed, Nov 29, 2017 at 5:58 PM, Michael Niedermayer  wrote:

>
> AV_EF_EXPLODE appears to be a possibility, yes
> in general demuxers should try to extract as much as possible from a
> file and not give up if some broken packet is found
>

I don't think this is a good idea; some of these errors seem fairly fatal
to the overall process. I think instead it's better to write off the sample
you have as being invalid. That said, I defer to your judgement here, so
I've produced both versions of the patch and leave it to your decision.
Chrome is now always using AV_EF_EXPLODE, so either works for our usage.

- dale
From e47bd6161b4e062c669dad1989d2289fd1e3a8dc Mon Sep 17 00:00:00 2001
From: Dale Curtis 
Date: Tue, 28 Nov 2017 13:40:20 -0800
Subject: [PATCH] Respect AVERROR codes returned by ogg parsers.

Fixes ticket #6804. All of the ogg header and packet parsers may
return standard AVERROR codes; these return values should not be
treated as success. Despite returning some fairly serious error
codes, this version of the patch puts these failures behind an
error_recognition flag of AV_EF_EXPLODE.

Signed-off-by: Dale Curtis 
---
 libavformat/oggdec.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 193a286e43..03053bef7a 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -543,7 +543,11 @@ static int ogg_packet(AVFormatContext *s, int *sid, int *dstart, int *dsize,
 os->incomplete = 0;
 
 if (os->header) {
-os->header = os->codec->header(s, idx);
+if ((ret = os->codec->header(s, idx)) < 0 && (s->error_recognition & AV_EF_EXPLODE)) {
+av_log(s, AV_LOG_ERROR, "Header processing failed: %d\n", ret);
+return ret;
+}
+os->header = ret;
 if (!os->header) {
 os->segp  = segp;
 os->psize = psize;
@@ -574,8 +578,12 @@ static int ogg_packet(AVFormatContext *s, int *sid, int *dstart, int *dsize,
 } else {
 os->pflags= 0;
 os->pduration = 0;
-if (os->codec && os->codec->packet)
-os->codec->packet(s, idx);
+if (os->codec && os->codec->packet) {
+if ((ret = os->codec->packet(s, idx)) < 0 && (s->error_recognition & AV_EF_EXPLODE)) {
+av_log(s, AV_LOG_ERROR, "Packet processing failed: %d\n", ret);
+return ret;
+}
+}
 if (sid)
 *sid = idx;
 if (dstart)
-- 
2.15.0.531.g2ccb3012c9-goog

From 80975de4c72f81d65ad9d3fa0c45ea2903a52434 Mon Sep 17 00:00:00 2001
From: Dale Curtis 
Date: Tue, 28 Nov 2017 13:40:20 -0800
Subject: [PATCH] Respect AVERROR codes returned by ogg parsers.

Fixes ticket #6804. All of the ogg header and packet parsers may
return standard AVERROR codes; these return values should not be
treated as success.

Signed-off-by: Dale Curtis 
---
 libavformat/oggdec.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 193a286e43..a55743db0d 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -543,7 +543,11 @@ static int ogg_packet(AVFormatContext *s, int *sid, int *dstart, int *dsize,
 os->incomplete = 0;
 
 if (os->header) {
-os->header = os->codec->header(s, idx);
+if ((ret = os->codec->header(s, idx)) < 0) {
+av_log(s, AV_LOG_ERROR, "Header processing failed: %d\n", ret);
+return ret;
+}
+os->header = ret;
 if (!os->header) {
 os->segp  = segp;
 os->psize = psize;
@@ -574,8 +578,12 @@ static int ogg_packet(AVFormatContext *s, int *sid, int *dstart, int *dsize,
 } else {
 os->pflags= 0;
 os->pduration = 0;
-if (os->codec && os->codec->packet)
-os->codec->packet(s, idx);
+if (os->codec && os->codec->packet) {
+if ((ret = os->codec->packet(s, idx)) < 0) {
+av_log(s, AV_LOG_ERROR, "Packet processing failed: %d\n", ret);
+return ret;
+}
+}
 if (sid)
 *sid = idx;
 if (dstart)
-- 
2.15.0.531.g2ccb3012c9-goog

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


[FFmpeg-devel] [vorbis] Fix another 1 << 31 > int32_t::max() with 1u.

2017-11-30 Thread Dale Curtis
Didn't notice this one when 9648cc6d was landed.

Signed-off-by: Dale Curtis 
From 2f7c0ee007cb28b8f3bf201279d7f17ca671728d Mon Sep 17 00:00:00 2001
From: Dale Curtis 
Date: Thu, 30 Nov 2017 12:20:36 -0800
Subject: [PATCH] [vorbis] Fix another 1 << 31 > int32_t::max() with 1u.

Didn't notice this one when 9648cc6d was landed.

Signed-off-by: Dale Curtis 
---
 libavcodec/vorbis.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/vorbis.c b/libavcodec/vorbis.c
index 5ccc37a2df..cca2aa7c63 100644
--- a/libavcodec/vorbis.c
+++ b/libavcodec/vorbis.c
@@ -67,7 +67,7 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num)
 if (bits[p] > 32)
 return AVERROR_INVALIDDATA;
 for (i = 0; i < bits[p]; ++i)
-exit_at_level[i+1] = 1 << i;
+exit_at_level[i+1] = 1u << i;
 
 ++p;
 
-- 
2.15.0.531.g2ccb3012c9-goog

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


Re: [FFmpeg-devel] [PATCH] swscale/utils: Remove bpc==8 gating init_range_convert

2017-11-30 Thread Michael Niedermayer
On Wed, Nov 29, 2017 at 08:08:40PM -0800, Neil Birkbeck wrote:
> On Wed, Nov 29, 2017 at 7:40 PM, Neil Birkbeck 
> wrote:
> 
> >
> >>
> >> If you are searching for a case where the patch makes a difference
> >> one is:
> >> ./ffmpeg -i ~/tickets/4493/AVCI100.mov out.nut
> >> file should be here:
> >> http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket524/
> >>
> >> if you want more cases that change, ill see if i can find more
> >>
> >
> > Perfect, thanks Michael. Let me check those samples out.

there are 2 more in 2939 which change:
https://trac.ffmpeg.org/ticket/2939


> >
> >
> For that sample, I feel like it may be incorrectly tagged as pc/full.

is it stored in the file or taken from:
ff_generate_avci_extradata()
maybe theres a bug in the AVCIntra handling



> Looking at the histogram of the original there is no data in low range and
> a peak due to clipping near where you'd expect higher up for studio/mpeg
> range
> ffplay /tmp/AVCI100.mov -vf histogram
> 
> And scaling, treating the input as studio/mpeg and outputting full range,
> stretches y to cover the entire range:
> ffplay /tmp/AVCI100.mov -vf
> scale=-1:-1:in_range=mpeg:out_range=jpeg,format=yuv422p10le,histogram
> 
> This is a real concern though. I don't have a good feel for how many higher
> bit depth files are incorrectly labelled as pc/full.
> 
> Here is a comparison of what I was described in the commit log.
> >
> > The naming of the files images are 
> > ${pixfmt}_${scaled}_${in_range}_${out_range}
> > for with/without the patch:
> > https://rawgit.com/nbirkbeck/ffmpeg-test-samples/master/
> > color-range/results/report.html
> >
> > My concern was the yuv444p10_${scaled}_jpeg_mpeg (explicit settings), give
> > different results than the implicit yuv444p10_unscaled_unspec_mpeg ones for
> > high bit depth. And the high bit depth is results are in general different
> > than the low bit depth ones.
> >

> > Report generated with:
> > https://raw.githubusercontent.com/nbirkbeck/ffmpeg-test-
> > samples/master/color-range/run.sh

Can you turn this into a fate test ?


> > Using these test files:
> > https://github.com/nbirkbeck/ffmpeg-test-samples/tree/
> > master/color-range/data
> >
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus


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


Re: [FFmpeg-devel] [PATCH] fix for transparencies in animated gifs

2017-11-30 Thread Bjorn Roche
We've done a bit more testing on this and it looks good here.

On Thu, Nov 30, 2017 at 12:26 PM, Bjorn Roche  wrote:

>
>
> On Mon, Nov 27, 2017 at 7:12 PM, Carl Eugen Hoyos 
> wrote:
>
>> 2017-11-28 1:07 GMT+01:00 Bjorn Roche :
>> > On Mon, Nov 27, 2017 at 5:41 PM, Carl Eugen Hoyos 
>> > wrote:
>>
>> >> >> Does remuxing animated gif with transparency work with your patch?
>> >> >
>> >> > A command like this:
>> >> >
>> >> > ffmpeg -i in.gif out.gif
>> >> >
>> >> > seems to produce the same output as before: transparency replaces
>> >> > with opacity.
>> >>
>> >> remuxing == -vcodec copy
>> >>
>> >> What about ffmpeg -i in.gif -vcodec copy out.gif ?
>> >>
>> >
>> > That doesn't work. Weather I use my patch or not it aborts:
>>
>> Of course, ticket #6640.
>
>
> I'm going to see if this is something I can tackle separately.
>
> bjorn
>
>
> --
>
>
> Bjorn Roche
>
> Sr. Video Pipeline Engineer
>
> bj...@giphy.com
>



-- 


Bjorn Roche

Sr. Video Pipeline Engineer

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


Re: [FFmpeg-devel] [PATCH] fix for transparencies in animated gifs

2017-11-30 Thread Bjorn Roche
On Mon, Nov 27, 2017 at 7:12 PM, Carl Eugen Hoyos 
wrote:

> 2017-11-28 1:07 GMT+01:00 Bjorn Roche :
> > On Mon, Nov 27, 2017 at 5:41 PM, Carl Eugen Hoyos 
> > wrote:
>
> >> >> Does remuxing animated gif with transparency work with your patch?
> >> >
> >> > A command like this:
> >> >
> >> > ffmpeg -i in.gif out.gif
> >> >
> >> > seems to produce the same output as before: transparency replaces
> >> > with opacity.
> >>
> >> remuxing == -vcodec copy
> >>
> >> What about ffmpeg -i in.gif -vcodec copy out.gif ?
> >>
> >
> > That doesn't work. Weather I use my patch or not it aborts:
>
> Of course, ticket #6640.


I'm going to see if this is something I can tackle separately.

bjorn


-- 


Bjorn Roche

Sr. Video Pipeline Engineer

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


Re: [FFmpeg-devel] [PATCH] libavformat/mov:the "stco" box parse no need return eof.

2017-11-30 Thread Michael Niedermayer
On Thu, Nov 30, 2017 at 03:18:47PM +0800, tiejun.peng wrote:
> discard corrupted track and good track have chance to play.
> 
> Signed-off-by: tiejun.peng 
> ---
>  libavformat/mov.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index c901859..5c2ce39 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -1991,8 +1991,10 @@ static int mov_read_stco(MOVContext *c, AVIOContext 
> *pb, MOVAtom atom)
>  
>  sc->chunk_count = i;
>  
> -if (pb->eof_reached)
> -return AVERROR_EOF;
> +if (i < entries) {
> +av_log(c->fc, AV_LOG_WARNING, "stream id[0x%x]: corrupted STCO 
> atom\n", st->id);
> +st->discard = AVDISCARD_ALL;

why do you need AVDISCARD_ALL ?
st->discard is set by the user so the user can change this


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

If you fake or manipulate statistics in a paper in physics you will never
get a job again.
If you fake or manipulate statistics in a paper in medicin you will get
a job for life at the pharma industry.


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


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-30 Thread Michael Niedermayer
On Thu, Nov 30, 2017 at 10:15:48AM +0100, Felix Matouschek wrote:
> Sorry, my mail client swallowed the attachment, sent it again.
> 

>  Changelog|1 
>  MAINTAINERS  |1 
>  configure|6 
>  doc/indevs.texi  |   40 ++
>  libavdevice/Makefile |1 
>  libavdevice/alldevices.c |1 
>  libavdevice/android_camera.c |  816 
> +++
>  libavdevice/version.h|2 
>  8 files changed, 867 insertions(+), 1 deletion(-)
> 2fea6cb3990aed83c3a3c492aa482f619a885ed7  
> 0001-avdevice-add-android_camera-indev.patch
> From b70da28e33e07b4565daffc94c8ffe3c8df747ff Mon Sep 17 00:00:00 2001
> From: Felix Matouschek 
> Date: Thu, 30 Nov 2017 10:03:54 +0100
> Subject: [PATCH] avdevice: add android_camera indev
> To: ffmpeg-devel@ffmpeg.org
> 
> This commit adds an indev for Android devices on API level 24+ which
> uses the Android NDK Camera2 API to capture video from builtin cameras
> 
> Signed-off-by: Felix Matouschek 
> ---
>  Changelog|   1 +
>  MAINTAINERS  |   1 +
>  configure|   6 +
>  doc/indevs.texi  |  40 +++
>  libavdevice/Makefile |   1 +
>  libavdevice/alldevices.c |   1 +
>  libavdevice/android_camera.c | 816 
> +++
>  libavdevice/version.h|   2 +-
>  8 files changed, 867 insertions(+), 1 deletion(-)
>  create mode 100644 libavdevice/android_camera.c
> 
> diff --git a/Changelog b/Changelog
> index 6592d868da..f58cd810e0 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -6,6 +6,7 @@ version :
>  - Dropped support for OpenJPEG versions 2.0 and below. Using OpenJPEG now
>requires 2.1 (or later) and pkg-config.
>  - VDA dropped (use VideoToolbox instead)
> +- Add android_camera indev
>  
>  
>  version 3.4:
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 1d2ff78b0e..d6cb135964 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -281,6 +281,7 @@ libavdevice
>  
>  
>avfoundation.mThilo Borgmann
> +  android_camera.c  Felix Matouschek
>decklink* Marton Balint
>dshow.c   Roger Pack (CC rogerdp...@gmail.com)
>fbdev_enc.c   Lukasz Marek
> diff --git a/configure b/configure
> index 7a53bc76c7..d52b18fab3 100755
> --- a/configure
> +++ b/configure
> @@ -3068,6 +3068,8 @@ xmv_demuxer_select="riffdec"
>  xwma_demuxer_select="riffdec"
>  
>  # indevs / outdevs
> +android_camera_indev_deps="android camera2ndk mediandk pthreads"
> +android_camera_indev_extralibs="-landroid -lcamera2ndk -lmediandk"
>  alsa_indev_deps="alsa"
>  alsa_outdev_deps="alsa"
>  avfoundation_indev_deps="avfoundation corevideo coremedia pthreads"
> @@ -5836,6 +5838,10 @@ check_lib shell32  "windows.h shellapi.h" 
> CommandLineToArgvW   -lshell32
>  check_lib wincrypt "windows.h wincrypt.h" CryptGenRandom   -ladvapi32
>  check_lib psapi"windows.h psapi.h"GetProcessMemoryInfo -lpsapi
>  
> +check_lib android android/native_window.h ANativeWindow_acquire -landroid
> +check_lib mediandk "stdint.h media/NdkImage.h" AImage_delete -lmediandk
> +check_lib camera2ndk "stdbool.h stdint.h camera/NdkCameraManager.h" 
> ACameraManager_create -lcamera2ndk
> +
>  enabled appkit   && check_apple_framework AppKit
>  enabled audiotoolbox && check_apple_framework AudioToolbox
>  enabled avfoundation && check_apple_framework AVFoundation
> diff --git a/doc/indevs.texi b/doc/indevs.texi
> index d308bbf7de..07056d762e 100644
> --- a/doc/indevs.texi
> +++ b/doc/indevs.texi
> @@ -63,6 +63,46 @@ Set the number of channels. Default is 2.
>  
>  @end table
>  
> +@section android_camera
> +
> +Android camera input device.
> +
> +This input devices uses the Android Camera2 NDK API which is
> +available on devices with API level 24+. The availability of
> +android_camera is autodetected during configuration.
> +
> +This device allows capturing from all cameras on an Android device,
> +which are integrated into the Camera2 NDK API.
> +
> +The available cameras are enumerated internally and can be selected
> +with the @var{camera_index} parameter. The input file string is
> +discarded.
> +
> +Generally the back facing camera has index 0 while the front facing
> +camera has index 1.
> +
> +@subsection Options
> +
> +@table @option
> +
> +@item video_size
> +Set the video size given as a string such as 640x480 or hd720.
> +Falls back to the first available configuration reported by
> +Android if requested video size is not available or by default.
> +
> +@item framerate
> +Set the video framerate.
> +Falls back to the first available configuration reported by
> +Android if requested framerate is not available or by default (-1).
> +
> +@item camera_index
> +Set the index of the camera to use. Default is 0.
> +
> +@item 

Re: [FFmpeg-devel] [PATCH v2 1/3] avformat/mxfenc: use track count to generate component instance uuid

2017-11-30 Thread Tomas Härdin
On Wed, 2017-11-29 at 20:18 -0800, Mark Reid wrote:
> On Wed, Nov 29, 2017 at 1:36 AM, Tomas Härdin 
> wrote:
> 
> > On 2017-11-29 05:11, Mark Reid wrote:
> > 
> > > @@ -980,7 +980,7 @@ static void
> > > mxf_write_structural_component(AVFormatContext
> > > *s, AVStream *st, MXF
> > > // write uid
> > >   mxf_write_local_tag(pb, 16, 0x3C0A);
> > > -mxf_write_uuid(pb, package->type == MaterialPackage ?
> > > SourceClip:
> > > SourceClip + TypeBottom, st->index);
> > > +mxf_write_uuid(pb, SourceClip, mxf->track_uuid_offset);
> > > PRINT_KEY(s, "structural component uid", pb->buf_ptr -
> > > 16);
> > >   mxf_write_common_fields(s, st);
> > > @@ -1357,7 +1357,7 @@ static void
> > > mxf_write_package(AVFormatContext *s,
> > > MXFPackage *package)
> > > // write package umid
> > >   mxf_write_local_tag(pb, 32, 0x4401);
> > > -mxf_write_umid(s, package->type == SourcePackage);
> > > +mxf_write_umid(s, package->instance);
> > >   PRINT_KEY(s, "package umid second part", pb->buf_ptr - 16);
> > > // package name
> > > @@ -1375,10 +1375,9 @@ static void
> > > mxf_write_package(AVFormatContext *s,
> > > MXFPackage *package)
> > >   // write track refs
> > >   mxf_write_local_tag(pb, track_count*16 + 8, 0x4403);
> > >   mxf_write_refs_count(pb, track_count);
> > > -mxf_write_uuid(pb, package->type == MaterialPackage ? Track
> > > :
> > > -   Track + TypeBottom, -1); // timecode track
> > > +mxf_write_uuid(pb, Track, mxf->track_uuid_offset); //
> > > timecode track
> > >   for (i = 0; i < s->nb_streams; i++)
> > > -mxf_write_uuid(pb, package->type == MaterialPackage ?
> > > Track :
> > > Track + TypeBottom, i);
> > > +mxf_write_uuid(pb, Track,  mxf->track_uuid_offset + i +
> > > 1);
> > > 
> > 
> > Do these refer to tracks that are about to be written? Seems so as
> > best I
> > can tell, so I guess it works. I'd be happier if the referencing
> > was done
> > more explicitly rather than implicitly
> 
> 
> yes they refer to the tracks about to be written. Those uuids need to
> match
> the uuid instance tag (0x3C0A) on a track written in mxf_write_track.
> then
> the uuid ref on the track needs to match the one on the sequence, and
> then
> the one the sequence needs to match the one on the component.
> 
> would you rather the instance id be a argument to each of the write
> functions? for example:
> mxf_write_package(AVFormatContext *s, MXFPackage *package, int
> track_uuid_offset)
> mxf_write_track(AVFormatContext *s, AVStream *st, MXFPackage
> *package, int
> instance_id)
> would that be more explicit?

I'm not quite sure tbh. It's been a few years since I worked with MXF,
so it's harder to say. Maybe a comment would be enough

/Tomas

signature.asc
Description: This is a digitally signed message part
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add fillborders filter

2017-11-30 Thread Paul B Mahol
On 11/30/17, Moritz Barsnick  wrote:
> On Wed, Nov 29, 2017 at 20:16:16 +0100, Paul B Mahol wrote:
>> +@item mode
>> +Set fill mode.
>> +
>> +It accepts the following values:
>> +@table @samp
>> +@item smear
>> +fill pixels using outermost pixels
>> +
>> +@item mirror
>> +fill pixels using mirroring
>> +
>> +@item fixed
>> +fill pixels with constant value
>> +@end table
>
> "Default value is @code{smear}."

Fixed.

>
>> +Set color for pixels in fixed mode. Defauls is @var{black}.
> Typo:  ^ Default

Fixed.

>
>
>> +s->yuv_color[Y] = RGB_TO_Y_CCIR(s->rgba_color[R], s->rgba_color[G],
>> s->rgba_color[B]);
>> +s->yuv_color[U] = RGB_TO_U_CCIR(s->rgba_color[R], s->rgba_color[G],
>> s->rgba_color[B], 0);
>> +s->yuv_color[V] = RGB_TO_V_CCIR(s->rgba_color[R], s->rgba_color[G],
>> s->rgba_color[B], 0);
>> +s->yuv_color[A] = s->rgba_color[A];
>
> This RGB to YUV calculation could go into the else block below, since
> it's only required/used there, right?:

It could but it does not hurt to have it where it is.

>
>> +if (desc->flags & AV_PIX_FMT_FLAG_RGB) {
>> +memcpy(s->fill, s->rgba_color, sizeof(s->rgba_color));
>> +} else {
>> +memcpy(s->fill, s->yuv_color, sizeof(s->yuv_color));
>> +}
>
> Moritz
> ___
> 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] avfilter/vf_tile: add init_padding option

2017-11-30 Thread Paul B Mahol
On 11/30/17, Nicolas George  wrote:
> Moritz Barsnick (2017-11-30):
>> Wouldn't
>>tile->first_frame = 0;
>> be faster and easier? Or did you mean to use different variables in the
>> check and the assignment?
>
> Or even clearing the option after is has been used. Single test, single
> field: faster, less memory, less code.

I like nano-optimizations!

Should I commit with that changed or send another one for review?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/4] lavc/parser: use C11 atomics

2017-11-30 Thread wm4
On Thu, 30 Nov 2017 15:44:19 +0100
Hendrik Leppkes  wrote:

> On Thu, Nov 30, 2017 at 3:29 PM, Hendrik Leppkes  wrote:
> > On Thu, Nov 30, 2017 at 3:17 PM, Michael Niedermayer
> >  wrote:  
> >> On Thu, Nov 30, 2017 at 11:55:03AM +, Rostislav Pehlivanov wrote:  
> >>> On 28 November 2017 at 01:26, Michael Niedermayer 
> >>> wrote:
> >>>  
> >>> > On Mon, Nov 27, 2017 at 04:30:18AM +, Rostislav Pehlivanov wrote:  
> >>> > > Signed-off-by: Rostislav Pehlivanov 
> >>> > > ---
> >>> > >  libavcodec/parser.c | 14 --
> >>> > >  1 file changed, 8 insertions(+), 6 deletions(-)
> >>> > >
> >>> > > diff --git a/libavcodec/parser.c b/libavcodec/parser.c
> >>> > > index 670680ea7c..baf1de4d88 100644
> >>> > > --- a/libavcodec/parser.c
> >>> > > +++ b/libavcodec/parser.c
> >>> > > @@ -23,30 +23,32 @@
> >>> > >  #include 
> >>> > >  #include 
> >>> > >  #include 
> >>> > > +#include 
> >>> > >
> >>> > >  #include "libavutil/avassert.h"
> >>> > > -#include "libavutil/atomic.h"
> >>> > >  #include "libavutil/internal.h"
> >>> > >  #include "libavutil/mem.h"
> >>> > >
> >>> > >  #include "internal.h"
> >>> > >  #include "parser.h"
> >>> > >
> >>> > > -static AVCodecParser *av_first_parser = NULL;
> >>> > > +static _Atomic(AVCodecParser *)av_first_parser = NULL;  
> >>> >
> >>> > This doesnt build here
> >>> >
> >>> > libavcodec/parser.c:35:8: warning: return type defaults to ‘int’ 
> >>> > [enabled
> >>> > by default]
> >>> >  static _Atomic(AVCodecParser *)av_first_parser = NULL;
> >>> > ^
> >>> > libavcodec/parser.c: In function ‘_Atomic’:
> >>> > libavcodec/parser.c:35:32: error: expected declaration specifiers before
> >>> > ‘av_first_parser’
> >>> >  static _Atomic(AVCodecParser *)av_first_parser = NULL;
> >>> > ^
> >>> > libavcodec/parser.c:38:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
> >>> > ‘__attribute__’ before ‘{’ token
> >>> >  {
> >>> >  ^
> >>> > libavcodec/parser.c:46:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
> >>> > ‘__attribute__’ before ‘{’ token
> >>> >  {
> >>> >  ^
> >>> > libavcodec/parser.c:55:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__a
> >>> >
> >>> >
> >>> > [...]
> >>> > --
> >>> > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> >>> >
> >>> > Observe your enemies, for they first find out your faults. -- 
> >>> > Antisthenes
> >>> >
> >>> > ___
> >>> > ffmpeg-devel mailing list
> >>> > ffmpeg-devel@ffmpeg.org
> >>> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >>> >
> >>> >  
> >>>
> >>> Does the attached patch work?  
> >>  
> >>>  parser.c |   14 --
> >>>  1 file changed, 8 insertions(+), 6 deletions(-)
> >>> 71f66a37fb46e29626f27da4658f34927e48033c  
> >>> v2-0001-lavc-parser-use-C11-atomics.patch
> >>> From b9ed59e9aff4a0fcc40f444f307c87acad55e139 Mon Sep 17 00:00:00 2001
> >>> From: Rostislav Pehlivanov 
> >>> Date: Mon, 27 Nov 2017 01:56:41 +
> >>> Subject: [PATCH v2 1/2] lavc/parser: use C11 atomics
> >>>
> >>> Signed-off-by: Rostislav Pehlivanov 
> >>> ---
> >>>  libavcodec/parser.c | 14 --
> >>>  1 file changed, 8 insertions(+), 6 deletions(-)
> >>>
> >>> diff --git a/libavcodec/parser.c b/libavcodec/parser.c
> >>> index 670680ea7c..d6df62bf70 100644
> >>> --- a/libavcodec/parser.c
> >>> +++ b/libavcodec/parser.c
> >>> @@ -23,30 +23,32 @@
> >>>  #include 
> >>>  #include 
> >>>  #include 
> >>> +#include 
> >>>
> >>>  #include "libavutil/avassert.h"
> >>> -#include "libavutil/atomic.h"
> >>>  #include "libavutil/internal.h"
> >>>  #include "libavutil/mem.h"
> >>>
> >>>  #include "internal.h"
> >>>  #include "parser.h"
> >>>
> >>> -static AVCodecParser *av_first_parser = NULL;
> >>> +static _Atomic(AVCodecParser *) av_first_parser = NULL;  
> >>
> >> no
> >>
> >>
> >> libavcodec/parser.c:35:8: warning: return type defaults to ‘int’ [enabled 
> >> by default]
> >>  static _Atomic(AVCodecParser *) av_first_parser = NULL;
> >> ^
> >> libavcodec/parser.c: In function ‘_Atomic’:
> >> libavcodec/parser.c:35:33: error: expected declaration specifiers before 
> >> ‘av_first_parser’
> >>  static _Atomic(AVCodecParser *) av_first_parser = NULL;
> >>
> >> also see
> >> compat/atomics/gcc/stdatomic.h
> >>
> >> i think what you do is not supportd in that
> >>
> >>  
> >
> > _Atomic is a keywork like volatile, so its syntax should be the same.
> > Perhaps those emulations should just define it to "volatile" if its
> > missing - the win32 emulation certainly would expect it to be
> > volatile, and I would expect this to be true for the others as well.
> >  
> 
> On that note, it seems a bit odd that the emulations don't typedef the
> atomic types to be volatile. We replace "volatile int" with
> "atomic_int" for example, and with win32 or gcc emulation for
> stdatomic.h, the 

Re: [FFmpeg-devel] [PATCH v5 3/3] avformat/hlsenc:addition of CODECS attribute in the master playlist

2017-11-30 Thread Dixit, Vishwanath


>On 11/30/17, 5:31 PM, "Steven Liu"  wrote:
>
>2017-11-30 19:32 GMT+08:00  :
>>   From: Vishwanath Dixit 
>>
>>---
>>  libavformat/Makefile  |  2 +-
>>  libavformat/dashenc.c |  2 +-
>>  libavformat/hlsenc.c  | 65 
>> +--
>>  libavformat/hlsplaylist.c |  5 +++-
>>  libavformat/hlsplaylist.h |  3 ++-
>>  libavformat/reverse.c |  1 +
>Remove this modify if this have nothing to do.
This new wrapper file is needed, as the patch is using the function ff_reverse, 
which is defined in libavutil/reverse.c. Without this libavformat library 
compilation will fail with the same error as reported for libavdevice here 
https://trac.ffmpeg.org/ticket/6544.

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


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-30 Thread Michael Niedermayer
On Thu, Nov 30, 2017 at 05:29:45PM +0100, Felix Matouschek wrote:
> Am 30.11.2017 14:48, schrieb Michael Niedermayer:
> >>You mean avg_frame_rate and r_frame_rate?
> >>The framerate can vary between the values in framerate_range[0]
> >>(min) and framerate_range[1] (max).
> >>Ideally both values are the same, sometimes min can be lower but for
> >>the average the framerate should be what is in max.
> >>Should I set r_frame_rate to min?
> >
> >I think if you do not know the base or average frame rate you
> >should not set it.
> >Or does this lead to some unreasonable latency ?
> >or are the computed values worse ?
> 
> On some devices min and max are the same so the framerate is fixed
> and I know it.
> On other devices the min framerate can be lower and so the actual
> framerate can vary between both values.
> 
> On average the framerate still should be around the maximum value.
> 

> Do you think I'm better off not setting it at all? Will it then get
> computed automatically?

yes, if you dont set it, it will be computet but it would give some
latency on startup as it needs a few frames first to base the computation
on. This latency may or may not be a bigger problem than slightly
incorrect values. I dont know, its up to you i think what you feel
is more important

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

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire


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


[FFmpeg-devel] [PATCH] hls: fix baseurl missing last char

2017-11-30 Thread Robert Nagy
---
 libavformat/hlsenc.c | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index cdfbf45823..394c7130ac 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1921,14 +1921,7 @@ static int hls_write_header(AVFormatContext *s)
 }

 if (hls->baseurl) {
-int baseurl_len;
-baseurl_len = strlen(hls->baseurl);
-vs->baseurl = av_malloc(baseurl_len);
-if (!vs->baseurl) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
-av_strlcpy(vs->baseurl, hls->baseurl, baseurl_len);
+vs->baseurl = av_strdup(hls->baseurl);
 }

 if ((hls->flags & HLS_SINGLE_FILE) && (hls->segment_type ==
SEGMENT_TYPE_FMP4)) {
--
2.15.0
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: slice processing for geq

2017-11-30 Thread Michael Niedermayer
On Thu, Nov 30, 2017 at 01:35:52PM +, Marc-Antoine ARNAUD wrote:
> Le jeu. 30 nov. 2017 à 01:51, Michael Niedermayer 
> a écrit :
> 
> > On Wed, Nov 29, 2017 at 11:28:40AM +, Marc-Antoine ARNAUD wrote:
> > > Le mer. 22 nov. 2017 à 17:54, Michael Niedermayer  > >
> > > a écrit :
> > >
> > > > On Wed, Nov 22, 2017 at 10:24:30AM +, Marc-Antoine ARNAUD wrote:
> > > > > New patch version which fixe the last remark.
> > > > >
> > > > >
> > > > > Le ven. 10 nov. 2017 à 00:47, Michael Niedermayer
> >  > > > >
> > > > > a écrit :
> > > > >
> > > > > > On Thu, Nov 09, 2017 at 10:22:23AM +, Marc-Antoine ARNAUD
> > wrote:
> > > > > > > Please find the merged patch in attachement.
> > > > > > >
> > > > > > > Thanks
> > > > > > >
> > > > > > > Le mer. 8 nov. 2017 à 17:12, Paul B Mahol  a
> > > > écrit :
> > > > > > >
> > > > > > > > On 11/8/17, Marc-Antoine ARNAUD 
> > > > wrote:
> > > > > > > > > This patch will fix the stride issue.
> > > > > > > > > Is it valid for you ?
> > > > > > > > >
> > > > > > > > > Does it required to merge these 2 patches ? (and remove
> > base64
> > > > > > encoding
> > > > > > > > on
> > > > > > > > > the first one)
> > > > > > > >
> > > > > > > > Please merge those two patches, base64 encoding should not be
> > > > needed
> > > > > > > > (it helps to faster review patches if they are not encoded).
> > > > > > > > ___
> > > > > > > > ffmpeg-devel mailing list
> > > > > > > > ffmpeg-devel@ffmpeg.org
> > > > > > > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > > > > > > >
> > > > > >
> > > > > > >  vf_geq.c |  124
> > > > > > +--
> > > > > > >  1 file changed, 90 insertions(+), 34 deletions(-)
> > > > > > > b41a90fffb5ddef553661007a38659c602f7ce56
> > > > > > 0001-avfilter-slice-processing-for-geq.patch
> > > > > > > From ac2a6322fa96835e02a24c31f014fb360e26561f Mon Sep 17 00:00:00
> > > > 2001
> > > > > > > From: Marc-Antoine Arnaud 
> > > > > > > Date: Thu, 9 Nov 2017 11:19:43 +0100
> > > > > > > Subject: [PATCH] avfilter: slice processing for geq
> > > > > > > Content-Type: text/x-patch; charset="utf-8"
> > > > > >
> > > > > > crashes:
> > > > > > ./ffmpeg_g -f lavfi -i
> > > > > >
> > > >
> > 'nullsrc=s=200x200,format=yuv444p16,geq=X*Y/10:sin(X/10)*255:cos(Y/10)*255'
> > > > > > -vframes 5 -y blah.avi
> > > > > >
> > > > > > ==24616== Thread 7:
> > > > > > ==24616== Invalid write of size 2
> > > > > > ==24616==at 0x4F3AAF: slice_geq_filter (vf_geq.c:289)
> > > > > > ==24616==by 0x48E4C9: worker_func (pthread.c:50)
> > > > > > ==24616==by 0x11DB932: run_jobs (slicethread.c:61)
> > > > > > ==24616==by 0x11DBA04: thread_worker (slicethread.c:85)
> > > > > > ==24616==by 0xC45D183: start_thread (pthread_create.c:312)
> > > > > > ==24616==by 0xC770FFC: clone (clone.S:111)
> > > > > > ==24616==  Address 0x1177143e is 93,214 bytes inside a block of
> > size
> > > > > > 93,215 alloc'd
> > > > > > ==24616==at 0x4C2A6C5: memalign (vg_replace_malloc.c:727)
> > > > > > ==24616==by 0x4C2A760: posix_memalign (vg_replace_malloc.c:876)
> > > > > > ==24616==by 0x11B0C43: av_malloc (mem.c:87)
> > > > > > ==24616==by 0x11987CC: av_buffer_alloc (buffer.c:72)
> > > > > > ==24616==by 0x1198831: av_buffer_allocz (buffer.c:85)
> > > > > > ==24616==by 0x1198F29: pool_alloc_buffer (buffer.c:312)
> > > > > > ==24616==by 0x1199057: av_buffer_pool_get (buffer.c:349)
> > > > > > ==24616==by 0x489D6D: ff_frame_pool_get (framepool.c:222)
> > > > > > ==24616==by 0x58F6EB: ff_default_get_video_buffer (video.c:89)
> > > > > > ==24616==by 0x58F768: ff_get_video_buffer (video.c:102)
> > > > > > ==24616==by 0x4F3BF3: geq_filter_frame (vf_geq.c:312)
> > > > > > ==24616==by 0x472FD0: ff_filter_frame_framed (avfilter.c:1104)
> > > > > > ==24616==by 0x473800: ff_filter_frame_to_filter
> > (avfilter.c:1252)
> > > > > > ==24616==by 0x4739F8: ff_filter_activate_default
> > (avfilter.c:1301)
> > > > > > ==24616==by 0x473C12: ff_filter_activate (avfilter.c:1462)
> > > > > > ==24616==by 0x478A4F: ff_filter_graph_run_once
> > > > (avfiltergraph.c:1456)
> > > > > > ==24616==by 0x478C72: get_frame_internal (buffersink.c:110)
> > > > > > ==24616==by 0x478CCF: av_buffersink_get_frame_flags
> > > > (buffersink.c:121)
> > > > > > ==24616==by 0x441808: lavfi_read_packet (lavfi.c:410)
> > > > > > ==24616==by 0x7AC315: ff_read_packet (utils.c:822)
> > > > > > ==24616==
> > > > > > --24616-- VALGRIND INTERNAL ERROR: Valgrind received a signal 11
> > > > (SIGSEGV)
> > > > > > - exiting
> > > > > > --24616-- si_code=80;  Faulting address: 0x0;  sp: 0x40a075db0
> > > > > >
> > > > > > [...]
> > > > > >
> > > > > > --
> > > > > > Michael GnuPG fingerprint:
> > 

Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-30 Thread Felix Matouschek

Am 30.11.2017 14:48, schrieb Michael Niedermayer:

You mean avg_frame_rate and r_frame_rate?
The framerate can vary between the values in framerate_range[0]
(min) and framerate_range[1] (max).
Ideally both values are the same, sometimes min can be lower but for
the average the framerate should be what is in max.
Should I set r_frame_rate to min?


I think if you do not know the base or average frame rate you
should not set it.
Or does this lead to some unreasonable latency ?
or are the computed values worse ?


On some devices min and max are the same so the framerate is fixed and I 
know it.
On other devices the min framerate can be lower and so the actual 
framerate can vary between both values.


On average the framerate still should be around the maximum value.

Do you think I'm better off not setting it at all? Will it then get 
computed automatically?

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


Re: [FFmpeg-devel] [PATCH 1/4] lavc/parser: use C11 atomics

2017-11-30 Thread James Almer
On 11/30/2017 11:44 AM, Hendrik Leppkes wrote:
> On Thu, Nov 30, 2017 at 3:29 PM, Hendrik Leppkes  wrote:
>> On Thu, Nov 30, 2017 at 3:17 PM, Michael Niedermayer
>>  wrote:
>>> On Thu, Nov 30, 2017 at 11:55:03AM +, Rostislav Pehlivanov wrote:
 On 28 November 2017 at 01:26, Michael Niedermayer 
 wrote:

> On Mon, Nov 27, 2017 at 04:30:18AM +, Rostislav Pehlivanov wrote:
>> Signed-off-by: Rostislav Pehlivanov 
>> ---
>>  libavcodec/parser.c | 14 --
>>  1 file changed, 8 insertions(+), 6 deletions(-)
>>
>> diff --git a/libavcodec/parser.c b/libavcodec/parser.c
>> index 670680ea7c..baf1de4d88 100644
>> --- a/libavcodec/parser.c
>> +++ b/libavcodec/parser.c
>> @@ -23,30 +23,32 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>
>>  #include "libavutil/avassert.h"
>> -#include "libavutil/atomic.h"
>>  #include "libavutil/internal.h"
>>  #include "libavutil/mem.h"
>>
>>  #include "internal.h"
>>  #include "parser.h"
>>
>> -static AVCodecParser *av_first_parser = NULL;
>> +static _Atomic(AVCodecParser *)av_first_parser = NULL;
>
> This doesnt build here
>
> libavcodec/parser.c:35:8: warning: return type defaults to ‘int’ [enabled
> by default]
>  static _Atomic(AVCodecParser *)av_first_parser = NULL;
> ^
> libavcodec/parser.c: In function ‘_Atomic’:
> libavcodec/parser.c:35:32: error: expected declaration specifiers before
> ‘av_first_parser’
>  static _Atomic(AVCodecParser *)av_first_parser = NULL;
> ^
> libavcodec/parser.c:38:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
> ‘__attribute__’ before ‘{’ token
>  {
>  ^
> libavcodec/parser.c:46:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
> ‘__attribute__’ before ‘{’ token
>  {
>  ^
> libavcodec/parser.c:55:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__a
>
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Observe your enemies, for they first find out your faults. -- Antisthenes
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>

 Does the attached patch work?
>>>
  parser.c |   14 --
  1 file changed, 8 insertions(+), 6 deletions(-)
 71f66a37fb46e29626f27da4658f34927e48033c  
 v2-0001-lavc-parser-use-C11-atomics.patch
 From b9ed59e9aff4a0fcc40f444f307c87acad55e139 Mon Sep 17 00:00:00 2001
 From: Rostislav Pehlivanov 
 Date: Mon, 27 Nov 2017 01:56:41 +
 Subject: [PATCH v2 1/2] lavc/parser: use C11 atomics

 Signed-off-by: Rostislav Pehlivanov 
 ---
  libavcodec/parser.c | 14 --
  1 file changed, 8 insertions(+), 6 deletions(-)

 diff --git a/libavcodec/parser.c b/libavcodec/parser.c
 index 670680ea7c..d6df62bf70 100644
 --- a/libavcodec/parser.c
 +++ b/libavcodec/parser.c
 @@ -23,30 +23,32 @@
  #include 
  #include 
  #include 
 +#include 

  #include "libavutil/avassert.h"
 -#include "libavutil/atomic.h"
  #include "libavutil/internal.h"
  #include "libavutil/mem.h"

  #include "internal.h"
  #include "parser.h"

 -static AVCodecParser *av_first_parser = NULL;
 +static _Atomic(AVCodecParser *) av_first_parser = NULL;
>>>
>>> no
>>>
>>>
>>> libavcodec/parser.c:35:8: warning: return type defaults to ‘int’ [enabled 
>>> by default]
>>>  static _Atomic(AVCodecParser *) av_first_parser = NULL;
>>> ^
>>> libavcodec/parser.c: In function ‘_Atomic’:
>>> libavcodec/parser.c:35:33: error: expected declaration specifiers before 
>>> ‘av_first_parser’
>>>  static _Atomic(AVCodecParser *) av_first_parser = NULL;
>>>
>>> also see
>>> compat/atomics/gcc/stdatomic.h
>>>
>>> i think what you do is not supportd in that
>>>
>>>
>>
>> _Atomic is a keywork like volatile, so its syntax should be the same.
>> Perhaps those emulations should just define it to "volatile" if its
>> missing - the win32 emulation certainly would expect it to be
>> volatile, and I would expect this to be true for the others as well.
>>
> 
> On that note, it seems a bit odd that the emulations don't typedef the
> atomic types to be volatile. We replace "volatile int" with
> "atomic_int" for example, and with win32 or gcc emulation for
> stdatomic.h, the volatile is basically just being dropped.
> Sounds like that might be missing?
> 

Probably. Guess nobody really noticed it because the emulation wrappers
are rarely used (msvc, gcc < 4.9, suncc).
Maybe someone with old gcc could try a thread sanitizer run or two and
compare the results with 

Re: [FFmpeg-devel] [PATCH 1/4] lavc/parser: use C11 atomics

2017-11-30 Thread Hendrik Leppkes
On Thu, Nov 30, 2017 at 3:29 PM, Hendrik Leppkes  wrote:
> On Thu, Nov 30, 2017 at 3:17 PM, Michael Niedermayer
>  wrote:
>> On Thu, Nov 30, 2017 at 11:55:03AM +, Rostislav Pehlivanov wrote:
>>> On 28 November 2017 at 01:26, Michael Niedermayer 
>>> wrote:
>>>
>>> > On Mon, Nov 27, 2017 at 04:30:18AM +, Rostislav Pehlivanov wrote:
>>> > > Signed-off-by: Rostislav Pehlivanov 
>>> > > ---
>>> > >  libavcodec/parser.c | 14 --
>>> > >  1 file changed, 8 insertions(+), 6 deletions(-)
>>> > >
>>> > > diff --git a/libavcodec/parser.c b/libavcodec/parser.c
>>> > > index 670680ea7c..baf1de4d88 100644
>>> > > --- a/libavcodec/parser.c
>>> > > +++ b/libavcodec/parser.c
>>> > > @@ -23,30 +23,32 @@
>>> > >  #include 
>>> > >  #include 
>>> > >  #include 
>>> > > +#include 
>>> > >
>>> > >  #include "libavutil/avassert.h"
>>> > > -#include "libavutil/atomic.h"
>>> > >  #include "libavutil/internal.h"
>>> > >  #include "libavutil/mem.h"
>>> > >
>>> > >  #include "internal.h"
>>> > >  #include "parser.h"
>>> > >
>>> > > -static AVCodecParser *av_first_parser = NULL;
>>> > > +static _Atomic(AVCodecParser *)av_first_parser = NULL;
>>> >
>>> > This doesnt build here
>>> >
>>> > libavcodec/parser.c:35:8: warning: return type defaults to ‘int’ [enabled
>>> > by default]
>>> >  static _Atomic(AVCodecParser *)av_first_parser = NULL;
>>> > ^
>>> > libavcodec/parser.c: In function ‘_Atomic’:
>>> > libavcodec/parser.c:35:32: error: expected declaration specifiers before
>>> > ‘av_first_parser’
>>> >  static _Atomic(AVCodecParser *)av_first_parser = NULL;
>>> > ^
>>> > libavcodec/parser.c:38:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
>>> > ‘__attribute__’ before ‘{’ token
>>> >  {
>>> >  ^
>>> > libavcodec/parser.c:46:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
>>> > ‘__attribute__’ before ‘{’ token
>>> >  {
>>> >  ^
>>> > libavcodec/parser.c:55:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__a
>>> >
>>> >
>>> > [...]
>>> > --
>>> > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>>> >
>>> > Observe your enemies, for they first find out your faults. -- Antisthenes
>>> >
>>> > ___
>>> > ffmpeg-devel mailing list
>>> > ffmpeg-devel@ffmpeg.org
>>> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>> >
>>> >
>>>
>>> Does the attached patch work?
>>
>>>  parser.c |   14 --
>>>  1 file changed, 8 insertions(+), 6 deletions(-)
>>> 71f66a37fb46e29626f27da4658f34927e48033c  
>>> v2-0001-lavc-parser-use-C11-atomics.patch
>>> From b9ed59e9aff4a0fcc40f444f307c87acad55e139 Mon Sep 17 00:00:00 2001
>>> From: Rostislav Pehlivanov 
>>> Date: Mon, 27 Nov 2017 01:56:41 +
>>> Subject: [PATCH v2 1/2] lavc/parser: use C11 atomics
>>>
>>> Signed-off-by: Rostislav Pehlivanov 
>>> ---
>>>  libavcodec/parser.c | 14 --
>>>  1 file changed, 8 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/libavcodec/parser.c b/libavcodec/parser.c
>>> index 670680ea7c..d6df62bf70 100644
>>> --- a/libavcodec/parser.c
>>> +++ b/libavcodec/parser.c
>>> @@ -23,30 +23,32 @@
>>>  #include 
>>>  #include 
>>>  #include 
>>> +#include 
>>>
>>>  #include "libavutil/avassert.h"
>>> -#include "libavutil/atomic.h"
>>>  #include "libavutil/internal.h"
>>>  #include "libavutil/mem.h"
>>>
>>>  #include "internal.h"
>>>  #include "parser.h"
>>>
>>> -static AVCodecParser *av_first_parser = NULL;
>>> +static _Atomic(AVCodecParser *) av_first_parser = NULL;
>>
>> no
>>
>>
>> libavcodec/parser.c:35:8: warning: return type defaults to ‘int’ [enabled by 
>> default]
>>  static _Atomic(AVCodecParser *) av_first_parser = NULL;
>> ^
>> libavcodec/parser.c: In function ‘_Atomic’:
>> libavcodec/parser.c:35:33: error: expected declaration specifiers before 
>> ‘av_first_parser’
>>  static _Atomic(AVCodecParser *) av_first_parser = NULL;
>>
>> also see
>> compat/atomics/gcc/stdatomic.h
>>
>> i think what you do is not supportd in that
>>
>>
>
> _Atomic is a keywork like volatile, so its syntax should be the same.
> Perhaps those emulations should just define it to "volatile" if its
> missing - the win32 emulation certainly would expect it to be
> volatile, and I would expect this to be true for the others as well.
>

On that note, it seems a bit odd that the emulations don't typedef the
atomic types to be volatile. We replace "volatile int" with
"atomic_int" for example, and with win32 or gcc emulation for
stdatomic.h, the volatile is basically just being dropped.
Sounds like that might be missing?

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


Re: [FFmpeg-devel] [PATCH 1/2] vaapi_h264: Add named options for setting profile and level

2017-11-30 Thread Moritz Barsnick
On Thu, Nov 30, 2017 at 08:52:21 +, Li, Zhong wrote:
> > +{ LEVEL("6",   60) },
> > +{ LEVEL("6.1", 61) },
> > +{ LEVEL("6.2", 62) },
> 
> IIRC, level 5.2 is the maximum level of H264? 

Higher levels were introduced in 2016. Edition V12 of H.264 lists 6,
6.1 and 6.2 in Annex A, Table A-1. It basically lists the same thing as
Wikipedia:
https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Levels

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


Re: [FFmpeg-devel] [PATCH 1/4] lavc/parser: use C11 atomics

2017-11-30 Thread Hendrik Leppkes
On Thu, Nov 30, 2017 at 3:17 PM, Michael Niedermayer
 wrote:
> On Thu, Nov 30, 2017 at 11:55:03AM +, Rostislav Pehlivanov wrote:
>> On 28 November 2017 at 01:26, Michael Niedermayer 
>> wrote:
>>
>> > On Mon, Nov 27, 2017 at 04:30:18AM +, Rostislav Pehlivanov wrote:
>> > > Signed-off-by: Rostislav Pehlivanov 
>> > > ---
>> > >  libavcodec/parser.c | 14 --
>> > >  1 file changed, 8 insertions(+), 6 deletions(-)
>> > >
>> > > diff --git a/libavcodec/parser.c b/libavcodec/parser.c
>> > > index 670680ea7c..baf1de4d88 100644
>> > > --- a/libavcodec/parser.c
>> > > +++ b/libavcodec/parser.c
>> > > @@ -23,30 +23,32 @@
>> > >  #include 
>> > >  #include 
>> > >  #include 
>> > > +#include 
>> > >
>> > >  #include "libavutil/avassert.h"
>> > > -#include "libavutil/atomic.h"
>> > >  #include "libavutil/internal.h"
>> > >  #include "libavutil/mem.h"
>> > >
>> > >  #include "internal.h"
>> > >  #include "parser.h"
>> > >
>> > > -static AVCodecParser *av_first_parser = NULL;
>> > > +static _Atomic(AVCodecParser *)av_first_parser = NULL;
>> >
>> > This doesnt build here
>> >
>> > libavcodec/parser.c:35:8: warning: return type defaults to ‘int’ [enabled
>> > by default]
>> >  static _Atomic(AVCodecParser *)av_first_parser = NULL;
>> > ^
>> > libavcodec/parser.c: In function ‘_Atomic’:
>> > libavcodec/parser.c:35:32: error: expected declaration specifiers before
>> > ‘av_first_parser’
>> >  static _Atomic(AVCodecParser *)av_first_parser = NULL;
>> > ^
>> > libavcodec/parser.c:38:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
>> > ‘__attribute__’ before ‘{’ token
>> >  {
>> >  ^
>> > libavcodec/parser.c:46:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
>> > ‘__attribute__’ before ‘{’ token
>> >  {
>> >  ^
>> > libavcodec/parser.c:55:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__a
>> >
>> >
>> > [...]
>> > --
>> > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>> >
>> > Observe your enemies, for they first find out your faults. -- Antisthenes
>> >
>> > ___
>> > ffmpeg-devel mailing list
>> > ffmpeg-devel@ffmpeg.org
>> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> >
>> >
>>
>> Does the attached patch work?
>
>>  parser.c |   14 --
>>  1 file changed, 8 insertions(+), 6 deletions(-)
>> 71f66a37fb46e29626f27da4658f34927e48033c  
>> v2-0001-lavc-parser-use-C11-atomics.patch
>> From b9ed59e9aff4a0fcc40f444f307c87acad55e139 Mon Sep 17 00:00:00 2001
>> From: Rostislav Pehlivanov 
>> Date: Mon, 27 Nov 2017 01:56:41 +
>> Subject: [PATCH v2 1/2] lavc/parser: use C11 atomics
>>
>> Signed-off-by: Rostislav Pehlivanov 
>> ---
>>  libavcodec/parser.c | 14 --
>>  1 file changed, 8 insertions(+), 6 deletions(-)
>>
>> diff --git a/libavcodec/parser.c b/libavcodec/parser.c
>> index 670680ea7c..d6df62bf70 100644
>> --- a/libavcodec/parser.c
>> +++ b/libavcodec/parser.c
>> @@ -23,30 +23,32 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>
>>  #include "libavutil/avassert.h"
>> -#include "libavutil/atomic.h"
>>  #include "libavutil/internal.h"
>>  #include "libavutil/mem.h"
>>
>>  #include "internal.h"
>>  #include "parser.h"
>>
>> -static AVCodecParser *av_first_parser = NULL;
>> +static _Atomic(AVCodecParser *) av_first_parser = NULL;
>
> no
>
>
> libavcodec/parser.c:35:8: warning: return type defaults to ‘int’ [enabled by 
> default]
>  static _Atomic(AVCodecParser *) av_first_parser = NULL;
> ^
> libavcodec/parser.c: In function ‘_Atomic’:
> libavcodec/parser.c:35:33: error: expected declaration specifiers before 
> ‘av_first_parser’
>  static _Atomic(AVCodecParser *) av_first_parser = NULL;
>
> also see
> compat/atomics/gcc/stdatomic.h
>
> i think what you do is not supportd in that
>
>

_Atomic is a keywork like volatile, so its syntax should be the same.
Perhaps those emulations should just define it to "volatile" if its
missing - the win32 emulation certainly would expect it to be
volatile, and I would expect this to be true for the others as well.

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


[FFmpeg-devel] Changing the framerate of an putput stream dynamically

2017-11-30 Thread Sharleen Go
Hello,
    I was wondering if someone has ever tried modifying the code of FFmpeg to 
support varying the framerate during streaming. So far, I tried to 
re-initialize the AVCodec Context of the output stream to apply the new 
framerate. Whenever I would suddenly change the framerate (from inside ffmpeg 
.c code, without any logic just through time), I would get a bunch of 
Non-monotonous DTS in output stream... errors. Furthermore, if I increase the 
framerate the errors would appear but streaming doesn't stop. If I decrease the 
framerate, frames would constantly be dropped and streaming stops. I am no 
video encoding expert so I really have no idea regarding the math behind the 
calculation of encoding parameters and such. 

If anyone has an idea please help me out. What exactly is the proper way of 
changing the framerate, aside from re-initializing the AVCodec Context, what 
else must be recalculated?

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


Re: [FFmpeg-devel] [PATCH 2/4] lavfi/avfilter: simplify filter registration

2017-11-30 Thread Hendrik Leppkes
On Thu, Nov 30, 2017 at 12:54 PM, Rostislav Pehlivanov
 wrote:
> On 29 November 2017 at 16:40, Michael Niedermayer 
> wrote:
>
>> On Wed, Nov 29, 2017 at 03:51:34AM +, Rostislav Pehlivanov wrote:
>> > On 28 November 2017 at 20:23, Michael Niedermayer > >
>> > wrote:
>> >
>> > > On Mon, Nov 27, 2017 at 04:30:19AM +, Rostislav Pehlivanov wrote:
>> > > > Atomics were entirely pointless and did nothing but slow and
>> complicate
>> > > > the process down. This could be improved further still but the main
>> > > > objective of this commit is to simplify.
>> > > >
>> > > > Signed-off-by: Rostislav Pehlivanov 
>> > > > ---
>> > > >  libavfilter/avfilter.c | 8 +---
>> > > >  1 file changed, 5 insertions(+), 3 deletions(-)
>> > >
>> > > *_register() can be called by the user app in a unsyncronized way
>> > > for example from a module like vlc used AFAIK.
>> > > or from libs loaded by an application which use libavfilter or other
>> > > internally.
>> > >
>> > > These registration functions should stay thread safe
>> > >
>> > >
>> > > [...]
>> > >
>> > > --
>> > > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC7
>> 87040B0FAB
>> > >
>> > > Those who would give up essential Liberty, to purchase a little
>> > > temporary Safety, deserve neither Liberty nor Safety -- Benjamin
>> Franklin
>> > >
>> > > ___
>> > > ffmpeg-devel mailing list
>> > > ffmpeg-devel@ffmpeg.org
>> > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> > >
>> > >
>> > What variable actually needs to be protected?
>>
>> The linked list of registered "entities"
>> That is if the addition is not synchronized by some means, an atomic
>> exchange a mutex or something then a race can generally occur
>> and only one addition might succeed or something else might get
>> entangled
>>
>> This is in practical terms a very unlikely event to occur of course
>>
>> [...]
>> --
>> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>>
>> You can kill me, but you cannot change the truth.
>>
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>>
> Could you test the attached patch? Pretty much everything is synchronized.
>

The only way to have two threads modify a linked list at the same time
is with a "compare exchange" (cas) instruction, so why not just keep
the old logic and replace the avpriv atomic with a stdatomic one?

ie.
while(*f || avpriv_atomic_ptr_cas((void * volatile *)f, NULL, filter))

becomes: (plus appropriate type changes/casts as required)
while(*f || atomic_compare_exchange_strong(f, NULL, filter) == false)

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


Re: [FFmpeg-devel] [PATCH 1/4] lavc/parser: use C11 atomics

2017-11-30 Thread Michael Niedermayer
On Thu, Nov 30, 2017 at 11:55:03AM +, Rostislav Pehlivanov wrote:
> On 28 November 2017 at 01:26, Michael Niedermayer 
> wrote:
> 
> > On Mon, Nov 27, 2017 at 04:30:18AM +, Rostislav Pehlivanov wrote:
> > > Signed-off-by: Rostislav Pehlivanov 
> > > ---
> > >  libavcodec/parser.c | 14 --
> > >  1 file changed, 8 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/libavcodec/parser.c b/libavcodec/parser.c
> > > index 670680ea7c..baf1de4d88 100644
> > > --- a/libavcodec/parser.c
> > > +++ b/libavcodec/parser.c
> > > @@ -23,30 +23,32 @@
> > >  #include 
> > >  #include 
> > >  #include 
> > > +#include 
> > >
> > >  #include "libavutil/avassert.h"
> > > -#include "libavutil/atomic.h"
> > >  #include "libavutil/internal.h"
> > >  #include "libavutil/mem.h"
> > >
> > >  #include "internal.h"
> > >  #include "parser.h"
> > >
> > > -static AVCodecParser *av_first_parser = NULL;
> > > +static _Atomic(AVCodecParser *)av_first_parser = NULL;
> >
> > This doesnt build here
> >
> > libavcodec/parser.c:35:8: warning: return type defaults to ‘int’ [enabled
> > by default]
> >  static _Atomic(AVCodecParser *)av_first_parser = NULL;
> > ^
> > libavcodec/parser.c: In function ‘_Atomic’:
> > libavcodec/parser.c:35:32: error: expected declaration specifiers before
> > ‘av_first_parser’
> >  static _Atomic(AVCodecParser *)av_first_parser = NULL;
> > ^
> > libavcodec/parser.c:38:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
> > ‘__attribute__’ before ‘{’ token
> >  {
> >  ^
> > libavcodec/parser.c:46:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
> > ‘__attribute__’ before ‘{’ token
> >  {
> >  ^
> > libavcodec/parser.c:55:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__a
> >
> >
> > [...]
> > --
> > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> >
> > Observe your enemies, for they first find out your faults. -- Antisthenes
> >
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> >
> 
> Does the attached patch work?

>  parser.c |   14 --
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 71f66a37fb46e29626f27da4658f34927e48033c  
> v2-0001-lavc-parser-use-C11-atomics.patch
> From b9ed59e9aff4a0fcc40f444f307c87acad55e139 Mon Sep 17 00:00:00 2001
> From: Rostislav Pehlivanov 
> Date: Mon, 27 Nov 2017 01:56:41 +
> Subject: [PATCH v2 1/2] lavc/parser: use C11 atomics
> 
> Signed-off-by: Rostislav Pehlivanov 
> ---
>  libavcodec/parser.c | 14 --
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/libavcodec/parser.c b/libavcodec/parser.c
> index 670680ea7c..d6df62bf70 100644
> --- a/libavcodec/parser.c
> +++ b/libavcodec/parser.c
> @@ -23,30 +23,32 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include "libavutil/avassert.h"
> -#include "libavutil/atomic.h"
>  #include "libavutil/internal.h"
>  #include "libavutil/mem.h"
>  
>  #include "internal.h"
>  #include "parser.h"
>  
> -static AVCodecParser *av_first_parser = NULL;
> +static _Atomic(AVCodecParser *) av_first_parser = NULL;

no


libavcodec/parser.c:35:8: warning: return type defaults to ‘int’ [enabled by 
default]
 static _Atomic(AVCodecParser *) av_first_parser = NULL;
^
libavcodec/parser.c: In function ‘_Atomic’:
libavcodec/parser.c:35:33: error: expected declaration specifiers before 
‘av_first_parser’
 static _Atomic(AVCodecParser *) av_first_parser = NULL;

also see
compat/atomics/gcc/stdatomic.h

i think what you do is not supportd in that

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

Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway


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


Re: [FFmpeg-devel] [PATCH] avfilter/vf_tile: add init_padding option

2017-11-30 Thread Nicolas George
Moritz Barsnick (2017-11-30):
> Wouldn't
>tile->first_frame = 0;
> be faster and easier? Or did you mean to use different variables in the
> check and the assignment?

Or even clearing the option after is has been used. Single test, single
field: faster, less memory, less code.

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] avfilter/vf_tile: add init_padding option

2017-11-30 Thread Moritz Barsnick
On Wed, Nov 29, 2017 at 20:29:49 +0100, Paul B Mahol wrote:
> +{ "init_padding", " set how many frames to initially pad", 
> OFFSET(init_padding),
  ^ space
Some whitespace slipped in there. 

> +if (tile->first_frame)
> +tile->first_frame = 0;

Wouldn't
   tile->first_frame = 0;
be faster and easier? Or did you mean to use different variables in the
check and the assignment?

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


Re: [FFmpeg-devel] [PATCH 2/4] lavfi/avfilter: simplify filter registration

2017-11-30 Thread Michael Niedermayer
On Thu, Nov 30, 2017 at 11:54:25AM +, Rostislav Pehlivanov wrote:
> On 29 November 2017 at 16:40, Michael Niedermayer 
> wrote:
> 
> > On Wed, Nov 29, 2017 at 03:51:34AM +, Rostislav Pehlivanov wrote:
> > > On 28 November 2017 at 20:23, Michael Niedermayer  > >
> > > wrote:
> > >
> > > > On Mon, Nov 27, 2017 at 04:30:19AM +, Rostislav Pehlivanov wrote:
> > > > > Atomics were entirely pointless and did nothing but slow and
> > complicate
> > > > > the process down. This could be improved further still but the main
> > > > > objective of this commit is to simplify.
> > > > >
> > > > > Signed-off-by: Rostislav Pehlivanov 
> > > > > ---
> > > > >  libavfilter/avfilter.c | 8 +---
> > > > >  1 file changed, 5 insertions(+), 3 deletions(-)
> > > >
> > > > *_register() can be called by the user app in a unsyncronized way
> > > > for example from a module like vlc used AFAIK.
> > > > or from libs loaded by an application which use libavfilter or other
> > > > internally.
> > > >
> > > > These registration functions should stay thread safe
> > > >
> > > >
> > > > [...]
> > > >
> > > > --
> > > > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC7
> > 87040B0FAB
> > > >
> > > > Those who would give up essential Liberty, to purchase a little
> > > > temporary Safety, deserve neither Liberty nor Safety -- Benjamin
> > Franklin
> > > >
> > > > ___
> > > > ffmpeg-devel mailing list
> > > > ffmpeg-devel@ffmpeg.org
> > > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > > >
> > > >
> > > What variable actually needs to be protected?
> >
> > The linked list of registered "entities"
> > That is if the addition is not synchronized by some means, an atomic
> > exchange a mutex or something then a race can generally occur
> > and only one addition might succeed or something else might get
> > entangled
> >
> > This is in practical terms a very unlikely event to occur of course
> >
> > [...]
> > --
> > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> >
> > You can kill me, but you cannot change the truth.
> >
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> >
> Could you test the attached patch? Pretty much everything is synchronized.

>  avfilter.c |   14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 8ab986fa3b0f735e025e5c0a3235ca4c7e227f1b  
> v2-0002-lavfi-avfilter-simplify-filter-registration.patch
> From fb9789206c76c876d6a79e81df68c6b8041f03c3 Mon Sep 17 00:00:00 2001
> From: Rostislav Pehlivanov 
> Date: Mon, 27 Nov 2017 04:12:26 +
> Subject: [PATCH v2 2/2] lavfi/avfilter: simplify filter registration
> 
> Atomics were entirely pointless and did nothing but slow and complicate
> the process down. This could be improved further still but the main
> objective of this commit is to simplify.
> 
> Signed-off-by: Rostislav Pehlivanov 
> ---
>  libavfilter/avfilter.c | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
> index b98b32bacb..76c9f12be9 100644
> --- a/libavfilter/avfilter.c
> +++ b/libavfilter/avfilter.c
> @@ -19,7 +19,6 @@
>   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
>   */
>  
> -#include "libavutil/atomic.h"
>  #include "libavutil/avassert.h"
>  #include "libavutil/avstring.h"
>  #include "libavutil/buffer.h"
> @@ -37,6 +36,7 @@
>  #define FF_INTERNAL_FIELDS 1
>  #include "framequeue.h"
>  
> +#include 
>  #include "audio.h"
>  #include "avfilter.h"
>  #include "filters.h"
> @@ -574,7 +574,7 @@ int avfilter_process_command(AVFilterContext *filter, 
> const char *cmd, const cha
>  }
>  
>  static AVFilter *first_filter;
> -static AVFilter **last_filter = _filter;
> +static _Atomic (AVFilter **) last_filter = ATOMIC_VAR_INIT(_filter);
>  
>  const AVFilter *avfilter_get_by_name(const char *name)
>  {
> @@ -592,16 +592,16 @@ const AVFilter *avfilter_get_by_name(const char *name)
>  
>  int avfilter_register(AVFilter *filter)
>  {
>  /* the filter must select generic or internal exclusively */
>  av_assert0((filter->flags & AVFILTER_FLAG_SUPPORT_TIMELINE) != 
> AVFILTER_FLAG_SUPPORT_TIMELINE);
>  
>  filter->next = NULL;
>  
> +/* Iterate through the list until the last entry has been reached */
> +do {
> +*atomic_load(_filter) = filter;
> +atomic_store(_filter, >next);
> +} while (*atomic_load(_filter));

assume 2 register run at the same time

both execute atomic_load(_filter)
and obtain a pointer to a pointer to first_filter, which they both
store their (different) filter arguments in (non atomically)

Thats a race & undefined behavior
and even if this store was atomic, the later would overwrite the

Re: [FFmpeg-devel] [PATCH] avfilter: add fillborders filter

2017-11-30 Thread Moritz Barsnick
On Wed, Nov 29, 2017 at 20:16:16 +0100, Paul B Mahol wrote:
> +@item mode
> +Set fill mode.
> +
> +It accepts the following values:
> +@table @samp
> +@item smear
> +fill pixels using outermost pixels
> +
> +@item mirror
> +fill pixels using mirroring
> +
> +@item fixed
> +fill pixels with constant value
> +@end table

"Default value is @code{smear}."

> +Set color for pixels in fixed mode. Defauls is @var{black}.
Typo:  ^ Default


> +s->yuv_color[Y] = RGB_TO_Y_CCIR(s->rgba_color[R], s->rgba_color[G], 
> s->rgba_color[B]);
> +s->yuv_color[U] = RGB_TO_U_CCIR(s->rgba_color[R], s->rgba_color[G], 
> s->rgba_color[B], 0);
> +s->yuv_color[V] = RGB_TO_V_CCIR(s->rgba_color[R], s->rgba_color[G], 
> s->rgba_color[B], 0);
> +s->yuv_color[A] = s->rgba_color[A];

This RGB to YUV calculation could go into the else block below, since
it's only required/used there, right?:

> +if (desc->flags & AV_PIX_FMT_FLAG_RGB) {
> +memcpy(s->fill, s->rgba_color, sizeof(s->rgba_color));
> +} else {
> +memcpy(s->fill, s->yuv_color, sizeof(s->yuv_color));
> +}

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


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-30 Thread Michael Niedermayer
On Thu, Nov 30, 2017 at 10:12:53AM +0100, Felix Matouschek wrote:
> Am 29.11.2017 04:31, schrieb Michael Niedermayer:
> 
> >if the identifer and the string always match you could do this
> >with a macro avoiding the neede to duplcate each string
> >see AV_STRINGIFY
> 
> I changed it, is it ok like this?
> 
> >[...]
> >>+static int add_video_stream(AVFormatContext *avctx)
> >>+{
> >>+AndroidCameraCtx *ctx = avctx->priv_data;
> >>+AVStream *st;
> >>+AVCodecParameters *codecpar;
> >>+
> >>+st = avformat_new_stream(avctx, NULL);
> >>+if (!st) {
> >>+return AVERROR(ENOMEM);
> >>+}
> >>+
> >>+st->id = VIDEO_STREAM_INDEX;
> >
> >>+st->avg_frame_rate = (AVRational) { ctx->framerate_range[1], 1 };
> >>+st->r_frame_rate = (AVRational) { ctx->framerate_range[1], 1 };
> >
> >Are these values always correct ?
> 
> You mean avg_frame_rate and r_frame_rate?
> The framerate can vary between the values in framerate_range[0]
> (min) and framerate_range[1] (max).
> Ideally both values are the same, sometimes min can be lower but for
> the average the framerate should be what is in max.
> Should I set r_frame_rate to min?

I think if you do not know the base or average frame rate you
should not set it.
Or does this lead to some unreasonable latency ?
or are the computed values worse ?


> 
> I fixed all other parts you mentioned.
> 
> Felix
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

-- 
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: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] Create .lib static libraries on Windows instead of .a libraries (using MSVC compiler)

2017-11-30 Thread Hendrik Leppkes
On Thu, Nov 30, 2017 at 2:43 PM, Carl Eugen Hoyos  wrote:
> 2017-09-27 22:26 GMT+02:00 Hendrik Leppkes :
>> On Wed, Sep 27, 2017 at 10:11 PM, Mateusz  wrote:
>>> W dniu 2017-09-27 o 17:40, Hendrik Leppkes pisze:
 On Wed, Sep 27, 2017 at 4:43 PM, Anonymous Maarten
  wrote:
> Hey,
>
> Building the static ffmpeg library using vcpkg is currently broken [1][2].
> This is mainly due to the fact that the built static libraries are .a 
> files
> with lib prefixes.
>
> The attached patch sets the lib prefix to "" and the lib suffix to ".lib".
>
> Tested by building ffmpeg using vcpkg and Visual Studio 2017 Community
> Edition on Windows 10.
> The resulted libraries link correctly to my application.
>
 This would break the workflow for everyone that is currently working
 with the current names, however.
>>>
>>> For gcc it breaks nothing (it still makes lib...a files), for msvc it is 
>>> improvement.
>>> Is there any person happy with lib...a names for lib in msvc?
>>>
>>
>> It doesn't really matter if you're happy with it or not, if you change
>> it stuff will still break.
>
> Given we are currently changing API and ABI, this shouldn't
> be an issue.
> But maybe there is a reason why .a files have an advantage?
>

I think its actually somewhat beneficial to have different names for
dynamic and static libraries, its easy to differentiate them.

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


Re: [FFmpeg-devel] Create .lib static libraries on Windows instead of .a libraries (using MSVC compiler)

2017-11-30 Thread Carl Eugen Hoyos
2017-09-27 22:26 GMT+02:00 Hendrik Leppkes :
> On Wed, Sep 27, 2017 at 10:11 PM, Mateusz  wrote:
>> W dniu 2017-09-27 o 17:40, Hendrik Leppkes pisze:
>>> On Wed, Sep 27, 2017 at 4:43 PM, Anonymous Maarten
>>>  wrote:
 Hey,

 Building the static ffmpeg library using vcpkg is currently broken [1][2].
 This is mainly due to the fact that the built static libraries are .a files
 with lib prefixes.

 The attached patch sets the lib prefix to "" and the lib suffix to ".lib".

 Tested by building ffmpeg using vcpkg and Visual Studio 2017 Community
 Edition on Windows 10.
 The resulted libraries link correctly to my application.

>>> This would break the workflow for everyone that is currently working
>>> with the current names, however.
>>
>> For gcc it breaks nothing (it still makes lib...a files), for msvc it is 
>> improvement.
>> Is there any person happy with lib...a names for lib in msvc?
>>
>
> It doesn't really matter if you're happy with it or not, if you change
> it stuff will still break.

Given we are currently changing API and ABI, this shouldn't
be an issue.
But maybe there is a reason why .a files have an advantage?

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


Re: [FFmpeg-devel] [PATCH] avfilter: slice processing for geq

2017-11-30 Thread Marc-Antoine ARNAUD
Le jeu. 30 nov. 2017 à 01:51, Michael Niedermayer 
a écrit :

> On Wed, Nov 29, 2017 at 11:28:40AM +, Marc-Antoine ARNAUD wrote:
> > Le mer. 22 nov. 2017 à 17:54, Michael Niedermayer  >
> > a écrit :
> >
> > > On Wed, Nov 22, 2017 at 10:24:30AM +, Marc-Antoine ARNAUD wrote:
> > > > New patch version which fixe the last remark.
> > > >
> > > >
> > > > Le ven. 10 nov. 2017 à 00:47, Michael Niedermayer
>  > > >
> > > > a écrit :
> > > >
> > > > > On Thu, Nov 09, 2017 at 10:22:23AM +, Marc-Antoine ARNAUD
> wrote:
> > > > > > Please find the merged patch in attachement.
> > > > > >
> > > > > > Thanks
> > > > > >
> > > > > > Le mer. 8 nov. 2017 à 17:12, Paul B Mahol  a
> > > écrit :
> > > > > >
> > > > > > > On 11/8/17, Marc-Antoine ARNAUD 
> > > wrote:
> > > > > > > > This patch will fix the stride issue.
> > > > > > > > Is it valid for you ?
> > > > > > > >
> > > > > > > > Does it required to merge these 2 patches ? (and remove
> base64
> > > > > encoding
> > > > > > > on
> > > > > > > > the first one)
> > > > > > >
> > > > > > > Please merge those two patches, base64 encoding should not be
> > > needed
> > > > > > > (it helps to faster review patches if they are not encoded).
> > > > > > > ___
> > > > > > > ffmpeg-devel mailing list
> > > > > > > ffmpeg-devel@ffmpeg.org
> > > > > > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > > > > > >
> > > > >
> > > > > >  vf_geq.c |  124
> > > > > +--
> > > > > >  1 file changed, 90 insertions(+), 34 deletions(-)
> > > > > > b41a90fffb5ddef553661007a38659c602f7ce56
> > > > > 0001-avfilter-slice-processing-for-geq.patch
> > > > > > From ac2a6322fa96835e02a24c31f014fb360e26561f Mon Sep 17 00:00:00
> > > 2001
> > > > > > From: Marc-Antoine Arnaud 
> > > > > > Date: Thu, 9 Nov 2017 11:19:43 +0100
> > > > > > Subject: [PATCH] avfilter: slice processing for geq
> > > > > > Content-Type: text/x-patch; charset="utf-8"
> > > > >
> > > > > crashes:
> > > > > ./ffmpeg_g -f lavfi -i
> > > > >
> > >
> 'nullsrc=s=200x200,format=yuv444p16,geq=X*Y/10:sin(X/10)*255:cos(Y/10)*255'
> > > > > -vframes 5 -y blah.avi
> > > > >
> > > > > ==24616== Thread 7:
> > > > > ==24616== Invalid write of size 2
> > > > > ==24616==at 0x4F3AAF: slice_geq_filter (vf_geq.c:289)
> > > > > ==24616==by 0x48E4C9: worker_func (pthread.c:50)
> > > > > ==24616==by 0x11DB932: run_jobs (slicethread.c:61)
> > > > > ==24616==by 0x11DBA04: thread_worker (slicethread.c:85)
> > > > > ==24616==by 0xC45D183: start_thread (pthread_create.c:312)
> > > > > ==24616==by 0xC770FFC: clone (clone.S:111)
> > > > > ==24616==  Address 0x1177143e is 93,214 bytes inside a block of
> size
> > > > > 93,215 alloc'd
> > > > > ==24616==at 0x4C2A6C5: memalign (vg_replace_malloc.c:727)
> > > > > ==24616==by 0x4C2A760: posix_memalign (vg_replace_malloc.c:876)
> > > > > ==24616==by 0x11B0C43: av_malloc (mem.c:87)
> > > > > ==24616==by 0x11987CC: av_buffer_alloc (buffer.c:72)
> > > > > ==24616==by 0x1198831: av_buffer_allocz (buffer.c:85)
> > > > > ==24616==by 0x1198F29: pool_alloc_buffer (buffer.c:312)
> > > > > ==24616==by 0x1199057: av_buffer_pool_get (buffer.c:349)
> > > > > ==24616==by 0x489D6D: ff_frame_pool_get (framepool.c:222)
> > > > > ==24616==by 0x58F6EB: ff_default_get_video_buffer (video.c:89)
> > > > > ==24616==by 0x58F768: ff_get_video_buffer (video.c:102)
> > > > > ==24616==by 0x4F3BF3: geq_filter_frame (vf_geq.c:312)
> > > > > ==24616==by 0x472FD0: ff_filter_frame_framed (avfilter.c:1104)
> > > > > ==24616==by 0x473800: ff_filter_frame_to_filter
> (avfilter.c:1252)
> > > > > ==24616==by 0x4739F8: ff_filter_activate_default
> (avfilter.c:1301)
> > > > > ==24616==by 0x473C12: ff_filter_activate (avfilter.c:1462)
> > > > > ==24616==by 0x478A4F: ff_filter_graph_run_once
> > > (avfiltergraph.c:1456)
> > > > > ==24616==by 0x478C72: get_frame_internal (buffersink.c:110)
> > > > > ==24616==by 0x478CCF: av_buffersink_get_frame_flags
> > > (buffersink.c:121)
> > > > > ==24616==by 0x441808: lavfi_read_packet (lavfi.c:410)
> > > > > ==24616==by 0x7AC315: ff_read_packet (utils.c:822)
> > > > > ==24616==
> > > > > --24616-- VALGRIND INTERNAL ERROR: Valgrind received a signal 11
> > > (SIGSEGV)
> > > > > - exiting
> > > > > --24616-- si_code=80;  Faulting address: 0x0;  sp: 0x40a075db0
> > > > >
> > > > > [...]
> > > > >
> > > > > --
> > > > > Michael GnuPG fingerprint:
> 9FF2128B147EF6730BADF133611EC787040B0FAB
> > > > >
> > > > > While the State exists there can be no freedom; when there is
> freedom
> > > there
> > > > > will be no State. -- Vladimir Lenin
> > > > > ___
> > > > > ffmpeg-devel mailing list
> > > > > 

Re: [FFmpeg-devel] [PATCH 1/4] lavc/parser: use C11 atomics

2017-11-30 Thread Rostislav Pehlivanov
On 28 November 2017 at 01:26, Michael Niedermayer 
wrote:

> On Mon, Nov 27, 2017 at 04:30:18AM +, Rostislav Pehlivanov wrote:
> > Signed-off-by: Rostislav Pehlivanov 
> > ---
> >  libavcodec/parser.c | 14 --
> >  1 file changed, 8 insertions(+), 6 deletions(-)
> >
> > diff --git a/libavcodec/parser.c b/libavcodec/parser.c
> > index 670680ea7c..baf1de4d88 100644
> > --- a/libavcodec/parser.c
> > +++ b/libavcodec/parser.c
> > @@ -23,30 +23,32 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >
> >  #include "libavutil/avassert.h"
> > -#include "libavutil/atomic.h"
> >  #include "libavutil/internal.h"
> >  #include "libavutil/mem.h"
> >
> >  #include "internal.h"
> >  #include "parser.h"
> >
> > -static AVCodecParser *av_first_parser = NULL;
> > +static _Atomic(AVCodecParser *)av_first_parser = NULL;
>
> This doesnt build here
>
> libavcodec/parser.c:35:8: warning: return type defaults to ‘int’ [enabled
> by default]
>  static _Atomic(AVCodecParser *)av_first_parser = NULL;
> ^
> libavcodec/parser.c: In function ‘_Atomic’:
> libavcodec/parser.c:35:32: error: expected declaration specifiers before
> ‘av_first_parser’
>  static _Atomic(AVCodecParser *)av_first_parser = NULL;
> ^
> libavcodec/parser.c:38:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
> ‘__attribute__’ before ‘{’ token
>  {
>  ^
> libavcodec/parser.c:46:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
> ‘__attribute__’ before ‘{’ token
>  {
>  ^
> libavcodec/parser.c:55:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__a
>
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Observe your enemies, for they first find out your faults. -- Antisthenes
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>

Does the attached patch work?
From b9ed59e9aff4a0fcc40f444f307c87acad55e139 Mon Sep 17 00:00:00 2001
From: Rostislav Pehlivanov 
Date: Mon, 27 Nov 2017 01:56:41 +
Subject: [PATCH v2 1/2] lavc/parser: use C11 atomics

Signed-off-by: Rostislav Pehlivanov 
---
 libavcodec/parser.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/libavcodec/parser.c b/libavcodec/parser.c
index 670680ea7c..d6df62bf70 100644
--- a/libavcodec/parser.c
+++ b/libavcodec/parser.c
@@ -23,30 +23,32 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "libavutil/avassert.h"
-#include "libavutil/atomic.h"
 #include "libavutil/internal.h"
 #include "libavutil/mem.h"
 
 #include "internal.h"
 #include "parser.h"
 
-static AVCodecParser *av_first_parser = NULL;
+static _Atomic(AVCodecParser *) av_first_parser = NULL;
 
 AVCodecParser *av_parser_next(const AVCodecParser *p)
 {
 if (p)
 return p->next;
 else
-return av_first_parser;
+return atomic_load(_first_parser);
 }
 
 void av_register_codec_parser(AVCodecParser *parser)
 {
+AVCodecParser *old_parser;
 do {
-parser->next = av_first_parser;
-} while (parser->next != avpriv_atomic_ptr_cas((void * volatile *)_first_parser, parser->next, parser));
+parser->next = old_parser = atomic_load(_first_parser);
+atomic_compare_exchange_strong(_first_parser, _parser, parser);
+} while (parser->next != old_parser);
 }
 
 AVCodecParserContext *av_parser_init(int codec_id)
@@ -58,7 +60,7 @@ AVCodecParserContext *av_parser_init(int codec_id)
 if (codec_id == AV_CODEC_ID_NONE)
 return NULL;
 
-for (parser = av_first_parser; parser; parser = parser->next) {
+for (parser = atomic_load(_first_parser); parser; parser = parser->next) {
 if (parser->codec_ids[0] == codec_id ||
 parser->codec_ids[1] == codec_id ||
 parser->codec_ids[2] == codec_id ||
-- 
2.15.1.424.g9478a66081

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


Re: [FFmpeg-devel] [PATCH v5 3/3] avformat/hlsenc:addition of CODECS attribute in the master playlist

2017-11-30 Thread Steven Liu
2017-11-30 19:32 GMT+08:00  :
> From: Vishwanath Dixit 
>
> ---
>  libavformat/Makefile  |  2 +-
>  libavformat/dashenc.c |  2 +-
>  libavformat/hlsenc.c  | 65 
> +--
>  libavformat/hlsplaylist.c |  5 +++-
>  libavformat/hlsplaylist.h |  3 ++-
>  libavformat/reverse.c |  1 +
Remove this modify if this have nothing to do.

>  tests/ref/fate/source |  1 +
>  7 files changed, 73 insertions(+), 6 deletions(-)
>  create mode 100644 libavformat/reverse.c
>
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 4bffdf2..2bdb777 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -61,7 +61,7 @@ OBJS-$(CONFIG_RTPDEC)+= rdt.o   
> \
>  rtpdec_vp9.o\
>  rtpdec_xiph.o
>  OBJS-$(CONFIG_RTPENC_CHAIN)  += rtpenc_chain.o rtp.o
> -OBJS-$(CONFIG_SHARED)+= log2_tab.o golomb_tab.o
> +OBJS-$(CONFIG_SHARED)+= log2_tab.o golomb_tab.o reverse.o
>  OBJS-$(CONFIG_SRTP)  += srtp.o
>
>  # muxers/demuxers
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 90cd2d0..e0b1679 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -754,7 +754,7 @@ static int write_manifest(AVFormatContext *s, int final)
>  AVStream *st = s->streams[i];
>  get_hls_playlist_name(playlist_file, sizeof(playlist_file), 
> NULL, i);
>  ff_hls_write_stream_info(st, out, st->codecpar->bit_rate,
> -playlist_file, NULL);
> +playlist_file, NULL, NULL);
>  }
>  avio_close(out);
>  if (use_rename)
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 8d4b333..0702124 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -39,6 +39,7 @@
>  #include "libavutil/avstring.h"
>  #include "libavutil/intreadwrite.h"
>  #include "libavutil/random_seed.h"
> +#include "libavutil/reverse.h"
>  #include "libavutil/opt.h"
>  #include "libavutil/log.h"
>  #include "libavutil/time_internal.h"
> @@ -1074,6 +1075,63 @@ static int get_relative_url(const char *master_url, 
> const char *media_url,
>  return 0;
>  }
>
> +static char *get_codec_str(AVStream *vid_st, AVStream *aud_st) {
> +size_t codec_str_size = 64;
> +char *codec_str = av_malloc(codec_str_size);
> +int video_str_len = 0;
> +
> +if (!codec_str)
> +return NULL;
> +
> +if (!vid_st && !aud_st) {
> +goto fail;
> +}
> +
> +if (vid_st) {
> +if (vid_st->codecpar->profile != FF_PROFILE_UNKNOWN &&
> +vid_st->codecpar->level != FF_LEVEL_UNKNOWN &&
> +vid_st->codecpar->codec_id == AV_CODEC_ID_H264) {
> +snprintf(codec_str, codec_str_size, "avc1.%02x%02x%02x",
> + vid_st->codecpar->profile & 0xFF,
> + ff_reverse[(vid_st->codecpar->profile >> 8) & 0xFF],
> + vid_st->codecpar->level);
> +} else {
> +goto fail;
> +}
> +video_str_len = strlen(codec_str);
> +}
> +
> +if (aud_st) {
> +char *audio_str = codec_str;
> +if (video_str_len) {
> +codec_str[video_str_len] = ',';
> +video_str_len += 1;
> +audio_str += video_str_len;
> +codec_str_size -= video_str_len;
> +}
> +if (aud_st->codecpar->codec_id == AV_CODEC_ID_MP2) {
> +snprintf(audio_str, codec_str_size, "mp4a.40.33");
> +} else if (aud_st->codecpar->codec_id == AV_CODEC_ID_MP3) {
> +snprintf(audio_str, codec_str_size, "mp4a.40.34");
> +} else if (aud_st->codecpar->codec_id == AV_CODEC_ID_AAC) {
> +/* TODO : For HE-AAC, HE-AACv2, the last digit needs to be set 
> to 5 and 29 respectively */
> +snprintf(audio_str, codec_str_size, "mp4a.40.2");
> +} else if (aud_st->codecpar->codec_id == AV_CODEC_ID_AC3) {
> +snprintf(audio_str, codec_str_size, "mp4a.A5");
> +} else if (aud_st->codecpar->codec_id == AV_CODEC_ID_EAC3) {
> +snprintf(audio_str, codec_str_size, "mp4a.A6");
> +} else {
> +goto fail;
> +}
> +}
> +
> +return codec_str;
> +
> +fail:
> +av_free(codec_str);
> +return NULL;
> +}
> +
>  static int create_master_playlist(AVFormatContext *s,
>VariantStream * const input_vs)
>  {
> @@ -1084,7 +1142,7 @@ static int create_master_playlist(AVFormatContext *s,
>  AVDictionary *options = NULL;
>  unsigned int i, j;
>  int m3u8_name_size, ret, bandwidth;
> -char *m3u8_rel_name;
> +char *m3u8_rel_name, *codec_str;
>
>  input_vs->m3u8_created = 1;
>  if (!hls->master_m3u8_created) {
> @@ -1198,9 +1256,12 @@ static 

Re: [FFmpeg-devel] [PATCH 2/4] lavfi/avfilter: simplify filter registration

2017-11-30 Thread Rostislav Pehlivanov
On 29 November 2017 at 16:40, Michael Niedermayer 
wrote:

> On Wed, Nov 29, 2017 at 03:51:34AM +, Rostislav Pehlivanov wrote:
> > On 28 November 2017 at 20:23, Michael Niedermayer  >
> > wrote:
> >
> > > On Mon, Nov 27, 2017 at 04:30:19AM +, Rostislav Pehlivanov wrote:
> > > > Atomics were entirely pointless and did nothing but slow and
> complicate
> > > > the process down. This could be improved further still but the main
> > > > objective of this commit is to simplify.
> > > >
> > > > Signed-off-by: Rostislav Pehlivanov 
> > > > ---
> > > >  libavfilter/avfilter.c | 8 +---
> > > >  1 file changed, 5 insertions(+), 3 deletions(-)
> > >
> > > *_register() can be called by the user app in a unsyncronized way
> > > for example from a module like vlc used AFAIK.
> > > or from libs loaded by an application which use libavfilter or other
> > > internally.
> > >
> > > These registration functions should stay thread safe
> > >
> > >
> > > [...]
> > >
> > > --
> > > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC7
> 87040B0FAB
> > >
> > > Those who would give up essential Liberty, to purchase a little
> > > temporary Safety, deserve neither Liberty nor Safety -- Benjamin
> Franklin
> > >
> > > ___
> > > ffmpeg-devel mailing list
> > > ffmpeg-devel@ffmpeg.org
> > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > >
> > >
> > What variable actually needs to be protected?
>
> The linked list of registered "entities"
> That is if the addition is not synchronized by some means, an atomic
> exchange a mutex or something then a race can generally occur
> and only one addition might succeed or something else might get
> entangled
>
> This is in practical terms a very unlikely event to occur of course
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> You can kill me, but you cannot change the truth.
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
Could you test the attached patch? Pretty much everything is synchronized.
From fb9789206c76c876d6a79e81df68c6b8041f03c3 Mon Sep 17 00:00:00 2001
From: Rostislav Pehlivanov 
Date: Mon, 27 Nov 2017 04:12:26 +
Subject: [PATCH v2 2/2] lavfi/avfilter: simplify filter registration

Atomics were entirely pointless and did nothing but slow and complicate
the process down. This could be improved further still but the main
objective of this commit is to simplify.

Signed-off-by: Rostislav Pehlivanov 
---
 libavfilter/avfilter.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index b98b32bacb..76c9f12be9 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -19,7 +19,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/atomic.h"
 #include "libavutil/avassert.h"
 #include "libavutil/avstring.h"
 #include "libavutil/buffer.h"
@@ -37,6 +36,7 @@
 #define FF_INTERNAL_FIELDS 1
 #include "framequeue.h"
 
+#include 
 #include "audio.h"
 #include "avfilter.h"
 #include "filters.h"
@@ -574,7 +574,7 @@ int avfilter_process_command(AVFilterContext *filter, const char *cmd, const cha
 }
 
 static AVFilter *first_filter;
-static AVFilter **last_filter = _filter;
+static _Atomic (AVFilter **) last_filter = ATOMIC_VAR_INIT(_filter);
 
 const AVFilter *avfilter_get_by_name(const char *name)
 {
@@ -592,16 +592,16 @@ const AVFilter *avfilter_get_by_name(const char *name)
 
 int avfilter_register(AVFilter *filter)
 {
-AVFilter **f = last_filter;
-
 /* the filter must select generic or internal exclusively */
 av_assert0((filter->flags & AVFILTER_FLAG_SUPPORT_TIMELINE) != AVFILTER_FLAG_SUPPORT_TIMELINE);
 
 filter->next = NULL;
 
-while(*f || avpriv_atomic_ptr_cas((void * volatile *)f, NULL, filter))
-f = &(*f)->next;
-last_filter = >next;
+/* Iterate through the list until the last entry has been reached */
+do {
+*atomic_load(_filter) = filter;
+atomic_store(_filter, >next);
+} while (*atomic_load(_filter));
 
 return 0;
 }
-- 
2.15.1.424.g9478a66081

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


[FFmpeg-devel] [PATCH v5 3/3] avformat/hlsenc:addition of CODECS attribute in the master playlist

2017-11-30 Thread vdixit
From: Vishwanath Dixit 

---
 libavformat/Makefile  |  2 +-
 libavformat/dashenc.c |  2 +-
 libavformat/hlsenc.c  | 65 +--
 libavformat/hlsplaylist.c |  5 +++-
 libavformat/hlsplaylist.h |  3 ++-
 libavformat/reverse.c |  1 +
 tests/ref/fate/source |  1 +
 7 files changed, 73 insertions(+), 6 deletions(-)
 create mode 100644 libavformat/reverse.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 4bffdf2..2bdb777 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -61,7 +61,7 @@ OBJS-$(CONFIG_RTPDEC)+= rdt.o 
  \
 rtpdec_vp9.o\
 rtpdec_xiph.o
 OBJS-$(CONFIG_RTPENC_CHAIN)  += rtpenc_chain.o rtp.o
-OBJS-$(CONFIG_SHARED)+= log2_tab.o golomb_tab.o
+OBJS-$(CONFIG_SHARED)+= log2_tab.o golomb_tab.o reverse.o
 OBJS-$(CONFIG_SRTP)  += srtp.o
 
 # muxers/demuxers
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 90cd2d0..e0b1679 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -754,7 +754,7 @@ static int write_manifest(AVFormatContext *s, int final)
 AVStream *st = s->streams[i];
 get_hls_playlist_name(playlist_file, sizeof(playlist_file), NULL, 
i);
 ff_hls_write_stream_info(st, out, st->codecpar->bit_rate,
-playlist_file, NULL);
+playlist_file, NULL, NULL);
 }
 avio_close(out);
 if (use_rename)
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 8d4b333..0702124 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -39,6 +39,7 @@
 #include "libavutil/avstring.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/random_seed.h"
+#include "libavutil/reverse.h"
 #include "libavutil/opt.h"
 #include "libavutil/log.h"
 #include "libavutil/time_internal.h"
@@ -1074,6 +1075,63 @@ static int get_relative_url(const char *master_url, 
const char *media_url,
 return 0;
 }
 
+static char *get_codec_str(AVStream *vid_st, AVStream *aud_st) {
+size_t codec_str_size = 64;
+char *codec_str = av_malloc(codec_str_size);
+int video_str_len = 0;
+
+if (!codec_str)
+return NULL;
+
+if (!vid_st && !aud_st) {
+goto fail;
+}
+
+if (vid_st) {
+if (vid_st->codecpar->profile != FF_PROFILE_UNKNOWN &&
+vid_st->codecpar->level != FF_LEVEL_UNKNOWN &&
+vid_st->codecpar->codec_id == AV_CODEC_ID_H264) {
+snprintf(codec_str, codec_str_size, "avc1.%02x%02x%02x",
+ vid_st->codecpar->profile & 0xFF,
+ ff_reverse[(vid_st->codecpar->profile >> 8) & 0xFF],
+ vid_st->codecpar->level);
+} else {
+goto fail;
+}
+video_str_len = strlen(codec_str);
+}
+
+if (aud_st) {
+char *audio_str = codec_str;
+if (video_str_len) {
+codec_str[video_str_len] = ',';
+video_str_len += 1;
+audio_str += video_str_len;
+codec_str_size -= video_str_len;
+}
+if (aud_st->codecpar->codec_id == AV_CODEC_ID_MP2) {
+snprintf(audio_str, codec_str_size, "mp4a.40.33");
+} else if (aud_st->codecpar->codec_id == AV_CODEC_ID_MP3) {
+snprintf(audio_str, codec_str_size, "mp4a.40.34");
+} else if (aud_st->codecpar->codec_id == AV_CODEC_ID_AAC) {
+/* TODO : For HE-AAC, HE-AACv2, the last digit needs to be set to 
5 and 29 respectively */
+snprintf(audio_str, codec_str_size, "mp4a.40.2");
+} else if (aud_st->codecpar->codec_id == AV_CODEC_ID_AC3) {
+snprintf(audio_str, codec_str_size, "mp4a.A5");
+} else if (aud_st->codecpar->codec_id == AV_CODEC_ID_EAC3) {
+snprintf(audio_str, codec_str_size, "mp4a.A6");
+} else {
+goto fail;
+}
+}
+
+return codec_str;
+
+fail:
+av_free(codec_str);
+return NULL;
+}
+
 static int create_master_playlist(AVFormatContext *s,
   VariantStream * const input_vs)
 {
@@ -1084,7 +1142,7 @@ static int create_master_playlist(AVFormatContext *s,
 AVDictionary *options = NULL;
 unsigned int i, j;
 int m3u8_name_size, ret, bandwidth;
-char *m3u8_rel_name;
+char *m3u8_rel_name, *codec_str;
 
 input_vs->m3u8_created = 1;
 if (!hls->master_m3u8_created) {
@@ -1198,9 +1256,12 @@ static int create_master_playlist(AVFormatContext *s,
 bandwidth += aud_st->codecpar->bit_rate;
 bandwidth += bandwidth / 10;
 
+codec_str = get_codec_str(vid_st, aud_st);
+
 ff_hls_write_stream_info(vid_st, master_pb, bandwidth, m3u8_rel_name,
-aud_st ? vs->agroup : NULL);
+codec_str, 

[FFmpeg-devel] [PATCH v5 2/3] avcodec/libx264:setting profile and level in avcodec context

2017-11-30 Thread vdixit
From: Vishwanath Dixit 

---
 libavcodec/libx264.c | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 9c67c91..545826c 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -19,11 +19,13 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/avassert.h"
 #include "libavutil/eval.h"
 #include "libavutil/internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/mem.h"
 #include "libavutil/pixdesc.h"
+#include "libavutil/reverse.h"
 #include "libavutil/stereo3d.h"
 #include "libavutil/intreadwrite.h"
 #include "avcodec.h"
@@ -454,6 +456,9 @@ static av_cold int X264_init(AVCodecContext *avctx)
 X264Context *x4 = avctx->priv_data;
 AVCPBProperties *cpb_props;
 int sw,sh;
+x264_nal_t *nal;
+uint8_t *p;
+int nnal, s, i;
 
 if (avctx->global_quality > 0)
 av_log(avctx, AV_LOG_WARNING, "-qscale is ignored, -crf is 
recommended.\n");
@@ -799,12 +804,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if (!x4->enc)
 return AVERROR_EXTERNAL;
 
-if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
-x264_nal_t *nal;
-uint8_t *p;
-int nnal, s, i;
+s = x264_encoder_headers(x4->enc, , );
+// Assert for NAL start code and SPS unit type
+av_assert0((nal->p_payload[0] | nal->p_payload[1] | nal->p_payload[2]) == 
0 && nal->p_payload[3] == 1);
+av_assert0((nal->p_payload[4] & 0x1F) == 7);
+// bits 0-7 LSB for profile. bits 8-11 for constrained set flags.
+avctx->profile = ((uint32_t)nal->p_payload[5]) | 
((uint32_t)ff_reverse[nal->p_payload[6]] << 8);
+avctx->level = nal->p_payload[7];
 
-s = x264_encoder_headers(x4->enc, , );
+if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
 avctx->extradata = p = av_mallocz(s + AV_INPUT_BUFFER_PADDING_SIZE);
 if (!p)
 return AVERROR(ENOMEM);
-- 
1.9.1

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


Re: [FFmpeg-devel] [PATCH] configure: Allow users to disable all hwaccel libraries

2017-11-30 Thread Gyan Doshi



On 11/30/2017 4:19 PM, Clément Bœsch wrote:


Is --disable-autodetect broken/not complete for you?


This disables more than just the hwaccel libs. I've tested my patch 
locally and configure lists no entries under External Libraries 
Providing Hardware Acceleration, unlike with --disable-hwaccels.


It builds without error (on Win7-64 / MinGW64).

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


Re: [FFmpeg-devel] [PATCH] configure: Allow users to disable all hwaccel libraries

2017-11-30 Thread Clément Bœsch
On Thu, Nov 30, 2017 at 03:58:21PM +0530, Gyan Doshi wrote:
> I added --disable-hwaccels during configure and noticed that all
> autodetected hwaccel libs were still being linked - 6 in my case, which
> makes for a more bloated binary than warranted.
> 
> Turns out the option only disables native components which make use of the
> hwaccel libs. The reporter of ticket #3906 had a similar concern.
> 
> Added option to disable all autodetected hwaccel libs.
> 

Is --disable-autodetect broken/not complete for you?

The autodetect handling in the configure is rather sensible as it needs to
work properly in combination with other options (see for instance around
lines 3720-3740), which makes me believe that the patch you're proposing
may not be enough.

Regards,

-- 
Clément B.


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


[FFmpeg-devel] [PATCH] configure: Allow users to disable all hwaccel libraries

2017-11-30 Thread Gyan Doshi
I added --disable-hwaccels during configure and noticed that all 
autodetected hwaccel libs were still being linked - 6 in my case, which 
makes for a more bloated binary than warranted.


Turns out the option only disables native components which make use of 
the hwaccel libs. The reporter of ticket #3906 had a similar concern.


Added option to disable all autodetected hwaccel libs.

Regards,
Gyan
From e89ed9ec2f476457552290315171bd2ef89490a5 Mon Sep 17 00:00:00 2001
From: Gyan Doshi 
Date: Thu, 30 Nov 2017 13:48:57 +0530
Subject: [PATCH] configure: Allow users to disable all autodetected libraries
 providing hardware acceleration.

---
 configure | 4 
 1 file changed, 4 insertions(+)

diff --git a/configure b/configure
index 1fa16e9dba..e5b390c955 100755
--- a/configure
+++ b/configure
@@ -304,6 +304,7 @@ External library support:
   --disable-zlib   disable zlib [autodetect]
 
   The following libraries provide various hardware acceleration features:
+  --disable-hwaccel-libs   disable all autodetected hwaccel libraries
   --disable-amfdisable AMF video encoding code [autodetect]
   --disable-audiotoolbox   disable Apple AudioToolbox code [autodetect]
   --disable-cuda   disable dynamically linked Nvidia CUDA code 
[autodetect]
@@ -3629,6 +3630,9 @@ for opt do
 --extra-libs=*)
 add_extralibs $optval
 ;;
+--disable-hwaccel-libs)
+disable $HWACCEL_AUTODETECT_LIBRARY_LIST
+;;
 --disable-devices)
 disable $INDEV_LIST $OUTDEV_LIST
 ;;
-- 
2.11.1.windows.1___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2 2/3] avformat/mxfenc: write reel_name if metadata key is present

2017-11-30 Thread Matthias Troffaes
Dear Mark,

On Thu, Nov 30, 2017 at 4:53 AM, Mark Reid  wrote:
> clang give me a warning telling to do this instead
> packages[3] = {{0}};
> I assume thats correct as I see thats used throughout the codebase.

Ah yes, that's perfect - good catch.

Kind regards,
Matthias
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] vaapi_h265: Add named options for setting profile and level

2017-11-30 Thread Hendrik Leppkes
On Thu, Nov 30, 2017 at 10:40 AM, Li, Zhong  wrote:
>> -Original Message-
>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
>> Of Mark Thompson
>> Sent: Thursday, November 30, 2017 7:30 AM
>> To: ffmpeg-devel@ffmpeg.org
>> Subject: [FFmpeg-devel] [PATCH 2/2] vaapi_h265: Add named options for
>> setting profile and level
>>
>> Also fixes the default, which previously contained a nonsense value.
>> ---
>> On 29/11/17 03:51, Li, Zhong wrote:
>> >> On 28/11/17 07:46, Ruiling Song wrote:
>> >>> Signed-off-by: Ruiling Song 
>> >>> ---
>> >>>  libavcodec/vaapi_encode_h265.c | 2 +-
>> >>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> >>>
>> >>> diff --git a/libavcodec/vaapi_encode_h265.c
>> >>> b/libavcodec/vaapi_encode_h265.c index 3ae92a7..32b8bc6 100644
>> >>> --- a/libavcodec/vaapi_encode_h265.c
>> >>> +++ b/libavcodec/vaapi_encode_h265.c
>> >>> @@ -219,7 +219,7 @@ static int
>> >> vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
>> >>>  .general_non_packed_constraint_flag = 1,
>> >>>  .general_frame_only_constraint_flag = 1,
>> >>>
>> >>> -.general_level_idc = avctx->level,
>> >>> +.general_level_idc = avctx->level * 3,
>> >>>  };
>> >>>
>> >>> vps->profile_tier_level.general_profile_compatibility_flag[avctx->pr
>> >>> vps->of
>> >>> ile & 31] = 1;
>> >>>
>> >>>
>> >> The documentation has always said "profile and level set the values
>> >> of general_profile_idc and general_level_idc respectively"
>> >> () - the code
>> >> disagreed for a while, but that was made consistent in
>> >> 00179664bccd1dd6fa0d1c40db453528757bf6f7.
>> >>
>> >> Why do you want to change it to be general_level_idc / 3 instead?
>> >
>> > As HEVC spec, "general_level_idc and sub_layer_level_idc[ i ] shall be
>> > set equal to a value of 30 times the level number specified in Table A.4."
>> > And use the tool "mediainfo" to check the encoded bitstream, it show the
>> level is 1.7 if set the option "-level" to be 51.
>> >
>> > Maybe the documentation
>> (()) also needs to
>> be changed?
>>
>> Hmm, right - the default is wrong, so you get a nonsense value there.
>>
>> How about we fix that and add named constants to make it clearer, like this?
>
> I think it is a good idea, except one situation:
> Suppose user set the level to be 41, they may want an encoded bitstream with 
> level 4.1, right?
> But actually the output level is 1.4 (using mediainfo to check this), 
> currently we are forcing them to set the option to be 4.1 or 123, right?
> Haven't verify your patch, just infer from the code.


But 41 is never 4.1 for HEVC, so using a scheme that was basically
"invented" doesn't seem right (probably as a carry-over from H264).
When decoding, avctx->level contains 123, not 41, for example, or for
a closer match, NVENC accepts -profile:v 123 or -profile:v 4.1, but
not 41.
I think its more important to stay consistent here (both to the HEVC
spec and other HEVC encoders), instead of catering to an imaginary
value that is never actually used in relation to HEVC.

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


Re: [FFmpeg-devel] [PATCH 2/2] vaapi_h265: Add named options for setting profile and level

2017-11-30 Thread Li, Zhong
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mark Thompson
> Sent: Thursday, November 30, 2017 7:30 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH 2/2] vaapi_h265: Add named options for
> setting profile and level
> 
> Also fixes the default, which previously contained a nonsense value.
> ---
> On 29/11/17 03:51, Li, Zhong wrote:
> >> On 28/11/17 07:46, Ruiling Song wrote:
> >>> Signed-off-by: Ruiling Song 
> >>> ---
> >>>  libavcodec/vaapi_encode_h265.c | 2 +-
> >>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>>
> >>> diff --git a/libavcodec/vaapi_encode_h265.c
> >>> b/libavcodec/vaapi_encode_h265.c index 3ae92a7..32b8bc6 100644
> >>> --- a/libavcodec/vaapi_encode_h265.c
> >>> +++ b/libavcodec/vaapi_encode_h265.c
> >>> @@ -219,7 +219,7 @@ static int
> >> vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
> >>>  .general_non_packed_constraint_flag = 1,
> >>>  .general_frame_only_constraint_flag = 1,
> >>>
> >>> -.general_level_idc = avctx->level,
> >>> +.general_level_idc = avctx->level * 3,
> >>>  };
> >>>
> >>> vps->profile_tier_level.general_profile_compatibility_flag[avctx->pr
> >>> vps->of
> >>> ile & 31] = 1;
> >>>
> >>>
> >> The documentation has always said "profile and level set the values
> >> of general_profile_idc and general_level_idc respectively"
> >> () - the code
> >> disagreed for a while, but that was made consistent in
> >> 00179664bccd1dd6fa0d1c40db453528757bf6f7.
> >>
> >> Why do you want to change it to be general_level_idc / 3 instead?
> >
> > As HEVC spec, "general_level_idc and sub_layer_level_idc[ i ] shall be
> > set equal to a value of 30 times the level number specified in Table A.4."
> > And use the tool "mediainfo" to check the encoded bitstream, it show the
> level is 1.7 if set the option "-level" to be 51.
> >
> > Maybe the documentation
> (()) also needs to
> be changed?
> 
> Hmm, right - the default is wrong, so you get a nonsense value there.
> 
> How about we fix that and add named constants to make it clearer, like this?

I think it is a good idea, except one situation:
Suppose user set the level to be 41, they may want an encoded bitstream with 
level 4.1, right? 
But actually the output level is 1.4 (using mediainfo to check this), currently 
we are forcing them to set the option to be 4.1 or 123, right? 
Haven't verify your patch, just infer from the code. 

> 
> Thanks,
> 
> - Mark
> 
> 
> 
>  libavcodec/vaapi_encode_h265.c | 44
> +++---
>  1 file changed, 41 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode_h265.c
> b/libavcodec/vaapi_encode_h265.c index 3ae92a7a09..8e98b0230d 100644
> --- a/libavcodec/vaapi_encode_h265.c
> +++ b/libavcodec/vaapi_encode_h265.c
> @@ -63,6 +63,8 @@ typedef struct VAAPIEncodeH265Context {  typedef
> struct VAAPIEncodeH265Options {
>  int qp;
>  int aud;
> +int profile;
> +int level;
>  } VAAPIEncodeH265Options;
> 
> 
> @@ -880,10 +882,17 @@ static const VAAPIEncodeType
> vaapi_encode_type_h265 = {
> 
>  static av_cold int vaapi_encode_h265_init(AVCodecContext *avctx)  {
> -VAAPIEncodeContext *ctx = avctx->priv_data;
> +VAAPIEncodeContext *ctx = avctx->priv_data;
> +VAAPIEncodeH265Options *opt =
> +(VAAPIEncodeH265Options*)ctx->codec_options_data;
> 
>  ctx->codec = _encode_type_h265;
> 
> +if (avctx->profile == FF_PROFILE_UNKNOWN)
> +avctx->profile = opt->profile;
> +if (avctx->level == FF_LEVEL_UNKNOWN)
> +avctx->level = opt->level;
> +
>  switch (avctx->profile) {
>  case FF_PROFILE_HEVC_MAIN:
>  case FF_PROFILE_UNKNOWN:
> @@ -946,12 +955,41 @@ static const AVOption
> vaapi_encode_h265_options[] = {
>  { "aud", "Include AUD",
>OFFSET(aud), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS },
> 
> +{ "profile", "Set profile (general_profile_idc)",
> +  OFFSET(profile), AV_OPT_TYPE_INT,
> +  { .i64 = FF_PROFILE_HEVC_MAIN }, 0x00, 0xff, FLAGS, "profile" },
> +
> +#define PROFILE(name, value)  name, NULL, 0, AV_OPT_TYPE_CONST, \
> +  { .i64 = value }, 0, 0, FLAGS, "profile"
> +{ PROFILE("main",   FF_PROFILE_HEVC_MAIN) },
> +{ PROFILE("main10", FF_PROFILE_HEVC_MAIN_10) },
> +#undef PROFILE
> +
> +{ "level", "Set level (general_level_idc)",
> +  OFFSET(level), AV_OPT_TYPE_INT,
> +  { .i64 = 153 }, 0x00, 0xff, FLAGS, "level" },
> +
> +#define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
> +  { .i64 = value }, 0, 0, FLAGS, "level"
> +{ LEVEL("1",30) },
> +{ LEVEL("2",60) },
> +{ LEVEL("2.1",  63) },
> +{ LEVEL("3",90) },
> +{ LEVEL("3.1",  93) },
> +{ LEVEL("4",   120) },
> +{ LEVEL("4.1", 123) },
> +{ LEVEL("5",   

Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-30 Thread Felix Matouschek
Sorry, my mail client swallowed the attachment, sent it again.



0001-avdevice-add-android_camera-indev.patch
Description: Binary data


> Am 30.11.2017 um 10:12 schrieb Felix Matouschek :
> 
> Am 29.11.2017 04:31, schrieb Michael Niedermayer:
> 
>> if the identifer and the string always match you could do this
>> with a macro avoiding the neede to duplcate each string
>> see AV_STRINGIFY
> 
> I changed it, is it ok like this?
> 
>> [...]
>>> +static int add_video_stream(AVFormatContext *avctx)
>>> +{
>>> +AndroidCameraCtx *ctx = avctx->priv_data;
>>> +AVStream *st;
>>> +AVCodecParameters *codecpar;
>>> +
>>> +st = avformat_new_stream(avctx, NULL);
>>> +if (!st) {
>>> +return AVERROR(ENOMEM);
>>> +}
>>> +
>>> +st->id = VIDEO_STREAM_INDEX;
>>> +st->avg_frame_rate = (AVRational) { ctx->framerate_range[1], 1 };
>>> +st->r_frame_rate = (AVRational) { ctx->framerate_range[1], 1 };
>> Are these values always correct ?
> 
> You mean avg_frame_rate and r_frame_rate?
> The framerate can vary between the values in framerate_range[0] (min) and 
> framerate_range[1] (max).
> Ideally both values are the same, sometimes min can be lower but for the 
> average the framerate should be what is in max.
> Should I set r_frame_rate to min?
> 
> I fixed all other parts you mentioned.
> 
> Felix
> ___
> 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] avfilter/vf_stereo3d: implement auto detection by using frame side data

2017-11-30 Thread Paul B Mahol
On 11/30/17, wm4  wrote:
> On Wed, 29 Nov 2017 23:15:44 +0100
> Paul B Mahol  wrote:
>
>> Signed-off-by: Paul B Mahol 
>> ---
>>  doc/filters.texi  |  4 
>>  libavfilter/vf_stereo3d.c | 35 ---
>>  2 files changed, 36 insertions(+), 3 deletions(-)
>>
>> diff --git a/doc/filters.texi b/doc/filters.texi
>> index 4a4efc70c8..e8da5e21a6 100644
>> --- a/doc/filters.texi
>> +++ b/doc/filters.texi
>> @@ -14057,6 +14057,10 @@ Set stereoscopic image format of input.
>>
>>  Available values for input image formats are:
>>  @table @samp
>> +@item auto
>> +set input format using frame side data
>> +If such data is not available filter will return unchanged input.
>> +
>>  @item sbsl
>>  side by side parallel (left eye left, right eye right)
>>
>> diff --git a/libavfilter/vf_stereo3d.c b/libavfilter/vf_stereo3d.c
>> index 8b22f880ca..a51fbeb75d 100644
>> --- a/libavfilter/vf_stereo3d.c
>> +++ b/libavfilter/vf_stereo3d.c
>> @@ -25,6 +25,7 @@
>>  #include "libavutil/opt.h"
>>  #include "libavutil/parseutils.h"
>>  #include "libavutil/pixdesc.h"
>> +#include "libavutil/stereo3d.h"
>>  #include "avfilter.h"
>>  #include "drawutils.h"
>>  #include "formats.h"
>> @@ -47,8 +48,8 @@ enum StereoCode {
>>  ANAGLYPH_YB_DUBOIS, // anaglyph yellow/blue dubois
>>  ANAGLYPH_RB_GRAY,   // anaglyph red/blue gray
>>  ANAGLYPH_RG_GRAY,   // anaglyph red/green gray
>> -MONO_L, // mono output for debugging (left eye only)
>> -MONO_R, // mono output for debugging (right eye only)
>> +MONO_L, // mono output (left eye only)
>> +MONO_R, // mono output (right eye only)
>>  INTERLEAVE_ROWS_LR, // row-interleave (left eye has top row)
>>  INTERLEAVE_ROWS_RL, // row-interleave (right eye has top row)
>>  SIDE_BY_SIDE_LR,// side by side parallel (left eye left, right
>> eye right)
>> @@ -66,7 +67,8 @@ enum StereoCode {
>>  INTERLEAVE_COLS_LR, // column-interleave (left eye first, right eye
>> second)
>>  INTERLEAVE_COLS_RL, // column-interleave (right eye first, left eye
>> second)
>>  HDMI,   // HDMI frame pack (left eye first, right eye
>> second)
>> -STEREO_CODE_COUNT   // TODO: needs autodetection
>> +AUTO,   // guess input format using frame's metadata.
>> +STEREO_CODE_COUNT
>>  };
>>
>>  typedef struct StereoComponent {
>> @@ -173,6 +175,7 @@ static const AVOption stereo3d_options[] = {
>>  { "irr",   "interleave rows right first", 0,
>> AV_OPT_TYPE_CONST, {.i64=INTERLEAVE_ROWS_RL}, 0, 0, FLAGS, "in" },
>>  { "icl",   "interleave columns left first",   0,
>> AV_OPT_TYPE_CONST, {.i64=INTERLEAVE_COLS_LR}, 0, 0, FLAGS, "in" },
>>  { "icr",   "interleave columns right first",  0,
>> AV_OPT_TYPE_CONST, {.i64=INTERLEAVE_COLS_RL}, 0, 0, FLAGS, "in" },
>> +{ "auto",  "guess using frame metadata",  0,
>> AV_OPT_TYPE_CONST, {.i64=AUTO},   0, 0, FLAGS, "in" },
>>  { "out",   "set output format", OFFSET(out.format),  AV_OPT_TYPE_INT,
>>   {.i64=ANAGLYPH_RC_DUBOIS}, 0, STEREO_CODE_COUNT-1, FLAGS, "out"},
>>  { "ab2l",  "above below half height left first",  0,
>> AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_2_LR},   0, 0, FLAGS, "out" },
>>  { "ab2r",  "above below half height right first", 0,
>> AV_OPT_TYPE_CONST, {.i64=ABOVE_BELOW_2_RL},   0, 0, FLAGS, "out" },
>> @@ -366,6 +369,9 @@ static int config_output(AVFilterLink *outlink)
>>  int ret;
>>  s->aspect = inlink->sample_aspect_ratio;
>>
>> +if (s->in.format == AUTO || (s->in.format == s->out.format))
>> +return 0;
>> +
>>  switch (s->in.format) {
>>  case INTERLEAVE_COLS_LR:
>>  case INTERLEAVE_COLS_RL:
>> @@ -670,6 +676,29 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
>> *inpicref)
>>  int out_off_left[4], out_off_right[4];
>>  int i, ret;
>>
>> +if (s->in.format == AUTO) {
>> +AVFrameSideData *sd = av_frame_get_side_data(inpicref,
>> AV_FRAME_DATA_STEREO3D);
>> +
>> +if (sd) {
>> +AVStereo3D *s3d = (AVStereo3D *)sd->data;
>> +
>> +switch (s3d->type) {
>> +case AV_STEREO3D_SIDEBYSIDE:  s->in.format =
>> SIDE_BY_SIDE_LR;break;
>> +case AV_STEREO3D_SIDEBYSIDE_QUINCUNX: s->in.format =
>> SIDE_BY_SIDE_LR;break;
>> +case AV_STEREO3D_TOPBOTTOM:   s->in.format =
>> ABOVE_BELOW_LR; break;
>> +case AV_STEREO3D_CHECKERBOARD:s->in.format =
>> CHECKERBOARD_LR;break;
>> +case AV_STEREO3D_FRAMESEQUENCE:   s->in.format =
>> ALTERNATING_LR; break;
>> +case AV_STEREO3D_LINES:   s->in.format =
>> INTERLEAVE_ROWS_LR; break;
>> +case AV_STEREO3D_COLUMNS: s->in.format =
>> INTERLEAVE_COLS_LR; break;
>> +default:  s->in.format =
>> 

Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2017-11-30 Thread Felix Matouschek

Am 29.11.2017 04:31, schrieb Michael Niedermayer:


if the identifer and the string always match you could do this
with a macro avoiding the neede to duplcate each string
see AV_STRINGIFY


I changed it, is it ok like this?


[...]

+static int add_video_stream(AVFormatContext *avctx)
+{
+AndroidCameraCtx *ctx = avctx->priv_data;
+AVStream *st;
+AVCodecParameters *codecpar;
+
+st = avformat_new_stream(avctx, NULL);
+if (!st) {
+return AVERROR(ENOMEM);
+}
+
+st->id = VIDEO_STREAM_INDEX;



+st->avg_frame_rate = (AVRational) { ctx->framerate_range[1], 1 };
+st->r_frame_rate = (AVRational) { ctx->framerate_range[1], 1 };


Are these values always correct ?


You mean avg_frame_rate and r_frame_rate?
The framerate can vary between the values in framerate_range[0] (min) 
and framerate_range[1] (max).
Ideally both values are the same, sometimes min can be lower but for the 
average the framerate should be what is in max.

Should I set r_frame_rate to min?

I fixed all other parts you mentioned.

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


[FFmpeg-devel] [PATCH 3/3] avformat/hlsenc: Extend persistent http connections to playlists

2017-11-30 Thread Karthick J
From: Karthick Jeyapal 

Before this patch persistent http connections would work only for media 
segments.
The playlists were still opening a new connection everytime.
This patch extends persistent http connections to playlists as well.
---
 libavformat/hlsenc.c | 46 ++
 1 file changed, 22 insertions(+), 24 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index ff982c5..350836d 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -201,6 +201,8 @@ typedef struct HLSContext {
 char *master_pl_name;
 unsigned int master_publish_rate;
 int http_persistent;
+AVIOContext *m3u8_out;
+AVIOContext *sub_m3u8_out;
 } HLSContext;
 
 static int mkdir_p(const char *path) {
@@ -1081,7 +1083,6 @@ static int create_master_playlist(AVFormatContext *s,
 HLSContext *hls = s->priv_data;
 VariantStream *vs;
 AVStream *vid_st, *aud_st;
-AVIOContext *master_pb = 0;
 AVDictionary *options = NULL;
 unsigned int i, j;
 int m3u8_name_size, ret, bandwidth;
@@ -1102,8 +1103,7 @@ static int create_master_playlist(AVFormatContext *s,
 
 set_http_options(s, , hls);
 
-ret = s->io_open(s, _pb, hls->master_m3u8_url, AVIO_FLAG_WRITE,\
- );
+ret = hlsenc_io_open(s, >m3u8_out, hls->master_m3u8_url, );
 av_dict_free();
 if (ret < 0) {
 av_log(NULL, AV_LOG_ERROR, "Failed to open master play list file 
'%s'\n",
@@ -,7 +,7 @@ static int create_master_playlist(AVFormatContext *s,
 goto fail;
 }
 
-ff_hls_write_playlist_version(master_pb, hls->version);
+ff_hls_write_playlist_version(hls->m3u8_out, hls->version);
 
 /* For variant streams with video add #EXT-X-STREAM-INF tag with 
attributes*/
 for (i = 0; i < hls->nb_varstreams; i++) {
@@ -1152,7 +1152,7 @@ static int create_master_playlist(AVFormatContext *s,
 bandwidth += aud_st->codecpar->bit_rate;
 bandwidth += bandwidth / 10;
 
-ff_hls_write_stream_info(vid_st, master_pb, bandwidth, m3u8_rel_name);
+ff_hls_write_stream_info(vid_st, hls->m3u8_out, bandwidth, 
m3u8_rel_name);
 
 av_freep(_rel_name);
 }
@@ -1160,7 +1160,7 @@ fail:
 if(ret >=0)
 hls->master_m3u8_created = 1;
 av_freep(_rel_name);
-ff_format_io_close(s, _pb);
+hlsenc_io_close(s, >m3u8_out, hls->master_m3u8_url);
 return ret;
 }
 
@@ -1170,8 +1170,6 @@ static int hls_window(AVFormatContext *s, int last, 
VariantStream *vs)
 HLSSegment *en;
 int target_duration = 0;
 int ret = 0;
-AVIOContext *out = NULL;
-AVIOContext *sub_out = NULL;
 char temp_filename[1024];
 int64_t sequence = FFMAX(hls->start_sequence, vs->sequence - 
vs->nb_entries);
 const char *proto = avio_find_protocol_name(s->filename);
@@ -1203,7 +1201,7 @@ static int hls_window(AVFormatContext *s, int last, 
VariantStream *vs)
 
 set_http_options(s, , hls);
 snprintf(temp_filename, sizeof(temp_filename), use_rename ? "%s.tmp" : 
"%s", vs->m3u8_name);
-if ((ret = s->io_open(s, , temp_filename, AVIO_FLAG_WRITE, )) 
< 0)
+if ((ret = hlsenc_io_open(s, >m3u8_out, temp_filename, )) < 0)
 goto fail;
 
 for (en = vs->segments; en; en = en->next) {
@@ -1212,33 +1210,33 @@ static int hls_window(AVFormatContext *s, int last, 
VariantStream *vs)
 }
 
 vs->discontinuity_set = 0;
-ff_hls_write_playlist_header(out, hls->version, hls->allowcache,
+ff_hls_write_playlist_header(hls->m3u8_out, hls->version, hls->allowcache,
  target_duration, sequence, hls->pl_type);
 
 if((hls->flags & HLS_DISCONT_START) && sequence==hls->start_sequence && 
vs->discontinuity_set==0 ){
-avio_printf(out, "#EXT-X-DISCONTINUITY\n");
+avio_printf(hls->m3u8_out, "#EXT-X-DISCONTINUITY\n");
 vs->discontinuity_set = 1;
 }
 if (vs->has_video && (hls->flags & HLS_INDEPENDENT_SEGMENTS)) {
-avio_printf(out, "#EXT-X-INDEPENDENT-SEGMENTS\n");
+avio_printf(hls->m3u8_out, "#EXT-X-INDEPENDENT-SEGMENTS\n");
 }
 for (en = vs->segments; en; en = en->next) {
 if ((hls->encrypt || hls->key_info_file) && (!key_uri || 
strcmp(en->key_uri, key_uri) ||
 av_strcasecmp(en->iv_string, iv_string))) {
-avio_printf(out, "#EXT-X-KEY:METHOD=AES-128,URI=\"%s\"", 
en->key_uri);
+avio_printf(hls->m3u8_out, "#EXT-X-KEY:METHOD=AES-128,URI=\"%s\"", 
en->key_uri);
 if (*en->iv_string)
-avio_printf(out, ",IV=0x%s", en->iv_string);
-avio_printf(out, "\n");
+avio_printf(hls->m3u8_out, ",IV=0x%s", en->iv_string);
+avio_printf(hls->m3u8_out, "\n");
 key_uri = en->key_uri;
 iv_string = en->iv_string;
 }
 
 if ((hls->segment_type == SEGMENT_TYPE_FMP4) && (en == vs->segments)) {
-

[FFmpeg-devel] [PATCH 1/3] avformat/hlsenc: Call avio_flush during persistent http connections

2017-11-30 Thread Karthick J
From: Karthick Jeyapal 

Since close is not called, during http persistent connection,
flush needs to be called so that output is written on time.
---
 libavformat/hlsenc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index cdfbf45..9048cb2 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -262,6 +262,8 @@ static void hlsenc_io_close(AVFormatContext *s, AVIOContext 
**pb, char *filename
 
 if (!http_base_proto || !hls->http_persistent || hls->key_info_file || 
hls->encrypt) {
 ff_format_io_close(s, pb);
+} else {
+avio_flush(*pb);
 }
 }
 
-- 
1.9.1

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


[FFmpeg-devel] [PATCH 2/3] avformat/hlsenc: Handle NULL input in IO open and close utility functions

2017-11-30 Thread Karthick J
From: Karthick Jeyapal 

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

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 9048cb2..ff982c5 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -244,7 +244,7 @@ static int is_http_proto(char *filename) {
 static int hlsenc_io_open(AVFormatContext *s, AVIOContext **pb, char *filename,
   AVDictionary **options) {
 HLSContext *hls = s->priv_data;
-int http_base_proto = is_http_proto(filename);
+int http_base_proto = filename ? is_http_proto(filename) : 0;
 int err;
 if (!*pb || !http_base_proto || !hls->http_persistent) {
 err = s->io_open(s, pb, filename, AVIO_FLAG_WRITE, options);
@@ -258,7 +258,7 @@ static int hlsenc_io_open(AVFormatContext *s, AVIOContext 
**pb, char *filename,
 
 static void hlsenc_io_close(AVFormatContext *s, AVIOContext **pb, char 
*filename) {
 HLSContext *hls = s->priv_data;
-int http_base_proto = is_http_proto(filename);
+int http_base_proto = filename ? is_http_proto(filename) : 0;
 
 if (!http_base_proto || !hls->http_persistent || hls->key_info_file || 
hls->encrypt) {
 ff_format_io_close(s, pb);
-- 
1.9.1

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


Re: [FFmpeg-devel] [PATCH 1/2] vaapi_h264: Add named options for setting profile and level

2017-11-30 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mark Thompson

> +#define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
> +  { .i64 = value }, 0, 0, FLAGS, "level"
> +{ LEVEL("1",   10) },
> +{ LEVEL("1.1", 11) },
> +{ LEVEL("1.2", 12) },
> +{ LEVEL("1.3", 13) },
> +{ LEVEL("2",   20) },
> +{ LEVEL("2.1", 21) },
> +{ LEVEL("2.2", 22) },
> +{ LEVEL("3",   30) },
> +{ LEVEL("3.1", 31) },
> +{ LEVEL("3.2", 32) },
> +{ LEVEL("4",   40) },
> +{ LEVEL("4.1", 41) },
> +{ LEVEL("4.2", 42) },
> +{ LEVEL("5",   50) },
> +{ LEVEL("5.1", 51) },
> +{ LEVEL("5.2", 52) },
> +{ LEVEL("6",   60) },
> +{ LEVEL("6.1", 61) },
> +{ LEVEL("6.2", 62) },

IIRC, level 5.2 is the maximum level of H264? 

> +#undef LEVEL
> +
>  { NULL },
>  };
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel