Re: [FFmpeg-devel] [GSoC] Motion Interpolation

2016-07-26 Thread Davinder Singh
On Wed, Jul 27, 2016 at 1:06 AM Ronald S. Bultje  wrote:

> Hi,
>
> On Tue, Jul 26, 2016 at 3:30 PM, Davinder Singh 
> wrote:
>
> > hi
> >
> > On Mon, Jul 25, 2016 at 9:55 PM Ronald S. Bultje 
> > wrote:
> >
> > > Hi,
> > >
> > > On Mon, Jul 25, 2016 at 5:39 AM, Michael Niedermayer
> > >  > > > wrote:
> > >
> > > > On Mon, Jul 25, 2016 at 04:05:54AM +, Davinder Singh wrote:
> > > > > https://github.com/dsmudhar/FFmpeg/commits/dev
> > >
> > >
> > > So, correct me if I'm wrong, but it seems the complete ME code
> currently
> > > lives inside the filter. I wonder if that is the best way forward. I
> > > thought the idea was to split out the ME code into its own module and
> > share
> > > it between various filters and the relevant encoders without a strict
> > > dependency on avfilter/avcodec, or more specifically, AVCodecContext or
> > > anything like that?
> > >
> > > Ronald
> > > ___
> > > ffmpeg-devel mailing list
> > > ffmpeg-devel@ffmpeg.org
> > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> >
> > The code is almost ready to be shared, I just didn't move that yet. That
> > makes changes difficult. mInterpolate will use those functions (which are
> > currently in mEstimate) to find true motion. My plan is to move that code
> > out of mEstimate to say, libavfilter/motion_estimation.c and can be
> shared
> > between multiple filters. Since that is general ME, I think it can be
> used
> > with encoding (with some changes). So, should I move it to libavutil
> > instead?
>
>
> I have no strong opinion on where it lives, I'd say libavcodec since we
> already have some lavfilters depending on lavcodec, but if you prefer
> lavutil that's fine also. As long as the code itself is shared in the final
> product, it's good with me.
>

Alright, I'll go with libavutil if that's okay with everyone.

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


[FFmpeg-devel] [PATCH 2/2] avformat/flvdec: parse keyframe before a\v stream was created add_keyframes_index() when stream created or keyframe parsed

2016-07-26 Thread Xinzheng Zhang
---
 libavformat/flvdec.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 633cad0..0afeba5 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -128,6 +128,7 @@ static void add_keyframes_index(AVFormatContext *s)
 
 static AVStream *create_stream(AVFormatContext *s, int codec_type)
 {
+FLVContext *flv   = s->priv_data;
 AVStream *st = avformat_new_stream(s, NULL);
 if (!st)
 return NULL;
@@ -138,6 +139,8 @@ static AVStream *create_stream(AVFormatContext *s, int 
codec_type)
 s->ctx_flags &= ~AVFMTCTX_NOHEADER;
 
 avpriv_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */
+flv->last_keyframe_stream_index = s->nb_streams - 1;
+add_keyframes_index(s);
 return st;
 }
 
