Re: [FFmpeg-devel] Refund request for FFmpeg at LinuxCon 2016

2016-11-02 Thread Michael Niedermayer
On Sun, Oct 16, 2016 at 12:16:25AM +0200, Thomas Volkert wrote:
> Hi,
> 
> I'd like to ask for refund of my expenses for LinuxCon (see thread
> "FFmpeg at LinuxCon 2016"):
> 
> - 191 € for 2 * 675km by car
> 
> I will contact Stefano if there are no objections.

LGTM

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

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch


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


Re: [FFmpeg-devel] [PATCH] pixblockdsp: disable altivec optimizations on ppc64be

2016-11-02 Thread Michael Niedermayer
On Wed, Nov 02, 2016 at 01:40:01AM +0100, Carl Eugen Hoyos wrote:
> 2016-11-01 0:27 GMT+01:00 Andreas Cadhalpun 
> :
> 
> > -#if HAVE_ALTIVEC
> > +#if HAVE_ALTIVEC && !(ARCH_PPC64 && HAVE_BIGENDIAN)
> >  if (!PPC_ALTIVEC(av_get_cpu_flags()))
> 
> Do the dnxhd tests work for you on 32bit BE powerpc?
> (It fails here afaict)

i find it strange to belive that the code never worked on either HW

if we assume it did once work for some case, what is differnt now ?
the testcase?
the compiler?
the code?
something else ?
or this really never worked and we didnt notice ?

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

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato


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


Re: [FFmpeg-devel] [PATCH] lavc: Add hevc main10 profile to ffmpeg cli

2016-11-02 Thread Michael Niedermayer
On Tue, Nov 01, 2016 at 07:17:37PM -0400, Vittorio Giovara wrote:
> ---
> Please CC.
> Vittorio
> 
>  libavcodec/options_table.h | 1 +
>  1 file changed, 1 insertion(+)

applied

thx

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

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin


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


Re: [FFmpeg-devel] [PATCH] avformat: close parser if codec changed

2016-11-02 Thread Michael Niedermayer
On Sat, Oct 22, 2016 at 01:16:00AM +0200, Andreas Cadhalpun wrote:
> On 22.10.2016 00:18, Michael Niedermayer wrote:
> > On Mon, Oct 17, 2016 at 08:49:23PM +0200, Andreas Cadhalpun wrote:
> >> The parser depends on the codec and thus must not be used with a different 
> >> one.
> >> If it is, the 'avctx->codec_id == s->parser->codec_ids[0] ...' assert in
> >> av_parser_parse2 gets triggered.
> >>
> >> Signed-off-by: Andreas Cadhalpun 
> >> ---
> >>  libavformat/utils.c | 12 
> >>  1 file changed, 12 insertions(+)
> > 
> > This changes the audio output from
> > http://samples.ffmpeg.org/MPEG2/vid_0x80.ts
> > 
> > is that intended ?
> 
> Nice catch: it shouldn't change, of course.
> 
> While processing that sample only the codec_tag gets changed, which is no 
> reason to
> close the parser. That is only necessary, when the codec_id changes.
> 
> Fixed patch is attached.
> 
> Best regards,
> Andreas
> 

>  utils.c |   12 
>  1 file changed, 12 insertions(+)
> ffefc22756b774cb7652587207ae66cfbf681be3  
> 0001-avformat-close-parser-if-codec-changed.patch
> From 9de87a4fb2c6c6311a11a2da5de8554a71adfa66 Mon Sep 17 00:00:00 2001
> From: Andreas Cadhalpun 
> Date: Mon, 17 Oct 2016 20:26:51 +0200
> Subject: [PATCH] avformat: close parser if codec changed
> 
> The parser depends on the codec and thus must not be used with a different 
> one.
> If it is, the 'avctx->codec_id == s->parser->codec_ids[0] ...' assert in
> av_parser_parse2 gets triggered.
> 
> Signed-off-by: Andreas Cadhalpun 
> ---
>  libavformat/utils.c | 12 
>  1 file changed, 12 insertions(+)
> 
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 70dbfa1..a8a78ed 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -480,6 +480,12 @@ static int update_stream_avctx(AVFormatContext *s)
>  if (!st->internal->need_context_update)
>  continue;
>  
> +/* close parser, because it depends on the codec */
> +if (st->parser && st->internal->avctx->codec_id != 
> st->codecpar->codec_id) {
> +av_parser_close(st->parser);
> +st->parser = NULL;
> +}
> +
>  /* update internal codec context, for the parser */
>  ret = avcodec_parameters_to_context(st->internal->avctx, 
> st->codecpar);
>  if (ret < 0)
> @@ -1515,6 +1521,12 @@ static int read_frame_internal(AVFormatContext *s, 
> AVPacket *pkt)
>  st->info->found_decoder = 0;
>  }
>  
> +/* close parser, because it depends on the codec */
> +if (st->parser && st->internal->avctx->codec_id != 
> st->codecpar->codec_id) {
> +av_parser_close(st->parser);
> +st->parser = NULL;
> +}
> +

what if the codec id differs but both are supported by the parser ?
AVCodecParser has a list of 5 codec ids ?

I didnt find a testcase where this makes a difference, just wondering

the patch seems fine otherwise

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu


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


Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: Add option to mark stream begin as discontinuous

2016-11-02 Thread Steven Liu
2016-11-02 7:51 GMT+08:00 Michael Niedermayer :

> This avoids continuity check failures in concatenated streams
>
> TODO: docs
>
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/mpegtsenc.c | 26 ++
>  1 file changed, 26 insertions(+)
>
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index 3ad3de7..71a6642 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> @@ -46,6 +46,7 @@
>  typedef struct MpegTSSection {
>  int pid;
>  int cc;
> +int discontinuity;
>  void (*write_packet)(struct MpegTSSection *s, const uint8_t *packet);
>  void *opaque;
>  } MpegTSSection;
> @@ -104,6 +105,7 @@ typedef struct MpegTSWrite {
>  #define MPEGTS_FLAG_AAC_LATM0x02
>  #define MPEGTS_FLAG_PAT_PMT_AT_FRAMES   0x04
>  #define MPEGTS_FLAG_SYSTEM_B0x08
> +#define MPEGTS_FLAG_DISCONT 0x10
>  int flags;
>  int copyts;
>  int tables_version;
> @@ -153,6 +155,12 @@ static void mpegts_write_section(MpegTSSection *s,
> uint8_t *buf, int len)
>  *q++  = s->pid;
>  s->cc = s->cc + 1 & 0xf;
>  *q++  = 0x10 | s->cc;
> +if (s->discontinuity) {
> +q[-1] |= 0x20;
> +*q++ = 1;
> +*q++ = 0x80;
> +s->discontinuity = 0;
> +}
>  if (first)
>  *q++ = 0; /* 0 offset */
>  len1 = TS_PACKET_SIZE - (q - packet);
> @@ -223,6 +231,7 @@ typedef struct MpegTSWriteStream {
>  struct MpegTSService *service;
>  int pid; /* stream associated pid */
>  int cc;
> +int discontinuity;
>  int payload_size;
>  int first_pts_check; ///< first pts check needed
>  int prev_payload_key;
> @@ -782,6 +791,7 @@ static int mpegts_init(AVFormatContext *s)
>  service->pmt.write_packet = section_write_packet;
>  service->pmt.opaque   = s;
>  service->pmt.cc   = 15;
> +service->pmt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
>  } else {
>  for (i = 0; i < s->nb_programs; i++) {
>  AVProgram *program = s->programs[i];
> @@ -800,6 +810,7 @@ static int mpegts_init(AVFormatContext *s)
>  service->pmt.write_packet = section_write_packet;
>  service->pmt.opaque   = s;
>  service->pmt.cc   = 15;
> +service->pmt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
>  service->program  = program;
>  }
>  }
> @@ -808,11 +819,13 @@ static int mpegts_init(AVFormatContext *s)
>  /* Initialize at 15 so that it wraps and is equal to 0 for the
>   * first packet we write. */
>  ts->pat.cc   = 15;
> +ts->pat.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
>  ts->pat.write_packet = section_write_packet;
>  ts->pat.opaque   = s;
>
>  ts->sdt.pid  = SDT_PID;
>  ts->sdt.cc   = 15;
> +ts->sdt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
>  ts->sdt.write_packet = section_write_packet;
>  ts->sdt.opaque   = s;
>
> @@ -883,6 +896,7 @@ static int mpegts_init(AVFormatContext *s)
>  ts_st->payload_dts = AV_NOPTS_VALUE;
>  ts_st->first_pts_check = 1;
>  ts_st->cc  = 15;
> +ts_st->discontinuity   = ts->flags & MPEGTS_FLAG_DISCONT;
>  /* update PCR pid by using the first video stream */
>  if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
>  service->pcr_pid == 0x1fff) {
> @@ -1078,6 +1092,10 @@ static void mpegts_insert_pcr_only(AVFormatContext
> *s, AVStream *st)
>  /* Continuity Count field does not increment (see 13818-1 section
> 2.4.3.3) */
>  *q++ = TS_PACKET_SIZE - 5; /* Adaptation Field Length */
>  *q++ = 0x10;   /* Adaptation flags: PCR present */
> +if (ts_st->discontinuity) {
> +q[-1] |= 0x80;
> +ts_st->discontinuity = 0;
> +}
>
>  /* PCR coded into 6 bytes */
>  q += write_pcr_bits(q, get_pcr(ts, s->pb));
> @@ -1195,6 +1213,11 @@ static void mpegts_write_pes(AVFormatContext *s,
> AVStream *st,
>  *q++  = ts_st->pid;
>  ts_st->cc = ts_st->cc + 1 & 0xf;
>  *q++  = 0x10 | ts_st->cc; // payload indicator + CC
> +if (ts_st->discontinuity) {
> +set_af_flag(buf, 0x80);
> +q = get_ts_payload_start(buf);
> +ts_st->discontinuity = 0;
> +}
>  if (key && is_start && pts != AV_NOPTS_VALUE) {
>  // set Random Access for key frames
>  if (ts_st->pid == ts_st->service->pcr_pid)
> @@ -1872,6 +1895,9 @@ static const AVOption options[] = {
>  { "system_b", "Conform to System B (DVB) instead of System A (ATSC)",
>0, AV_OPT_TYPE_CONST, { .i64 = MPEGTS_FLAG_SYSTEM_B }, 0, INT_MAX,
>AV_OPT_FLAG_ENCODING_PARAM, "mpegts_flags" },
> +{ "initial_discontinuity", "Mark initial packets as discontinuous",
> +  0, AV_OPT_TYPE_CONST, { .i64 = 

[FFmpeg-devel] [PATCH] libx265: Add option to force IDR frames

2016-11-02 Thread Derek Buitenhuis
This is in the same the same vein as c981b1145a857c8f962c93b8eecb1c613b20ffe9.

Signed-off-by: Derek Buitenhuis 
---
 libavcodec/libx265.c | 5 -
 libavcodec/version.h | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index d25be70..f9b287e 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -42,6 +42,7 @@ typedef struct libx265Context {
 const x265_api *api;
 
 float crf;
+int   forced_idr;
 char *preset;
 char *tune;
 char *x265_opts;
@@ -273,7 +274,8 @@ static int libx265_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 x265pic.pts  = pic->pts;
 x265pic.bitDepth = av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth;
 
-x265pic.sliceType = pic->pict_type == AV_PICTURE_TYPE_I ? X265_TYPE_I :
+x265pic.sliceType = pic->pict_type == AV_PICTURE_TYPE_I ?
+  (ctx->forced_idr ? X265_TYPE_IDR 
: X265_TYPE_I) :
 pic->pict_type == AV_PICTURE_TYPE_P ? X265_TYPE_P :
 pic->pict_type == AV_PICTURE_TYPE_B ? X265_TYPE_B :
 X265_TYPE_AUTO;
@@ -382,6 +384,7 @@ static av_cold void libx265_encode_init_csp(AVCodec *codec)
 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
 { "crf", "set the x265 crf",   
 OFFSET(crf),   AV_OPT_TYPE_FLOAT,  { .dbl = -1 }, -1, 
FLT_MAX, VE },
+{ "forced-idr",  "if forcing keyframes, force them as IDR frames", 
 OFFSET(forced_idr),AV_OPT_TYPE_BOOL,   { .i64 =  0 },  0,  
 1, VE },
 { "preset",  "set the x265 preset",
 OFFSET(preset),AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
 { "tune","set the x265 tune parameter",
 OFFSET(tune),  AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
 { "x265-params", "set the x265 configuration using a :-separated list of 
key=value parameters", OFFSET(x265_opts), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
diff --git a/libavcodec/version.h b/libavcodec/version.h
index f292d9d..31d5f19 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR  57
 #define LIBAVCODEC_VERSION_MINOR  65
-#define LIBAVCODEC_VERSION_MICRO 100
+#define LIBAVCODEC_VERSION_MICRO 101
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
-- 
1.8.3.1

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


Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: Add option to mark stream begin as discontinuous

2016-11-02 Thread Michael Niedermayer
On Wed, Nov 02, 2016 at 10:31:38PM +0800, Steven Liu wrote:
> 2016-11-02 7:51 GMT+08:00 Michael Niedermayer :
> 
> > This avoids continuity check failures in concatenated streams
> >
> > TODO: docs
> >
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavformat/mpegtsenc.c | 26 ++
> >  1 file changed, 26 insertions(+)
> >
> > diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> > index 3ad3de7..71a6642 100644
> > --- a/libavformat/mpegtsenc.c
> > +++ b/libavformat/mpegtsenc.c
> > @@ -46,6 +46,7 @@
> >  typedef struct MpegTSSection {
> >  int pid;
> >  int cc;
> > +int discontinuity;
> >  void (*write_packet)(struct MpegTSSection *s, const uint8_t *packet);
> >  void *opaque;
> >  } MpegTSSection;
> > @@ -104,6 +105,7 @@ typedef struct MpegTSWrite {
> >  #define MPEGTS_FLAG_AAC_LATM0x02
> >  #define MPEGTS_FLAG_PAT_PMT_AT_FRAMES   0x04
> >  #define MPEGTS_FLAG_SYSTEM_B0x08
> > +#define MPEGTS_FLAG_DISCONT 0x10
> >  int flags;
> >  int copyts;
> >  int tables_version;
> > @@ -153,6 +155,12 @@ static void mpegts_write_section(MpegTSSection *s,
> > uint8_t *buf, int len)
> >  *q++  = s->pid;
> >  s->cc = s->cc + 1 & 0xf;
> >  *q++  = 0x10 | s->cc;
> > +if (s->discontinuity) {
> > +q[-1] |= 0x20;
> > +*q++ = 1;
> > +*q++ = 0x80;
> > +s->discontinuity = 0;
> > +}
> >  if (first)
> >  *q++ = 0; /* 0 offset */
> >  len1 = TS_PACKET_SIZE - (q - packet);
> > @@ -223,6 +231,7 @@ typedef struct MpegTSWriteStream {
> >  struct MpegTSService *service;
> >  int pid; /* stream associated pid */
> >  int cc;
> > +int discontinuity;
> >  int payload_size;
> >  int first_pts_check; ///< first pts check needed
> >  int prev_payload_key;
> > @@ -782,6 +791,7 @@ static int mpegts_init(AVFormatContext *s)
> >  service->pmt.write_packet = section_write_packet;
> >  service->pmt.opaque   = s;
> >  service->pmt.cc   = 15;
> > +service->pmt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
> >  } else {
> >  for (i = 0; i < s->nb_programs; i++) {
> >  AVProgram *program = s->programs[i];
> > @@ -800,6 +810,7 @@ static int mpegts_init(AVFormatContext *s)
> >  service->pmt.write_packet = section_write_packet;
> >  service->pmt.opaque   = s;
> >  service->pmt.cc   = 15;
> > +service->pmt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
> >  service->program  = program;
> >  }
> >  }
> > @@ -808,11 +819,13 @@ static int mpegts_init(AVFormatContext *s)
> >  /* Initialize at 15 so that it wraps and is equal to 0 for the
> >   * first packet we write. */
> >  ts->pat.cc   = 15;
> > +ts->pat.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
> >  ts->pat.write_packet = section_write_packet;
> >  ts->pat.opaque   = s;
> >
> >  ts->sdt.pid  = SDT_PID;
> >  ts->sdt.cc   = 15;
> > +ts->sdt.discontinuity= ts->flags & MPEGTS_FLAG_DISCONT;
> >  ts->sdt.write_packet = section_write_packet;
> >  ts->sdt.opaque   = s;
> >
> > @@ -883,6 +896,7 @@ static int mpegts_init(AVFormatContext *s)
> >  ts_st->payload_dts = AV_NOPTS_VALUE;
> >  ts_st->first_pts_check = 1;
> >  ts_st->cc  = 15;
> > +ts_st->discontinuity   = ts->flags & MPEGTS_FLAG_DISCONT;
> >  /* update PCR pid by using the first video stream */
> >  if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
> >  service->pcr_pid == 0x1fff) {
> > @@ -1078,6 +1092,10 @@ static void mpegts_insert_pcr_only(AVFormatContext
> > *s, AVStream *st)
> >  /* Continuity Count field does not increment (see 13818-1 section
> > 2.4.3.3) */
> >  *q++ = TS_PACKET_SIZE - 5; /* Adaptation Field Length */
> >  *q++ = 0x10;   /* Adaptation flags: PCR present */
> > +if (ts_st->discontinuity) {
> > +q[-1] |= 0x80;
> > +ts_st->discontinuity = 0;
> > +}
> >
> >  /* PCR coded into 6 bytes */
> >  q += write_pcr_bits(q, get_pcr(ts, s->pb));
> > @@ -1195,6 +1213,11 @@ static void mpegts_write_pes(AVFormatContext *s,
> > AVStream *st,
> >  *q++  = ts_st->pid;
> >  ts_st->cc = ts_st->cc + 1 & 0xf;
> >  *q++  = 0x10 | ts_st->cc; // payload indicator + CC
> > +if (ts_st->discontinuity) {
> > +set_af_flag(buf, 0x80);
> > +q = get_ts_payload_start(buf);
> > +ts_st->discontinuity = 0;
> > +}
> >  if (key && is_start && pts != AV_NOPTS_VALUE) {
> >  // set Random Access for key frames
> >  if (ts_st->pid == ts_st->service->pcr_pid)
> > @@ -1872,6 +1895,9 @@ static const AVOption options[] = {
> >  { "system_b", "Con

Re: [FFmpeg-devel] [PATCH 1/2] img2: added support for %t output pattern

2016-11-02 Thread Roger Pack
On 11/1/16, James Almer  wrote:
> On 10/25/2016 9:38 PM, Roger Pack wrote:
>> From e8cac5c7de18766ce0f8f286f7dc140b82129df2 Mon Sep 17 00:00:00 2001
>> From: rogerdpack 
>> Date: Tue, 25 Oct 2016 18:33:12 -0600
>> Subject: [PATCH 1/2] img2 encoder: allow %t in filename, based on patch
>> from
>>  Yuval Adam
>>
>> Signed-off-by: rogerdpack 
>> ---
>>  doc/muxers.texi| 13 +
>>  libavformat/avformat.h |  3 ++-
>>  libavformat/hlsenc.c   |  6 +++---
>>  libavformat/img2enc.c  |  6 --
>>  libavformat/utils.c| 42 ++
>>  5 files changed, 60 insertions(+), 10 deletions(-)
>>
>> diff --git a/doc/muxers.texi b/doc/muxers.texi
>> index 0d856db..0c3a198 100644
>> --- a/doc/muxers.texi
>> +++ b/doc/muxers.texi
>> @@ -619,6 +619,12 @@ If the pattern contains "%d" or "%0@var{N}d", the
>> first filename of
>>  the file list specified will contain the number 1, all the following
>>  numbers will be sequential.
>>
>> +If the pattern contains "%t", the frame's timestamps will be inserted
>> +in the filename like "00.00.00.000" for hours, minutes, seconds,
>> +and milliseconds.
>> +
>> +The "%t" and "%d" patterns may be used simultaneously.
>> +
>>  The pattern may contain a suffix which is used to automatically
>>  determine the format of the image files to write.
>>
>> @@ -664,6 +670,13 @@ can be used:
>>  ffmpeg -f v4l2 -r 1 -i /dev/video0 -f image2 -strftime 1
>> "%Y-%m-%d_%H-%M-%S.jpg"
>>  @end example
>>
>> +The following example uses the timestamp parameter to generate one
>> +image file per video frame from the input, and name it including its
>> original
>> +timestamp.
>> +@example
>> +ffmpeg -i in.avi -vsync vfr -copyts img-%t.jpg
>> +@end example
>> +
>>  @subsection Options
>>
>>  @table @option
>> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
>> index f9f4d72..7f39698 100644
>> --- a/libavformat/avformat.h
>> +++ b/libavformat/avformat.h
>> @@ -2780,10 +2780,11 @@ void av_dump_format(AVFormatContext *ic,
>>   * @param path numbered sequence string
>>   * @param number frame number
>>   * @param flags AV_FRAME_FILENAME_FLAGS_*
>> + * @param ts frame timestamp in AV_TIME_BASE fractional seconds.
>>   * @return 0 if OK, -1 on format error
>>   */
>>  int av_get_frame_filename2(char *buf, int buf_size,
>> -  const char *path, int number, int flags);
>> +  const char *path, int number, int flags,
>> int64_t ts);
>
> Uhh, what? did you just break API modifying a public function?

Yes, it was a recently added method so I hoped to get it "included"
before a version was released (but it took so long it maybe missed a
deadline...?)
Cheers!
-roger-
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] hevc: Move hevc_decode_extradata before frame decoding

2016-11-02 Thread Vittorio Giovara
Avoids a forward-declaration in the following commit.

Signed-off-by: Vittorio Giovara 
---
Please CC.
Vittorio

libavcodec/hevc.c | 148 +++---
 1 file changed, 74 insertions(+), 74 deletions(-)

diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index 764e093..29e0d49 100644
--- a/libavcodec/hevc.c
+++ b/libavcodec/hevc.c
@@ -2973,6 +2973,80 @@ static int verify_md5(HEVCContext *s, AVFrame *frame)
 return 0;
 }
 
+static int hevc_decode_extradata(HEVCContext *s)
+{
+AVCodecContext *avctx = s->avctx;
+GetByteContext gb;
+int ret, i;
+
+bytestream2_init(&gb, avctx->extradata, avctx->extradata_size);
+
+if (avctx->extradata_size > 3 &&
+(avctx->extradata[0] || avctx->extradata[1] ||
+ avctx->extradata[2] > 1)) {
+/* It seems the extradata is encoded as hvcC format.
+ * Temporarily, we support configurationVersion==0 until 14496-15 3rd
+ * is finalized. When finalized, configurationVersion will be 1 and we
+ * can recognize hvcC by checking if avctx->extradata[0]==1 or not. */
+int i, j, num_arrays, nal_len_size;
+
+s->is_nalff = 1;
+
+bytestream2_skip(&gb, 21);
+nal_len_size = (bytestream2_get_byte(&gb) & 3) + 1;
+num_arrays   = bytestream2_get_byte(&gb);
+
+/* nal units in the hvcC always have length coded with 2 bytes,
+ * so put a fake nal_length_size = 2 while parsing them */
+s->nal_length_size = 2;
+
+/* Decode nal units from hvcC. */
+for (i = 0; i < num_arrays; i++) {
+int type = bytestream2_get_byte(&gb) & 0x3f;
+int cnt  = bytestream2_get_be16(&gb);
+
+for (j = 0; j < cnt; j++) {
+// +2 for the nal size field
+int nalsize = bytestream2_peek_be16(&gb) + 2;
+if (bytestream2_get_bytes_left(&gb) < nalsize) {
+av_log(s->avctx, AV_LOG_ERROR,
+   "Invalid NAL unit size in extradata.\n");
+return AVERROR_INVALIDDATA;
+}
+
+ret = decode_nal_units(s, gb.buffer, nalsize);
+if (ret < 0) {
+av_log(avctx, AV_LOG_ERROR,
+   "Decoding nal unit %d %d from hvcC failed\n",
+   type, i);
+return ret;
+}
+bytestream2_skip(&gb, nalsize);
+}
+}
+
+/* Now store right nal length size, that will be used to parse
+ * all other nals */
+s->nal_length_size = nal_len_size;
+} else {
+s->is_nalff = 0;
+ret = decode_nal_units(s, avctx->extradata, avctx->extradata_size);
+if (ret < 0)
+return ret;
+}
+
+/* export stream parameters from the first SPS */
+for (i = 0; i < FF_ARRAY_ELEMS(s->ps.sps_list); i++) {
+if (s->ps.sps_list[i]) {
+const HEVCSPS *sps = (const HEVCSPS*)s->ps.sps_list[i]->data;
+export_stream_params(s->avctx, &s->ps, sps);
+break;
+}
+}
+
+return 0;
+}
+
 static int hevc_decode_frame(AVCodecContext *avctx, void *data, int 
*got_output,
  AVPacket *avpkt)
 {
@@ -3243,80 +3317,6 @@ static int hevc_update_thread_context(AVCodecContext 
*dst,
 return 0;
 }
 
-static int hevc_decode_extradata(HEVCContext *s)
-{
-AVCodecContext *avctx = s->avctx;
-GetByteContext gb;
-int ret, i;
-
-bytestream2_init(&gb, avctx->extradata, avctx->extradata_size);
-
-if (avctx->extradata_size > 3 &&
-(avctx->extradata[0] || avctx->extradata[1] ||
- avctx->extradata[2] > 1)) {
-/* It seems the extradata is encoded as hvcC format.
- * Temporarily, we support configurationVersion==0 until 14496-15 3rd
- * is finalized. When finalized, configurationVersion will be 1 and we
- * can recognize hvcC by checking if avctx->extradata[0]==1 or not. */
-int i, j, num_arrays, nal_len_size;
-
-s->is_nalff = 1;
-
-bytestream2_skip(&gb, 21);
-nal_len_size = (bytestream2_get_byte(&gb) & 3) + 1;
-num_arrays   = bytestream2_get_byte(&gb);
-
-/* nal units in the hvcC always have length coded with 2 bytes,
- * so put a fake nal_length_size = 2 while parsing them */
-s->nal_length_size = 2;
-
-/* Decode nal units from hvcC. */
-for (i = 0; i < num_arrays; i++) {
-int type = bytestream2_get_byte(&gb) & 0x3f;
-int cnt  = bytestream2_get_be16(&gb);
-
-for (j = 0; j < cnt; j++) {
-// +2 for the nal size field
-int nalsize = bytestream2_peek_be16(&gb) + 2;
-if (bytestream2_get_bytes_left(&gb) < nalsize) {
-av_log(s->avctx, AV_LOG_ERROR,
-   "Invalid NAL unit size in extradata.\n");
-ret

[FFmpeg-devel] [PATCH 2/2] hevc: Support extradata changes

2016-11-02 Thread Vittorio Giovara
Signed-off-by: Vittorio Giovara 
---
Please CC.
Vittorio

 libavcodec/hevc.c | 18 ++
 libavformat/mov.c |  4 
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index 29e0d49..b50120e 100644
--- a/libavcodec/hevc.c
+++ b/libavcodec/hevc.c
@@ -3051,6 +3051,8 @@ static int hevc_decode_frame(AVCodecContext *avctx, void 
*data, int *got_output,
  AVPacket *avpkt)
 {
 int ret;
+int new_extradata_size;
+uint8_t *new_extradata;
 HEVCContext *s = avctx->priv_data;
 
 if (!avpkt->size) {
@@ -3062,6 +3064,22 @@ static int hevc_decode_frame(AVCodecContext *avctx, void 
*data, int *got_output,
 return 0;
 }
 
+new_extradata_size = 0;
+new_extradata = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA,
+&new_extradata_size);
+if (new_extradata_size > 0 && new_extradata) {
+if (new_extradata_size > avctx->extradata_size) {
+avctx->extradata = av_realloc(avctx->extradata, 
new_extradata_size);
+if (!avctx->extradata)
+return AVERROR(ENOMEM);
+}
+avctx->extradata_size = new_extradata_size;
+memcpy(avctx->extradata, new_extradata, new_extradata_size);
+ret = hevc_decode_extradata(s);
+if (ret < 0)
+return ret;
+}
+
 s->ref = NULL;
 ret= decode_nal_units(s, avpkt->data, avpkt->size);
 if (ret < 0)
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 4222088..24c75ab 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2212,10 +2212,6 @@ static int mov_skip_multiple_stsd(MOVContext *c, 
AVIOContext *pb,
 avio_skip(pb, size);
 return 1;
 }
-if ( codec_tag == AV_RL32("hvc1") ||
- codec_tag == AV_RL32("hev1")
-)
-av_log(c->fc, AV_LOG_WARNING, "Concatenated H.264 or H.265 might not 
play correctly.\n");
 
 return 0;
 }
-- 
2.10.0

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


Re: [FFmpeg-devel] [PATCH] avformat/apngenc: use the stream parameters extradata if no updated one is made available

2016-11-02 Thread James Almer
On 11/1/2016 7:10 PM, Hendrik Leppkes wrote:
> Am 01.11.2016 17:17 schrieb "Andreas Cadhalpun" <
> andreas.cadhal...@googlemail.com>:
>>
>> On 01.11.2016 17:06, James Almer wrote:
>>> On 11/1/2016 12:54 PM, Andreas Cadhalpun wrote:
 What I like about the approach of using the private extra_data context
> buffer is
 that is is quite obvious where it is set. On the other hand the
> codecpar
 extradata can be set anywhere, which makes it difficult to
> understand/debug.
 The very bug this patch would fix is an excellent example of that.

 So I'd rather convert the apngdec demuxer to pass the extradata as
> side data.
 I'll send a patch doing that.
>>>
>>> Is it worth doing that? This patch is pretty simple and solves the
> issue for
>>> both encoder and demuxer.
>>> With it the muxer will use either the original extradata or any new one
> sent
>>> within a packet. In both cases, the muxer uses its own buffer to keep
> it.
>>>
>>> I don't think changing the demuxer to append the same extradata it
> already
>>> sent during init() again with a packet makes sense. It's extra
> complexity
>>> for no gain.
>>
>> Not again, but instead, as the extradata is then only transferred as side
> data.
>> That way it is again consistent between demuxer/decoder and encoder/muxer.
>>
> 
> I don't think thats a good idea. Demuxers should fill the extradata field
> if any is present and required for decoding - some other decoder might want
> extradata for init or something, and that way you can accommodate it
> without having to wait for the first packet.
> 
> That's basically how all demuxers work, will extradata and if it can and
> does change just send an update notice.

Agree, that's how it's done for flac for example.

Should i revert this and apply my patch instead? Or something else?

> 
> - 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] avformat/apngenc: use the stream parameters extradata if no updated one is made available

2016-11-02 Thread Andreas Cadhalpun
On 01.11.2016 23:10, Hendrik Leppkes wrote:
> Am 01.11.2016 17:17 schrieb "Andreas Cadhalpun" <
> andreas.cadhal...@googlemail.com>:
>> Not again, but instead, as the extradata is then only transferred as side 
>> data.
>> That way it is again consistent between demuxer/decoder and encoder/muxer.
>>
> 
> I don't think thats a good idea. Demuxers should fill the extradata field
> if any is present and required for decoding - some other decoder might want
> extradata for init or something, and that way you can accommodate it
> without having to wait for the first packet.

Is this documented somewhere?

> That's basically how all demuxers work, will extradata and if it can and
> does change just send an update notice.

Requiring to use codecpar->extradata for passing this from demuxer to decoder,
while at the same time requiring to use AV_PKT_DATA_NEW_EXTRADATA side data
to pass this from muxer to encoder seems quite strange to me.

Best regards,
Andreas

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


Re: [FFmpeg-devel] [OPW] OPW Project Proposal

2016-11-02 Thread Pallavi Kumari
Necessary changes has been done. PFA.

Usage:

./ffmpeg -i kpg.mp3 -filter_complex peakpoints=wsize=16 -f null -

On Wed, Nov 2, 2016 at 6:14 AM, Michael Niedermayer 
wrote:

> On Wed, Nov 02, 2016 at 05:00:09AM +0530, Pallavi Kumari wrote:
> > Hi Michael,
> >
> > I have attached a working patch with the mail. PFA.
> >
> > Usage:
> >
>
> > ./ffmpeg -i kpg.mp3 -filter_complex peakpoints=input=kpg.mp3:wsize=16
>
> I realize now, theres a mistake in this, you must provide a output
> as in
> ./ffmpeg -i kpg.mp3 -af peakpoints -f null -
>
> without some output like  "-f null -" it wont read the file fully and
> wont pass it through filter_frame()
>
> you could see this failure as in:
> ./ffmpeg -i ~/videos/matrixbench_mpeg2.mpg -af volumedetect  -f null -
> vs.
> ./ffmpeg -i ~/videos/matrixbench_mpeg2.mpg -af volumedetect
>
> you get the histogram from the volume detect filter in the first case
> but not the 2nd.
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Many things microsoft did are stupid, but not doing something just because
> microsoft did it is even more stupid. If everything ms did were stupid they
> would be bankrupt already.
>
From e10f73d363d0313774bcb132b3b1f2417fcfba11 Mon Sep 17 00:00:00 2001
From: Atana 
Date: Thu, 3 Nov 2016 01:05:51 +0530
Subject: [PATCH] avfilter: added peakpoints filter

---
 libavfilter/af_peakpoints.c | 226 
 1 file changed, 226 insertions(+)
 create mode 100644 libavfilter/af_peakpoints.c

diff --git a/libavfilter/af_peakpoints.c b/libavfilter/af_peakpoints.c
new file mode 100644
index 000..9265c47
--- /dev/null
+++ b/libavfilter/af_peakpoints.c
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 2016 Atana
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/avcodec.h"
+#include "libavcodec/avfft.h"
+#include "libavformat/avformat.h"
+#include "libswscale/swscale.h"
+#include "avfilter.h"
+#include "audio.h"
+#include "libavutil/opt.h"
+
+
+/* Structure to contain peak points context */
+typedef struct {
+const AVClass *class;
+double *data;
+int nsamples;
+int index;
+double *peaks;
+int size; // number of peaks
+int windowSize;
+//char *inputFile;
+} PeakPointsContext;
+
+/* returns maximum value from an array conditioned on start and end index */
+static double getMax(double *res_arr, int startIndex, int endIndex) {
+int i;
+double max = res_arr[startIndex];
+for (i = startIndex; i <= endIndex; i++) {
+	if (res_arr[i] > max) {
+	max = res_arr[i];
+	}
+}
+return max;
+}
+
+/* Stores peak frequency for each window(of chunkSize) in peaks array */
+static void getPeakPointInChunk(int chunkSize, double *res_arr, int size, double *peaks) {
+int i = 0, peakIndex = 0;
+int startIndex = 0;
+double max;
+// get a chunk and find max value in it
+while (i < size) {
+	if (i % chunkSize-1 == 0) {
+max = getMax(res_arr, startIndex, i);
+	peaks[peakIndex++] = max;
+	startIndex = startIndex + chunkSize;
+	}
+i += 1;
+}
+}
+
+/* Get peaks points from windowed frequency domain data*/
+static int getPeakPoints(PeakPointsContext *ppc) {
+int i, m, k, size, chunkSize, pSize, chunkSampleSize, resSize;
+double *fft_res;
+void *avc;
+RDFTContext *rdftC;
+FFTSample *data;
+
+size = ppc->index;
+m = log2(ppc->windowSize);
+chunkSize = ppc->windowSize;
+chunkSampleSize = size/chunkSize;
+resSize = chunkSize * chunkSampleSize;
+
+fft_res = av_malloc(sizeof(double) * resSize);
+
+if (!fft_res) {
+av_log(avc, AV_LOG_ERROR, "Cann't allocate memmory for storing fft data\n");
+return 0;
+}
+
+
+rdftC = av_rdft_init(m, DFT_R2C);
+data = av_malloc(sizeof(FFTSample)*chunkSize);
+
+if (!data) {
+av_log(avc, AV_LOG_ERROR, "Cann't allocate memmory for chunk fft data\n");
+return 0;
+}
+// FFT transform for windowed time domain data
+// window is of size chunkSize
+k = 0;
+while (k < resSize) {
+//copy data
+for (i = 0; i < chunkSize; i++) {
+data[i] = ppc->data[i+k];
+}
+//calculate FFT
+av

[FFmpeg-devel] [PATCH 1/2] avformat/matroskaenc: postpone writing the Tracks master

2016-11-02 Thread James Almer
This will allow us to write updated stream information not available
during write_header().

Signed-off-by: James Almer 
---
 libavformat/matroskaenc.c | 20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 78540fb..f41aabe 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -121,6 +121,8 @@ typedef struct MatroskaMuxContext {
 ebml_master tags;
 AVIOContext *info_bc;
 ebml_master info;
+AVIOContext *tracks_bc;
+ebml_master tracks_master;
 ebml_master segment;
 int64_t segment_offset;
 ebml_master cluster;
@@ -1264,15 +1266,14 @@ static int mkv_write_track(AVFormatContext *s, 
MatroskaMuxContext *mkv,
 static int mkv_write_tracks(AVFormatContext *s)
 {
 MatroskaMuxContext *mkv = s->priv_data;
-AVIOContext *dyn_cp, *pb = s->pb;
-ebml_master tracks;
+AVIOContext *pb = s->pb;
 int i, ret, default_stream_exists = 0;
 
 ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_TRACKS, 
avio_tell(pb));
 if (ret < 0)
 return ret;
 
-ret = start_ebml_master_crc32(pb, &dyn_cp, mkv, &tracks, 
MATROSKA_ID_TRACKS, 0);
+ret = start_ebml_master_crc32(pb, &mkv->tracks_bc, mkv, 
&mkv->tracks_master, MATROSKA_ID_TRACKS, 0);
 if (ret < 0)
 return ret;
 
@@ -1281,11 +1282,16 @@ static int mkv_write_tracks(AVFormatContext *s)
 default_stream_exists |= st->disposition & AV_DISPOSITION_DEFAULT;
 }
 for (i = 0; i < s->nb_streams; i++) {
-ret = mkv_write_track(s, mkv, i, dyn_cp, default_stream_exists);
+ret = mkv_write_track(s, mkv, i, mkv->tracks_bc, 
default_stream_exists);
 if (ret < 0)
 return ret;
 }
-end_ebml_master_crc32(pb, &dyn_cp, mkv, tracks);
+
+if (pb->seekable && !mkv->is_live)
+put_ebml_void(pb, avio_tell(mkv->tracks_bc));
+else
+end_ebml_master_crc32(pb, &mkv->tracks_bc, mkv, mkv->tracks_master);
+
 return 0;
 }
 
@@ -2317,6 +2323,10 @@ static int mkv_write_trailer(AVFormatContext *s)
 avio_seek(pb, mkv->info.pos, SEEK_SET);
 end_ebml_master_crc32(pb, &mkv->info_bc, mkv, mkv->info);
 
+// dump tracks master
+avio_seek(pb, mkv->tracks_master.pos, SEEK_SET);
+end_ebml_master_crc32(pb, &mkv->tracks_bc, mkv, mkv->tracks_master);
+
 // update stream durations
 if (!mkv->is_live && mkv->stream_durations) {
 int i;
-- 
2.10.1

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


Re: [FFmpeg-devel] [PATCH] avformat/apngenc: use the stream parameters extradata if no updated one is made available

2016-11-02 Thread Hendrik Leppkes
On Wed, Nov 2, 2016 at 8:13 PM, Andreas Cadhalpun
 wrote:
> On 01.11.2016 23:10, Hendrik Leppkes wrote:
>> Am 01.11.2016 17:17 schrieb "Andreas Cadhalpun" <
>> andreas.cadhal...@googlemail.com>:
>>> Not again, but instead, as the extradata is then only transferred as side 
>>> data.
>>> That way it is again consistent between demuxer/decoder and encoder/muxer.
>>>
>>
>> I don't think thats a good idea. Demuxers should fill the extradata field
>> if any is present and required for decoding - some other decoder might want
>> extradata for init or something, and that way you can accommodate it
>> without having to wait for the first packet.
>
> Is this documented somewhere?

What documented? This seems quite logical. If you have extradata, set
extradata in codecpar

>
>> That's basically how all demuxers work, will extradata and if it can and
>> does change just send an update notice.
>
> Requiring to use codecpar->extradata for passing this from demuxer to decoder,
> while at the same time requiring to use AV_PKT_DATA_NEW_EXTRADATA side data
> to pass this from muxer to encoder seems quite strange to me.
>

encoders should also be able to just set extradata and the muxer read
that, this is how many other encoders work.
I don't know how the apng muxer works, but maybe it also just pretends
to be special.

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


[FFmpeg-devel] [PATCH 2/2] avformat/matroskaenc: write updated STREAMINFO metadata for FLAC streams if available

2016-11-02 Thread James Almer
FLAC streams originating from the FLAC encoder send updated and more
complete STREAMINFO metadata as part of the last packet, so write that
to CodecPrivate instead of the incomplete one available in extradata
during init.

Signed-off-by: James Almer 
---
 libavformat/matroskaenc.c | 49 +++
 1 file changed, 49 insertions(+)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index f41aabe..8a6a57d 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -130,6 +130,7 @@ typedef struct MatroskaMuxContext {
 int64_t cluster_pts;
 int64_t duration_offset;
 int64_t duration;
+int64_t codecpriv_offset;
 mkv_seekhead*main_seekhead;
 mkv_cues*cues;
 mkv_track   *tracks;
@@ -1253,6 +1254,7 @@ static int mkv_write_track(AVFormatContext *s, 
MatroskaMuxContext *mkv,
 }
 
 if (mkv->mode != MODE_WEBM || par->codec_id != AV_CODEC_ID_WEBVTT) {
+mkv->codecpriv_offset = avio_tell(pb);
 ret = mkv_write_codecprivate(s, pb, par, native_id, qt_id);
 if (ret < 0)
 return ret;
@@ -2078,6 +2080,49 @@ static void mkv_start_new_cluster(AVFormatContext *s, 
AVPacket *pkt)
 avio_flush(s->pb);
 }
 
+static int mkv_check_new_extra_data(AVFormatContext *s, AVPacket *pkt)
+{
+MatroskaMuxContext *mkv = s->priv_data;
+AVCodecParameters *par  = s->streams[pkt->stream_index]->codecpar;
+uint8_t *side_data;
+int side_data_size = 0, ret;
+
+side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
+ &side_data_size);
+
+switch (par->codec_id) {
+case AV_CODEC_ID_FLAC:
+if (side_data_size && s->pb->seekable) {
+AVCodecParameters *codecpriv_par;
+int64_t curpos;
+if (side_data_size != par->extradata_size) {
+av_log(s, AV_LOG_ERROR, "Invalid FLAC STREAMINFO metadata for 
output stream %d\n",
+   pkt->stream_index);
+return AVERROR(EINVAL);
+}
+codecpriv_par = avcodec_parameters_alloc();
+if (!codecpriv_par)
+return AVERROR(ENOMEM);
+ret = avcodec_parameters_copy(codecpriv_par, par);
+if (ret < 0)
+return ret;
+memcpy(codecpriv_par->extradata, side_data, side_data_size);
+curpos = avio_tell(mkv->tracks_bc);
+avio_seek(mkv->tracks_bc, mkv->codecpriv_offset, SEEK_SET);
+mkv_write_codecprivate(s, mkv->tracks_bc, codecpriv_par, 1, 0);
+avio_seek(mkv->tracks_bc, curpos, SEEK_SET);
+avcodec_parameters_free(&codecpriv_par);
+}
+break;
+default:
+if (side_data_size)
+av_log(s, AV_LOG_DEBUG, "Ignoring new extradata in a packet for 
stream %d.\n", pkt->stream_index);
+break;
+}
+
+return 0;
+}
+
 static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt, int 
add_cue)
 {
 MatroskaMuxContext *mkv = s->priv_data;
@@ -2170,6 +2215,10 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 int ret;
 int start_new_cluster;
 
+ret = mkv_check_new_extra_data(s, pkt);
+if (ret < 0)
+return ret;
+
 if (mkv->tracks[pkt->stream_index].write_dts)
 cluster_time = pkt->dts - mkv->cluster_pts;
 else
-- 
2.10.1

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


Re: [FFmpeg-devel] [PATCH] mov: add option to ignore moov atoms which are detected in free atoms, so apps can have flexibility to use moov atom not in free atoms as default.

2016-11-02 Thread Zhenni Huang
On Tue, Nov 1, 2016 at 5:45 PM, Carl Eugen Hoyos  wrote:

> 2016-10-31 21:33 GMT+01:00 Zhenni Huang  ffmpeg.org>:
>
> > Thanks Carl, I think setting strict_std_compliance is fine. Could please
> > you apply the change?
>
> Done.
>
> Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

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


Re: [FFmpeg-devel] [PATCH] avformat/apngenc: use the stream parameters extradata if no updated one is made available

2016-11-02 Thread Andreas Cadhalpun
On 02.11.2016 21:10, Hendrik Leppkes wrote:
> On Wed, Nov 2, 2016 at 8:13 PM, Andreas Cadhalpun
>  wrote:
>> On 01.11.2016 23:10, Hendrik Leppkes wrote:
>>> Am 01.11.2016 17:17 schrieb "Andreas Cadhalpun" <
>>> andreas.cadhal...@googlemail.com>:
 Not again, but instead, as the extradata is then only transferred as side 
 data.
 That way it is again consistent between demuxer/decoder and encoder/muxer.

>>>
>>> I don't think thats a good idea. Demuxers should fill the extradata field
>>> if any is present and required for decoding - some other decoder might want
>>> extradata for init or something, and that way you can accommodate it
>>> without having to wait for the first packet.
>>
>> Is this documented somewhere?
> 
> What documented?

You're claim that 'Demuxers should fill the extradata field'.

> This seems quite logical. If you have extradata, set extradata in codecpar

It's not logical to do this, if it's not necessary, e.g. for the apng demuxer.
It is only necessary if the decoder actually needs this information during
init, but the apng decoder does not.

>>> That's basically how all demuxers work, will extradata and if it can and
>>> does change just send an update notice.
>>
>> Requiring to use codecpar->extradata for passing this from demuxer to 
>> decoder,
>> while at the same time requiring to use AV_PKT_DATA_NEW_EXTRADATA side data
>> to pass this from muxer to encoder seems quite strange to me.
>>
> 
> encoders should also be able to just set extradata and the muxer read
> that, this is how many other encoders work.

That only works if it is set during write_header, setting it during
write_packet was broken by commit 5ef1959.

> I don't know how the apng muxer works, but maybe it also just pretends
> to be special.

It's special in that it doesn't set the extradata during write_header.

Best regards,
Andreas

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


Re: [FFmpeg-devel] [PATCH 1/3] avformat/matroskaenc: support writting Chroma Location elements

2016-11-02 Thread James Almer
On 10/28/2016 12:08 AM, James Almer wrote:
> On 10/22/2016 5:38 PM, James Almer wrote:
>> On 10/15/2016 12:40 PM, James Almer wrote:
>>> Signed-off-by: James Almer 
>>> ---
>>>  libavformat/matroskaenc.c | 8 
>>>  1 file changed, 8 insertions(+)
>>>
>>> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
>>> index a48f5bb..d6557a1 100644
>>> --- a/libavformat/matroskaenc.c
>>> +++ b/libavformat/matroskaenc.c
>>> @@ -829,6 +829,14 @@ static int mkv_write_video_color(AVIOContext *pb, 
>>> AVCodecParameters *par, AVStre
>>>  par->color_range < AVCOL_RANGE_NB) {
>>>  put_ebml_uint(dyn_cp, MATROSKA_ID_VIDEOCOLORRANGE, 
>>> par->color_range);
>>>  }
>>> +if (par->chroma_location != AVCHROMA_LOC_UNSPECIFIED &&
>>> +par->chroma_location <= AVCHROMA_LOC_TOP) {
>>> +int xpos, ypos;
>>> +
>>> +avcodec_enum_to_chroma_pos(&xpos, &ypos, par->chroma_location);
>>> +put_ebml_uint(dyn_cp, MATROSKA_ID_VIDEOCOLORCHROMASITINGHORZ, 
>>> (xpos >> 7) + 1);
>>> +put_ebml_uint(dyn_cp, MATROSKA_ID_VIDEOCOLORCHROMASITINGVERT, 
>>> (ypos >> 7) + 1);
>>> +}
>>>  if (side_data_size == sizeof(AVMasteringDisplayMetadata)) {
>>>  ebml_master meta_element = start_ebml_master(
>>>  dyn_cp, MATROSKA_ID_VIDEOCOLORMASTERINGMETA, 0);
>>
>> Ping.
> 
> Ping. Will apply soon if nobody comments.
> 

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


Re: [FFmpeg-devel] [PATCH] avformat/matroskaenc: use display aspect ratio for DisplayWidth and DisplayHeight when possible

2016-11-02 Thread James Almer
On 10/28/2016 12:03 AM, James Almer wrote:
> On 10/22/2016 5:33 PM, James Almer wrote:
>> This avoids potential rounding errors and guarantees the source aspect
>> ratio is preserved.
>> Keep writing pixel values when Stereo 3D Mode is enabled and for WebM,
>> as the format doesn't support anything else.
>>
>> This fixes ticket #5743, implementing the suggestion from ticket #5903.
>>
>> Signed-off-by: James Almer 
>> ---
>>  libavformat/matroskaenc.c | 15 +--
>>  1 file changed, 13 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
>> index 03d5326..5790fe1 100644
>> --- a/libavformat/matroskaenc.c
>> +++ b/libavformat/matroskaenc.c
>> @@ -1193,8 +1193,19 @@ static int mkv_write_track(AVFormatContext *s, 
>> MatroskaMuxContext *mkv,
>>  return AVERROR(EINVAL);
>>  }
>>  if (d_width != par->width || display_width_div != 1 || 
>> display_height_div != 1) {
>> -put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYWIDTH , d_width / 
>> display_width_div);
>> -put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYHEIGHT, 
>> par->height / display_height_div);
>> +if (mkv->mode == MODE_WEBM || display_width_div != 1 || 
>> display_height_div != 1) {
>> +put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYWIDTH , 
>> d_width / display_width_div);
>> +put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYHEIGHT, 
>> par->height / display_height_div);
>> +} else {
>> +AVRational display_aspect_ratio;
>> +av_reduce(&display_aspect_ratio.num, 
>> &display_aspect_ratio.den,
>> +  par->width  * 
>> (int64_t)st->sample_aspect_ratio.num,
>> +  par->height * 
>> (int64_t)st->sample_aspect_ratio.den,
>> +  1024 * 1024);
>> +put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYWIDTH,  
>> display_aspect_ratio.num);
>> +put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYHEIGHT, 
>> display_aspect_ratio.den);
>> +put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYUNIT, 
>> MATROSKA_VIDEO_DISPLAYUNIT_DAR);
>> +}
>>  }
>>  } else if (display_width_div != 1 || display_height_div != 1) {
>>  put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYWIDTH , par->width / 
>> display_width_div);
> 
> Ping.
> 

Applied

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


Re: [FFmpeg-devel] [OPW] OPW Project Proposal

2016-11-02 Thread Michael Niedermayer
On Thu, Nov 03, 2016 at 01:10:26AM +0530, Pallavi Kumari wrote:
> Necessary changes has been done. PFA.
> 
> Usage:
> 
> ./ffmpeg -i kpg.mp3 -filter_complex peakpoints=wsize=16 -f null -
> 
> On Wed, Nov 2, 2016 at 6:14 AM, Michael Niedermayer 
> wrote:
> 
> > On Wed, Nov 02, 2016 at 05:00:09AM +0530, Pallavi Kumari wrote:
> > > Hi Michael,
> > >
> > > I have attached a working patch with the mail. PFA.
> > >
> > > Usage:
> > >
> >
> > > ./ffmpeg -i kpg.mp3 -filter_complex peakpoints=input=kpg.mp3:wsize=16
> >
> > I realize now, theres a mistake in this, you must provide a output
> > as in
> > ./ffmpeg -i kpg.mp3 -af peakpoints -f null -
> >
> > without some output like  "-f null -" it wont read the file fully and
> > wont pass it through filter_frame()
> >
> > you could see this failure as in:
> > ./ffmpeg -i ~/videos/matrixbench_mpeg2.mpg -af volumedetect  -f null -
> > vs.
> > ./ffmpeg -i ~/videos/matrixbench_mpeg2.mpg -af volumedetect
> >
> > you get the histogram from the volume detect filter in the first case
> > but not the 2nd.
> >
> > [...]
> > --
> > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> >
> > Many things microsoft did are stupid, but not doing something just because
> > microsoft did it is even more stupid. If everything ms did were stupid they
> > would be bankrupt already.
> >

>  af_peakpoints.c |  226 
> 
>  1 file changed, 226 insertions(+)
> 206d91b47bc6066dd01db1c3369d4674ac95f04c  
> 0001-avfilter-added-peakpoints-filter.patch
> From e10f73d363d0313774bcb132b3b1f2417fcfba11 Mon Sep 17 00:00:00 2001
> From: Atana 
> Date: Thu, 3 Nov 2016 01:05:51 +0530
> Subject: [PATCH] avfilter: added peakpoints filter
> 
> ---
>  libavfilter/af_peakpoints.c | 226 
> 
>  1 file changed, 226 insertions(+)
>  create mode 100644 libavfilter/af_peakpoints.c

This is missing changes to the Makefile and libavfilter/allfilters*


> 
> diff --git a/libavfilter/af_peakpoints.c b/libavfilter/af_peakpoints.c
> new file mode 100644
> index 000..9265c47
> --- /dev/null
> +++ b/libavfilter/af_peakpoints.c
> @@ -0,0 +1,226 @@
> +/*
> + * Copyright (c) 2016 Atana
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +#include "libavcodec/avcodec.h"
> +#include "libavcodec/avfft.h"
> +#include "libavformat/avformat.h"
> +#include "libswscale/swscale.h"
> +#include "avfilter.h"
> +#include "audio.h"
> +#include "libavutil/opt.h"
> +
> +
> +/* Structure to contain peak points context */
> +typedef struct {
> +const AVClass *class;
> +double *data;
> +int nsamples;
> +int index;
> +double *peaks;
> +int size; // number of peaks
> +int windowSize;
> +//char *inputFile;
> +} PeakPointsContext;
> +
> +/* returns maximum value from an array conditioned on start and end index */
> +static double getMax(double *res_arr, int startIndex, int endIndex) {
> +int i;
> +double max = res_arr[startIndex];
> +for (i = startIndex; i <= endIndex; i++) {
> + if (res_arr[i] > max) {
> + max = res_arr[i];
> + }
> +}
> +return max;
> +}
> +
> +/* Stores peak frequency for each window(of chunkSize) in peaks array */
> +static void getPeakPointInChunk(int chunkSize, double *res_arr, int size, 
> double *peaks) {
> +int i = 0, peakIndex = 0;
> +int startIndex = 0;
> +double max;
> +// get a chunk and find max value in it
> +while (i < size) {
> + if (i % chunkSize-1 == 0) {
> +max = getMax(res_arr, startIndex, i);
> + peaks[peakIndex++] = max;
> + startIndex = startIndex + chunkSize;
> + }
> +i += 1;
> +}
> +}
> +
> +/* Get peaks points from windowed frequency domain data*/
> +static int getPeakPoints(PeakPointsContext *ppc) {
> +int i, m, k, size, chunkSize, pSize, chunkSampleSize, resSize;
> +double *fft_res;
> +void *avc;
> +RDFTContext *rdftC;
> +FFTSample *data;
> +
> +size = ppc->index;
> +m = log2(ppc->windowSize);
> +chunkSize = ppc->windowSize;
> +chunkSampleSize = size/chunkSize;
> +resSize = chunkSize * chunkSampleSize;
> +
> +fft_res = av_

Re: [FFmpeg-devel] [PATCH] pixblockdsp: disable altivec optimizations on ppc64be

2016-11-02 Thread Andreas Cadhalpun
On 02.11.2016 11:31, Michael Niedermayer wrote:
> On Wed, Nov 02, 2016 at 01:40:01AM +0100, Carl Eugen Hoyos wrote:
>> 2016-11-01 0:27 GMT+01:00 Andreas Cadhalpun 
>> :
>>
>>> -#if HAVE_ALTIVEC
>>> +#if HAVE_ALTIVEC && !(ARCH_PPC64 && HAVE_BIGENDIAN)
>>>  if (!PPC_ALTIVEC(av_get_cpu_flags()))
>>
>> Do the dnxhd tests work for you on 32bit BE powerpc?

Not when using the altivec functions.
(It's not tested on the Debian buildd, since the baseline of Debian's
powerpc architecture does not include altivec.)

>> (It fails here afaict)
> 
> i find it strange to belive that the code never worked on either HW

Your intuition is correct. ;-)

> if we assume it did once work for some case, what is differnt now ?
> the testcase?

It wasn't tested with FATE, so it wasn't noticed, when it broke.

> the compiler?

No.

> the code?

Yes, by the following Libav commit:
4c387c7 ppc: dsputil: do unaligned block accesses correctly

LOL!

I'll send a patch fixing this in a moment.

Best regards,
Andreas


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


[FFmpeg-devel] [PATCH] ppc: pixblockdsp: do unaligned block accesses correctly again

2016-11-02 Thread Andreas Cadhalpun
This was broken by the following Libav commit:
4c387c7 ppc: dsputil: do unaligned block accesses correctly

The following tests fail due to this:
fate-checkasm
fate-vsynth1-dnxhd-2k-hr-hq fate-vsynth1-dnxhd-edge1-hr
fate-vsynth1-dnxhd-edge2-hr fate-vsynth1-dnxhd-edge3-hr
fate-vsynth1-dnxhd-hr-sq-mov fate-vsynth1-dnxhd-hr-hq-mov
fate-vsynth2-dnxhd-2k-hr-hq fate-vsynth2-dnxhd-edge1-hr
fate-vsynth2-dnxhd-edge2-hr fate-vsynth2-dnxhd-edge3-hr
fate-vsynth2-dnxhd-hr-sq-mov fate-vsynth2-dnxhd-hr-hq-mov
fate-vsynth3-dnxhd-2k-hr-hq fate-vsynth3-dnxhd-edge1-hr
fate-vsynth3-dnxhd-edge2-hr fate-vsynth3-dnxhd-edge3-hr
fate-vsynth3-dnxhd-hr-sq-mov fate-vsynth3-dnxhd-hr-hq-mov

Fixes trac ticket #5508.

Signed-off-by: Andreas Cadhalpun 
---

Tested with qemu on ppc32be and ppc64be.

---
 libavcodec/ppc/pixblockdsp.c | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/libavcodec/ppc/pixblockdsp.c b/libavcodec/ppc/pixblockdsp.c
index 84aa562..f3a5050 100644
--- a/libavcodec/ppc/pixblockdsp.c
+++ b/libavcodec/ppc/pixblockdsp.c
@@ -67,10 +67,10 @@ static void get_pixels_altivec(int16_t *restrict block, 
const uint8_t *pixels,
ptrdiff_t line_size)
 {
 int i;
-vec_u8 perm = vec_lvsl(0, pixels);
 const vec_u8 zero = (const vec_u8)vec_splat_u8(0);
 
 for (i = 0; i < 8; i++) {
+vec_u8 perm = vec_lvsl(0, pixels);
 /* Read potentially unaligned pixels.
  * We're reading 16 pixels, and actually only want 8,
  * but we simply ignore the extras. */
@@ -157,8 +157,7 @@ static void diff_pixels_altivec(int16_t *restrict block, 
const uint8_t *s1,
 const uint8_t *s2, int stride)
 {
 int i;
-vec_u8 perm1 = vec_lvsl(0, s1);
-vec_u8 perm2 = vec_lvsl(0, s2);
+vec_u8 perm;
 const vec_u8 zero = (const vec_u8)vec_splat_u8(0);
 vec_s16 shorts1, shorts2;
 
@@ -166,17 +165,19 @@ static void diff_pixels_altivec(int16_t *restrict block, 
const uint8_t *s1,
 /* Read potentially unaligned pixels.
  * We're reading 16 pixels, and actually only want 8,
  * but we simply ignore the extras. */
+perm = vec_lvsl(0, s1);
 vec_u8 pixl  = vec_ld(0,  s1);
 vec_u8 pixr  = vec_ld(15, s1);
-vec_u8 bytes = vec_perm(pixl, pixr, perm1);
+vec_u8 bytes = vec_perm(pixl, pixr, perm);
 
 // Convert the bytes into shorts.
 shorts1 = (vec_s16)vec_mergeh(zero, bytes);
 
 // Do the same for the second block of pixels.
+perm = vec_lvsl(0, s2);
 pixl  = vec_ld(0,  s2);
 pixr  = vec_ld(15, s2);
-bytes = vec_perm(pixl, pixr, perm2);
+bytes = vec_perm(pixl, pixr, perm);
 
 // Convert the bytes into shorts.
 shorts2 = (vec_s16)vec_mergeh(zero, bytes);
@@ -197,17 +198,19 @@ static void diff_pixels_altivec(int16_t *restrict block, 
const uint8_t *s1,
 /* Read potentially unaligned pixels.
  * We're reading 16 pixels, and actually only want 8,
  * but we simply ignore the extras. */
+perm = vec_lvsl(0, s1);
 pixl  = vec_ld(0,  s1);
 pixr  = vec_ld(15, s1);
-bytes = vec_perm(pixl, pixr, perm1);
+bytes = vec_perm(pixl, pixr, perm);
 
 // Convert the bytes into shorts.
 shorts1 = (vec_s16)vec_mergeh(zero, bytes);
 
 // Do the same for the second block of pixels.
+perm = vec_lvsl(0, s2);
 pixl  = vec_ld(0,  s2);
 pixr  = vec_ld(15, s2);
-bytes = vec_perm(pixl, pixr, perm2);
+bytes = vec_perm(pixl, pixr, perm);
 
 // Convert the bytes into shorts.
 shorts2 = (vec_s16)vec_mergeh(zero, bytes);
-- 
2.10.1
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat: close parser if codec changed

2016-11-02 Thread Andreas Cadhalpun
On 02.11.2016 13:07, Michael Niedermayer wrote:
> On Sat, Oct 22, 2016 at 01:16:00AM +0200, Andreas Cadhalpun wrote:
>>  utils.c |   12 
>>  1 file changed, 12 insertions(+)
>> ffefc22756b774cb7652587207ae66cfbf681be3  
>> 0001-avformat-close-parser-if-codec-changed.patch
>> From 9de87a4fb2c6c6311a11a2da5de8554a71adfa66 Mon Sep 17 00:00:00 2001
>> From: Andreas Cadhalpun 
>> Date: Mon, 17 Oct 2016 20:26:51 +0200
>> Subject: [PATCH] avformat: close parser if codec changed
>>
>> The parser depends on the codec and thus must not be used with a different 
>> one.
>> If it is, the 'avctx->codec_id == s->parser->codec_ids[0] ...' assert in
>> av_parser_parse2 gets triggered.
>>
>> Signed-off-by: Andreas Cadhalpun 
>> ---
>>  libavformat/utils.c | 12 
>>  1 file changed, 12 insertions(+)
>>
>> diff --git a/libavformat/utils.c b/libavformat/utils.c
>> index 70dbfa1..a8a78ed 100644
>> --- a/libavformat/utils.c
>> +++ b/libavformat/utils.c
>> @@ -480,6 +480,12 @@ static int update_stream_avctx(AVFormatContext *s)
>>  if (!st->internal->need_context_update)
>>  continue;
>>  
>> +/* close parser, because it depends on the codec */
>> +if (st->parser && st->internal->avctx->codec_id != 
>> st->codecpar->codec_id) {
>> +av_parser_close(st->parser);
>> +st->parser = NULL;
>> +}
>> +
>>  /* update internal codec context, for the parser */
>>  ret = avcodec_parameters_to_context(st->internal->avctx, 
>> st->codecpar);
>>  if (ret < 0)
>> @@ -1515,6 +1521,12 @@ static int read_frame_internal(AVFormatContext *s, 
>> AVPacket *pkt)
>>  st->info->found_decoder = 0;
>>  }
>>  
>> +/* close parser, because it depends on the codec */
>> +if (st->parser && st->internal->avctx->codec_id != 
>> st->codecpar->codec_id) {
>> +av_parser_close(st->parser);
>> +st->parser = NULL;
>> +}
>> +
> 
> what if the codec id differs but both are supported by the parser ?
> AVCodecParser has a list of 5 codec ids ?
> 
> I didnt find a testcase where this makes a difference, just wondering

I think the parser should be re-initialized in that case, too.
For example the ac3 parser stores the codec_id in the parser context with:
if(hdr.bitstream_id>10)
hdr_info->codec_id = AV_CODEC_ID_EAC3;
else if (hdr_info->codec_id == AV_CODEC_ID_NONE)
hdr_info->codec_id = AV_CODEC_ID_AC3;

So if it is first AV_CODEC_ID_EAC3 and then AV_CODEC_ID_AC3, this wouldn't
be updated and the parser would change the avctx codec_id back, which
seems wrong.

> the patch seems fine otherwise

OK, pushed.

Best regards,
Andreas

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


[FFmpeg-devel] [PATCH] WIP: subtitles in AVFrame

2016-11-02 Thread Clément Bœsch
---
So this is just a prototype that is starting to work. It needs a split
(and completion of the long TODO list) before review but I wanted to
share it for early feedbacks.

So long story short: AVSubtitle → AVFrame, you have to use the new M:N
API, and it's integrated into lavfi.

Now a bit longer: the AVFrame->extended_data are
AVFrameSubtitleRectangle (declared in lavu/frame). Frames are
refcounted. So far this is not really meaningful as a frame ref will
alloc and copy every rectangle but that's a limitation we will have to
deal with for now but it allows proper integration into the framework.

It actually simplifies a lot the workflow so I'm optimistic about the
end result. Unfortunately, there is a lot of work remaining.

End note: despite my obsession with subtitles, I'd like to remind
everyone that I actually hate working with them, I just believe it's
really important to get that historical burden out of sight. That means,
if anyone wants to help with that, they are extremelly welcome.

Thanks,

TODO:
- what to do about sub2video?
- properly deal with -ss and -t (need strim filter?)
- sub_start_display/sub_end_display needs to be honored
- find a test case for dvbsub as it's likely broken (ffmpeg.c hack is
  removed and should be replaced by a EAGAIN logic in lavc/utils.c)
- make it pass FATE:
  * fix cc/subcc
  * broke various other stuff
- split commit
- Changelog/APIchanges
- proper API doxy
- update lavfi/subtitles?
---
 ffmpeg.c   | 231 -
 ffmpeg_filter.c|  94 +-
 ffmpeg_opt.c   |  33 ++-
 libavcodec/avcodec.h   |   9 ++
 libavcodec/utils.c | 214 +
 libavfilter/Makefile   |   3 +
 libavfilter/allfilters.c   |   8 ++
 libavfilter/avfilter.c |   8 ++
 libavfilter/buffersink.c   |  28 ++
 libavfilter/buffersrc.c|  59 
 libavfilter/fifo.c |  31 ++
 libavfilter/formats.c  |   4 +
 libavfilter/internal.h |   8 ++
 libavfilter/sf_snull.c |  48 ++
 libavfilter/subtitle.c |  60 
 libavfilter/subtitle.h |  31 ++
 libavfilter/vf_subtitles.c |  42 +
 libavformat/assenc.c   |   3 +
 libavutil/frame.c  | 131 +++--
 libavutil/frame.h  |  59 ++--
 tests/ref/fate/sub-charenc |   6 +-
 21 files changed, 895 insertions(+), 215 deletions(-)
 create mode 100644 libavfilter/sf_snull.c
 create mode 100644 libavfilter/subtitle.c
 create mode 100644 libavfilter/subtitle.h

diff --git a/ffmpeg.c b/ffmpeg.c
index 36a921a..8222b8b 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -856,6 +856,50 @@ static int check_recording_time(OutputStream *ost)
 return 1;
 }
 
+static void do_subtitle_out(OutputFile *of,
+OutputStream *ost,
+AVFrame *frame)
+{
+AVCodecContext *enc = ost->enc_ctx;
+AVPacket pkt;
+int ret;
+
+av_init_packet(&pkt);
+pkt.data = NULL;
+pkt.size = 0;
+
+if (!check_recording_time(ost))
+return;
+
+ost->frames_encoded++;
+
+av_assert0(pkt.size || !pkt.data);
+update_benchmark(NULL);
+
+ret = avcodec_send_frame(enc, frame);
+if (ret < 0)
+goto error;
+
+while (1) {
+ret = avcodec_receive_packet(enc, &pkt);
+if (ret == AVERROR(EAGAIN))
+break;
+if (ret < 0)
+goto error;
+
+update_benchmark("encode_subtitle %d.%d", ost->file_index, ost->index);
+
+av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base);
+
+output_packet(of, &pkt, ost);
+}
+
+return;
+error:
+av_log(NULL, AV_LOG_FATAL, "Subtitle encoding failed\n");
+exit_program(1);
+}
+
 static void do_audio_out(OutputFile *of, OutputStream *ost,
  AVFrame *frame)
 {
@@ -916,89 +960,6 @@ error:
 exit_program(1);
 }
 
-static void do_subtitle_out(OutputFile *of,
-OutputStream *ost,
-AVSubtitle *sub)
-{
-int subtitle_out_max_size = 1024 * 1024;
-int subtitle_out_size, nb, i;
-AVCodecContext *enc;
-AVPacket pkt;
-int64_t pts;
-
-if (sub->pts == AV_NOPTS_VALUE) {
-av_log(NULL, AV_LOG_ERROR, "Subtitle packets must have a pts\n");
-if (exit_on_error)
-exit_program(1);
-return;
-}
-
-enc = ost->enc_ctx;
-
-if (!subtitle_out) {
-subtitle_out = av_malloc(subtitle_out_max_size);
-if (!subtitle_out) {
-av_log(NULL, AV_LOG_FATAL, "Failed to allocate subtitle_out\n");
-exit_program(1);
-}
-}
-
-/* Note: DVB subtitle need one packet to draw them and one other
-   packet to clear them */
-/* XXX: signal it in the codec context ? */
-if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE)
-nb = 2;
-else
-nb = 1;
-
-/* shift timestamp to hono

Re: [FFmpeg-devel] [PATCH 01/12] adxdec: validate sample_rate

2016-11-02 Thread Andreas Cadhalpun
On 26.10.2016 21:44, Andreas Cadhalpun wrote:
> On 26.10.2016 20:15, Paul B Mahol wrote:
>> On 10/25/16, Michael Niedermayer  wrote:
>>> On Tue, Oct 25, 2016 at 07:45:25PM +0200, Andreas Cadhalpun wrote:
 On 25.10.2016 12:58, Paul B Mahol wrote:
> patch(es)have good intent, but better fix is doing/checking it in single
> place.

 I don't agree.
 In general, validity checks should be where the values are actually read.
 This eliminates the risk that bogus values could cause problems between
 being set
 and being checked.
 Also, having only a check in a central place is bad for debugging, because
 it is
 not immediately clear where the bogus value came from, when the check is
 triggered.
 (I know this from personal experience debugging all the cases triggering
 the
 assert in av_rescale_rnd.)

 The problem with that approach is that such checks can easily be
 forgotten, which
 is why I think a check in a central place would make sense in addition to
 checking
 the individual cases.
>>>
>>> some formats may also lack a sample rate like mpeg ps/ts
>>> the fact is known insude the demuxer, generic code after it doesnt
>>> know. Doing the only check after the parser is a bit late OTOH
>>>
>>> [...]
>>>
>>> --
>>> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>>>
>>> What does censorship reveal? It reveals fear. -- Julian Assange
>>>
>>
>> I'm not (yet) aware of better "fix" so do as you like.
> 
> Have you seen the patch for checking this in a central place [1]?
> It would catch all the negative sample rates, but not the negative
> timescales.
> (I still think it should be checked both centrally and locally.)

In the absence of further comments, I intend to push this set in a few days.

Best regards,
Andreas

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


Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Use the first sidx for tracks without sidx.

2016-11-02 Thread Sasi Inguva
Ping. Sorry for the urgency on this, but this is blocking us internally.

Thanks

On Mon, Oct 31, 2016 at 10:23 AM, Sasi Inguva  wrote:

> ping.
>
> Thanks!
>
> On Wed, Oct 26, 2016 at 11:31 AM, Sasi Inguva  wrote:
>
>> According to spec ISO_IEC_15444_12 "For any media stream for which no
>> segment index is present, referred to as non‐indexed stream, the media
>> stream associated with the first Segment Index box in the segment serves as
>> a reference stream in a sense that it also describes the subsegments for
>> any non‐indexed media stream."
>>
>> Signed-off-by: Sasi Inguva 
>> ---
>>  libavformat/isom.h |  1 +
>>  libavformat/mov.c  | 25 ++---
>>  2 files changed, 23 insertions(+), 3 deletions(-)
>>
>> diff --git a/libavformat/isom.h b/libavformat/isom.h
>> index 9038057..d684502 100644
>> --- a/libavformat/isom.h
>> +++ b/libavformat/isom.h
>> @@ -179,6 +179,7 @@ typedef struct MOVStreamContext {
>>  int32_t *display_matrix;
>>  uint32_t format;
>>
>> +int has_sidx;  // If there is an sidx entry for this stream.
>>  struct {
>>  int use_subsamples;
>>  uint8_t* auxiliary_info;
>> diff --git a/libavformat/mov.c b/libavformat/mov.c
>> index 357d800..d9ed5a3 100644
>> --- a/libavformat/mov.c
>> +++ b/libavformat/mov.c
>> @@ -4202,7 +4202,8 @@ static int mov_read_sidx(MOVContext *c, AVIOContext
>> *pb, MOVAtom atom)
>>  uint8_t version;
>>  unsigned i, track_id;
>>  AVStream *st = NULL;
>> -MOVStreamContext *sc;
>> +AVStream *ref_st;
>> +MOVStreamContext *sc, *ref_sc;
>>  MOVFragmentIndex *index = NULL;
>>  MOVFragmentIndex **tmp;
>>  AVRational timescale;
>> @@ -4284,9 +4285,26 @@ static int mov_read_sidx(MOVContext *c,
>> AVIOContext *pb, MOVAtom atom)
>>
>>  c->fragment_index_data = tmp;
>>  c->fragment_index_data[c->fragment_index_count++] = index;
>> +sc->has_sidx = 1;
>> +
>> +if (offset == avio_size(pb)) {
>> +for (i = 0; i < c->fc->nb_streams; i++) {
>> +if (c->fc->streams[i]->id == 
>> c->fragment_index_data[0]->track_id)
>> {
>> +ref_st = c->fc->streams[i];
>> +ref_sc = ref_st->priv_data;
>> +break;
>> +}
>> +}
>> +for (i = 0; i < c->fc->nb_streams; i++) {
>> +st = c->fc->streams[i];
>> +sc = st->priv_data;
>> +if (!sc->has_sidx) {
>> +st->duration = sc->track_end =
>> av_rescale(ref_st->duration, sc->time_scale, ref_sc->time_scale);
>> +}
>> +}
>>
>> -if (offset == avio_size(pb))
>>  c->fragment_index_complete = 1;
>> +}
>>
>>  return 0;
>>  }
>> @@ -5846,13 +5864,14 @@ static int mov_read_packet(AVFormatContext *s,
>> AVPacket *pkt)
>>  static int mov_seek_fragment(AVFormatContext *s, AVStream *st, int64_t
>> timestamp)
>>  {
>>  MOVContext *mov = s->priv_data;
>> +MOVStreamContext *sc = st->priv_data;
>>  int i, j;
>>
>>  if (!mov->fragment_index_complete)
>>  return 0;
>>
>>  for (i = 0; i < mov->fragment_index_count; i++) {
>> -if (mov->fragment_index_data[i]->track_id == st->id) {
>> +if (mov->fragment_index_data[i]->track_id == st->id ||
>> !sc->has_sidx) {
>>  MOVFragmentIndex *index = mov->fragment_index_data[i];
>>  for (j = index->item_count - 1; j >= 0; j--) {
>>  if (index->items[j].time <= timestamp) {
>> --
>> 2.8.0.rc3.226.g39d4020
>>
>>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/matroskaenc: use display aspect ratio for DisplayWidth and DisplayHeight when possible

2016-11-02 Thread Carl Eugen Hoyos
2016-10-22 22:33 GMT+02:00 James Almer :
> This avoids potential rounding errors and guarantees the source aspect
> ratio is preserved.
> Keep writing pixel values when Stereo 3D Mode is enabled and for WebM,
> as the format doesn't support anything else.
>
> This fixes ticket #5743, implementing the suggestion from ticket #5903.

Thank you for fixing this!

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


Re: [FFmpeg-devel] [PATCH] WIP: subtitles in AVFrame

2016-11-02 Thread Clément Bœsch
On Wed, Nov 02, 2016 at 11:11:06PM +0100, Carl Eugen Hoyos wrote:
> 2016-11-02 23:09 GMT+01:00 Clément Bœsch :
> 
> > - find a test case for dvbsub
> 
> Please elaborate;-)
> 

I need a FATE test involving dvb transcoding.

-- 
Clément B.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] WIP: subtitles in AVFrame

2016-11-02 Thread Carl Eugen Hoyos
2016-11-02 23:09 GMT+01:00 Clément Bœsch :

> - find a test case for dvbsub

Please elaborate;-)

Thanks for working on this, Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavf/mov: Add support for edit list parsing.

2016-11-02 Thread Derek Buitenhuis
On 10/24/2016 6:43 AM, Sasi Inguva wrote:
> Just sent a patch, correcting a bug in the edit list code. PTAL.

Hi again, it's me. Back with more files this patch set broke :).

This time it's very easy to reproduce:

$ ffmpeg -i sample.mp4 -f null -

This works before your patchset, and also if I use -ignore_editlist 1.

After your patchset, it fails with:

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x34a1380] Missing key frame while reordering 
index according to edit list
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x34a1380] Could not find codec parameters for 
stream 0 (Video: h264 (avc1 / 0x31637661), none, 1280x720, 2000 kb/s): 
unspecified pixel format
[...]
[buffer @ 0x38b0760] Unable to parse option value "-1" as pixel format
Last message repeated 1 times
[buffer @ 0x38b0760] Error setting option pix_fmt to value -1.
[graph 0 input from stream 0:0 @ 0x34a11a0] Error applying options to the 
filter.
Error opening filters!

I will forward you the sample privately.

I've seen a lot (hundreds/thousands) of files broken like this so far.

Cheers,
- Derek

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


Re: [FFmpeg-devel] [PATCH] avformat/matroskaenc: use display aspect ratio for DisplayWidth and DisplayHeight when possible

2016-11-02 Thread Kieran O Leary
Hi

On 2 Nov 2016 10:15 p.m., "Carl Eugen Hoyos"  wrote:
>

> >
> > This fixes ticket #5743, implementing the suggestion from ticket #5903.
>
> Thank you for fixing this!
>
> Carl Eugen
>

+1 Thanks James!
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ppc: pixblockdsp: do unaligned block accesses correctly again

2016-11-02 Thread Carl Eugen Hoyos
2016-11-02 21:34 GMT+01:00 Andreas Cadhalpun :
> This was broken by the following Libav commit:
> 4c387c7 ppc: dsputil: do unaligned block accesses correctly
>
> The following tests fail due to this:
> fate-checkasm
> fate-vsynth1-dnxhd-2k-hr-hq fate-vsynth1-dnxhd-edge1-hr
> fate-vsynth1-dnxhd-edge2-hr fate-vsynth1-dnxhd-edge3-hr
> fate-vsynth1-dnxhd-hr-sq-mov fate-vsynth1-dnxhd-hr-hq-mov
> fate-vsynth2-dnxhd-2k-hr-hq fate-vsynth2-dnxhd-edge1-hr
> fate-vsynth2-dnxhd-edge2-hr fate-vsynth2-dnxhd-edge3-hr
> fate-vsynth2-dnxhd-hr-sq-mov fate-vsynth2-dnxhd-hr-hq-mov
> fate-vsynth3-dnxhd-2k-hr-hq fate-vsynth3-dnxhd-edge1-hr
> fate-vsynth3-dnxhd-edge2-hr fate-vsynth3-dnxhd-edge3-hr
> fate-vsynth3-dnxhd-hr-sq-mov fate-vsynth3-dnxhd-hr-hq-mov
>
> Fixes trac ticket #5508.
>
> Signed-off-by: Andreas Cadhalpun 
> ---
>
> Tested with qemu on ppc32be and ppc64be.

Fixes the affected fate tests on ppc32 and ppc64be, ppc64le still works.

(rv20-1239 fails on ppc32 and ppc64le, works on ppc64be)

Thank you!

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


Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Use the first sidx for tracks without sidx.

2016-11-02 Thread Derek Buitenhuis
On 10/26/2016 7:31 PM, Sasi Inguva wrote:
> According to spec ISO_IEC_15444_12 "For any media stream for which no segment 
> index is present, referred to as non‐indexed stream, the media stream 
> associated with the first Segment Index box in the segment serves as a 
> reference stream in a sense that it also describes the subsegments for any 
> non‐indexed media stream."
> 
> Signed-off-by: Sasi Inguva 
> ---
>  libavformat/isom.h |  1 +
>  libavformat/mov.c  | 25 ++---
>  2 files changed, 23 insertions(+), 3 deletions(-)

The idea seems to sound OK.

[...]

> st->duration = sc->track_end = av_rescale(ref_st->duration, sc->time_scale, 
> ref_sc->time_scale);

Without surrounding context, this line seems a bit funky. You're intending
to set the duration/end to ... timescale? One second?

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


Re: [FFmpeg-devel] [PATCH] avformat: close parser if codec changed

2016-11-02 Thread Michael Niedermayer
On Wed, Nov 02, 2016 at 10:30:30PM +0100, Andreas Cadhalpun wrote:
> On 02.11.2016 13:07, Michael Niedermayer wrote:
> > On Sat, Oct 22, 2016 at 01:16:00AM +0200, Andreas Cadhalpun wrote:
> >>  utils.c |   12 
> >>  1 file changed, 12 insertions(+)
> >> ffefc22756b774cb7652587207ae66cfbf681be3  
> >> 0001-avformat-close-parser-if-codec-changed.patch
> >> From 9de87a4fb2c6c6311a11a2da5de8554a71adfa66 Mon Sep 17 00:00:00 2001
> >> From: Andreas Cadhalpun 
> >> Date: Mon, 17 Oct 2016 20:26:51 +0200
> >> Subject: [PATCH] avformat: close parser if codec changed
> >>
> >> The parser depends on the codec and thus must not be used with a different 
> >> one.
> >> If it is, the 'avctx->codec_id == s->parser->codec_ids[0] ...' assert in
> >> av_parser_parse2 gets triggered.
> >>
> >> Signed-off-by: Andreas Cadhalpun 
> >> ---
> >>  libavformat/utils.c | 12 
> >>  1 file changed, 12 insertions(+)
> >>
> >> diff --git a/libavformat/utils.c b/libavformat/utils.c
> >> index 70dbfa1..a8a78ed 100644
> >> --- a/libavformat/utils.c
> >> +++ b/libavformat/utils.c
> >> @@ -480,6 +480,12 @@ static int update_stream_avctx(AVFormatContext *s)
> >>  if (!st->internal->need_context_update)
> >>  continue;
> >>  
> >> +/* close parser, because it depends on the codec */
> >> +if (st->parser && st->internal->avctx->codec_id != 
> >> st->codecpar->codec_id) {
> >> +av_parser_close(st->parser);
> >> +st->parser = NULL;
> >> +}
> >> +
> >>  /* update internal codec context, for the parser */
> >>  ret = avcodec_parameters_to_context(st->internal->avctx, 
> >> st->codecpar);
> >>  if (ret < 0)
> >> @@ -1515,6 +1521,12 @@ static int read_frame_internal(AVFormatContext *s, 
> >> AVPacket *pkt)
> >>  st->info->found_decoder = 0;
> >>  }
> >>  
> >> +/* close parser, because it depends on the codec */
> >> +if (st->parser && st->internal->avctx->codec_id != 
> >> st->codecpar->codec_id) {
> >> +av_parser_close(st->parser);
> >> +st->parser = NULL;
> >> +}
> >> +
> > 
> > what if the codec id differs but both are supported by the parser ?
> > AVCodecParser has a list of 5 codec ids ?
> > 
> > I didnt find a testcase where this makes a difference, just wondering
> 
> I think the parser should be re-initialized in that case, too.

doesnt this lead to data loss (parser internal buffers being lost at
a transition between 2 types)?
both types might be handled by the same decoder so nothing special
might be needed "downstream"


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

There will always be a question for which you do not know the correct answer.


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


Re: [FFmpeg-devel] [PATCH] WIP: subtitles in AVFrame

2016-11-02 Thread Marton Balint


On Wed, 2 Nov 2016, Clément Bœsch wrote:


---
So this is just a prototype that is starting to work. It needs a split
(and completion of the long TODO list) before review but I wanted to
share it for early feedbacks.


Great, thanks!


So long story short: AVSubtitle → AVFrame, you have to use the new M:N
API, and it's integrated into lavfi.

Now a bit longer: the AVFrame->extended_data are
AVFrameSubtitleRectangle (declared in lavu/frame).


Wouldn't it make sense to simply use video AVFrames here instead of a 
separate struct?


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


Re: [FFmpeg-devel] [PATCH] avformat: close parser if codec changed

2016-11-02 Thread Andreas Cadhalpun
On 03.11.2016 00:42, Michael Niedermayer wrote:
> On Wed, Nov 02, 2016 at 10:30:30PM +0100, Andreas Cadhalpun wrote:
>> On 02.11.2016 13:07, Michael Niedermayer wrote:
>>> On Sat, Oct 22, 2016 at 01:16:00AM +0200, Andreas Cadhalpun wrote:
  utils.c |   12 
  1 file changed, 12 insertions(+)
 ffefc22756b774cb7652587207ae66cfbf681be3  
 0001-avformat-close-parser-if-codec-changed.patch
 From 9de87a4fb2c6c6311a11a2da5de8554a71adfa66 Mon Sep 17 00:00:00 2001
 From: Andreas Cadhalpun 
 Date: Mon, 17 Oct 2016 20:26:51 +0200
 Subject: [PATCH] avformat: close parser if codec changed

 The parser depends on the codec and thus must not be used with a different 
 one.
 If it is, the 'avctx->codec_id == s->parser->codec_ids[0] ...' assert in
 av_parser_parse2 gets triggered.

 Signed-off-by: Andreas Cadhalpun 
 ---
  libavformat/utils.c | 12 
  1 file changed, 12 insertions(+)

 diff --git a/libavformat/utils.c b/libavformat/utils.c
 index 70dbfa1..a8a78ed 100644
 --- a/libavformat/utils.c
 +++ b/libavformat/utils.c
 @@ -480,6 +480,12 @@ static int update_stream_avctx(AVFormatContext *s)
  if (!st->internal->need_context_update)
  continue;
  
 +/* close parser, because it depends on the codec */
 +if (st->parser && st->internal->avctx->codec_id != 
 st->codecpar->codec_id) {
 +av_parser_close(st->parser);
 +st->parser = NULL;
 +}
 +
  /* update internal codec context, for the parser */
  ret = avcodec_parameters_to_context(st->internal->avctx, 
 st->codecpar);
  if (ret < 0)
 @@ -1515,6 +1521,12 @@ static int read_frame_internal(AVFormatContext *s, 
 AVPacket *pkt)
  st->info->found_decoder = 0;
  }
  
 +/* close parser, because it depends on the codec */
 +if (st->parser && st->internal->avctx->codec_id != 
 st->codecpar->codec_id) {
 +av_parser_close(st->parser);
 +st->parser = NULL;
 +}
 +
>>>
>>> what if the codec id differs but both are supported by the parser ?
>>> AVCodecParser has a list of 5 codec ids ?
>>>
>>> I didnt find a testcase where this makes a difference, just wondering
>>
>> I think the parser should be re-initialized in that case, too.
> 
> doesnt this lead to data loss (parser internal buffers being lost at
> a transition between 2 types)?

Yes, but it's not clear that the parser internal state is still correct
after a change of the codec id.

> both types might be handled by the same decoder so nothing special
> might be needed "downstream"

It might work for some decoders and might not work for others.
It's hard to tell without samples.

Best regards,
Andreas

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


[FFmpeg-devel] [PATCH] hls: call avformat_find_stream_info for mpegts subdemuxer

2016-11-02 Thread Andreas Cadhalpun
This fixes probing dts/eac3/mp2 in hls.

The problem was introduced in commit 04964ac311abe670fb3b60290a330f2067544b13.

Also update the fate reference for the fate-segment-mp4-to-ts test.

Signed-off-by: Andreas Cadhalpun 
---

I've no idea why the fate reference changes, but this also happens when
partially/fully reverting commit 04964ac311abe670fb3b60290a330f2067544b13.
And it's a very recent fate test...

---
 libavformat/hls.c|  2 +-
 tests/ref/fate/segment-mp4-to-ts | 77 +---
 2 files changed, 50 insertions(+), 29 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 3c09dd8..543e65c 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1756,7 +1756,7 @@ static int hls_read_header(AVFormatContext *s)
  * but for other streams we can rely on our user calling 
avformat_find_stream_info()
  * on us if they want to.
  */
-if (pls->is_id3_timestamped) {
+if (pls->is_id3_timestamped || av_match_name(in_fmt->name, "mpegts")) {
 ret = avformat_find_stream_info(pls->ctx, NULL);
 if (ret < 0)
 goto fail;
diff --git a/tests/ref/fate/segment-mp4-to-ts b/tests/ref/fate/segment-mp4-to-ts
index 8513027..acb1199 100644
--- a/tests/ref/fate/segment-mp4-to-ts
+++ b/tests/ref/fate/segment-mp4-to-ts
@@ -5,34 +5,55 @@
 #dimensions 0: 640x360
 #sar 0: 1/1
 0,  -7200,  0,0,22630, 0x9b109541, S=1,1, 
0x00e000e0
-0,  -3600,  14400,0, 4021, 0xbf7cdb02, F=0x0, S=1,
1, 0x00e000e0
-0,  0,   7200,0, 1096, 0x4f162690, F=0x0, S=1,
1, 0x00e000e0
-0,   3600,   3600,0,  687, 0x00394b95, F=0x0, S=1,
1, 0x00e000e0
-0,   7200,  10800,0,  445, 0x08c3d065, F=0x0, S=1,
1, 0x00e000e0
-0,  10800,  28800,0, 4212, 0x56d12b8f, F=0x0, S=1,
1, 0x00e000e0
-0,  14400,  21600,0, 1117, 0xd521260b, F=0x0, S=1,
1, 0x00e000e0
-0,  18000,  18000,0,  892, 0x4262bdbc, F=0x0, S=1,
1, 0x00e000e0
-0,  21600,  25200,0,  480, 0x3be1ef0b, F=0x0, S=1,
1, 0x00e000e0
-0,  25200,  43200,0, 4065, 0x40dee237, F=0x0, S=1,
1, 0x00e000e0
-0,  28800,  36000,0,  962, 0x31a4ceb1, F=0x0, S=1,
1, 0x00e000e0
-0,  32400,  32400,0,  651, 0xb2aa317a, F=0x0, S=1,
1, 0x00e000e0
-0,  36000,  39600,0,  543, 0x9c4e0024, F=0x0, S=1,
1, 0x00e000e0
-0,  39600,  57600,0, 4221, 0x77c23977, F=0x0, S=1,
1, 0x00e000e0
-0,  43200,  50400,0, 1040, 0x482cfa34, F=0x0, S=1,
1, 0x00e000e0
-0,  46800,  46800,0,  576, 0x2686136a, F=0x0, S=1,
1, 0x00e000e0
-0,  50400,  54000,0,  607, 0xc53c2339, F=0x0, S=1,
1, 0x00e000e0
-0,  54000,  72000,0, 4755, 0x2f642b58, F=0x0, S=1,
1, 0x00e000e0
-0,  57600,  64800,0, 1182, 0xbe1a4847, F=0x0, S=1,
1, 0x00e000e0
-0,  61200,  61200,0,  809, 0x8d948a4e, F=0x0, S=1,
1, 0x00e000e0
-0,  64800,  68400,0,  656, 0x4fa03c2b, F=0x0, S=1,
1, 0x00e000e0
-0,  68400,  86400,0,26555, 0x5629b584, S=1,1, 
0x00e000e0
-0,  72000,  79200,0, 1141, 0x761b31e8, F=0x0, S=1,
1, 0x00e000e0
-0,  75600,  75600,0,  717, 0x57746351, F=0x0, S=1,
1, 0x00e000e0
-0,  79200,  82800,0,  693, 0x78b24263, F=0x0, S=1,
1, 0x00e000e0
-0,  82800, 100800,0, 3417, 0x560dbc89, F=0x0, S=1,
1, 0x00e000e0
-0,  86400,  93600,0, 1128, 0xc0f1383c, F=0x0, S=1,
1, 0x00e000e0
-0,  9,  9,0,  650, 0xc3ad485e, F=0x0, S=1,
1, 0x00e000e0
-0,  93600,  97200,0,  766, 0xd3e9757d, F=0x0, S=1,
1, 0x00e000e0
+0,  -3600,  14400, 3600, 4021, 0xbf7cdb02, F=0x0, S=1,
1, 0x00e000e0
+0,  0,   7200, 3600, 1096, 0x4f162690, F=0x0, S=1,
1, 0x00e000e0
+0,   3600,   3600, 3600,  687, 0x00394b95, F=0x0, S=1,
1, 0x00e000e0
+0,   7200,  10800, 3600,  445, 0x08c3d065, F=0x0, S=1,
1, 0x00e000e0
+0,  10800,  28800, 3600, 4212, 0x56d12b8f, F=0x0, S=1,
1, 0x00e000e0
+0,  14400,  21600, 3600, 1117, 0xd521260b, F=0x0, S=1,
1, 0x00e000e0
+0,  18000,  18000, 3600,  892, 0x4262bdbc, F=0x0, S=1,
1, 0x00e000e0
+0,  21600,  25200, 3600,  480, 0x3be1ef0b, F=0x0, S=1,
1, 0x00e000e0
+0,  25200,  43200, 3600, 4065, 0x40dee237, F=0x0, S=1,
1, 0x00e000e0
+0,  28800,  36000,

Re: [FFmpeg-devel] [PATCH] hls: always call avformat_find_stream_info for subdemuxers

2016-11-02 Thread Andreas Cadhalpun
On 27.10.2016 22:31, Andreas Cadhalpun wrote:
> On 27.10.2016 21:30, Hendrik Leppkes wrote:
>> On Thu, Oct 27, 2016 at 9:20 PM, Andreas Cadhalpun
>>  wrote:
>>> This fixes probing dts/eac3/mp2 in hls.
>>>
>>> This partly reverts commit 04964ac311abe670fb3b60290a330f2067544b13.
>>>
>>
>> That commit does a lot of magic flag handling to avoid calling that
>> function all the time (in fact that seems to be one of the main
>> purposes of that commit), I don't think a partial revert is a good
>> idea.
> 
> I just wanted to keep the change minimal.
> Would you prefer a full revert of that commit?
> 
>> At the very least I would like to hear from the author of that
>> particular commit.
> 
> CC'ed the author. Better ideas/patches are always welcome.

I've just sent an alternative patch [1], that keeps the sample from
ticket 4930 working.

Best regards,
Andreas


1: https://ffmpeg.org/pipermail/ffmpeg-devel/2016-November/202165.html

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


Re: [FFmpeg-devel] [PATCH] ppc: pixblockdsp: do unaligned block accesses correctly again

2016-11-02 Thread Andreas Cadhalpun
On 02.11.2016 23:41, Carl Eugen Hoyos wrote:
> 2016-11-02 21:34 GMT+01:00 Andreas Cadhalpun 
> :
>> This was broken by the following Libav commit:
>> 4c387c7 ppc: dsputil: do unaligned block accesses correctly
>>
>> The following tests fail due to this:
>> fate-checkasm
>> fate-vsynth1-dnxhd-2k-hr-hq fate-vsynth1-dnxhd-edge1-hr
>> fate-vsynth1-dnxhd-edge2-hr fate-vsynth1-dnxhd-edge3-hr
>> fate-vsynth1-dnxhd-hr-sq-mov fate-vsynth1-dnxhd-hr-hq-mov
>> fate-vsynth2-dnxhd-2k-hr-hq fate-vsynth2-dnxhd-edge1-hr
>> fate-vsynth2-dnxhd-edge2-hr fate-vsynth2-dnxhd-edge3-hr
>> fate-vsynth2-dnxhd-hr-sq-mov fate-vsynth2-dnxhd-hr-hq-mov
>> fate-vsynth3-dnxhd-2k-hr-hq fate-vsynth3-dnxhd-edge1-hr
>> fate-vsynth3-dnxhd-edge2-hr fate-vsynth3-dnxhd-edge3-hr
>> fate-vsynth3-dnxhd-hr-sq-mov fate-vsynth3-dnxhd-hr-hq-mov
>>
>> Fixes trac ticket #5508.
>>
>> Signed-off-by: Andreas Cadhalpun 
>> ---
>>
>> Tested with qemu on ppc32be and ppc64be.
> 
> Fixes the affected fate tests on ppc32 and ppc64be, ppc64le still works.

Thanks for confirming, pushed.

> (rv20-1239 fails on ppc32 and ppc64le, works on ppc64be)

This test works for me with qemu emulating ppc32, haven't tested the others.

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


[FFmpeg-devel] [PATCH] avfilter/af_firequalizer: add fft2 option

2016-11-02 Thread Muhammad Faiz
2-channels convolution using complex fft
improves speed significantly

not sure if it should be enabled by default
so disable it by default

Signed-off-by: Muhammad Faiz 
---
 doc/filters.texi|  4 +++
 libavfilter/af_firequalizer.c   | 80 -
 tests/filtergraphs/firequalizer |  8 +++--
 3 files changed, 88 insertions(+), 4 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 867b932..5bced37 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -2585,6 +2585,10 @@ Set file for dumping, suitable for gnuplot.
 @item dumpscale
 Set scale for dumpfile. Acceptable values are same with scale option.
 Default is linlog.
+
+@item fft2
+Enable 2-channel convolution using complex FFT. This improves speed 
significantly.
+Default is disabled.
 @end table
 
 @subsection Examples
diff --git a/libavfilter/af_firequalizer.c b/libavfilter/af_firequalizer.c
index 4988717..5c6fd54 100644
--- a/libavfilter/af_firequalizer.c
+++ b/libavfilter/af_firequalizer.c
@@ -69,6 +69,7 @@ typedef struct {
 RDFTContext   *analysis_irdft;
 RDFTContext   *rdft;
 RDFTContext   *irdft;
+FFTContext*fft_ctx;
 int   analysis_rdft_len;
 int   rdft_len;
 
@@ -97,6 +98,7 @@ typedef struct {
 int   scale;
 char  *dumpfile;
 int   dumpscale;
+int   fft2;
 
 int   nb_gain_entry;
 int   gain_entry_err;
@@ -132,6 +134,7 @@ static const AVOption firequalizer_options[] = {
 { "loglog", "logarithmic-freq logarithmic-gain", 0, AV_OPT_TYPE_CONST, 
{ .i64 = SCALE_LOGLOG }, 0, 0, FLAGS, "scale" },
 { "dumpfile", "set dump file", OFFSET(dumpfile), AV_OPT_TYPE_STRING, { 
.str = NULL }, 0, 0, FLAGS },
 { "dumpscale", "set dump scale", OFFSET(dumpscale), AV_OPT_TYPE_INT, { 
.i64 = SCALE_LINLOG }, 0, NB_SCALE-1, FLAGS, "scale" },
+{ "fft2", "set 2-channels fft", OFFSET(fft2), AV_OPT_TYPE_BOOL, { .i64 = 0 
}, 0, 1, FLAGS },
 { NULL }
 };
 
@@ -143,7 +146,9 @@ static void common_uninit(FIREqualizerContext *s)
 av_rdft_end(s->analysis_irdft);
 av_rdft_end(s->rdft);
 av_rdft_end(s->irdft);
+av_fft_end(s->fft_ctx);
 s->analysis_rdft = s->analysis_irdft = s->rdft = s->irdft = NULL;
+s->fft_ctx = NULL;
 
 av_freep(&s->analysis_buf);
 av_freep(&s->dump_buf);
@@ -230,6 +235,70 @@ static void fast_convolute(FIREqualizerContext *s, const 
float *kernel_buf, floa
 }
 }
 
+static void fast_convolute2(FIREqualizerContext *s, const float *kernel_buf, 
FFTComplex *conv_buf,
+OverlapIndex *idx, float *data0, float *data1, int 
nsamples)
+{
+if (nsamples <= s->nsamples_max) {
+FFTComplex *buf = conv_buf + idx->buf_idx * s->rdft_len;
+FFTComplex *obuf = conv_buf + !idx->buf_idx * s->rdft_len + 
idx->overlap_idx;
+int center = s->fir_len/2;
+int k;
+float tmp;
+
+memset(buf, 0, center * sizeof(*buf));
+for (k = 0; k < nsamples; k++) {
+buf[center+k].re = data0[k];
+buf[center+k].im = data1[k];
+}
+memset(buf + center + nsamples, 0, (s->rdft_len - nsamples - center) * 
sizeof(*buf));
+av_fft_permute(s->fft_ctx, buf);
+av_fft_calc(s->fft_ctx, buf);
+
+/* swap re <-> im, do backward fft using forward fft_ctx */
+/* normalize with 0.5f */
+tmp = buf[0].re;
+buf[0].re = 0.5f * kernel_buf[0] * buf[0].im;
+buf[0].im = 0.5f * kernel_buf[0] * tmp;
+for (k = 1; k < s->rdft_len/2; k++) {
+int m = s->rdft_len - k;
+tmp = buf[k].re;
+buf[k].re = 0.5f * kernel_buf[k] * buf[k].im;
+buf[k].im = 0.5f * kernel_buf[k] * tmp;
+tmp = buf[m].re;
+buf[m].re = 0.5f * kernel_buf[k] * buf[m].im;
+buf[m].im = 0.5f * kernel_buf[k] * tmp;
+}
+tmp = buf[k].re;
+buf[k].re = 0.5f * kernel_buf[k] * buf[k].im;
+buf[k].im = 0.5f * kernel_buf[k] * tmp;
+
+av_fft_permute(s->fft_ctx, buf);
+av_fft_calc(s->fft_ctx, buf);
+
+for (k = 0; k < s->rdft_len - idx->overlap_idx; k++) {
+buf[k].re += obuf[k].re;
+buf[k].im += obuf[k].im;
+}
+
+/* swapped re <-> im */
+for (k = 0; k < nsamples; k++) {
+data0[k] = buf[k].im;
+data1[k] = buf[k].re;
+}
+idx->buf_idx = !idx->buf_idx;
+idx->overlap_idx = nsamples;
+} else {
+while (nsamples > s->nsamples_max * 2) {
+fast_convolute2(s, kernel_buf, conv_buf, idx, data0, data1, 
s->nsamples_max);
+data0 += s->nsamples_max;
+data1 += s->nsamples_max;
+nsamples -= s->nsamples_max;
+}
+fast_convolute2(s, kernel_buf, conv_buf, idx, data0, data1, 
nsamples/2);
+fast_convolute2(s, kernel_buf, conv_buf, idx, data0 + nsamples/2, 
data1 + nsamples/2, ns