@@ -413,7 +416,6 @@ static int parse_keyframes_index(AVFormatContext *s, 
AVIOContext *ioc, int64_t m
 flv->keyframe_count = timeslen;
 times = NULL;
 filepositions = NULL;
-add_keyframes_index(s);
 } else {
 invalid:
 av_log(s, AV_LOG_WARNING, "Invalid keyframes object, skipping.\n");
@@ -455,12 +457,14 @@ static int amf_parse_object(AVFormatContext *s, AVStream 
*astream,
 }
 break;
 case AMF_DATA_TYPE_OBJECT:
-if ((vstream || astream) && key &&
+if (key &&
 ioc->seekable &&
 !strcmp(KEYFRAMES_TAG, key) && depth == 1)
 if (parse_keyframes_index(s, ioc,
   max_pos) < 0)
 av_log(s, AV_LOG_ERROR, "Keyframe index parsing failed\n");
+else
+add_keyframes_index(s);
 while (avio_tell(ioc) < max_pos - 2 &&
amf_get_string(ioc, str_val, sizeof(str_val)) > 0)
 if (amf_parse_object(s, astream, vstream, str_val, max_pos,
-- 
2.6.4 (Apple Git-63)

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


[FFmpeg-devel] [PATCH 1/2] avformat/flvdec: splitting add_keyframes_index() out from parse_keyframes_index()

2016-07-26 Thread Xinzheng Zhang
---
 libavformat/flvdec.c | 76 +---
 1 file changed, 60 insertions(+), 16 deletions(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 2bf1e05..633cad0 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -61,6 +61,11 @@ typedef struct FLVContext {
 
 int broken_sizes;
 int sum_flv_tag_size;
+
+int last_keyframe_stream_index;
+int keyframe_count;
+int64_t *keyframe_times;
+int64_t *keyframe_filepositions;
 } FLVContext;
 
 static int probe(AVProbeData *p, int live)
@@ -92,6 +97,35 @@ static int live_flv_probe(AVProbeData *p)
 return probe(p, 1);
 }
 
+static void add_keyframes_index(AVFormatContext *s)
+{
+FLVContext *flv   = s->priv_data;
+AVStream *stream  = NULL;
+unsigned int i= 0;
+
+if (flv->last_keyframe_stream_index < 0) {
+av_log(s, AV_LOG_DEBUG, "keyframe stream hasn't been created\n");
+return;
+}
+
+av_assert0(flv->last_keyframe_stream_index <= s->nb_streams);
+stream = s->streams[flv->last_keyframe_stream_index];
+
+if (stream->nb_index_entries == 0) {
+for (i = 0; i < flv->keyframe_count; i++) {
+av_add_index_entry(stream, flv->keyframe_filepositions[i],
+flv->keyframe_times[i] * 1000, 0, 0, AVINDEX_KEYFRAME);
+}
+} else
+av_log(s, AV_LOG_WARNING, "Skipping duplicate index\n");
+
+if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+av_freep(>keyframe_times);
+av_freep(>keyframe_filepositions);
+flv->keyframe_count = 0;
+}
+}
+
 static AVStream *create_stream(AVFormatContext *s, int codec_type)
 {
 AVStream *st = avformat_new_stream(s, NULL);
@@ -305,8 +339,7 @@ static int amf_get_string(AVIOContext *ioc, char *buffer, 
int buffsize)
 return length;
 }
 
-static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc,
- AVStream *vstream, int64_t max_pos)
+static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, int64_t 
max_pos)
 {
 FLVContext *flv   = s->priv_data;
 unsigned int timeslen = 0, fileposlen = 0, i;
@@ -316,10 +349,12 @@ static int parse_keyframes_index(AVFormatContext *s, 
AVIOContext *ioc,
 int ret= AVERROR(ENOSYS);
 int64_t initial_pos= avio_tell(ioc);
 
-if (vstream->nb_index_entries>0) {
-av_log(s, AV_LOG_WARNING, "Skipping duplicate index\n");
+if (flv->keyframe_count > 0) {
+av_log(s, AV_LOG_DEBUG, "keyframes have been paresed\n");
 return 0;
 }
+av_assert0(!flv->keyframe_times);
+av_assert0(!flv->keyframe_filepositions);
 
 if (s->flags & AVFMT_FLAG_IGNIDX)
 return 0;
@@ -368,15 +403,17 @@ static int parse_keyframes_index(AVFormatContext *s, 
AVIOContext *ioc,
 }
 
 if (timeslen == fileposlen && fileposlen>1 && max_pos <= filepositions[0]) 
{
-for (i = 0; i < fileposlen; i++) {
-av_add_index_entry(vstream, filepositions[i], times[i] * 1000,
-   0, 0, AVINDEX_KEYFRAME);
-if (i < 2) {
-flv->validate_index[i].pos = filepositions[i];
-flv->validate_index[i].dts = times[i] * 1000;
-flv->validate_count= i + 1;
-}
+for (i = 0; i < FFMIN(2,fileposlen); i++) {
+flv->validate_index[i].pos = filepositions[i];
+flv->validate_index[i].dts = times[i] * 1000;
+flv->validate_count= i + 1;
 }
+flv->keyframe_times = times;
+flv->keyframe_filepositions = filepositions;
+flv->keyframe_count = timeslen;
+times = NULL;
+filepositions = NULL;
+add_keyframes_index(s);
 } else {
 invalid:
 av_log(s, AV_LOG_WARNING, "Invalid keyframes object, skipping.\n");
@@ -421,10 +458,9 @@ static int amf_parse_object(AVFormatContext *s, AVStream 
*astream,
 if ((vstream || astream) && key &&
 ioc->seekable &&
 !strcmp(KEYFRAMES_TAG, key) && depth == 1)
-if (parse_keyframes_index(s, ioc, vstream ? vstream : astream,
+if (parse_keyframes_index(s, ioc,
   max_pos) < 0)
 av_log(s, AV_LOG_ERROR, "Keyframe index parsing failed\n");
-
 while (avio_tell(ioc) < max_pos - 2 &&
amf_get_string(ioc, str_val, sizeof(str_val)) > 0)
 if (amf_parse_object(s, astream, vstream, str_val, max_pos,
@@ -574,6 +610,7 @@ static int amf_parse_object(AVFormatContext *s, AVStream 
*astream,
 
 static int flv_read_metabody(AVFormatContext *s, int64_t next_pos)
 {
+FLVContext *flv = s->priv_data;
 AMFDataType type;
 AVStream *stream, *astream, *vstream;
 AVStream av_unused *dstream;
@@ -612,10 +649,14 @@ static int flv_read_metabody(AVFormatContext *s, int64_t 
next_pos)
 // the lookup every time it is called.
 for (i = 0; 

Re: [FFmpeg-devel] [PATCH] avformat/matroskaenc: Write duration early during mkv_write_header (Rev #3)

2016-07-26 Thread Soft Works

> From: ffmpeg-devel  on behalf of Soft Works 
> 
> Sent: Tuesday, July 19, 2016 3:33 AM
> To: FFmpeg development discussions and patches
> Subject: [FFmpeg-devel] [PATCH] avformat/matroskaenc: Write duration early 
> during mkv_write_header (Rev #3)
> 
> From 7d6d6a7775fef707ea1e8e705acc3362f20b6b89 Mon Sep 17 00:00:00 2001
>  From: softworkz 
>  Date: Sun, 17 Jul 2016 04:19:41 +0200
>  Subject: [PATCH] avformat/matroskaenc: Write duration early during 
> mkv_write_header (Rev #3)
> 
>  Rev #2: Fixes doubled header writing, checked FATE running without errors
>  Rev #3: Fixed coding style
> 
>  This commit addresses the following scenario:
> 
>  we are using ffmpeg to transcode or remux mkv (or something else) to mkv. 
> The result is being streamed on-the-fly to an HTML5 clie> nt (> streaming 
> starts while ffmpeg is still running). The problem here is that the client is 
> unable to detect the duration because the > duration is only written to the 
> mkv at the end of > the transcoding/remoxing process. In matroskaenc.c, the 
> duration is only written>  during > mkv_write_trailer but not during 
> mkv_write_header.> 
> 
>  The approach:
> 
>  FFMPEG is currently putting quite some effort to estimate the durations of 
> source streams, but in many cases the source stream durati> ons > are still 
> left at 0 and these durations are nowhere mapped to or used for output 
> streams. As much as I would have liked to deduct o> r > estimate output 
> durations based on input stream durations - I realized that this is a hard 
> task (as Nicolas already mentioned in a > previous conversation). It would 
> involve changes to the duration ca> lculation/estimation/deduction for input 
> streams and propagating>  these > durations to output streams or the output 
> context in a correct way.> 
>  So I looked for a simple and small solution with better chances to > get 
> accepted. In webmdashenc.c I found that > a duration is writte> n > during 
> write_header and this duration is taken from the streams' me> tadata, so I 
> decided for a similar approach.> 
> 
>  And here's what it does:
> 
>  At first it is checking the duration of the AVFormatContext. In typical 
> cases th> is value is not set, but: It is set in cases where the > user has 
> specified a recording_time or an end_time via the -t or -to parameters.> 
>  Then it is looking for a DURATION metadata field in the metadata of the 
> output c> ontext (AV> FormatContext::metadata). This would only exi> st > in 
> case the user has explicitly specified a metadata DURATION value from the 
> com> mand line.> 
>  Then it is iterating all streams > looking for a "DURATION" metadata (this 
> works u> nless the > option "-map_metadata -1" has been specified) > and 
> determines the maximum value.> 
>  The precendence is as follows: 1.>  Use durat> ion of AVFormatContext - 2. 
> Use explicitly specified metadata duration value - 3. Use maximum (> mapped) 
> metadata duration over al> l streams.> 
> 

Hi, 

I wanted to kindly ask if there are any objections regarding this patch and if 
I could/should do anything else to get this merged?

Thank you very much,

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


Re: [FFmpeg-devel] [PATCH] avcodec/alsdec: implement floating point decoding

2016-07-26 Thread Umair Khan
On Tue, Jul 26, 2016 at 4:52 AM, Michael Niedermayer
 wrote:
> On Mon, Jul 25, 2016 at 10:13:38PM +0530, Umair Khan wrote:
>> On Sun, Jul 24, 2016 at 1:47 AM, Umair Khan  wrote:
>> >
>> > HI,
>> >
>> > On Fri, Jul 22, 2016 at 9:19 PM, Michael Niedermayer
>> >  wrote:
>> > > On Fri, Jul 22, 2016 at 06:22:30PM +0530, Umair Khan wrote:
>> > >> On Thu, Jul 21, 2016 at 6:18 PM, Michael Niedermayer
>> > >>  wrote:
>> > >> > On Sun, Jul 17, 2016 at 12:06:03AM +0530, Umair Khan wrote:
>> > > [...]
>> > >> >> +static int decode_string(MLZDict *dict, unsigned char *buff, int 
>> > >> >> string_code, int *first_char_code, unsigned long bufsize) {
>> > >> >> +unsigned long count, offset;
>> > >> >> +int current_code, parent_code, tmp_code;
>> > >> >> +
>> > >> >> +count= 0;
>> > >> >> +current_code = string_code;
>> > >> >> +*first_char_code = CODE_UNSET;
>> > >> >> +
>> > >> >> +while (count < bufsize) {
>> > >> >> +switch (current_code) {
>> > >> >> +case CODE_UNSET:
>> > >> >> +return count;
>> > >> >> +break;
>> > >> >> +default:
>> > >> >> +if (current_code < FIRST_CODE) {
>> > >> >> +*first_char_code = current_code;
>> > >> >> +buff[0] = current_code;
>> > >> >> +count++;
>> > >> >> +return count;
>> > >> >> +} else {
>> > >> >> +offset  = dict[current_code].match_len - 1;
>> > >> >> +tmp_code = dict[current_code].char_code;
>> > >> >> +buff[offset] = tmp_code;
>> > >> >> +count++;
>> > >> >> +}
>> > >> >> +current_code = dict[current_code].parent_code;
>> > >> >> +if ((current_code < 0) || (current_code > 
>> > >> >> (DIC_INDEX_MAX - 1))) {
>> > >> >
>> > >> >> +av_log(NULL, AV_LOG_ERROR, "MLZ dic index 
>> > >> >> error.\n");
>> > >> >
>> > >> > it would be ideal if all av_log() would have a context instead of NULL
>> > >>
>> > >> How to go ahead with this? Should I create MLZContext or something? If
>> > >> yes, could you please tell how?
>> > >
>> > > possible or you pass a void *context
>> >
>> > Updated patch.
>>
>> Another revision. Fixes some things I had overlooked.
>>
>> - Umair
>
>>  Changelog |3
>>  libavcodec/Makefile   |2
>>  libavcodec/alsdec.c   |  286 
>> +-
>>  libavcodec/mlz.c  |  173 +
>>  libavcodec/mlz.h  |   70 ++
>>  libavutil/softfloat_ieee754.h |  115 
>>  6 files changed, 646 insertions(+), 3 deletions(-)
>> 66dd916fe5b2e98b30aed21f4cf656b66c51ce1f  
>> 0001-avcodec-alsdec-implement-floating-point-decoding.patch
>> From 44567b208cf0b697a4403420bc3f7ba0cebabbc1 Mon Sep 17 00:00:00 2001
>> From: Umair Khan 
>> Date: Sun, 24 Jul 2016 00:28:55 +0530
>> Subject: [PATCH 1/1] avcodec/alsdec: implement floating point decoding
>>
>> It conforms to RM22 version of the reference codec.
>
> gcc generates these warnings:
>
> libavcodec/mlz.c: In function ‘ff_mlz_decompression’:
> libavcodec/mlz.c:152:25: warning: passing argument 1 of ‘decode_string’ from 
> incompatible pointer type [enabled by default]
> libavcodec/mlz.c:61:12: note: expected ‘struct MLZ *’ but argument is of type 
> ‘struct MLZDict *’
> libavcodec/mlz.c:153:25: warning: passing argument 1 of ‘decode_string’ from 
> incompatible pointer type [enabled by default]
> libavcodec/mlz.c:61:12: note: expected ‘struct MLZ *’ but argument is of type 
> ‘struct MLZDict *’
> libavcodec/mlz.c:157:25: warning: passing argument 1 of ‘decode_string’ from 
> incompatible pointer type [enabled by default]

Fixed.

> [...]
>> +
>> +/** Read and decode the floating point sample data
>> + */
>> +static int read_diff_float_data(ALSDecContext *ctx, unsigned int ra_frame) {
>> +AVCodecContext *avctx   = ctx->avctx;
>> +GetBitContext *gb   = >gb;
>> +SoftFloat_IEEE754 *acf  = ctx->acf;
>> +int *shift_value= ctx->shift_value;
>> +int *last_shift_value   = ctx->last_shift_value;
>> +int *last_acf_mantissa  = ctx->last_acf_mantissa;
>> +int **raw_mantissa  = ctx->raw_mantissa;
>> +int *nbits  = ctx->nbits;
>> +unsigned char *larray   = ctx->larray;
>> +int frame_length= ctx->cur_frame_length;
>> +SoftFloat_IEEE754 scale = av_int2sf_ieee754(0x1u, 23);
>> +unsigned int partA_flag;
>> +unsigned int highest_byte;
>> +unsigned int shift_amp;
>> +uint32_t tmp_32;
>> +int use_acf;
>> +int nchars;
>> +int i;
>> +int c;
>> +long k;
>> +long nbits_aligned;
>> +unsigned long acc;
>> +unsigned long j;
>> +uint32_t sign;
>> +uint32_t e;
>> +uint32_t mantissa;
>> +
>> +

Re: [FFmpeg-devel] [PATCH] avformat/fivdec: cached keyframes before video or audio stream was created

2016-07-26 Thread XinZheng Zhang
On Wed, Jul 27, 2016 at 10:17 AM, Michael Niedermayer
 wrote:
> On Wed, Jul 27, 2016 at 09:56:02AM +0800, XinZheng Zhang wrote:
>> On Wed, Jul 27, 2016 at 7:25 AM, Michael Niedermayer
>>  wrote:
>> > On Wed, Jul 27, 2016 at 01:31:29AM +0800, XinZheng Zhang wrote:
>> >> On Wed, Jul 27, 2016 at 1:12 AM, Michael Niedermayer
>> >>  wrote:
>> >> > On Tue, Jul 26, 2016 at 08:17:46PM +0800, Xinzheng Zhang wrote:
>> > [...]
>> >> >> +
>> >> >> +AVStream *streams[2] = {vstream, astream};
>> >> >> +for (i = 0; i < 2; i++) {
>> >> >> +current_stream = streams[i];
>> >> >> +if (current_stream && current_stream->nb_index_entries==0) {
>> >> >> +for (j = 0; j < flv->keyframe_count; j++) {
>> >> >> +av_add_index_entry(current_stream, 
>> >> >> flv->keyframe_filepositions[j], flv->keyframe_times[j] * 1000,
>> >> >> +   0, 0, AVINDEX_KEYFRAME);
>> >> >> +}
>> >> >> +}
>> >> >> +}
>> >> >> +
>> >> >> +// free keyframe index only if all expected streams have been 
>> >> >> created
>> >> >> +if (((vstream && vstream->nb_index_entries>0) || 
>> >> >> !flv->vhead_exists) &&
>> >> >> +((astream && astream->nb_index_entries>0) || 
>> >> >> !flv->ahead_exists)) {
>> >> >> +av_freep(>keyframe_times);
>> >> >> +av_freep(>keyframe_filepositions);
>> >> >> +flv->keyframe_count = 0;
>> >> >> +}
>> >> >> +}
>> >> >
>> >> > spliting add_keyframes_index() out must be in a seperate patch
>> >> >
>> >> > also i would not trust the *head_exists flags, IIRC they can be
>> >> > wrong and they are not needed
>> >> > the function should just take the table load it with
>> >> > av_add_index_entry() and free the table.
>> >> > The rest should not be needed
>> >> > should be much simpler unless iam missing something
>> >> >
>> >> >
>> >>
>> >> If I don't trust the head_exists flags, when should I free the index 
>> >> table?
>> >> Should I keep the index util both a\v stream have been loaded or keep
>> >> it util the flv_read_close().
>> >
>> > the table was freed after av_add_index_entry()
>> > that should still work fine unless i miss somethig
>> >
>>
>> [meta]-[v]-[v]..[a]
>> In this case both video and audio stream share the same index table.
>> I am not know whether the audio stream exists until the first audio
>> packet parsed.
>> I thought that I should keep the index until all the streams have been 
>> loaded.
>
> in the example above the video key frame table would be loaded
> and added into the video stream once it has been created, and
> freed afterwards
> nothing is done with audio (currently or after the change)
>
> if the audio table is prior the video one its loaded and freed once
> the video table is encountered
>
> do i miss something ?
>

Now I understand it.
Before that I thought that both streams have to install the index table.

> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> There will always be a question for which you do not know the correct answer.
>
> ___
> 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/fivdec: cached keyframes before video or audio stream was created

2016-07-26 Thread Michael Niedermayer
On Wed, Jul 27, 2016 at 09:56:02AM +0800, XinZheng Zhang wrote:
> On Wed, Jul 27, 2016 at 7:25 AM, Michael Niedermayer
>  wrote:
> > On Wed, Jul 27, 2016 at 01:31:29AM +0800, XinZheng Zhang wrote:
> >> On Wed, Jul 27, 2016 at 1:12 AM, Michael Niedermayer
> >>  wrote:
> >> > On Tue, Jul 26, 2016 at 08:17:46PM +0800, Xinzheng Zhang wrote:
> > [...]
> >> >> +
> >> >> +AVStream *streams[2] = {vstream, astream};
> >> >> +for (i = 0; i < 2; i++) {
> >> >> +current_stream = streams[i];
> >> >> +if (current_stream && current_stream->nb_index_entries==0) {
> >> >> +for (j = 0; j < flv->keyframe_count; j++) {
> >> >> +av_add_index_entry(current_stream, 
> >> >> flv->keyframe_filepositions[j], flv->keyframe_times[j] * 1000,
> >> >> +   0, 0, AVINDEX_KEYFRAME);
> >> >> +}
> >> >> +}
> >> >> +}
> >> >> +
> >> >> +// free keyframe index only if all expected streams have been 
> >> >> created
> >> >> +if (((vstream && vstream->nb_index_entries>0) || 
> >> >> !flv->vhead_exists) &&
> >> >> +((astream && astream->nb_index_entries>0) || 
> >> >> !flv->ahead_exists)) {
> >> >> +av_freep(>keyframe_times);
> >> >> +av_freep(>keyframe_filepositions);
> >> >> +flv->keyframe_count = 0;
> >> >> +}
> >> >> +}
> >> >
> >> > spliting add_keyframes_index() out must be in a seperate patch
> >> >
> >> > also i would not trust the *head_exists flags, IIRC they can be
> >> > wrong and they are not needed
> >> > the function should just take the table load it with
> >> > av_add_index_entry() and free the table.
> >> > The rest should not be needed
> >> > should be much simpler unless iam missing something
> >> >
> >> >
> >>
> >> If I don't trust the head_exists flags, when should I free the index table?
> >> Should I keep the index util both a\v stream have been loaded or keep
> >> it util the flv_read_close().
> >
> > the table was freed after av_add_index_entry()
> > that should still work fine unless i miss somethig
> >
> 
> [meta]-[v]-[v]..[a]
> In this case both video and audio stream share the same index table.
> I am not know whether the audio stream exists until the first audio
> packet parsed.
> I thought that I should keep the index until all the streams have been loaded.

in the example above the video key frame table would be loaded
and added into the video stream once it has been created, and
freed afterwards
nothing is done with audio (currently or after the change)

if the audio table is prior the video one its loaded and freed once
the video table is encountered

do i miss something ?

[...]
-- 
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] avformat/fivdec: cached keyframes before video or audio stream was created

2016-07-26 Thread XinZheng Zhang
On Wed, Jul 27, 2016 at 7:25 AM, Michael Niedermayer
 wrote:
> On Wed, Jul 27, 2016 at 01:31:29AM +0800, XinZheng Zhang wrote:
>> On Wed, Jul 27, 2016 at 1:12 AM, Michael Niedermayer
>>  wrote:
>> > On Tue, Jul 26, 2016 at 08:17:46PM +0800, Xinzheng Zhang wrote:
> [...]
>> >> +
>> >> +AVStream *streams[2] = {vstream, astream};
>> >> +for (i = 0; i < 2; i++) {
>> >> +current_stream = streams[i];
>> >> +if (current_stream && current_stream->nb_index_entries==0) {
>> >> +for (j = 0; j < flv->keyframe_count; j++) {
>> >> +av_add_index_entry(current_stream, 
>> >> flv->keyframe_filepositions[j], flv->keyframe_times[j] * 1000,
>> >> +   0, 0, AVINDEX_KEYFRAME);
>> >> +}
>> >> +}
>> >> +}
>> >> +
>> >> +// free keyframe index only if all expected streams have been created
>> >> +if (((vstream && vstream->nb_index_entries>0) || !flv->vhead_exists) 
>> >> &&
>> >> +((astream && astream->nb_index_entries>0) || 
>> >> !flv->ahead_exists)) {
>> >> +av_freep(>keyframe_times);
>> >> +av_freep(>keyframe_filepositions);
>> >> +flv->keyframe_count = 0;
>> >> +}
>> >> +}
>> >
>> > spliting add_keyframes_index() out must be in a seperate patch
>> >
>> > also i would not trust the *head_exists flags, IIRC they can be
>> > wrong and they are not needed
>> > the function should just take the table load it with
>> > av_add_index_entry() and free the table.
>> > The rest should not be needed
>> > should be much simpler unless iam missing something
>> >
>> >
>>
>> If I don't trust the head_exists flags, when should I free the index table?
>> Should I keep the index util both a\v stream have been loaded or keep
>> it util the flv_read_close().
>
> the table was freed after av_add_index_entry()
> that should still work fine unless i miss somethig
>

[meta]-[v]-[v]..[a]
In this case both video and audio stream share the same index table.
I am not know whether the audio stream exists until the first audio
packet parsed.
I thought that I should keep the index until all the streams have been loaded.

> some cleanup code at close might be needed to catch error conditions
> so theres never a memleak
>
> [...]
> --
> 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
>
> ___
> 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/fivdec: cached keyframes before video or audio stream was created

2016-07-26 Thread Michael Niedermayer
On Tue, Jul 26, 2016 at 08:17:46PM +0800, Xinzheng Zhang wrote:
> ---
>  libavformat/flvdec.c | 84 
> ++--
>  1 file changed, 69 insertions(+), 15 deletions(-)

also: someone please fix the spelling in the commit message:

"avformat/fivdec: cached keyframes before video or audio stream was created"

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

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


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/fivdec: cached keyframes before video or audio stream was created

2016-07-26 Thread Michael Niedermayer
On Wed, Jul 27, 2016 at 01:31:29AM +0800, XinZheng Zhang wrote:
> On Wed, Jul 27, 2016 at 1:12 AM, Michael Niedermayer
>  wrote:
> > On Tue, Jul 26, 2016 at 08:17:46PM +0800, Xinzheng Zhang wrote:
[...]
> >> +
> >> +AVStream *streams[2] = {vstream, astream};
> >> +for (i = 0; i < 2; i++) {
> >> +current_stream = streams[i];
> >> +if (current_stream && current_stream->nb_index_entries==0) {
> >> +for (j = 0; j < flv->keyframe_count; j++) {
> >> +av_add_index_entry(current_stream, 
> >> flv->keyframe_filepositions[j], flv->keyframe_times[j] * 1000,
> >> +   0, 0, AVINDEX_KEYFRAME);
> >> +}
> >> +}
> >> +}
> >> +
> >> +// free keyframe index only if all expected streams have been created
> >> +if (((vstream && vstream->nb_index_entries>0) || !flv->vhead_exists) 
> >> &&
> >> +((astream && astream->nb_index_entries>0) || !flv->ahead_exists)) 
> >> {
> >> +av_freep(>keyframe_times);
> >> +av_freep(>keyframe_filepositions);
> >> +flv->keyframe_count = 0;
> >> +}
> >> +}
> >
> > spliting add_keyframes_index() out must be in a seperate patch
> >
> > also i would not trust the *head_exists flags, IIRC they can be
> > wrong and they are not needed
> > the function should just take the table load it with
> > av_add_index_entry() and free the table.
> > The rest should not be needed
> > should be much simpler unless iam missing something
> >
> >
> 
> If I don't trust the head_exists flags, when should I free the index table?
> Should I keep the index util both a\v stream have been loaded or keep
> it util the flv_read_close().

the table was freed after av_add_index_entry()
that should still work fine unless i miss somethig

some cleanup code at close might be needed to catch error conditions
so theres never a memleak

[...]
-- 
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] avformat/utils: Fix find_stream_info not considering the extradata it found

2016-07-26 Thread Michael Niedermayer
On Tue, Jul 26, 2016 at 08:39:03PM +0300, Anssi Hannula wrote:
> 26.07.2016, 17:59, Michael Niedermayer kirjoitti:
> > On Tue, Jul 26, 2016 at 03:56:13PM +0300, Anssi Hannula wrote:
> >> Commit 9200514ad8717c6 ("lavf: replace AVStream.codec with
> >> AVStream.codecpar") merged in commit 6f69f7a8bf6a0d01 changed
> >> avformat_find_stream_info() to put the extradata it got from
> >> st->parser->parser->split() to st->internal->avctx instead of st->codec
> >> (from where it will be later copied to st->codecpar).
> >>
> >> However, in the same function, the "is stream ready?" check was changed
> >> to check for extradata in st->codecpar instead of st->codec.
> >>
> >> Extradata retrieved from split() is therefore not considered anymore,
> >> and avformat_find_stream_info() will therefore needlessly continue
> >> probing in some cases.
> >>
> >> Fix that by checking for the extradata at st->internal->avctx where it
> >> is actually put.
> >>
> >> ---
> >>
> >> Michael Niedermayer wrote:
> >>> seems to break fate here:
> >> [...]
> >>
> >> Oops, seems I messed up running fate and missed the "warning: only a
> >> subset of the fate tests will be run because SAMPLES is not specified"
> >> warning it gave... Thanks for catching that.
> >>
> >> Seems this reverse fix is actually needed, as extradata is actually
> >> copied in the other direction (from st->internal->avctx to
> >> st->codecpar).
> > 
> > it seems this causes some changes, quite possibly thats simply due to
> > less packets being read
> > 
> > libavformat/tests/seek 
> > Matrix.Reloaded.Trailer-640x346-XviD-1.0beta2-HE_AAC_subtitled.mkv 
> > -duration 400
> > with 
> > http://samples.ffmpeg.org/Matroska/matrix/Matrix.Reloaded.Trailer-640x346-XviD-1.0beta2-HE_AAC_subtitled.mkv
> 
> @@ -9,7 +9,7 @@
>  ret: 0 st:13 flags:1 dts: 86.75 pts: 86.75 pos: -1
> size: 50436
>  ret:-1 st: 1 flags:0  ts: 250.577000
>  ret: 0 st: 1 flags:1  ts: 13.471000
> -ret: 0 st:13 flags:1 dts: 5.909000 pts: 5.909000 pos: -1
> size: 50436
> +ret: 0 st:13 flags:1 dts: 1.776000 pts: 1.776000 pos: -1
> size: 50436
>  ret:-1 st: 2 flags:0  ts: 176.365000
>  ret: 0 st: 2 flags:1  ts: 339.259000
>  ret: 0 st:13 flags:1 dts: 145.08 pts: 145.08 pos:
> -1 size: 50436
> 
> Seems to indeed be due to less packets being read in
> avformat_find_stream_info().
> 
> Matroska demuxer seems to add keyframes to the index as it encounters
> them, and in this case more keyframes are encountered in
> avformat_stream_info() phase, which seems to result in more accurate
> seeking in the early seconds of the file.
> 
> > for tickets//2254/ttvHD_vlc_sample.ts the tbr changes from
> > 1001/3 to 1/30
> 
> Looks like the timestamps are jittery in that sample:
> 
> 36072.231911, dts = prev + 3002
> 36072.265289, dts = prev + 3004
> 36072.298656, dts = prev + 3003
> 36072.331433, dts = prev + 2950
> 36072.364800, dts = prev + 3003
> 36072.398167, dts = prev + 3003
> 36072.431533, dts = prev + 3003
> 36072.464900, dts = prev + 3003
> 36072.498267, dts = prev + 3003
> 36072.531633, dts = prev + 3003
> 36072.565000, dts = prev + 3003
> 36072.598367, dts = prev + 3003
> 36072.630667, dts = prev + 2907
> 36072.664033, dts = prev + 3003
> 36072.697400, dts = prev + 3003
> 36072.730767, dts = prev + 3003
> 36072.764133, dts = prev + 3003
> 36072.797500, dts = prev + 3003
> 36072.830867, dts = prev + 3003
> 36072.864233, dts = prev + 3003
> 36072.897600, dts = prev + 3003
> 36072.939278, dts = prev + 3751
> 36072.972644, dts = prev + 3003
> 36073.006011, dts = prev + 3003
> 36073.034478, dts = prev + 2562
> 36073.067844, dts = prev + 3003
> 
> And this throws the ff_rfps_calculate() algorithm off unless it is
> called with fpsprobesize (fps_analyze_framecount) of 160 or more
> (default is 20).
> 
> Not sure if something could/should be done to keep tbr of that file to
> be detected as 1001/3000.
> 
> 
> For both of these cases I verified that FFmpeg 3.0 had the same behavior
> as with this patch, i.e. their behavior was unintendedly changed by the
> original commit 6f69f7a8bf6a0d01.

thanks alot for the deep analysis
i have no objections to the change


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad


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


Re: [FFmpeg-devel] [PATCH] ffprobe.xsd: add missing timecode attribute to frameSideDataType

2016-07-26 Thread Michael Niedermayer
On Tue, Jun 07, 2016 at 07:58:10PM -0400, Dave Rice wrote:
> A timecode attribute was added to the ffprobe output of side_data. This patch 
> updates the XSD to include the attribute as well.
> Dave Rice
> 

>  ffprobe.xsd |1 +
>  1 file changed, 1 insertion(+)
> dbc571dacd2fbb68dd1ac830b5ce5357100f9fef  
> 0001-ffprobe.xsd-add-missing-timecode-attribute-to-frameS.patch
> From b980b08ca8d4816fa3259302c31d71ccd079c283 Mon Sep 17 00:00:00 2001
> From: dericed 
> Date: Tue, 7 Jun 2016 19:53:40 -0400
> Subject: [PATCH] ffprobe.xsd: add missing timecode attribute to
>  frameSideDataType

applied

thanks

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad


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


Re: [FFmpeg-devel] [PATCH 2/2] libopenh264: Support building with the 1.6 release

2016-07-26 Thread Michael Niedermayer
On Tue, Jul 26, 2016 at 09:31:18PM +0300, Martin Storsjö wrote:
> This fixes trac issue #5417.
> 
> This is cherry-picked from libav commit
> d825b1a5306576dcd0553b7d0d24a3a46ad92864.
> ---
> Updated the commit message to mention the ticket number.
> ---
>  libavcodec/libopenh264dec.c |  2 ++
>  libavcodec/libopenh264enc.c | 26 --
>  2 files changed, 26 insertions(+), 2 deletions(-)

LGTM

thanks

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

The real ebay dictionary, page 3
"Rare item" - "Common item with rare defect or maybe just a lie"
"Professional" - "'Toy' made in china, not functional except as doorstop"
"Experts will know" - "The seller hopes you are not an expert"


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


Re: [FFmpeg-devel] [PATCH 1/2] Add an OpenH264 decoder wrapper

2016-07-26 Thread Michael Niedermayer
On Tue, Jul 26, 2016 at 09:31:17PM +0300, Martin Storsjö wrote:
> This is cherrypicked from libav, from commits
> 82b7525173f20702a8cbc26ebedbf4b69b8fecec and
> d0b1e6049b06ca146ece4d2f199c5dba1565.
> 
> ---
> Fixed the issues pointed out by Michael, removed the parts of the
> commit message as requested by Carl.
> ---
>  Changelog   |   1 +
>  configure   |   2 +
>  doc/general.texi|   9 +-
>  libavcodec/Makefile |   3 +-
>  libavcodec/allcodecs.c  |   2 +-
>  libavcodec/libopenh264.c|  62 +++
>  libavcodec/libopenh264.h|  39 +++
>  libavcodec/libopenh264dec.c | 243 
> 
>  libavcodec/libopenh264enc.c |  48 ++---
>  libavcodec/version.h|   2 +-
>  10 files changed, 366 insertions(+), 45 deletions(-)
>  create mode 100644 libavcodec/libopenh264.c
>  create mode 100644 libavcodec/libopenh264.h
>  create mode 100644 libavcodec/libopenh264dec.c

LGTM, please push, unless someone else has more comments

thanks

[...]
-- 
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] [GSoC] Motion Interpolation

2016-07-26 Thread Ronald S. Bultje
Hi,

On Tue, Jul 26, 2016 at 3:30 PM, Davinder Singh  wrote:

> hi
>
> On Mon, Jul 25, 2016 at 9:55 PM Ronald S. Bultje 
> wrote:
>
> > Hi,
> >
> > On Mon, Jul 25, 2016 at 5:39 AM, Michael Niedermayer
> >  > > wrote:
> >
> > > On Mon, Jul 25, 2016 at 04:05:54AM +, Davinder Singh wrote:
> > > > https://github.com/dsmudhar/FFmpeg/commits/dev
> >
> >
> > So, correct me if I'm wrong, but it seems the complete ME code currently
> > lives inside the filter. I wonder if that is the best way forward. I
> > thought the idea was to split out the ME code into its own module and
> share
> > it between various filters and the relevant encoders without a strict
> > dependency on avfilter/avcodec, or more specifically, AVCodecContext or
> > anything like that?
> >
> > Ronald
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
> The code is almost ready to be shared, I just didn't move that yet. That
> makes changes difficult. mInterpolate will use those functions (which are
> currently in mEstimate) to find true motion. My plan is to move that code
> out of mEstimate to say, libavfilter/motion_estimation.c and can be shared
> between multiple filters. Since that is general ME, I think it can be used
> with encoding (with some changes). So, should I move it to libavutil
> instead?


I have no strong opinion on where it lives, I'd say libavcodec since we
already have some lavfilters depending on lavcodec, but if you prefer
lavutil that's fine also. As long as the code itself is shared in the final
product, it's good with me.

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


Re: [FFmpeg-devel] [GSoC] Motion Interpolation

2016-07-26 Thread Davinder Singh
hi

On Mon, Jul 25, 2016 at 9:55 PM Ronald S. Bultje  wrote:

> Hi,
>
> On Mon, Jul 25, 2016 at 5:39 AM, Michael Niedermayer
>  > wrote:
>
> > On Mon, Jul 25, 2016 at 04:05:54AM +, Davinder Singh wrote:
> > > https://github.com/dsmudhar/FFmpeg/commits/dev
>
>
> So, correct me if I'm wrong, but it seems the complete ME code currently
> lives inside the filter. I wonder if that is the best way forward. I
> thought the idea was to split out the ME code into its own module and share
> it between various filters and the relevant encoders without a strict
> dependency on avfilter/avcodec, or more specifically, AVCodecContext or
> anything like that?
>
> Ronald
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


The code is almost ready to be shared, I just didn't move that yet. That
makes changes difficult. mInterpolate will use those functions (which are
currently in mEstimate) to find true motion. My plan is to move that code
out of mEstimate to say, libavfilter/motion_estimation.c and can be shared
between multiple filters. Since that is general ME, I think it can be used
with encoding (with some changes). So, should I move it to libavutil
instead?


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


Re: [FFmpeg-devel] [PATCH 1/2] v2 SCTE extraction from mpegts

2016-07-26 Thread Carlos Fernandez Sanz
On Mon, Jul 25, 2016 at 5:41 PM, Michael Niedermayer
 wrote:

> This breaks 
> http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket1827/vc1_dts_mplayerAudioProblem_sb41_cut.m2ts


I need some help with this. HDMV audio is not detected correctly,
since we are giving priority to ISO based stream_type

817 mpegts_find_stream_type(st, pes->stream_type, ISO_types);
818 if (pes->stream_type == 4)
819 st->request_probe = 50;
820 if ((prog_reg_desc == AV_RL32("HDMV") ||
821  prog_reg_desc == AV_RL32("HDPR")) &&
822 st->codecpar->codec_id == AV_CODEC_ID_NONE) {
823 mpegts_find_stream_type(st, pes->stream_type, HDMV_types);

In the code above we are first giving priority to ISO_types, if ffmpeg
does not find any matching stream_type in ISO_types then it goes for
HDMV standard.

Possible solutions:
a) Give more priority to HDMV and HDPR then ISO_type,
b) Remove SCTE_35 codec id from ISO_type and put in MISC type

a) Is correct according to the standard but there must be some reason
for ISO_type being placed before HDMV.
Thoughts?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] libavformat/matroskadec: fix unsigned overflow to improve seeking

2016-07-26 Thread Chris Cunningham
Happy to make a test. Stand by for patch.

On Sat, Jul 23, 2016 at 2:26 AM, Michael Niedermayer  wrote:

> On Thu, Jul 21, 2016 at 12:01:45PM -0700, Chris Cunningham wrote:
> > When seeking a file where codec delay is greater than 0, the timecode
> > can become negative after offsetting by the codec delay. Failing to cast
> > to a signed int64 will cause the check against skip_to_timecode to
> evaluate
> > true for these negative values. This breaks the "skip_to" seek mechanism.
> > ---
> >  libavformat/matroskadec.c | 5 -
> >  1 file changed, 4 insertions(+), 1 deletion(-)
>
> applied
>
> can you create a fate testcase for this ?
> (maybe libavformat/tests/seek.c could be used)
>
> i can upload the sample file to the fate-samples
>
> Thanks
>
> [...]
> --
> 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
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/2] libopenh264: Support building with the 1.6 release

2016-07-26 Thread Martin Storsjö
This fixes trac issue #5417.

This is cherry-picked from libav commit
d825b1a5306576dcd0553b7d0d24a3a46ad92864.
---
Updated the commit message to mention the ticket number.
---
 libavcodec/libopenh264dec.c |  2 ++
 libavcodec/libopenh264enc.c | 26 --
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/libavcodec/libopenh264dec.c b/libavcodec/libopenh264dec.c
index f642082..6af60af 100644
--- a/libavcodec/libopenh264dec.c
+++ b/libavcodec/libopenh264dec.c
@@ -90,7 +90,9 @@ static av_cold int svc_decode_init(AVCodecContext *avctx)
 (*s->decoder)->SetOption(s->decoder, DECODER_OPTION_TRACE_CALLBACK, (void 
*)_function);
 (*s->decoder)->SetOption(s->decoder, 
DECODER_OPTION_TRACE_CALLBACK_CONTEXT, (void *));
 
+#if !OPENH264_VER_AT_LEAST(1, 6)
 param.eOutputColorFormat = videoFormatI420;
+#endif
 param.eEcActiveIdc   = ERROR_CON_DISABLE;
 param.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
 
diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index d27fc41..07af31d 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -33,6 +33,10 @@
 #include "internal.h"
 #include "libopenh264.h"
 
+#if !OPENH264_VER_AT_LEAST(1, 6)
+#define SM_SIZELIMITED_SLICE SM_DYN_SLICE
+#endif
+
 typedef struct SVCContext {
 const AVClass *av_class;
 ISVCEncoder *encoder;
@@ -48,11 +52,20 @@ typedef struct SVCContext {
 #define OFFSET(x) offsetof(SVCContext, x)
 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
+#if OPENH264_VER_AT_LEAST(1, 6)
+{ "slice_mode", "set slice mode", OFFSET(slice_mode), AV_OPT_TYPE_INT, { 
.i64 = SM_FIXEDSLCNUM_SLICE }, SM_SINGLE_SLICE, SM_RESERVED, VE, "slice_mode" },
+#else
 { "slice_mode", "set slice mode", OFFSET(slice_mode), AV_OPT_TYPE_INT, { 
.i64 = SM_AUTO_SLICE }, SM_SINGLE_SLICE, SM_RESERVED, VE, "slice_mode" },
+#endif
 { "fixed", "a fixed number of slices", 0, AV_OPT_TYPE_CONST, { .i64 = 
SM_FIXEDSLCNUM_SLICE }, 0, 0, VE, "slice_mode" },
+#if OPENH264_VER_AT_LEAST(1, 6)
+{ "dyn", "Size limited (compatibility name)", 0, AV_OPT_TYPE_CONST, { 
.i64 = SM_SIZELIMITED_SLICE }, 0, 0, VE, "slice_mode" },
+{ "sizelimited", "Size limited", 0, AV_OPT_TYPE_CONST, { .i64 = 
SM_SIZELIMITED_SLICE }, 0, 0, VE, "slice_mode" },
+#else
 { "rowmb", "one slice per row of macroblocks", 0, AV_OPT_TYPE_CONST, { 
.i64 = SM_ROWMB_SLICE }, 0, 0, VE, "slice_mode" },
 { "auto", "automatic number of slices according to number of threads", 
0, AV_OPT_TYPE_CONST, { .i64 = SM_AUTO_SLICE }, 0, 0, VE, "slice_mode" },
 { "dyn", "Dynamic slicing", 0, AV_OPT_TYPE_CONST, { .i64 = 
SM_DYN_SLICE }, 0, 0, VE, "slice_mode" },
+#endif
 { "loopfilter", "enable loop filter", OFFSET(loopfilter), AV_OPT_TYPE_INT, 
{ .i64 = 1 }, 0, 1, VE },
 { "profile", "set profile restrictions", OFFSET(profile), 
AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VE },
 { "max_nal_size", "set maximum NAL size in bytes", OFFSET(max_nal_size), 
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
@@ -159,15 +172,24 @@ FF_ENABLE_DEPRECATION_WARNINGS
 s->slice_mode = SM_FIXEDSLCNUM_SLICE;
 
 if (s->max_nal_size)
-s->slice_mode = SM_DYN_SLICE;
+s->slice_mode = SM_SIZELIMITED_SLICE;
 
+#if OPENH264_VER_AT_LEAST(1, 6)
+param.sSpatialLayers[0].sSliceArgument.uiSliceMode = s->slice_mode;
+param.sSpatialLayers[0].sSliceArgument.uiSliceNum  = avctx->slices;
+#else
 param.sSpatialLayers[0].sSliceCfg.uiSliceMode   = 
s->slice_mode;
 param.sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceNum = 
avctx->slices;
+#endif
 
-if (s->slice_mode == SM_DYN_SLICE) {
+if (s->slice_mode == SM_SIZELIMITED_SLICE) {
 if (s->max_nal_size){
 param.uiMaxNalSize = s->max_nal_size;
+#if OPENH264_VER_AT_LEAST(1, 6)
+param.sSpatialLayers[0].sSliceArgument.uiSliceSizeConstraint = 
s->max_nal_size;
+#else
 
param.sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 
s->max_nal_size;
+#endif
 } else {
 av_log(avctx, AV_LOG_ERROR, "Invalid -max_nal_size, "
"specify a valid max_nal_size to use -slice_mode dyn\n");
-- 
2.7.4 (Apple Git-66)

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


[FFmpeg-devel] [PATCH 1/2] Add an OpenH264 decoder wrapper

2016-07-26 Thread Martin Storsjö
This is cherrypicked from libav, from commits
82b7525173f20702a8cbc26ebedbf4b69b8fecec and
d0b1e6049b06ca146ece4d2f199c5dba1565.

---
Fixed the issues pointed out by Michael, removed the parts of the
commit message as requested by Carl.
---
 Changelog   |   1 +
 configure   |   2 +
 doc/general.texi|   9 +-
 libavcodec/Makefile |   3 +-
 libavcodec/allcodecs.c  |   2 +-
 libavcodec/libopenh264.c|  62 +++
 libavcodec/libopenh264.h|  39 +++
 libavcodec/libopenh264dec.c | 243 
 libavcodec/libopenh264enc.c |  48 ++---
 libavcodec/version.h|   2 +-
 10 files changed, 366 insertions(+), 45 deletions(-)
 create mode 100644 libavcodec/libopenh264.c
 create mode 100644 libavcodec/libopenh264.h
 create mode 100644 libavcodec/libopenh264dec.c

diff --git a/Changelog b/Changelog
index 479f164..7f536db 100644
--- a/Changelog
+++ b/Changelog
@@ -10,6 +10,7 @@ version :
 - curves filter doesn't automatically insert points at x=0 and x=1 anymore
 - 16-bit support in curves filter
 - 16-bit support in selectivecolor filter
+- OpenH264 decoder wrapper
 
 
 version 3.1:
diff --git a/configure b/configure
index 1b41303..9f5b31f 100755
--- a/configure
+++ b/configure
@@ -2771,6 +2771,8 @@ libopencore_amrnb_decoder_deps="libopencore_amrnb"
 libopencore_amrnb_encoder_deps="libopencore_amrnb"
 libopencore_amrnb_encoder_select="audio_frame_queue"
 libopencore_amrwb_decoder_deps="libopencore_amrwb"
+libopenh264_decoder_deps="libopenh264"
+libopenh264_decoder_select="h264_mp4toannexb_bsf"
 libopenh264_encoder_deps="libopenh264"
 libopenjpeg_decoder_deps="libopenjpeg"
 libopenjpeg_encoder_deps="libopenjpeg"
diff --git a/doc/general.texi b/doc/general.texi
index 7823dc1..6b5975c 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -103,12 +103,19 @@ enable it.
 
 @section OpenH264
 
-FFmpeg can make use of the OpenH264 library for H.264 encoding.
+FFmpeg can make use of the OpenH264 library for H.264 encoding and decoding.
 
 Go to @url{http://www.openh264.org/} and follow the instructions for
 installing the library. Then pass @code{--enable-libopenh264} to configure to
 enable it.
 
+For decoding, this library is much more limited than the built-in decoder
+in libavcodec; currently, this library lacks support for decoding B-frames
+and some other main/high profile features. (It currently only supports
+constrained baseline profile and CABAC.) Using it is mostly useful for
+testing and for taking advantage of Cisco's patent portfolio license
+(@url{http://www.openh264.org/BINARY_LICENSE.txt}).
+
 @section x264
 
 FFmpeg can make use of the x264 library for H.264 encoding.
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index a548e02..3def3ad 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -868,7 +868,8 @@ OBJS-$(CONFIG_LIBMP3LAME_ENCODER) += libmp3lame.o 
mpegaudiodata.o mpegau
 OBJS-$(CONFIG_LIBOPENCORE_AMRNB_DECODER)  += libopencore-amr.o
 OBJS-$(CONFIG_LIBOPENCORE_AMRNB_ENCODER)  += libopencore-amr.o
 OBJS-$(CONFIG_LIBOPENCORE_AMRWB_DECODER)  += libopencore-amr.o
-OBJS-$(CONFIG_LIBOPENH264_ENCODER)+= libopenh264enc.o
+OBJS-$(CONFIG_LIBOPENH264_DECODER)+= libopenh264dec.o libopenh264.o
+OBJS-$(CONFIG_LIBOPENH264_ENCODER)+= libopenh264enc.o libopenh264.o
 OBJS-$(CONFIG_LIBOPENJPEG_DECODER)+= libopenjpegdec.o
 OBJS-$(CONFIG_LIBOPENJPEG_ENCODER)+= libopenjpegenc.o
 OBJS-$(CONFIG_LIBOPUS_DECODER)+= libopusdec.o libopus.o \
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 951e199..a1ae61f 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -623,7 +623,7 @@ void avcodec_register_all(void)
 
 /* external libraries, that shouldn't be used by default if one of the
  * above is available */
-REGISTER_ENCODER(LIBOPENH264,   libopenh264);
+REGISTER_ENCDEC (LIBOPENH264,   libopenh264);
 REGISTER_DECODER(H264_CUVID,h264_cuvid);
 REGISTER_ENCODER(H264_NVENC,h264_nvenc);
 REGISTER_ENCODER(H264_OMX,  h264_omx);
diff --git a/libavcodec/libopenh264.c b/libavcodec/libopenh264.c
new file mode 100644
index 000..59c61a3
--- /dev/null
+++ b/libavcodec/libopenh264.c
@@ -0,0 +1,62 @@
+/*
+ * OpenH264 shared utils
+ * Copyright (C) 2014 Martin Storsjo
+ *
+ * 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 

Re: [FFmpeg-devel] [PATCH] libavformat/matroskaenc: omit segment UID for webm

2016-07-26 Thread James Almer
On 7/26/2016 2:47 PM, Michael Bradshaw wrote:
> Could this patch please be reapplied? It seems like it was accidentally
> reverted in commit 5d48e4eafa6c4559683892b8638d10508125f3cf

Done. I wonder how a merge did that to begin with.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] ffmpeg stuck in transcoding H264 using QSV

2016-07-26 Thread Chao Liu
On Tue, Jul 26, 2016 at 2:08 AM, Ivan Uskov  wrote:

>
> Hello Chao,
>
> Tuesday, July 26, 2016, 9:04:49 AM, you wrote:
>
> > I tried to debug it a bit by comparing ffmpeg code with intel media SDK.
> > There is sth. I don't understand. Not sure whether it's related..
> > In ffmpeg, we decode the frame in a loop
> > ,
> it
> > sleeps and retries as long as MFXVideoDECODE_DecodeFrameAsync returns
> busy.
> > In intel media SDK sample_decode, it calls SyncOperation when
> > MFXVideoDECODE_DecodeFrameAsync returns busy.
>
> > Could this be the cause?
> The documentation for MFXVideoDECODE_DecodeFrameAsync says:
> =
> MFX_WRN_DEVICE_BUSY
> Hardware device is currently busy. Call this function again in a few
> milliseconds.
> =
> So if documented way does not work it looks like we have issue inside SDK.
> But I will try to double check sample_decode code.
>
> By the way, what is your platform? Linux? Do you use a patched kernel
> recommended by Intel for specific sdk version?
>
You are right. It seems to be caused by the kernel.
It works well on Intel's golden CentOS 7.1 (3.10.0-229 with patches)
The same code and environment doesn't work on Ubuntu 16.04 (4.4.0)
I'll ask help on Intel forum. Thanks.

>
>
> --
> Best regards,
>  Ivanmailto:ivan.us...@nablet.com
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] libavformat/matroskaenc: omit segment UID for webm

2016-07-26 Thread Michael Bradshaw
Could this patch please be reapplied? It seems like it was accidentally
reverted in commit 5d48e4eafa6c4559683892b8638d10508125f3cf
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/utils: Fix find_stream_info not considering the extradata it found

2016-07-26 Thread Anssi Hannula
26.07.2016, 17:59, Michael Niedermayer kirjoitti:
> On Tue, Jul 26, 2016 at 03:56:13PM +0300, Anssi Hannula wrote:
>> Commit 9200514ad8717c6 ("lavf: replace AVStream.codec with
>> AVStream.codecpar") merged in commit 6f69f7a8bf6a0d01 changed
>> avformat_find_stream_info() to put the extradata it got from
>> st->parser->parser->split() to st->internal->avctx instead of st->codec
>> (from where it will be later copied to st->codecpar).
>>
>> However, in the same function, the "is stream ready?" check was changed
>> to check for extradata in st->codecpar instead of st->codec.
>>
>> Extradata retrieved from split() is therefore not considered anymore,
>> and avformat_find_stream_info() will therefore needlessly continue
>> probing in some cases.
>>
>> Fix that by checking for the extradata at st->internal->avctx where it
>> is actually put.
>>
>> ---
>>
>> Michael Niedermayer wrote:
>>> seems to break fate here:
>> [...]
>>
>> Oops, seems I messed up running fate and missed the "warning: only a
>> subset of the fate tests will be run because SAMPLES is not specified"
>> warning it gave... Thanks for catching that.
>>
>> Seems this reverse fix is actually needed, as extradata is actually
>> copied in the other direction (from st->internal->avctx to
>> st->codecpar).
> 
> it seems this causes some changes, quite possibly thats simply due to
> less packets being read
> 
> libavformat/tests/seek 
> Matrix.Reloaded.Trailer-640x346-XviD-1.0beta2-HE_AAC_subtitled.mkv -duration 
> 400
> with 
> http://samples.ffmpeg.org/Matroska/matrix/Matrix.Reloaded.Trailer-640x346-XviD-1.0beta2-HE_AAC_subtitled.mkv

@@ -9,7 +9,7 @@
 ret: 0 st:13 flags:1 dts: 86.75 pts: 86.75 pos: -1
size: 50436
 ret:-1 st: 1 flags:0  ts: 250.577000
 ret: 0 st: 1 flags:1  ts: 13.471000
-ret: 0 st:13 flags:1 dts: 5.909000 pts: 5.909000 pos: -1
size: 50436
+ret: 0 st:13 flags:1 dts: 1.776000 pts: 1.776000 pos: -1
size: 50436
 ret:-1 st: 2 flags:0  ts: 176.365000
 ret: 0 st: 2 flags:1  ts: 339.259000
 ret: 0 st:13 flags:1 dts: 145.08 pts: 145.08 pos:
-1 size: 50436

Seems to indeed be due to less packets being read in
avformat_find_stream_info().

Matroska demuxer seems to add keyframes to the index as it encounters
them, and in this case more keyframes are encountered in
avformat_stream_info() phase, which seems to result in more accurate
seeking in the early seconds of the file.

> for tickets//2254/ttvHD_vlc_sample.ts the tbr changes from
> 1001/3 to 1/30

Looks like the timestamps are jittery in that sample:

36072.231911, dts = prev + 3002
36072.265289, dts = prev + 3004
36072.298656, dts = prev + 3003
36072.331433, dts = prev + 2950
36072.364800, dts = prev + 3003
36072.398167, dts = prev + 3003
36072.431533, dts = prev + 3003
36072.464900, dts = prev + 3003
36072.498267, dts = prev + 3003
36072.531633, dts = prev + 3003
36072.565000, dts = prev + 3003
36072.598367, dts = prev + 3003
36072.630667, dts = prev + 2907
36072.664033, dts = prev + 3003
36072.697400, dts = prev + 3003
36072.730767, dts = prev + 3003
36072.764133, dts = prev + 3003
36072.797500, dts = prev + 3003
36072.830867, dts = prev + 3003
36072.864233, dts = prev + 3003
36072.897600, dts = prev + 3003
36072.939278, dts = prev + 3751
36072.972644, dts = prev + 3003
36073.006011, dts = prev + 3003
36073.034478, dts = prev + 2562
36073.067844, dts = prev + 3003

And this throws the ff_rfps_calculate() algorithm off unless it is
called with fpsprobesize (fps_analyze_framecount) of 160 or more
(default is 20).

Not sure if something could/should be done to keep tbr of that file to
be detected as 1001/3000.


For both of these cases I verified that FFmpeg 3.0 had the same behavior
as with this patch, i.e. their behavior was unintendedly changed by the
original commit 6f69f7a8bf6a0d01.


> are these in intended / expected ?
> 
> I can confirm that this reduces the amount of data read in many files


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


[FFmpeg-devel] [PATCH] avformat/matroskaenc: fix Voids with size < 10

2016-07-26 Thread Michael Bradshaw
Hi,

Attached patch fixes the MKV muxer when trying to write Void elements that
have a size < 10. The current code subtracts 1 from the size, which
accounts for the element ID byte, but it doesn't account for the additional
size byte. This causes the Void element to take up 1 more byte than
intended, which will corrupt the file.

A simple example to reproduce the issue:

$ ffmpeg -f lavfi -i testsrc -vframes 1 -reserve_index_space 38 test.webm
$ mkvinfo test.webm
[...]
test.webm: Error in the Matroska file structure at position 479. Resyncing
to the next level 1 element.
Resync failed: no valid Matroska level 1 element found.


0001-avformat-matroskaenc-fix-Voids-with-size-10.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/fivdec: cached keyframes before video or audio stream was created

2016-07-26 Thread XinZheng Zhang
On Wed, Jul 27, 2016 at 1:12 AM, Michael Niedermayer
 wrote:
> On Tue, Jul 26, 2016 at 08:17:46PM +0800, Xinzheng Zhang wrote:
>> ---
>>  libavformat/flvdec.c | 84 
>> ++--
>>  1 file changed, 69 insertions(+), 15 deletions(-)
>>
>> diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
>> index 2bf1e05..82b9f83 100644
>> --- a/libavformat/flvdec.c
>> +++ b/libavformat/flvdec.c
>> @@ -61,6 +61,12 @@ typedef struct FLVContext {
>>
>>  int broken_sizes;
>>  int sum_flv_tag_size;
>> +
>> +int vhead_exists;
>> +int ahead_exists;
>> +int keyframe_count;
>> +int64_t *keyframe_times;
>> +int64_t *keyframe_filepositions;
>>  } FLVContext;
>>
>>  static int probe(AVProbeData *p, int live)
>> @@ -92,6 +98,42 @@ static int live_flv_probe(AVProbeData *p)
>>  return probe(p, 1);
>>  }
>>
>> +static void add_keyframes_index(AVFormatContext *s)
>> +{
>> +FLVContext *flv   = s->priv_data;
>> +AVStream *current_stream  = NULL;
>> +AVStream *vstream = NULL;
>> +AVStream *astream = NULL;
>> +unsigned int i,j;
>> +
>> +for (i = 0; i< s->nb_streams; i++) {
>> +if (s->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
>> +vstream = s->streams[i];
>> +} else if (s->streams[i]->codecpar->codec_type == 
>> AVMEDIA_TYPE_AUDIO) {
>> +astream = s->streams[i];
>> +}
>> +}
>
> this shouldt be needed
> just keep track of the stram index that the table belongs to
> that is add a flv->keyframe_stream_index
>
>
ok

>> +
>> +AVStream *streams[2] = {vstream, astream};
>> +for (i = 0; i < 2; i++) {
>> +current_stream = streams[i];
>> +if (current_stream && current_stream->nb_index_entries==0) {
>> +for (j = 0; j < flv->keyframe_count; j++) {
>> +av_add_index_entry(current_stream, 
>> flv->keyframe_filepositions[j], flv->keyframe_times[j] * 1000,
>> +   0, 0, AVINDEX_KEYFRAME);
>> +}
>> +}
>> +}
>> +
>> +// free keyframe index only if all expected streams have been created
>> +if (((vstream && vstream->nb_index_entries>0) || !flv->vhead_exists) &&
>> +((astream && astream->nb_index_entries>0) || !flv->ahead_exists)) {
>> +av_freep(>keyframe_times);
>> +av_freep(>keyframe_filepositions);
>> +flv->keyframe_count = 0;
>> +}
>> +}
>
> spliting add_keyframes_index() out must be in a seperate patch
>
> also i would not trust the *head_exists flags, IIRC they can be
> wrong and they are not needed
> the function should just take the table load it with
> av_add_index_entry() and free the table.
> The rest should not be needed
> should be much simpler unless iam missing something
>
>

If I don't trust the head_exists flags, when should I free the index table?
Should I keep the index util both a\v stream have been loaded or keep
it util the flv_read_close().

> [...]
>> @@ -305,8 +348,7 @@ static int amf_get_string(AVIOContext *ioc, char 
>> *buffer, int buffsize)
>>  return length;
>>  }
>>
>> -static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc,
>> - AVStream *vstream, int64_t max_pos)
>> +static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, 
>> int64_t max_pos)
>>  {
>>  FLVContext *flv   = s->priv_data;
>>  unsigned int timeslen = 0, fileposlen = 0, i;
>> @@ -316,7 +358,7 @@ static int parse_keyframes_index(AVFormatContext *s, 
>> AVIOContext *ioc,
>>  int ret= AVERROR(ENOSYS);
>>  int64_t initial_pos= avio_tell(ioc);
>>
>> -if (vstream->nb_index_entries>0) {
>> +if (flv->keyframe_count > 0) {
>>  av_log(s, AV_LOG_WARNING, "Skipping duplicate index\n");
>>  return 0;
>>  }
>
> this looks wrong, a file can contain an index for each stream
> that shouldnt trigger a warning, only if there are 2 for the same
> stream its a duplicate
>
>
ok

> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> What does censorship reveal? It reveals fear. -- Julian Assange
>
> ___
> 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] ffprobe missing string in code

2016-07-26 Thread Michael Niedermayer
On Fri, Jul 22, 2016 at 08:52:00AM +0300, Dmitry Vagin wrote:
> Hi Michael,
> 
> sorry for my mistake, updated patch in attachment.

applied

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Those who are best at talking, realize last or never when they are wrong.


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/fivdec: cached keyframes before video or audio stream was created

2016-07-26 Thread Michael Niedermayer
On Tue, Jul 26, 2016 at 08:17:46PM +0800, Xinzheng Zhang wrote:
> ---
>  libavformat/flvdec.c | 84 
> ++--
>  1 file changed, 69 insertions(+), 15 deletions(-)
> 
> diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
> index 2bf1e05..82b9f83 100644
> --- a/libavformat/flvdec.c
> +++ b/libavformat/flvdec.c
> @@ -61,6 +61,12 @@ typedef struct FLVContext {
>  
>  int broken_sizes;
>  int sum_flv_tag_size;
> +
> +int vhead_exists;
> +int ahead_exists;
> +int keyframe_count;
> +int64_t *keyframe_times;
> +int64_t *keyframe_filepositions;
>  } FLVContext;
>  
>  static int probe(AVProbeData *p, int live)
> @@ -92,6 +98,42 @@ static int live_flv_probe(AVProbeData *p)
>  return probe(p, 1);
>  }
>  
> +static void add_keyframes_index(AVFormatContext *s)
> +{
> +FLVContext *flv   = s->priv_data;
> +AVStream *current_stream  = NULL;
> +AVStream *vstream = NULL;
> +AVStream *astream = NULL;
> +unsigned int i,j;
> +
> +for (i = 0; i< s->nb_streams; i++) {
> +if (s->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
> +vstream = s->streams[i];
> +} else if (s->streams[i]->codecpar->codec_type == 
> AVMEDIA_TYPE_AUDIO) {
> +astream = s->streams[i];
> +}
> +}

this shouldt be needed
just keep track of the stram index that the table belongs to
that is add a flv->keyframe_stream_index


> +
> +AVStream *streams[2] = {vstream, astream};
> +for (i = 0; i < 2; i++) {
> +current_stream = streams[i];
> +if (current_stream && current_stream->nb_index_entries==0) {
> +for (j = 0; j < flv->keyframe_count; j++) {
> +av_add_index_entry(current_stream, 
> flv->keyframe_filepositions[j], flv->keyframe_times[j] * 1000,
> +   0, 0, AVINDEX_KEYFRAME);
> +}
> +}
> +}
> +
> +// free keyframe index only if all expected streams have been created
> +if (((vstream && vstream->nb_index_entries>0) || !flv->vhead_exists) &&
> +((astream && astream->nb_index_entries>0) || !flv->ahead_exists)) {
> +av_freep(>keyframe_times);
> +av_freep(>keyframe_filepositions);
> +flv->keyframe_count = 0;
> +}
> +}

spliting add_keyframes_index() out must be in a seperate patch

also i would not trust the *head_exists flags, IIRC they can be
wrong and they are not needed
the function should just take the table load it with
av_add_index_entry() and free the table.
The rest should not be needed
should be much simpler unless iam missing something


[...]
> @@ -305,8 +348,7 @@ static int amf_get_string(AVIOContext *ioc, char *buffer, 
> int buffsize)
>  return length;
>  }
>  
> -static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc,
> - AVStream *vstream, int64_t max_pos)
> +static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, 
> int64_t max_pos)
>  {
>  FLVContext *flv   = s->priv_data;
>  unsigned int timeslen = 0, fileposlen = 0, i;
> @@ -316,7 +358,7 @@ static int parse_keyframes_index(AVFormatContext *s, 
> AVIOContext *ioc,
>  int ret= AVERROR(ENOSYS);
>  int64_t initial_pos= avio_tell(ioc);
>  
> -if (vstream->nb_index_entries>0) {
> +if (flv->keyframe_count > 0) {
>  av_log(s, AV_LOG_WARNING, "Skipping duplicate index\n");
>  return 0;
>  }

this looks wrong, a file can contain an index for each stream
that shouldnt trigger a warning, only if there are 2 for the same
stream its a duplicate


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

What does censorship reveal? It reveals fear. -- Julian Assange


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


Re: [FFmpeg-devel] [PATCH 1/4] lavc: add mpeg4 mediacodec decoder

2016-07-26 Thread Thomas Volkert
On 26.07.2016 11:15, Matthieu Bouron wrote:
> On Tue, Jul 26, 2016 at 11:00:46AM +0200, Matthieu Bouron wrote:
>> On Sun, Jul 24, 2016 at 03:06:14PM +0200, Thomas Volkert wrote:
>>> From: Thomas Volkert 
>>>
>>> ---
>>>  Changelog|   1 +
>>>  configure|   1 +
>>>  libavcodec/Makefile  |   1 +
>>>  libavcodec/allcodecs.c   |   1 +
>>>  libavcodec/mediacodecdec_mpeg4.c | 239 
>>> +++
>>>  libavcodec/version.h |   2 +-
>>>  6 files changed, 244 insertions(+), 1 deletion(-)
>>>  create mode 100644 libavcodec/mediacodecdec_mpeg4.c
>>>
>>> diff --git a/Changelog b/Changelog
>>> index 2bd18ec..b8bbdb9 100644
>>> --- a/Changelog
>>> +++ b/Changelog
>>> @@ -7,6 +7,7 @@ version :
>>>  - Changed metadata print option to accept general urls
>>>  - Alias muxer for Ogg Video (.ogv)
>>>  - VP8 in Ogg muxing
>>> +- MediaCodec MPEG-4 decoding
>>>  
>>>  
>>>  version 3.1:
>>> diff --git a/configure b/configure
>>> index 1b41303..9004b06 100755
>>> --- a/configure
>>> +++ b/configure
>>> @@ -2621,6 +2621,7 @@ mpeg2_videotoolbox_hwaccel_select="mpeg2video_decoder"
>>>  mpeg2_xvmc_hwaccel_deps="xvmc"
>>>  mpeg2_xvmc_hwaccel_select="mpeg2video_decoder"
>>>  mpeg4_crystalhd_decoder_select="crystalhd"
>>> +mpeg4_mediacodec_decoder_deps="mediacodec"
>>>  mpeg4_mmal_decoder_deps="mmal"
>>>  mpeg4_mmal_decoder_select="mmal"
>>>  mpeg4_mmal_hwaccel_deps="mmal"
>>> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
>>> index abef19e..642cf2a 100644
>>> --- a/libavcodec/Makefile
>>> +++ b/libavcodec/Makefile
>>> @@ -317,6 +317,7 @@ OBJS-$(CONFIG_H264_DECODER)+= h264.o 
>>> h264_cabac.o h264_cavlc.o \
>>>h2645_parse.o
>>>  OBJS-$(CONFIG_H264_CUVID_DECODER)  += cuvid.o
>>>  OBJS-$(CONFIG_H264_MEDIACODEC_DECODER) += mediacodecdec_h264.o
>>> +OBJS-$(CONFIG_MPEG4_MEDIACODEC_DECODER) += mediacodecdec_mpeg4.o
>>>  OBJS-$(CONFIG_H264_MMAL_DECODER)   += mmaldec.o
>>>  OBJS-$(CONFIG_H264_NVENC_ENCODER)  += nvenc_h264.o
>>>  OBJS-$(CONFIG_NVENC_ENCODER)   += nvenc_h264.o
>>> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
>>> index 951e199..2d98694 100644
>>> --- a/libavcodec/allcodecs.c
>>> +++ b/libavcodec/allcodecs.c
>>> @@ -239,6 +239,7 @@ void avcodec_register_all(void)
>>>  REGISTER_ENCDEC (MPEG2VIDEO,mpeg2video);
>>>  REGISTER_ENCDEC (MPEG4, mpeg4);
>>>  REGISTER_DECODER(MPEG4_CRYSTALHD,   mpeg4_crystalhd);
>>> +REGISTER_DECODER(MPEG4_MEDIACODEC,  mpeg4_mediacodec);
>>>  REGISTER_DECODER(MPEG4_MMAL,mpeg4_mmal);
>> You should also add the relevant hwaccel entry in this file:
>>
>> +REGISTER_HWACCEL(MPEG4_MEDIACODEC,  mpeg4_mediacodec);
>>
>> and declare the hwaccel at the bottom of libavcodec/mediacodecdec.c, like 
>> the h264 one.
>>
>>>  #if FF_API_VDPAU
>>>  REGISTER_DECODER(MPEG4_VDPAU,   mpeg4_vdpau);
>>> diff --git a/libavcodec/mediacodecdec_mpeg4.c 
>>> b/libavcodec/mediacodecdec_mpeg4.c
>>> new file mode 100644
>>> index 000..7c4559b
>>> --- /dev/null
>>> +++ b/libavcodec/mediacodecdec_mpeg4.c
>>> @@ -0,0 +1,239 @@
>>> +/*
>>> + * Android MediaCodec MPEG 4 decoder
>>> + *
>>> + * Copyright (c) 2016 Thomas Volkert 
>>> + *
>>> + * 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 "libavutil/avassert.h"
>>> +#include "libavutil/common.h"
>>> +#include "libavutil/fifo.h"
>>> +
>>> +#include "avcodec.h"
>>> +#include "internal.h"
>>> +#include "mediacodecdec.h"
>>> +#include "mediacodec_wrapper.h"
>>> +
>>> +#define CODEC_MIME "video/mp4v-es"
>>> +
>>> +typedef struct MediaCodecMPEG4DecContext {
>>> +
>>> +MediaCodecDecContext *ctx;
>>> +
>>> +AVBSFContext *bsf;
>>> +
>>> +AVFifoBuffer *fifo;
>>> +
>>> +AVPacket filtered_pkt;
>>> +
>>> +} MediaCodecMPEG4DecContext;
>>> +
>>> +static av_cold int mediacodec_decode_close(AVCodecContext *avctx)
>>> +{
>>> +MediaCodecMPEG4DecContext *s = avctx->priv_data;
>>> +
>>> +ff_mediacodec_dec_close(avctx, s->ctx);
>>> +s->ctx = NULL;
>>> +
>>> +av_fifo_free(s->fifo);
>>> 

Re: [FFmpeg-devel] [PATCH 1/2] Add an OpenH264 decoder wrapper

2016-07-26 Thread Michael Niedermayer
On Tue, Jul 26, 2016 at 03:41:52PM +0300, Martin Storsjö wrote:
[...]

> +static int svc_decode_frame(AVCodecContext *avctx, void *data,
> +int *got_frame, AVPacket *avpkt)
> +{
> +SVCContext *s = avctx->priv_data;
> +SBufferInfo info = { 0 };
> +uint8_t* ptrs[3];
> +int linesize[3];
> +AVFrame *avframe = data;
> +int ret;
> +DECODING_STATE state;
> +
> +if ((ret = init_bsf(avctx)) < 0)
> +return ret;
> +
> +if (avpkt->size) {
> +AVPacket input_ref = { 0 };
> +if (av_fifo_space(s->packet_fifo) < sizeof(input_ref)) {
> +ret = av_fifo_realloc2(s->packet_fifo,
> +   av_fifo_size(s->packet_fifo) + 
> sizeof(input_ref));
> +if (ret < 0)
> +return ret;
> +}
> +
> +ret = av_packet_ref(_ref, avpkt);
> +if (ret < 0)
> +return ret;
> +av_fifo_generic_write(s->packet_fifo, _ref, sizeof(input_ref), 
> NULL);
> +}
> +
> +while (!*got_frame) {
> +/* prepare the input data -- convert to Annex B if needed */
> +if (s->pkt_filtered.size <= 0) {
> +AVPacket input_ref;
> +
> +/* no more data */
> +if (av_fifo_size(s->packet_fifo) < sizeof(AVPacket))
> +return avpkt->size ? avpkt->size : 0;
> +
> +av_packet_unref(>pkt_filtered);
> +
> +av_fifo_generic_read(s->packet_fifo, _ref, 
> sizeof(input_ref), NULL);
> +ret = av_bsf_send_packet(s->bsf, _ref);
> +if (ret < 0) {
> +av_packet_unref(_ref);
> +return ret;
> +}
> +
> +ret = av_bsf_receive_packet(s->bsf, >pkt_filtered);
> +if (ret < 0)
> +av_packet_move_ref(>pkt_filtered, _ref);
> +else
> +av_packet_unref(_ref);
> +}
> +
> +state = (*s->decoder)->DecodeFrame2(s->decoder, 
> s->pkt_filtered.data, s->pkt_filtered.size, ptrs, );
> +s->pkt_filtered.size = 0;
> +if (state != dsErrorFree) {
> +av_log(avctx, AV_LOG_ERROR, "DecodeFrame2 failed\n");
> +return AVERROR_UNKNOWN;
> +}
> +if (info.iBufferStatus != 1) {
> +av_log(avctx, AV_LOG_DEBUG, "No frame produced\n");
> +continue;
> +}
> +

> +ff_set_dimensions(avctx, info.UsrData.sSystemBuffer.iWidth, 
> info.UsrData.sSystemBuffer.iHeight);

The return code should be checked
(its checked in all other cases in our codebase except some "0,0"
 calls IIRC)


> +// The decoder doesn't (currently) support decoding into a user
> +// provided buffer, so do a copy instead.
> +if (ff_get_buffer(avctx, avframe, 0) < 0) {
> +av_log(avctx, AV_LOG_ERROR, "Unable to allocate buffer\n");
> +return AVERROR(ENOMEM);
> +}
> +
> +linesize[0] = info.UsrData.sSystemBuffer.iStride[0];
> +linesize[1] = linesize[2] = info.UsrData.sSystemBuffer.iStride[1];
> +av_image_copy(avframe->data, avframe->linesize, (const uint8_t **) 
> ptrs, linesize, avctx->pix_fmt, avctx->width, avctx->height);
> +
> +avframe->pts = s->pkt_filtered.pts;
> +avframe->pkt_dts = s->pkt_filtered.dts;

> +#if FF_API_PKT_PTS
> +FF_DISABLE_DEPRECATION_WARNINGS
> +avframe->pkt_pts = s->pkt_filtered.pts;
> +FF_ENABLE_DEPRECATION_WARNINGS
> +#endif

this produces a warning:
libavcodec/libopenh264dec.c:222:5: warning: "FF_API_PKT_PTS" is not defined 
[-Wundef]

thanks

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

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


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


Re: [FFmpeg-devel] [PATCH] avformat/utils: Fix find_stream_info not considering the extradata it found

2016-07-26 Thread Michael Niedermayer
On Tue, Jul 26, 2016 at 03:56:13PM +0300, Anssi Hannula wrote:
> Commit 9200514ad8717c6 ("lavf: replace AVStream.codec with
> AVStream.codecpar") merged in commit 6f69f7a8bf6a0d01 changed
> avformat_find_stream_info() to put the extradata it got from
> st->parser->parser->split() to st->internal->avctx instead of st->codec
> (from where it will be later copied to st->codecpar).
> 
> However, in the same function, the "is stream ready?" check was changed
> to check for extradata in st->codecpar instead of st->codec.
> 
> Extradata retrieved from split() is therefore not considered anymore,
> and avformat_find_stream_info() will therefore needlessly continue
> probing in some cases.
> 
> Fix that by checking for the extradata at st->internal->avctx where it
> is actually put.
> 
> ---
> 
> Michael Niedermayer wrote:
> > seems to break fate here:
> [...]
> 
> Oops, seems I messed up running fate and missed the "warning: only a
> subset of the fate tests will be run because SAMPLES is not specified"
> warning it gave... Thanks for catching that.
> 
> Seems this reverse fix is actually needed, as extradata is actually
> copied in the other direction (from st->internal->avctx to
> st->codecpar).

it seems this causes some changes, quite possibly thats simply due to
less packets being read

libavformat/tests/seek 
Matrix.Reloaded.Trailer-640x346-XviD-1.0beta2-HE_AAC_subtitled.mkv -duration 400
with 
http://samples.ffmpeg.org/Matroska/matrix/Matrix.Reloaded.Trailer-640x346-XviD-1.0beta2-HE_AAC_subtitled.mkv

for tickets//2254/ttvHD_vlc_sample.ts the tbr changes from
1001/3 to 1/30

are these in intended / expected ?

I can confirm that this reduces the amount of data read in many files

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

Democracy is the form of government in which you can choose your dictator


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


Re: [FFmpeg-devel] [PATCH 1/2] Add an OpenH264 decoder wrapper

2016-07-26 Thread Carl Eugen Hoyos
compn  mi.rr.com> writes:

> > > one could potentially want to use it to take advantage
> > > of the cisco patent license offer.
> > 
> > I am not sure I understand this, could you elaborate?
> > In any case, this should imo not be part of the commit 
> > message.
> 
> http://www.openh264.org/faq.html
> 
> https://github.com/cisco/openh264

How are these links related to FFmpeg development?

Carl Eugen

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


Re: [FFmpeg-devel] [PATCH 1/2] Add an OpenH264 decoder wrapper

2016-07-26 Thread compn
On Tue, 26 Jul 2016 14:06:57 + (UTC)
Carl Eugen Hoyos  wrote:

> > one could potentially want to use it to take advantage
> > of the cisco patent license offer.
> 
> I am not sure I understand this, could you elaborate?
> In any case, this should imo not be part of the commit 
> message.

http://www.openh264.org/faq.html

https://github.com/cisco/openh264

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


Re: [FFmpeg-devel] [PATCH 2/2] libopenh264: Support building with the 1.6 release

2016-07-26 Thread Carl Eugen Hoyos
Martin Storsjö  martin.st> writes:

> This is cherry-picked from libav commit
> d825b1a5306576dcd0553b7d0d24a3a46ad92864.

Please mention ticket #5417 in the commit message, 
push if it works for you, this was requested often.

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


Re: [FFmpeg-devel] [PATCH 0/1] af_hdcd: Process stereo channels together, fix #5727

2016-07-26 Thread Carl Eugen Hoyos
Burt P  gmail.com> writes:

> For review, a fix for #5727. Please test and comment.

My suggestion is that you send your public key to 
Michael and commit yourself including adding yourself 
as maintainer of hdcd.

[...]

> One strange case is John Mellencamp - [1994] Mr. Happy Go Lucky
> 06. Emotional Love, where there is one extra HDCD packet in one
> channel, and that target_gain value ends up being ignored.

Is this a regression against the code in current git head?
Or just a (possibly) unsolved issue?

> This patch is against master, so it also includes the changes in an
> earlier (not yet applied) patch set for HDCD detection, PE mode,
> cdt counter, and code comments.

Please split the patches as much as it makes sense.

Carl Eugen

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


Re: [FFmpeg-devel] [PATCH 1/2] Add an OpenH264 decoder wrapper

2016-07-26 Thread Carl Eugen Hoyos
Hi!

Martin Storsjö  martin.st> writes:

> While it is less featureful (and slower) than the 
> built-in H264 decoder,

I don't think this is an issue, having an additional 
decoder can make testing issues much easier.

> one could potentially want to use it to take advantage
> of the cisco patent license offer.

I am not sure I understand this, could you elaborate?
In any case, this should imo not be part of the commit 
message.

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


Re: [FFmpeg-devel] avio starting offset and hls regression in 3.1

2016-07-26 Thread Anssi Hannula
25.07.2016, 22:13, Anssi Hannula kirjoitti:
> Hi all,
> 
> Commit d0fc5de3a643fe7f974ed14e410c2ac2f4147d7e [1] merged in
> commit 81306fd4bdeb5c17d4db771e4fec684773b5790f "hls: eliminate ffurl_*
> usage" from libav, which changed the hls demuxer to use AVIOContext
> instead of URLContext for its HTTP requests.
> 
> HLS demuxer uses the "offset" option for the http demuxer, requesting
> the initial file offset for the I/O (http URLProtocol uses the "Range:"
> HTTP header to try to accommodate that).
> 
> However, the code in libavformat/aviobuf.c seems to be doing its own
> accounting for the current file offset (AVIOContext.pos), with the
> assumption that the initial offset is always zero.
> 
> HLS demuxer does an explicit seek after open_url to account for cases
> where the "offset" was not effective (due to the URL being a local file
> or the HTTP server not obeying it), which should be a no-op in case the
> file offset is already at that position.
> 
> However, since aviobuf.c code thinks the starting offset is 0, this
> doesn't work properly.
> 
> E.g. this command, which worked fine in FFmpeg 3.0, now fails after
> approx. 10 seconds of playback:
> ffplay
> https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8
> 
> 
> Now, what should be done to fix this regression?
> 
> I guess there are at least these options:
> 
> 1. Make aviobuf.c call seek() to check the offset after open:
> 
> --- a/libavformat/aviobuf.c
> +++ b/libavformat/aviobuf.c
> @@ -913,6 +913,14 @@ int ffio_fdopen(AVIOContext **s, URLContext *h)
>  (*s)->read_pause = io_read_pause;
>  (*s)->read_seek  = io_read_seek;
>  }
> +
> +/* get initial buffer position (may be non-zero with e.g. offset
> option for http) */
> +if ((*s)->seek) {
> +int64_t pos = (*s)->seek((*s)->opaque, 0, SEEK_CUR);
> +if (pos >= 0)
> +(*s)->pos = pos;
> +}
> +
>  (*s)->av_class = _avio_class;
>  return 0;
>  fail:
> 
> I guess that has a high chance of further regressions (*if* it is even
> correct), though, as I guess there may be seek() handlers that don't
> have SEEK_CUR = 0 as a no-op.
> 
> 2. Revert the commit. I'm not familiar enough (or I've just forgotten
> that stuff) with avio/ffurl to know how big the benefit of using avio_
> instead of ffurl_ is, though...
> 
> 3. Drop the seek call from HLS demuxer in case protocol is http*, and
> assume the HTTP server obeyed the ranged request.

After thinking about it a bit, I think I'll go with this 3rd one to fix
the regression, unless a better idea surfaces.

It is quite trivial to implement, and server obeying ranged requests is
mandatory anyway in HLS specs when byte-ranged segments are used - the
failure mode in the non-spec-compliant will just be a bit different.

> 
> Any other ideas / opinions for the course of action?
> 
> 
> [1] https://github.com/FFmpeg/FFmpeg/commit/d0fc5de3a643fe7f974ed14
> 


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


Re: [FFmpeg-devel] libavcodec : add psd image file decoder

2016-07-26 Thread Martin Vignali
Sorry, forgot one out of array issue in the previous patch

Correct patch in attach

Martin
From 99c60ace42f29b681fc8e5729f4b0081a204cfe5 Mon Sep 17 00:00:00 2001
From: Martin Vignali 
Date: Tue, 26 Jul 2016 15:05:57 +0200
Subject: [PATCH 1/2] libavformat : add Photoshop PSD file.

---
 libavformat/Makefile |  1 +
 libavformat/allformats.c |  1 +
 libavformat/img2dec.c| 33 +
 3 files changed, 35 insertions(+)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index c49f9de..a79ca8f 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -234,6 +234,7 @@ OBJS-$(CONFIG_IMAGE_PGM_PIPE_DEMUXER) += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_PICTOR_PIPE_DEMUXER)  += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_PNG_PIPE_DEMUXER) += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_PPM_PIPE_DEMUXER) += img2dec.o img2.o
+OBJS-$(CONFIG_IMAGE_PSD_PIPE_DEMUXER) += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_QDRAW_PIPE_DEMUXER)   += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_SGI_PIPE_DEMUXER) += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER) += img2dec.o img2.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index d490cc4..3d631e1 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -364,6 +364,7 @@ void av_register_all(void)
 REGISTER_DEMUXER (IMAGE_PICTOR_PIPE, image_pictor_pipe);
 REGISTER_DEMUXER (IMAGE_PNG_PIPE,image_png_pipe);
 REGISTER_DEMUXER (IMAGE_PPM_PIPE,image_ppm_pipe);
+REGISTER_DEMUXER (IMAGE_PSD_PIPE,image_psd_pipe);
 REGISTER_DEMUXER (IMAGE_QDRAW_PIPE,  image_qdraw_pipe);
 REGISTER_DEMUXER (IMAGE_SGI_PIPE,image_sgi_pipe);
 REGISTER_DEMUXER (IMAGE_SUNRAST_PIPE,image_sunrast_pipe);
diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 9d6796f..c23f379 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -821,6 +821,38 @@ static int png_probe(AVProbeData *p)
 return 0;
 }
 
+static int psd_probe(AVProbeData *p)
+{
+const uint8_t *b = p->buf;
+int ret = 0;
+uint16_t color_mode;
+
+if (AV_RL32(b) == MKTAG('8','B','P','S')) {
+ret += 1;
+} else {
+return 0;
+}
+
+if ((b[4] == 0) && (b[5] == 1)) {/* version 1 is PSD, version 2 is PSB */
+ret += 1;
+} else {
+return 0;
+}
+
+if ((AV_RL32(b+6) == 0) && (AV_RL16(b+10) == 0))/* reserved must be 0 */
+ret += 1;
+if (p->buf_size >= 26) {
+color_mode = AV_RB16(b+24);
+if ((color_mode <= 9) && (color_mode != 5) && (color_mode != 6))
+ret += 1;
+}
+
+if (ret)
+return AVPROBE_SCORE_EXTENSION + ret;
+
+return 0;
+}
+
 static int sgi_probe(AVProbeData *p)
 {
 const uint8_t *b = p->buf;
@@ -946,6 +978,7 @@ IMAGEAUTO_DEMUXER(pgmyuv,  AV_CODEC_ID_PGMYUV)
 IMAGEAUTO_DEMUXER(pictor,  AV_CODEC_ID_PICTOR)
 IMAGEAUTO_DEMUXER(png, AV_CODEC_ID_PNG)
 IMAGEAUTO_DEMUXER(ppm, AV_CODEC_ID_PPM)
+IMAGEAUTO_DEMUXER(psd, AV_CODEC_ID_PSD)
 IMAGEAUTO_DEMUXER(qdraw,   AV_CODEC_ID_QDRAW)
 IMAGEAUTO_DEMUXER(sgi, AV_CODEC_ID_SGI)
 IMAGEAUTO_DEMUXER(sunrast, AV_CODEC_ID_SUNRAST)
-- 
1.9.3 (Apple Git-50)

From df3cfa66fa71e512125526c226c1629f00949409 Mon Sep 17 00:00:00 2001
From: Martin Vignali 
Date: Tue, 26 Jul 2016 15:06:10 +0200
Subject: [PATCH 2/2] libavcodec : add decoder for Photoshop PSD image file.

Decode the Image Data Section (who contain merge picture).
Support RGB/A and Grayscale/A in 8bits and 16 bits by channel.
Support uncompress and rle compression in Image Data Section.
---
 Changelog  |   1 +
 doc/general.texi   |   2 +
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/avcodec.h   |   1 +
 libavcodec/psd.c   | 402 +
 6 files changed, 408 insertions(+)
 create mode 100644 libavcodec/psd.c

diff --git a/Changelog b/Changelog
index 99cdb80..f41d2b6 100644
--- a/Changelog
+++ b/Changelog
@@ -3,6 +3,7 @@ releases are sorted from youngest to oldest.
 
 version :
 
+- PSD Decoder
 
 version 3.1:
 - DXVA2-accelerated HEVC Main10 decoding
diff --git a/doc/general.texi b/doc/general.texi
index 4db209f..06775f4 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -577,6 +577,8 @@ following image formats are supported:
 @item PNG  @tab X @tab X
 @item PPM  @tab X @tab X
 @tab Portable PixelMap image
+@item PSD  @tab   @tab X
+@tab Photoshop
 @item PTX  @tab   @tab X
 @tab V.Flash PTX format
 @item SGI  @tab X @tab X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index fd0d1f0..913b4a8 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -456,6 +456,7 @@ OBJS-$(CONFIG_PRORES_LGPL_DECODER) += proresdec_lgpl.o proresdsp.o proresdat
 OBJS-$(CONFIG_PRORES_ENCODER)  += proresenc_anatoliy.o
 OBJS-$(CONFIG_PRORES_AW_ENCODER)   += 

[FFmpeg-devel] [PATCH] avformat/utils: Fix find_stream_info not considering the extradata it found

2016-07-26 Thread Anssi Hannula
Commit 9200514ad8717c6 ("lavf: replace AVStream.codec with
AVStream.codecpar") merged in commit 6f69f7a8bf6a0d01 changed
avformat_find_stream_info() to put the extradata it got from
st->parser->parser->split() to st->internal->avctx instead of st->codec
(from where it will be later copied to st->codecpar).

However, in the same function, the "is stream ready?" check was changed
to check for extradata in st->codecpar instead of st->codec.

Extradata retrieved from split() is therefore not considered anymore,
and avformat_find_stream_info() will therefore needlessly continue
probing in some cases.

Fix that by checking for the extradata at st->internal->avctx where it
is actually put.

---

Michael Niedermayer wrote:
> seems to break fate here:
[...]

Oops, seems I messed up running fate and missed the "warning: only a
subset of the fate tests will be run because SAMPLES is not specified"
warning it gave... Thanks for catching that.

Seems this reverse fix is actually needed, as extradata is actually
copied in the other direction (from st->internal->avctx to
st->codecpar).

Fate passes here now.


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

diff --git a/libavformat/utils.c b/libavformat/utils.c
index e5a99ff..5a902ea 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3432,7 +3432,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 break;
 }
 if (st->parser && st->parser->parser->split &&
-!st->codecpar->extradata)
+!st->internal->avctx->extradata)
 break;
 if (st->first_dts == AV_NOPTS_VALUE &&
 !(ic->iformat->flags & AVFMT_NOTIMESTAMPS) &&
-- 
2.7.4

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


[FFmpeg-devel] [PATCH 1/2] Add an OpenH264 decoder wrapper

2016-07-26 Thread Martin Storsjö
While it is less featureful (and slower) than the built-in H264
decoder, one could potentially want to use it to take advantage
of the cisco patent license offer.

This is cherrypicked from libav, from commits
82b7525173f20702a8cbc26ebedbf4b69b8fecec and
d0b1e6049b06ca146ece4d2f199c5dba1565.
---
 Changelog   |   1 +
 configure   |   2 +
 doc/general.texi|   9 +-
 libavcodec/Makefile |   3 +-
 libavcodec/allcodecs.c  |   2 +-
 libavcodec/libopenh264.c|  62 +++
 libavcodec/libopenh264.h|  39 +++
 libavcodec/libopenh264dec.c | 245 
 libavcodec/libopenh264enc.c |  48 ++---
 libavcodec/version.h|   2 +-
 10 files changed, 368 insertions(+), 45 deletions(-)
 create mode 100644 libavcodec/libopenh264.c
 create mode 100644 libavcodec/libopenh264.h
 create mode 100644 libavcodec/libopenh264dec.c

diff --git a/Changelog b/Changelog
index 479f164..7f536db 100644
--- a/Changelog
+++ b/Changelog
@@ -10,6 +10,7 @@ version :
 - curves filter doesn't automatically insert points at x=0 and x=1 anymore
 - 16-bit support in curves filter
 - 16-bit support in selectivecolor filter
+- OpenH264 decoder wrapper
 
 
 version 3.1:
diff --git a/configure b/configure
index 1b41303..9f5b31f 100755
--- a/configure
+++ b/configure
@@ -2771,6 +2771,8 @@ libopencore_amrnb_decoder_deps="libopencore_amrnb"
 libopencore_amrnb_encoder_deps="libopencore_amrnb"
 libopencore_amrnb_encoder_select="audio_frame_queue"
 libopencore_amrwb_decoder_deps="libopencore_amrwb"
+libopenh264_decoder_deps="libopenh264"
+libopenh264_decoder_select="h264_mp4toannexb_bsf"
 libopenh264_encoder_deps="libopenh264"
 libopenjpeg_decoder_deps="libopenjpeg"
 libopenjpeg_encoder_deps="libopenjpeg"
diff --git a/doc/general.texi b/doc/general.texi
index 7823dc1..6b5975c 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -103,12 +103,19 @@ enable it.
 
 @section OpenH264
 
-FFmpeg can make use of the OpenH264 library for H.264 encoding.
+FFmpeg can make use of the OpenH264 library for H.264 encoding and decoding.
 
 Go to @url{http://www.openh264.org/} and follow the instructions for
 installing the library. Then pass @code{--enable-libopenh264} to configure to
 enable it.
 
+For decoding, this library is much more limited than the built-in decoder
+in libavcodec; currently, this library lacks support for decoding B-frames
+and some other main/high profile features. (It currently only supports
+constrained baseline profile and CABAC.) Using it is mostly useful for
+testing and for taking advantage of Cisco's patent portfolio license
+(@url{http://www.openh264.org/BINARY_LICENSE.txt}).
+
 @section x264
 
 FFmpeg can make use of the x264 library for H.264 encoding.
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index a548e02..3def3ad 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -868,7 +868,8 @@ OBJS-$(CONFIG_LIBMP3LAME_ENCODER) += libmp3lame.o 
mpegaudiodata.o mpegau
 OBJS-$(CONFIG_LIBOPENCORE_AMRNB_DECODER)  += libopencore-amr.o
 OBJS-$(CONFIG_LIBOPENCORE_AMRNB_ENCODER)  += libopencore-amr.o
 OBJS-$(CONFIG_LIBOPENCORE_AMRWB_DECODER)  += libopencore-amr.o
-OBJS-$(CONFIG_LIBOPENH264_ENCODER)+= libopenh264enc.o
+OBJS-$(CONFIG_LIBOPENH264_DECODER)+= libopenh264dec.o libopenh264.o
+OBJS-$(CONFIG_LIBOPENH264_ENCODER)+= libopenh264enc.o libopenh264.o
 OBJS-$(CONFIG_LIBOPENJPEG_DECODER)+= libopenjpegdec.o
 OBJS-$(CONFIG_LIBOPENJPEG_ENCODER)+= libopenjpegenc.o
 OBJS-$(CONFIG_LIBOPUS_DECODER)+= libopusdec.o libopus.o \
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 951e199..a1ae61f 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -623,7 +623,7 @@ void avcodec_register_all(void)
 
 /* external libraries, that shouldn't be used by default if one of the
  * above is available */
-REGISTER_ENCODER(LIBOPENH264,   libopenh264);
+REGISTER_ENCDEC (LIBOPENH264,   libopenh264);
 REGISTER_DECODER(H264_CUVID,h264_cuvid);
 REGISTER_ENCODER(H264_NVENC,h264_nvenc);
 REGISTER_ENCODER(H264_OMX,  h264_omx);
diff --git a/libavcodec/libopenh264.c b/libavcodec/libopenh264.c
new file mode 100644
index 000..59c61a3
--- /dev/null
+++ b/libavcodec/libopenh264.c
@@ -0,0 +1,62 @@
+/*
+ * OpenH264 shared utils
+ * Copyright (C) 2014 Martin Storsjo
+ *
+ * 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 

[FFmpeg-devel] [PATCH 2/2] libopenh264: Support building with the 1.6 release

2016-07-26 Thread Martin Storsjö
This is cherry-picked from libav commit
d825b1a5306576dcd0553b7d0d24a3a46ad92864.
---
 libavcodec/libopenh264dec.c |  2 ++
 libavcodec/libopenh264enc.c | 26 --
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/libavcodec/libopenh264dec.c b/libavcodec/libopenh264dec.c
index 8388e4e..80dff4c 100644
--- a/libavcodec/libopenh264dec.c
+++ b/libavcodec/libopenh264dec.c
@@ -90,7 +90,9 @@ static av_cold int svc_decode_init(AVCodecContext *avctx)
 (*s->decoder)->SetOption(s->decoder, DECODER_OPTION_TRACE_CALLBACK, (void 
*)_function);
 (*s->decoder)->SetOption(s->decoder, 
DECODER_OPTION_TRACE_CALLBACK_CONTEXT, (void *));
 
+#if !OPENH264_VER_AT_LEAST(1, 6)
 param.eOutputColorFormat = videoFormatI420;
+#endif
 param.eEcActiveIdc   = ERROR_CON_DISABLE;
 param.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
 
diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index d27fc41..07af31d 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -33,6 +33,10 @@
 #include "internal.h"
 #include "libopenh264.h"
 
+#if !OPENH264_VER_AT_LEAST(1, 6)
+#define SM_SIZELIMITED_SLICE SM_DYN_SLICE
+#endif
+
 typedef struct SVCContext {
 const AVClass *av_class;
 ISVCEncoder *encoder;
@@ -48,11 +52,20 @@ typedef struct SVCContext {
 #define OFFSET(x) offsetof(SVCContext, x)
 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
+#if OPENH264_VER_AT_LEAST(1, 6)
+{ "slice_mode", "set slice mode", OFFSET(slice_mode), AV_OPT_TYPE_INT, { 
.i64 = SM_FIXEDSLCNUM_SLICE }, SM_SINGLE_SLICE, SM_RESERVED, VE, "slice_mode" },
+#else
 { "slice_mode", "set slice mode", OFFSET(slice_mode), AV_OPT_TYPE_INT, { 
.i64 = SM_AUTO_SLICE }, SM_SINGLE_SLICE, SM_RESERVED, VE, "slice_mode" },
+#endif
 { "fixed", "a fixed number of slices", 0, AV_OPT_TYPE_CONST, { .i64 = 
SM_FIXEDSLCNUM_SLICE }, 0, 0, VE, "slice_mode" },
+#if OPENH264_VER_AT_LEAST(1, 6)
+{ "dyn", "Size limited (compatibility name)", 0, AV_OPT_TYPE_CONST, { 
.i64 = SM_SIZELIMITED_SLICE }, 0, 0, VE, "slice_mode" },
+{ "sizelimited", "Size limited", 0, AV_OPT_TYPE_CONST, { .i64 = 
SM_SIZELIMITED_SLICE }, 0, 0, VE, "slice_mode" },
+#else
 { "rowmb", "one slice per row of macroblocks", 0, AV_OPT_TYPE_CONST, { 
.i64 = SM_ROWMB_SLICE }, 0, 0, VE, "slice_mode" },
 { "auto", "automatic number of slices according to number of threads", 
0, AV_OPT_TYPE_CONST, { .i64 = SM_AUTO_SLICE }, 0, 0, VE, "slice_mode" },
 { "dyn", "Dynamic slicing", 0, AV_OPT_TYPE_CONST, { .i64 = 
SM_DYN_SLICE }, 0, 0, VE, "slice_mode" },
+#endif
 { "loopfilter", "enable loop filter", OFFSET(loopfilter), AV_OPT_TYPE_INT, 
{ .i64 = 1 }, 0, 1, VE },
 { "profile", "set profile restrictions", OFFSET(profile), 
AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VE },
 { "max_nal_size", "set maximum NAL size in bytes", OFFSET(max_nal_size), 
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
@@ -159,15 +172,24 @@ FF_ENABLE_DEPRECATION_WARNINGS
 s->slice_mode = SM_FIXEDSLCNUM_SLICE;
 
 if (s->max_nal_size)
-s->slice_mode = SM_DYN_SLICE;
+s->slice_mode = SM_SIZELIMITED_SLICE;
 
+#if OPENH264_VER_AT_LEAST(1, 6)
+param.sSpatialLayers[0].sSliceArgument.uiSliceMode = s->slice_mode;
+param.sSpatialLayers[0].sSliceArgument.uiSliceNum  = avctx->slices;
+#else
 param.sSpatialLayers[0].sSliceCfg.uiSliceMode   = 
s->slice_mode;
 param.sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceNum = 
avctx->slices;
+#endif
 
-if (s->slice_mode == SM_DYN_SLICE) {
+if (s->slice_mode == SM_SIZELIMITED_SLICE) {
 if (s->max_nal_size){
 param.uiMaxNalSize = s->max_nal_size;
+#if OPENH264_VER_AT_LEAST(1, 6)
+param.sSpatialLayers[0].sSliceArgument.uiSliceSizeConstraint = 
s->max_nal_size;
+#else
 
param.sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 
s->max_nal_size;
+#endif
 } else {
 av_log(avctx, AV_LOG_ERROR, "Invalid -max_nal_size, "
"specify a valid max_nal_size to use -slice_mode dyn\n");
-- 
2.7.4 (Apple Git-66)

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


Re: [FFmpeg-devel] why are audio/video encoding/decoding functions marked as attribute_deprecated?

2016-07-26 Thread Hendrik Leppkes
On Tue, Jul 26, 2016 at 12:57 PM, qw  wrote:
> Hi,
>
> avcodec_decode_video2(), avcodec_decode_audio4(), avcodec_encode_video2(), 
> and avcodec_encode_audio2(). The following url links are ffmpeg 3.1.1 
> description:
>

Because they are deprecated and replacement functions have been created.
That they are still used is irrelevant, they are not removed yet.

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


Re: [FFmpeg-devel] [PATCH] libavcodec/libopenjpegenc: don't define OPJ_STATIC with openjpeg 2.1.1

2016-07-26 Thread Michael Bradshaw
On Sun, Jul 24, 2016 at 10:09 PM, Kia  wrote:

> This fixes bug #5694 and builds with libopenjpeg 2.1.1.
>
> openjpeg commit 3ed5858902055d3500a6ab183f1395686921d026 hides all
> symbols with __attribute__ ((visibility ("hidden"))) if OPJ_STATIC is
> defined
>
> Signed-off-by: Kia 
> ---
>  libavcodec/libopenjpegdec.c | 1 +
>  libavcodec/libopenjpegenc.c | 1 +
>  2 files changed, 2 insertions(+)
>
> diff --git a/libavcodec/libopenjpegdec.c b/libavcodec/libopenjpegdec.c
> index 65167e6..efc0648 100644
> --- a/libavcodec/libopenjpegdec.c
> +++ b/libavcodec/libopenjpegdec.c
> @@ -37,6 +37,7 @@
>  #include "thread.h"
>
>  #if HAVE_OPENJPEG_2_1_OPENJPEG_H
> +#undef  OPJ_STATIC
>  #  include 
>  #elif HAVE_OPENJPEG_2_0_OPENJPEG_H
>  #  include 
> diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
> index 1443551..2bc75e2 100644
> --- a/libavcodec/libopenjpegenc.c
> +++ b/libavcodec/libopenjpegenc.c
> @@ -35,6 +35,7 @@
>  #include "internal.h"
>
>  #if HAVE_OPENJPEG_2_1_OPENJPEG_H
> +#undef  OPJ_STATIC
>  #  include 
>  #elif HAVE_OPENJPEG_2_0_OPENJPEG_H
>  #  include 
> --
> 2.9.0
>

In addition to what James Almer asked, does this build on Windows with
mingw?

See https://github.com/uclouvain/openjpeg/issues/766
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avformat/fivdec: cached keyframes before video or audio stream was created

2016-07-26 Thread Xinzheng Zhang
---
 libavformat/flvdec.c | 84 ++--
 1 file changed, 69 insertions(+), 15 deletions(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 2bf1e05..82b9f83 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -61,6 +61,12 @@ typedef struct FLVContext {
 
 int broken_sizes;
 int sum_flv_tag_size;
+
+int vhead_exists;
+int ahead_exists;
+int keyframe_count;
+int64_t *keyframe_times;
+int64_t *keyframe_filepositions;
 } FLVContext;
 
 static int probe(AVProbeData *p, int live)
@@ -92,6 +98,42 @@ static int live_flv_probe(AVProbeData *p)
 return probe(p, 1);
 }
 
+static void add_keyframes_index(AVFormatContext *s)
+{
+FLVContext *flv   = s->priv_data;
+AVStream *current_stream  = NULL;
+AVStream *vstream = NULL;
+AVStream *astream = NULL;
+unsigned int i,j;
+
+for (i = 0; i< s->nb_streams; i++) {
+if (s->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+vstream = s->streams[i];
+} else if (s->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+astream = s->streams[i];
+}
+}
+
+AVStream *streams[2] = {vstream, astream};
+for (i = 0; i < 2; i++) {
+current_stream = streams[i];
+if (current_stream && current_stream->nb_index_entries==0) {
+for (j = 0; j < flv->keyframe_count; j++) {
+av_add_index_entry(current_stream, 
flv->keyframe_filepositions[j], flv->keyframe_times[j] * 1000,
+   0, 0, AVINDEX_KEYFRAME);
+}
+}
+}
+
+// free keyframe index only if all expected streams have been created
+if (((vstream && vstream->nb_index_entries>0) || !flv->vhead_exists) &&
+((astream && astream->nb_index_entries>0) || !flv->ahead_exists)) {
+av_freep(>keyframe_times);
+av_freep(>keyframe_filepositions);
+flv->keyframe_count = 0;
+}
+}
+
 static AVStream *create_stream(AVFormatContext *s, int codec_type)
 {
 AVStream *st = avformat_new_stream(s, NULL);
@@ -104,6 +146,7 @@ static AVStream *create_stream(AVFormatContext *s, int 
codec_type)
 s->ctx_flags &= ~AVFMTCTX_NOHEADER;
 
 avpriv_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */
+add_keyframes_index(s);
 return st;
 }
 
@@ -305,8 +348,7 @@ static int amf_get_string(AVIOContext *ioc, char *buffer, 
int buffsize)
 return length;
 }
 
-static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc,
- AVStream *vstream, int64_t max_pos)
+static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, int64_t 
max_pos)
 {
 FLVContext *flv   = s->priv_data;
 unsigned int timeslen = 0, fileposlen = 0, i;
@@ -316,7 +358,7 @@ static int parse_keyframes_index(AVFormatContext *s, 
AVIOContext *ioc,
 int ret= AVERROR(ENOSYS);
 int64_t initial_pos= avio_tell(ioc);
 
-if (vstream->nb_index_entries>0) {
+if (flv->keyframe_count > 0) {
 av_log(s, AV_LOG_WARNING, "Skipping duplicate index\n");
 return 0;
 }
@@ -324,6 +366,10 @@ static int parse_keyframes_index(AVFormatContext *s, 
AVIOContext *ioc,
 if (s->flags & AVFMT_FLAG_IGNIDX)
 return 0;
 
+av_freep(>keyframe_times);
+av_freep(>keyframe_filepositions);
+flv->keyframe_count = 0;
+
 while (avio_tell(ioc) < max_pos - 2 &&
amf_get_string(ioc, str_val, sizeof(str_val)) > 0) {
 int64_t **current_array;
@@ -366,17 +412,17 @@ static int parse_keyframes_index(AVFormatContext *s, 
AVIOContext *ioc,
 break;
 }
 }
-
 if (timeslen == fileposlen && fileposlen>1 && max_pos <= filepositions[0]) 
{
-for (i = 0; i < fileposlen; i++) {
-av_add_index_entry(vstream, filepositions[i], times[i] * 1000,
-   0, 0, AVINDEX_KEYFRAME);
-if (i < 2) {
-flv->validate_index[i].pos = filepositions[i];
-flv->validate_index[i].dts = times[i] * 1000;
-flv->validate_count= i + 1;
-}
+for (i = 0; i < FFMIN(2,fileposlen); i++) {
+flv->validate_index[i].pos = filepositions[i];
+flv->validate_index[i].dts = times[i] * 1000;
+flv->validate_count= i + 1;
 }
+flv->keyframe_times = times;
+flv->keyframe_filepositions = filepositions;
+flv->keyframe_count = timeslen;
+times = NULL;
+filepositions = NULL;
 } else {
 invalid:
 av_log(s, AV_LOG_WARNING, "Invalid keyframes object, skipping.\n");
@@ -418,12 +464,14 @@ static int amf_parse_object(AVFormatContext *s, AVStream 
*astream,
 }
 break;
 case AMF_DATA_TYPE_OBJECT:
-if ((vstream || astream) && key &&
+if (key &&
 ioc->seekable &&
 

Re: [FFmpeg-devel] [PATCH] avformat/utils: Fix find_stream_info not considering the extradata it found

2016-07-26 Thread Michael Niedermayer
On Tue, Jul 26, 2016 at 01:51:04PM +0300, Anssi Hannula wrote:
> Commit 9200514ad8717c6 ("lavf: replace AVStream.codec with
> AVStream.codecpar") merged in commit 6f69f7a8bf6a0d01 changed
> avformat_find_stream_info() to put the extradata it got from
> st->parser->parser->split() to avctx instead of st->codec.
> 
> However, in the same function, the "is stream ready?" check was changed
> to check for extradata in st->codecpar instead of st->codec.
> 
> Extradata retrieved from split() is therefore not considered anymore,
> and avformat_find_stream_info() will therefore needlessly continue
> probing in some cases.
> 
> Fix that by putting the extradata in st->codecpar, from where it will be
> copied to avctx at the end of avformat_find_stream_info() along with
> all other parameters.
> 
> ---
> 
> I'm not overly familiar with this code, so review accordingly :)
> 
> This can be reproduced e.g. with a simple sample generated with
> "ffmpeg -t 20 -f lavfi -i cellauto out.ts", where ffprobe will analyze
> for 7 seconds (mpegts max_stream_analyze_duration) instead of the
> expected 5 seconds (max_analyze_duration).
> 
> The difference will be more dramatic with streams that trigger the
> "stop find_stream_info from waiting for more streams when all programs
> have received a PMT" check in mpegts demuxer.

seems to break fate here:
make: *** [fate-iv8-demux] Error 1
make: *** [fate-lmlm4-demux] Error 1
make: *** [fate-nc-demux] Error 1
make: *** [fate-pva-demux] Error 69
make: *** [fate-wtv-demux] Error 1
make: *** [fate-ts-demux] Error 1
make: *** [fate-vc1_sa00040] Error 1
make: *** [fate-vc1_sa00050] Error 1
make: *** [fate-vc1_sa10091] Error 1
make: *** [fate-vc1_sa20021] Error 1
make: *** [fate-vc1_sa10143] Error 1
make: *** [fate-vc1_ilaced_twomv] Error

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

What does censorship reveal? It reveals fear. -- Julian Assange


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/f_drawgraph: add another slide mode

2016-07-26 Thread Nicolas George
Le nonidi 9 thermidor, an CCXXIV, Paul B Mahol a écrit :
> patch attached.

I think you forgot to update the docs.

Regards,

-- 
  Nicolas George


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


[FFmpeg-devel] [PATCH]: avfilter/f_drawgraph: add another slide mode

2016-07-26 Thread Paul B Mahol
Hi,

patch attached.


0001-avfilter-f_drawgraph-add-another-slide-mode.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avdev/jack: remove duplicated dispatch macros

2016-07-26 Thread Michael Niedermayer
On Fri, Jul 22, 2016 at 04:09:06PM +0100, Josh de Kock wrote:
> The macros were moved to compat/dispatch_semaphore/semaphore.h after a libav 
> merge, and were never removed from jack.c
> ---
>  libavdevice/jack.c | 10 --
>  1 file changed, 10 deletions(-)

LGTM

thx

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

Avoid a single point of failure, be that a person or equipment.


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


[FFmpeg-devel] why are audio/video encoding/decoding functions marked as attribute_deprecated?

2016-07-26 Thread qw
Hi,

avcodec_decode_video2(), avcodec_decode_audio4(), avcodec_encode_video2(), and 
avcodec_encode_audio2(). The following url links are ffmpeg 3.1.1 description:

http://ffmpeg.org/doxygen/3.1/group__lavc__decoding.html#ga3ac51525b7ad8bca4ced9f3446e96532
http://ffmpeg.org/doxygen/3.1/group__lavc__decoding.html#gaaa1fbe477c04455cdc7a994090100db4
http://ffmpeg.org/doxygen/3.1/group__lavc__encoding.html#ga2c08a4729f72f9bdac41b5533c4f2642
http://ffmpeg.org/doxygen/3.1/group__lavc__encoding.html#gae4b5ba4d50b1264a5cf5408ff32fb622

Why are the four functions marked as attribute_deprecated?

The four encoding/decoding functions are still used in ffmpeg.c and 
transcoding.c.

Thanks!

Regards

Andrew


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


[FFmpeg-devel] [PATCH] avformat/utils: Fix find_stream_info not considering the extradata it found

2016-07-26 Thread Anssi Hannula
Commit 9200514ad8717c6 ("lavf: replace AVStream.codec with
AVStream.codecpar") merged in commit 6f69f7a8bf6a0d01 changed
avformat_find_stream_info() to put the extradata it got from
st->parser->parser->split() to avctx instead of st->codec.

However, in the same function, the "is stream ready?" check was changed
to check for extradata in st->codecpar instead of st->codec.

Extradata retrieved from split() is therefore not considered anymore,
and avformat_find_stream_info() will therefore needlessly continue
probing in some cases.

Fix that by putting the extradata in st->codecpar, from where it will be
copied to avctx at the end of avformat_find_stream_info() along with
all other parameters.

---

I'm not overly familiar with this code, so review accordingly :)

This can be reproduced e.g. with a simple sample generated with
"ffmpeg -t 20 -f lavfi -i cellauto out.ts", where ffprobe will analyze
for 7 seconds (mpegts max_stream_analyze_duration) instead of the
expected 5 seconds (max_analyze_duration).

The difference will be more dramatic with streams that trigger the
"stop find_stream_info from waiting for more streams when all programs
have received a PMT" check in mpegts demuxer.


 libavformat/utils.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index e5a99ff..392143e 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3581,16 +3581,16 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
 ff_rfps_add_frame(ic, st, pkt->dts);
 #endif
-if (st->parser && st->parser->parser->split && !avctx->extradata) {
+if (st->parser && st->parser->parser->split && 
!st->codecpar->extradata) {
 int i = st->parser->parser->split(avctx, pkt->data, pkt->size);
 if (i > 0 && i < FF_MAX_EXTRADATA_SIZE) {
-avctx->extradata_size = i;
-avctx->extradata  = av_mallocz(avctx->extradata_size +
-   
AV_INPUT_BUFFER_PADDING_SIZE);
-if (!avctx->extradata)
+st->codecpar->extradata_size = i;
+st->codecpar->extradata  = 
av_mallocz(st->codecpar->extradata_size +
+  
AV_INPUT_BUFFER_PADDING_SIZE);
+if (!st->codecpar->extradata)
 return AVERROR(ENOMEM);
-memcpy(avctx->extradata, pkt->data,
-   avctx->extradata_size);
+memcpy(st->codecpar->extradata, pkt->data,
+   st->codecpar->extradata_size);
 }
 }
 
-- 
2.7.4

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


[FFmpeg-devel] [PATCH v3 2/2] avcodec/bsf: Forbid packet without payload in av_bsf_send_packet

2016-07-26 Thread sebechlebskyjan
From: Jan Sebechlebsky 

Signed-off-by: Jan Sebechlebsky 
---
 libavcodec/avcodec.h | 3 ++-
 libavcodec/bsf.c | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index ca8dba8..36f7935 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -5898,7 +5898,8 @@ int av_bsf_init(AVBSFContext *ctx);
  * av_bsf_receive_packet() repeatedly until it returns AVERROR(EAGAIN) or
  * AVERROR_EOF.
  *
- * @param pkt the packet to filter. The bitstream filter will take ownership of
+ * @param pkt the packet to filter. pkt must contain some payload (i.e data or
+ * side data must be present in pkt). The bitstream filter will take ownership 
of
  * the packet and reset the contents of pkt. pkt is not touched if an error 
occurs.
  * This parameter may be NULL, which signals the end of the stream (i.e. no 
more
  * packets will be sent). That will cause the filter to output any packets it
diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
index 9b9ada7..8e36861 100644
--- a/libavcodec/bsf.c
+++ b/libavcodec/bsf.c
@@ -21,6 +21,7 @@
 #include "libavutil/log.h"
 #include "libavutil/mem.h"
 #include "libavutil/opt.h"
+#include "libavutil/avassert.h"
 
 #include "avcodec.h"
 #include "bsf.h"
@@ -177,6 +178,8 @@ int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
 return 0;
 }
 
+av_assert0(pkt->data || pkt->side_data);
+
 if (ctx->internal->eof) {
 av_log(ctx, AV_LOG_ERROR, "A non-NULL packet sent after an EOF.\n");
 return AVERROR(EINVAL);
-- 
1.9.1

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


[FFmpeg-devel] [PATCH v3 1/2] avcodec/bsf: Set EOF flag only in pkt == NULL

2016-07-26 Thread sebechlebskyjan
From: Jan Sebechlebsky 

Set BSF EOF flag only if pkt == NULL in av_bsf_send_packet().

Signed-off-by: Jan Sebechlebsky 
---
 libavcodec/bsf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
index 88b7f29..9b9ada7 100644
--- a/libavcodec/bsf.c
+++ b/libavcodec/bsf.c
@@ -172,7 +172,7 @@ int av_bsf_init(AVBSFContext *ctx)
 
 int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
 {
-if (!pkt || !pkt->data) {
+if (!pkt) {
 ctx->internal->eof = 1;
 return 0;
 }
-- 
1.9.1

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


Re: [FFmpeg-devel] [PATCH v2] avcodec/bsf: Set EOF flag only if pkt == NULL

2016-07-26 Thread Jan Sebechlebsky

On 07/25/2016 05:14 PM, Nicolas George wrote:


Le septidi 7 thermidor, an CCXXIV, Jan Sebechlebsky a écrit :

I gave this a second thought, wouldn't it be better to simply ignore pkt
without payload? So after caller would send empty packet using
av_bsf_send_packet, he would get AVERROR(EAGAIN) from the next
av_bsf_receive_packet call (from the definition in documentation
AVERROR(EAGAIN) means "more data needed" when returned by
av_bsf_receive_packet).
However, if you think it is better to reserve packet without payload for
some future use, I won't object.

Both are possible, it is a matter of balance between convenience for us and
convenience for the applications.

If at some point someone finds a way to use that kind of packet. If they
used to be ignored, it makes an incompatible API change. If they used to be
forbidden, it works.

The same logic applies for functions that return 0 for success or an AVERROR
code: the documentation usually states ">= 0 for success", that allows to
extend their return value later.

In this particular case, I do not see how an application can accidentally
send a completely empty packet, and therefore I think forbidding them is
better.


OK, Let's make it that way then :)

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


Re: [FFmpeg-devel] [PATCH 1/4] lavc: add mpeg4 mediacodec decoder

2016-07-26 Thread Matthieu Bouron
On Sun, Jul 24, 2016 at 03:06:14PM +0200, Thomas Volkert wrote:
> From: Thomas Volkert 
> 
> ---
>  Changelog|   1 +
>  configure|   1 +
>  libavcodec/Makefile  |   1 +
>  libavcodec/allcodecs.c   |   1 +
>  libavcodec/mediacodecdec_mpeg4.c | 239 
> +++
>  libavcodec/version.h |   2 +-
>  6 files changed, 244 insertions(+), 1 deletion(-)
>  create mode 100644 libavcodec/mediacodecdec_mpeg4.c
> 
> diff --git a/Changelog b/Changelog
> index 2bd18ec..b8bbdb9 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -7,6 +7,7 @@ version :
>  - Changed metadata print option to accept general urls
>  - Alias muxer for Ogg Video (.ogv)
>  - VP8 in Ogg muxing
> +- MediaCodec MPEG-4 decoding
>  
>  
>  version 3.1:
> diff --git a/configure b/configure
> index 1b41303..9004b06 100755
> --- a/configure
> +++ b/configure
> @@ -2621,6 +2621,7 @@ mpeg2_videotoolbox_hwaccel_select="mpeg2video_decoder"
>  mpeg2_xvmc_hwaccel_deps="xvmc"
>  mpeg2_xvmc_hwaccel_select="mpeg2video_decoder"
>  mpeg4_crystalhd_decoder_select="crystalhd"
> +mpeg4_mediacodec_decoder_deps="mediacodec"
>  mpeg4_mmal_decoder_deps="mmal"
>  mpeg4_mmal_decoder_select="mmal"
>  mpeg4_mmal_hwaccel_deps="mmal"
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index abef19e..642cf2a 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -317,6 +317,7 @@ OBJS-$(CONFIG_H264_DECODER)+= h264.o 
> h264_cabac.o h264_cavlc.o \
>h2645_parse.o
>  OBJS-$(CONFIG_H264_CUVID_DECODER)  += cuvid.o
>  OBJS-$(CONFIG_H264_MEDIACODEC_DECODER) += mediacodecdec_h264.o
> +OBJS-$(CONFIG_MPEG4_MEDIACODEC_DECODER) += mediacodecdec_mpeg4.o
>  OBJS-$(CONFIG_H264_MMAL_DECODER)   += mmaldec.o
>  OBJS-$(CONFIG_H264_NVENC_ENCODER)  += nvenc_h264.o
>  OBJS-$(CONFIG_NVENC_ENCODER)   += nvenc_h264.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index 951e199..2d98694 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -239,6 +239,7 @@ void avcodec_register_all(void)
>  REGISTER_ENCDEC (MPEG2VIDEO,mpeg2video);
>  REGISTER_ENCDEC (MPEG4, mpeg4);
>  REGISTER_DECODER(MPEG4_CRYSTALHD,   mpeg4_crystalhd);
> +REGISTER_DECODER(MPEG4_MEDIACODEC,  mpeg4_mediacodec);
>  REGISTER_DECODER(MPEG4_MMAL,mpeg4_mmal);

You should also add the relevant hwaccel entry in this file:

+REGISTER_HWACCEL(MPEG4_MEDIACODEC,  mpeg4_mediacodec);

and declare the hwaccel at the bottom of libavcodec/mediacodecdec.c, like the 
h264 one.

>  #if FF_API_VDPAU
>  REGISTER_DECODER(MPEG4_VDPAU,   mpeg4_vdpau);
> diff --git a/libavcodec/mediacodecdec_mpeg4.c 
> b/libavcodec/mediacodecdec_mpeg4.c
> new file mode 100644
> index 000..7c4559b
> --- /dev/null
> +++ b/libavcodec/mediacodecdec_mpeg4.c
> @@ -0,0 +1,239 @@
> +/*
> + * Android MediaCodec MPEG 4 decoder
> + *
> + * Copyright (c) 2016 Thomas Volkert 
> + *
> + * 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 "libavutil/avassert.h"
> +#include "libavutil/common.h"
> +#include "libavutil/fifo.h"
> +
> +#include "avcodec.h"
> +#include "internal.h"
> +#include "mediacodecdec.h"
> +#include "mediacodec_wrapper.h"
> +
> +#define CODEC_MIME "video/mp4v-es"
> +
> +typedef struct MediaCodecMPEG4DecContext {
> +
> +MediaCodecDecContext *ctx;
> +
> +AVBSFContext *bsf;
> +
> +AVFifoBuffer *fifo;
> +
> +AVPacket filtered_pkt;
> +
> +} MediaCodecMPEG4DecContext;
> +
> +static av_cold int mediacodec_decode_close(AVCodecContext *avctx)
> +{
> +MediaCodecMPEG4DecContext *s = avctx->priv_data;
> +
> +ff_mediacodec_dec_close(avctx, s->ctx);
> +s->ctx = NULL;
> +
> +av_fifo_free(s->fifo);
> +
> +av_bsf_free(>bsf);
> +av_packet_unref(>filtered_pkt);
> +
> +return 0;
> +}
> +
> +static av_cold int mediacodec_decode_init(AVCodecContext *avctx)
> +{
> +int ret;
> +
> +FFAMediaFormat *format = NULL;
> +MediaCodecMPEG4DecContext *s = avctx->priv_data;
> +
> +format = ff_AMediaFormat_new();
> +if (!format) {
> +av_log(avctx, 

Re: [FFmpeg-devel] [PATCH 1/4] lavc: add mpeg4 mediacodec decoder

2016-07-26 Thread Matthieu Bouron
On Tue, Jul 26, 2016 at 11:00:46AM +0200, Matthieu Bouron wrote:
> On Sun, Jul 24, 2016 at 03:06:14PM +0200, Thomas Volkert wrote:
> > From: Thomas Volkert 
> > 
> > ---
> >  Changelog|   1 +
> >  configure|   1 +
> >  libavcodec/Makefile  |   1 +
> >  libavcodec/allcodecs.c   |   1 +
> >  libavcodec/mediacodecdec_mpeg4.c | 239 
> > +++
> >  libavcodec/version.h |   2 +-
> >  6 files changed, 244 insertions(+), 1 deletion(-)
> >  create mode 100644 libavcodec/mediacodecdec_mpeg4.c
> > 
> > diff --git a/Changelog b/Changelog
> > index 2bd18ec..b8bbdb9 100644
> > --- a/Changelog
> > +++ b/Changelog
> > @@ -7,6 +7,7 @@ version :
> >  - Changed metadata print option to accept general urls
> >  - Alias muxer for Ogg Video (.ogv)
> >  - VP8 in Ogg muxing
> > +- MediaCodec MPEG-4 decoding
> >  
> >  
> >  version 3.1:
> > diff --git a/configure b/configure
> > index 1b41303..9004b06 100755
> > --- a/configure
> > +++ b/configure
> > @@ -2621,6 +2621,7 @@ mpeg2_videotoolbox_hwaccel_select="mpeg2video_decoder"
> >  mpeg2_xvmc_hwaccel_deps="xvmc"
> >  mpeg2_xvmc_hwaccel_select="mpeg2video_decoder"
> >  mpeg4_crystalhd_decoder_select="crystalhd"
> > +mpeg4_mediacodec_decoder_deps="mediacodec"
> >  mpeg4_mmal_decoder_deps="mmal"
> >  mpeg4_mmal_decoder_select="mmal"
> >  mpeg4_mmal_hwaccel_deps="mmal"
> > diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> > index abef19e..642cf2a 100644
> > --- a/libavcodec/Makefile
> > +++ b/libavcodec/Makefile
> > @@ -317,6 +317,7 @@ OBJS-$(CONFIG_H264_DECODER)+= h264.o 
> > h264_cabac.o h264_cavlc.o \
> >h2645_parse.o
> >  OBJS-$(CONFIG_H264_CUVID_DECODER)  += cuvid.o
> >  OBJS-$(CONFIG_H264_MEDIACODEC_DECODER) += mediacodecdec_h264.o
> > +OBJS-$(CONFIG_MPEG4_MEDIACODEC_DECODER) += mediacodecdec_mpeg4.o
> >  OBJS-$(CONFIG_H264_MMAL_DECODER)   += mmaldec.o
> >  OBJS-$(CONFIG_H264_NVENC_ENCODER)  += nvenc_h264.o
> >  OBJS-$(CONFIG_NVENC_ENCODER)   += nvenc_h264.o
> > diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> > index 951e199..2d98694 100644
> > --- a/libavcodec/allcodecs.c
> > +++ b/libavcodec/allcodecs.c
> > @@ -239,6 +239,7 @@ void avcodec_register_all(void)
> >  REGISTER_ENCDEC (MPEG2VIDEO,mpeg2video);
> >  REGISTER_ENCDEC (MPEG4, mpeg4);
> >  REGISTER_DECODER(MPEG4_CRYSTALHD,   mpeg4_crystalhd);
> > +REGISTER_DECODER(MPEG4_MEDIACODEC,  mpeg4_mediacodec);
> >  REGISTER_DECODER(MPEG4_MMAL,mpeg4_mmal);
> 
> You should also add the relevant hwaccel entry in this file:
> 
> +REGISTER_HWACCEL(MPEG4_MEDIACODEC,  mpeg4_mediacodec);
> 
> and declare the hwaccel at the bottom of libavcodec/mediacodecdec.c, like the 
> h264 one.
> 
> >  #if FF_API_VDPAU
> >  REGISTER_DECODER(MPEG4_VDPAU,   mpeg4_vdpau);
> > diff --git a/libavcodec/mediacodecdec_mpeg4.c 
> > b/libavcodec/mediacodecdec_mpeg4.c
> > new file mode 100644
> > index 000..7c4559b
> > --- /dev/null
> > +++ b/libavcodec/mediacodecdec_mpeg4.c
> > @@ -0,0 +1,239 @@
> > +/*
> > + * Android MediaCodec MPEG 4 decoder
> > + *
> > + * Copyright (c) 2016 Thomas Volkert 
> > + *
> > + * 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 "libavutil/avassert.h"
> > +#include "libavutil/common.h"
> > +#include "libavutil/fifo.h"
> > +
> > +#include "avcodec.h"
> > +#include "internal.h"
> > +#include "mediacodecdec.h"
> > +#include "mediacodec_wrapper.h"
> > +
> > +#define CODEC_MIME "video/mp4v-es"
> > +
> > +typedef struct MediaCodecMPEG4DecContext {
> > +
> > +MediaCodecDecContext *ctx;
> > +
> > +AVBSFContext *bsf;
> > +
> > +AVFifoBuffer *fifo;
> > +
> > +AVPacket filtered_pkt;
> > +
> > +} MediaCodecMPEG4DecContext;
> > +
> > +static av_cold int mediacodec_decode_close(AVCodecContext *avctx)
> > +{
> > +MediaCodecMPEG4DecContext *s = avctx->priv_data;
> > +
> > +ff_mediacodec_dec_close(avctx, s->ctx);
> > +s->ctx = NULL;
> > +
> > +av_fifo_free(s->fifo);
> > +
> > +av_bsf_free(>bsf);
> > +

Re: [FFmpeg-devel] ffmpeg stuck in transcoding H264 using QSV

2016-07-26 Thread Ivan Uskov

Hello Chao,

Tuesday, July 26, 2016, 9:04:49 AM, you wrote:

> I tried to debug it a bit by comparing ffmpeg code with intel media SDK.
> There is sth. I don't understand. Not sure whether it's related..
> In ffmpeg, we decode the frame in a loop
> , it
> sleeps and retries as long as MFXVideoDECODE_DecodeFrameAsync returns busy.
> In intel media SDK sample_decode, it calls SyncOperation when
> MFXVideoDECODE_DecodeFrameAsync returns busy.

> Could this be the cause?
The documentation for MFXVideoDECODE_DecodeFrameAsync says:
=
MFX_WRN_DEVICE_BUSY
Hardware device is currently busy. Call this function again in a few 
milliseconds.
=
So if documented way does not work it looks like we have issue inside SDK.
But I will try to double check sample_decode code.

By the way, what is your platform? Linux? Do you use a patched kernel
recommended by Intel for specific sdk version?


-- 
Best regards,
 Ivanmailto:ivan.us...@nablet.com

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


Re: [FFmpeg-devel] [PATCH] lavc/ffjni: replace ff_jni_{attach, detach} with ff_jni_get_env

2016-07-26 Thread Matthieu Bouron
On Mon, Jul 25, 2016 at 09:50:58AM +0200, Benoit Fouet wrote:
> Hi,

Hi,

> 
> On 24/07/2016 23:05, Matthieu Bouron wrote:
> > From: Matthieu Bouron
> > 
> > If a JNI environment is not already attached to the thread where the
> > MediaCodec calls are made the current implementation will attach /
> > detach an environment for each MediaCodec call wasting some CPU time.
> > 
> > ff_jni_get_env replaces ff_jni_{attach,detach} by permanently attaching
> > an environment (if it is not already the case) to the current thread.
> > The environment will be automatically detached at the thread destruction
> > using a pthread_key callback.
> > 
> > Saves around 5% of CPU time (out of 20%) while decoding a stream with
> > MediaCodec.
> > ---
> >   libavcodec/ffjni.c  |  43 +
> >   libavcodec/ffjni.h  |  15 +--
> 
> LGTM

Thanks for the review. I will push the patch in a few hours.

Matthieu

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


Re: [FFmpeg-devel] ffmpeg stuck in transcoding H264 using QSV

2016-07-26 Thread Chao Liu
On Mon, Jul 25, 2016 at 11:08 PM, Chao Liu  wrote:

>
>
> On Mon, Jul 25, 2016 at 11:04 PM, Chao Liu  wrote:
>
>> Hi,
>>
>> (Ivan, I am sending this mail to you directly because you said you are
>> the maintainer of QSV related code in a recent mail. Apologize if this is
>> inappropriate.. )
>>
>> I am trying to use h264_qsv to transcode a MP4 file. This is my command:
>> ffmpeg -c:v h264_qsv -i input.mp4 -look_ahead 0 -c:v h264_qsv -b:v 800k
>> -maxrate 1600k -preset fast output.mp4
>> It always stucks in this loop
>> .
>>
>> It works if I change the command to
>> ffmpeg -i input.mp4 -look_ahead 0 -c:v h264_qsv -b:v 800k -maxrate 1600k
>> -preset fast output.mp4
>> (not using qsv for decoding).
>>
>> Looks like the decoding and encoding were contending for the resources
>> and there is a deadlock or sth. like that..
>>
>> I tried to debug it a bit by comparing ffmpeg code with intel media SDK.
>> There is sth. I don't understand. Not sure whether it's related..
>> In ffmpeg, we decode the frame in a loop
>> ,
>> it sleeps and retries as long as MFXVideoDECODE_DecodeFrameAsync returns
>> busy.
>> In intel media SDK sample_decode, it calls SyncOperation when
>> MFXVideoDECODE_DecodeFrameAsync returns busy.
>>
> Sorry, forgot to paste the link to the code
> https://github.com/Intel-Media-SDK/samples/blob/master/samples/sample_decode/src/pipeline_decode.cpp#L1631
>
>

>> Could this be the cause?
>>
>
I think this is red herring. I could repro the deadlock w/o qsv decoding,
just the chance is pretty low.
And looks like this is a known issue: https://trac.ffmpeg.org/ticket/4832
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] ffmpeg stuck in transcoding H264 using QSV

2016-07-26 Thread Chao Liu
On Mon, Jul 25, 2016 at 11:04 PM, Chao Liu  wrote:

> Hi,
>
> (Ivan, I am sending this mail to you directly because you said you are the
> maintainer of QSV related code in a recent mail. Apologize if this is
> inappropriate.. )
>
> I am trying to use h264_qsv to transcode a MP4 file. This is my command:
> ffmpeg -c:v h264_qsv -i input.mp4 -look_ahead 0 -c:v h264_qsv -b:v 800k
> -maxrate 1600k -preset fast output.mp4
> It always stucks in this loop
> .
>
> It works if I change the command to
> ffmpeg -i input.mp4 -look_ahead 0 -c:v h264_qsv -b:v 800k -maxrate 1600k
> -preset fast output.mp4
> (not using qsv for decoding).
>
> Looks like the decoding and encoding were contending for the resources and
> there is a deadlock or sth. like that..
>
> I tried to debug it a bit by comparing ffmpeg code with intel media SDK.
> There is sth. I don't understand. Not sure whether it's related..
> In ffmpeg, we decode the frame in a loop
> ,
> it sleeps and retries as long as MFXVideoDECODE_DecodeFrameAsync returns
> busy.
> In intel media SDK sample_decode, it calls SyncOperation when
> MFXVideoDECODE_DecodeFrameAsync returns busy.
>
Sorry, forgot to paste the link to the code
https://github.com/Intel-Media-SDK/samples/blob/master/samples/sample_decode/src/pipeline_decode.cpp#L1631


>
> Could this be the cause?
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] ffmpeg stuck in transcoding H264 using QSV

2016-07-26 Thread Chao Liu
Hi,

(Ivan, I am sending this mail to you directly because you said you are the
maintainer of QSV related code in a recent mail. Apologize if this is
inappropriate.. )

I am trying to use h264_qsv to transcode a MP4 file. This is my command:
ffmpeg -c:v h264_qsv -i input.mp4 -look_ahead 0 -c:v h264_qsv -b:v 800k
-maxrate 1600k -preset fast output.mp4
It always stucks in this loop
.

It works if I change the command to
ffmpeg -i input.mp4 -look_ahead 0 -c:v h264_qsv -b:v 800k -maxrate 1600k
-preset fast output.mp4
(not using qsv for decoding).

Looks like the decoding and encoding were contending for the resources and
there is a deadlock or sth. like that..

I tried to debug it a bit by comparing ffmpeg code with intel media SDK.
There is sth. I don't understand. Not sure whether it's related..
In ffmpeg, we decode the frame in a loop
, it
sleeps and retries as long as MFXVideoDECODE_DecodeFrameAsync returns busy.
In intel media SDK sample_decode, it calls SyncOperation when
MFXVideoDECODE_DecodeFrameAsync returns busy.

Could this be the cause?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel