Re: [FFmpeg-devel] [PATCH] avfilter/decode: do not treat discarded frames as eof when draining

2017-04-30 Thread Muhammad Faiz
On Sun, Apr 30, 2017 at 12:50 PM, Muhammad Faiz  wrote:
> Fix fate failures:
>   make fate-mov THREADS=32
>
> Signed-off-by: Muhammad Faiz 
> ---
>  libavcodec/decode.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index edfae55..6ec423b 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -557,9 +557,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  avci->showed_multi_packet_warning = 1;
>  }
>
> -if (!got_frame)
> -av_frame_unref(frame);
> -
>  if (ret >= 0 && avctx->codec->type == AVMEDIA_TYPE_VIDEO && 
> !(avctx->flags & AV_CODEC_FLAG_TRUNCATED))
>  ret = pkt->size;
>
> @@ -568,8 +565,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, 
> (AVRational){avctx->ticks_per_frame, 1}));
>  #endif
>
> -/* do not stop draining when got_frame != 0 or ret < 0 */
> -if (avctx->internal->draining && !got_frame) {
> +/* do not stop draining when frame->buf[0] != NULL or ret < 0 */
> +/* at this point, got_frame == 0 when discarding frame */
> +if (avctx->internal->draining && !frame->buf[0]) {
>  if (ret < 0) {
>  /* prevent infinite loop if a decoder wrongly always return 
> error on draining */
>  /* reasonable nb_errors_max = maximum b frames + thread count */
> @@ -603,7 +601,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  avci->last_pkt_props->dts = AV_NOPTS_VALUE;
>  }
>
> -if (got_frame)
> +if (!got_frame)
> +av_frame_unref(frame);
> +else
>  av_assert0(frame->buf[0]);
>
>  return ret < 0 ? ret : 0;
> --
> 2.9.3
>

I'm sorry, typo in the subject.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avcodec/decode: do not treat discarded frames as eof when draining

2017-04-30 Thread Muhammad Faiz
Fix fate failures:
  make fate-mov THREADS=32

Signed-off-by: Muhammad Faiz 
---
 libavcodec/decode.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index edfae55..6ec423b 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -557,9 +557,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 avci->showed_multi_packet_warning = 1;
 }
 
-if (!got_frame)
-av_frame_unref(frame);
-
 if (ret >= 0 && avctx->codec->type == AVMEDIA_TYPE_VIDEO && !(avctx->flags 
& AV_CODEC_FLAG_TRUNCATED))
 ret = pkt->size;
 
@@ -568,8 +565,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
 avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, 
(AVRational){avctx->ticks_per_frame, 1}));
 #endif
 
-/* do not stop draining when got_frame != 0 or ret < 0 */
-if (avctx->internal->draining && !got_frame) {
+/* do not stop draining when frame->buf[0] != NULL or ret < 0 */
+/* at this point, got_frame == 0 when discarding frame */
+if (avctx->internal->draining && !frame->buf[0]) {
 if (ret < 0) {
 /* prevent infinite loop if a decoder wrongly always return error 
on draining */
 /* reasonable nb_errors_max = maximum b frames + thread count */
@@ -603,7 +601,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
 avci->last_pkt_props->dts = AV_NOPTS_VALUE;
 }
 
-if (got_frame)
+if (!got_frame)
+av_frame_unref(frame);
+else
 av_assert0(frame->buf[0]);
 
 return ret < 0 ? ret : 0;
-- 
2.9.3

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


Re: [FFmpeg-devel] Match source video timestamp

2017-04-30 Thread Eran Kornblau
Ping, re-attaching the same patch

Eran

-Original Message-
From: Eran Kornblau 
Sent: Sunday, April 23, 2017 12:32 PM
To: 'FFmpeg development discussions and patches' 
Subject: RE: Match source video timestamp

> Hi all,
> 
> I'm trying to transcode some video file (MP4/h264 baseline vfr/AAC) 
> with ffmpeg, and I would like to have the frame timestamps in the 
> transcoded file perfectly match the source video. This is in order to 
> have them both play together adaptively without issues (from my 
> experience, DASH is very sensitive to timestamp continuity, a 
> difference as small as a couple of frames between renditions causes 
> playback to fail)
> 
> After trying all sorts of parameters (-vsync 0/2, -copytb, with/out 
> -r, -video_track_timescale) without success, I found that the reason 
> for the mismatched timestamps is that ffmpeg uses 1/frame_rate as the 
> time base of the encoder. With cfr this is probably ok, but with vfr this 
> quantizes the timestamps and they come out different than the source.
> 
> Just for testing, I made this change:
> root@pa-front-vod-stg2 FFmpeg# git diff diff --git a/ffmpeg.c 
> b/ffmpeg.c index 3b91710..9cba0d5 100644
> --- a/ffmpeg.c
> +++ b/ffmpeg.c
> @@ -3351,7 +3351,7 @@ static int transcode_init(void)
>  enc_ctx->time_base  = (AVRational){ 1, 
> enc_ctx->sample_rate };
>  break;
>  case AVMEDIA_TYPE_VIDEO:
> -enc_ctx->time_base = av_inv_q(ost->frame_rate);
> +enc_ctx->time_base = ist->st->time_base; 
> + //av_inv_q(ost->frame_rate);
>  if (!(enc_ctx->time_base.num && enc_ctx->time_base.den))
>  enc_ctx->time_base = 
> ost->filter->filter->inputs[0]->time_base;
>  if (   av_q2d(enc_ctx->time_base) < 0.001 && 
> video_sync_method != VSYNC_PASSTHROUGH
> 
> And I am able to get a perfect match (=identical stts atom) between the 
> source & transcoded videos.
> This is the command line I'm using (the -r is probably meaningless...):
> ffmpeg -threads 1 -i input.mp4 -c:v libx264  -subq 2 -qcomp 0.6 -qmin 
> 10 -qmax 50 -qdiff 4 -coder 0 -x264opts stitchable -vprofile baseline 
> -force_key_frames source -pix_fmt yuv420p -b:v 400k -s 640x480 -r 
> 25.174 -g 86400 -aspect 640:480 -c:a copy -map_chapters -1 
> -map_metadata -1  -f mp4 -flags +loop+mv4 -cmp 256 -partitions 
> +parti4x4+partp8x8+partb8x8 -trellis 1 -refs 1 -me_range 16 
> -keyint_min 20 -sc_threshold 0 -i_qfactor 0.71 -bt 100k -maxrate 400k 
> -bufsize 1200k -rc_eq 'blurCplx^(1-qComp)' -level 30  -vsync 2 
> -threads 4  -y output.mp4
> 
> I'm thinking about adding variables for this -video_timescale / 
> -audio_timescale (following the convention of movenc's video_track_timescale) 
> that will get these values:
> 1.0 (default) - the existing behavior - 1/frame rate for video, 
> 1/sampling rate for audio
> 2.-1 - match the input stream (as in the patch above)
> 3.>0 - fixed value (e.g. when passing 1000 it will use 1/1000)
> 
> Does this make sense? Any other ideas for solving this?
> 
> Thank you!
> 
> Eran
>
As I got no feedback on the above... sending a patch with my suggestion for this

Thanks,

Eran


0001-ffmpeg-add-video-audio_timescale-options.patch
Description: 0001-ffmpeg-add-video-audio_timescale-options.patch
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] Match source video timestamp

2017-04-30 Thread Carl Eugen Hoyos
2017-04-30 13:09 GMT+02:00 Eran Kornblau :

>> I'm trying to transcode some video file (MP4/h264 baseline vfr/AAC)
>> with ffmpeg, and I would like to have the frame timestamps in the
>> transcoded file perfectly match the source video.

Why does this not work with -copyts?

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


Re: [FFmpeg-devel] [PATCH v9] - Added Turing codec interface for ffmpeg

2017-04-30 Thread Carl Eugen Hoyos
2017-04-28 17:18 GMT+02:00 Saverio Blasi :

> The patch applies nicely to my local ffmpeg repository.

Please confirm that tools/patcheck does not report any issues
(trailing whitespace cannot be committed to our repository).

> This e-mail (and any attachments) is confidential

Please do not top-post here and please remove this
from your email footer, you cannot send a confidential
email to a public mailing list.

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


Re: [FFmpeg-devel] Match source video timestamp

2017-04-30 Thread Nicolas George
Le primidi 11 floréal, an CCXXV, Eran Kornblau a écrit :
> Ping, re-attaching the same patch

Hi. Thanks for the bug report and patch. I do not know the issue well
enough to address the core validity in principle, but I have a few
design comments that will need to be addressed.

> Subject: [PATCH] ffmpeg: add video/audio_timescale options
> 
> video/audio_timescale set the encoding time base -
>  0 - for video, uses 1/frame_rate, for audio uses 1/sample_rate (this is
>   the default)
> -1 - matches the input time base (when possible)
> >0 - sets the time base to 1/(the provided timescale value)

First, I think that "timescale" is slang specific to the MOV/MP4
formats. It looks similar to what FFmpeg calls "time base" all over the
place, but I am not entirely sure it is exactly the same thing. For the
sake of readability, it would be better to use a consistent vocabulary
within FFmpeg and not import new terms.

Second, this interface relies on magic numbers, we try to avoid that.
Internally, you should define the magic numbers as symbolic constants,
either using #define or enums. For the user interface, you should use
AV_OPT_TYPE_CONST and a named constant.

> ---
>  ffmpeg.c | 36 ++--
>  ffmpeg.h |  2 ++
>  ffmpeg_opt.c |  8 
>  3 files changed, 44 insertions(+), 2 deletions(-)

This is missing the documentation for the new options.

> 
> diff --git a/ffmpeg.c b/ffmpeg.c
> index 70431e8..d18f923 100644
> --- a/ffmpeg.c
> +++ b/ffmpeg.c
> @@ -3301,10 +3301,42 @@ static int init_output_stream_encode(OutputStream 
> *ost)
>  enc_ctx->sample_rate= 
> av_buffersink_get_sample_rate(ost->filter->filter);
>  enc_ctx->channel_layout = 
> av_buffersink_get_channel_layout(ost->filter->filter);
>  enc_ctx->channels   = 
> av_buffersink_get_channels(ost->filter->filter);

> -enc_ctx->time_base  = (AVRational){ 1, enc_ctx->sample_rate };

I think the ability to control the time base chosen by FFmpeg may be
useful. But note that there are two time bases at play here: the encoder
time base and the stream time base. The interaction between the twos is
quite subtle at several places.

> +
> +switch (audio_timescale) {
> +case -1:
> +if (ist) {
> +enc_ctx->time_base = ist->st->time_base;
> +break;
> +}
> +av_log(oc, AV_LOG_WARNING, "Input stream data not available, 
> using the sample rate as the time base\n");
> +/* fall-through */
> +case 0:

> +enc_ctx->time_base = (AVRational){ 1, enc_ctx->sample_rate };

I would suggest to use av_make_q() in new code.

> +break;
> +
> +default:
> +enc_ctx->time_base = (AVRational){ 1, audio_timescale };
> +break;
> +}
>  break;

>  case AVMEDIA_TYPE_VIDEO:

The two branches of the switch look now very similar and non trivial, I
think you should invert the tests to refactor the common code.

> -enc_ctx->time_base = av_inv_q(ost->frame_rate);
> +switch (video_timescale) {
> +case -1:
> +if (ist) {
> +enc_ctx->time_base = ist->st->time_base;
> +break;
> +}
> +av_log(oc, AV_LOG_WARNING, "Input stream data not available, 
> using the frame rate as the time base\n");
> + /* fall-through */
> +case 0:
> +enc_ctx->time_base = av_inv_q(ost->frame_rate);
> +break;
> +
> +default:
> +enc_ctx->time_base = (AVRational){ 1, video_timescale };
> +break;
> +}
> +
>  if (!(enc_ctx->time_base.num && enc_ctx->time_base.den))
>  enc_ctx->time_base = 
> av_buffersink_get_time_base(ost->filter->filter);
>  if (   av_q2d(enc_ctx->time_base) < 0.001 && video_sync_method != 
> VSYNC_PASSTHROUGH
> diff --git a/ffmpeg.h b/ffmpeg.h
> index 4d0456c..84c168a 100644
> --- a/ffmpeg.h
> +++ b/ffmpeg.h
> @@ -594,6 +594,8 @@ extern int do_pkt_dump;
>  extern int copy_ts;
>  extern int start_at_zero;
>  extern int copy_tb;

> +extern int audio_timescale;
> +extern int video_timescale;

This can not do. The "timescale" do not apply to all audio and all video
the same. Whenever you feel the need to add almost the same option, one
for audio and one for video, odds are it should be a per-stream option
instead. And I think it is the case here.

>  extern int debug_ts;
>  extern int exit_on_error;
>  extern int abort_on_flags;
> diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
> index d1fe874..36a85c0 100644
> --- a/ffmpeg_opt.c
> +++ b/ffmpeg_opt.c
> @@ -111,6 +111,8 @@ int do_pkt_dump   = 0;
>  int copy_ts   = 0;
>  int start_at_zero = 0;
>  int copy_tb   = -1;
> +int audio_timescale   = 0;
> +int video_timescale   = 0;
>  int debug_ts  = 0;
>  int exit_on_error = 0;
>  int abort_on_flags= 0;
> @@ -3392,6 +3394,12 @@ const Opti

[FFmpeg-devel] [PATCH] hevc: Fix scaling list prediction delta for the 32x32 inter matrix

2017-04-30 Thread Mark Thompson
Fixes ticket #6356.
---
This was broken in 627c044f50da3046809314f7cc742b8a10cf26a1, which changed the 
array index of the 32x32 inter matrix but missed this case.

Sample at  - with this change the output 
for that sample matches the reference decoder.


 libavcodec/hevc_ps.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 6d67dd9c69..3e00e4b3f3 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -719,6 +719,7 @@ static int scaling_list_data(GetBitContext *gb, 
AVCodecContext *avctx, ScalingLi
  * which should already be in the arrays. */
 if (delta) {
 // Copy from previous array.
+delta *= (size_id == 3) ? 3 : 1;
 if (matrix_id < delta) {
 av_log(avctx, AV_LOG_ERROR,
"Invalid delta in scaling list data: %d.\n", 
delta);
-- 
2.11.0

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


Re: [FFmpeg-devel] [PATCH] lavc/vaapi_encode_h265: Suppress the "above array bounds" warning.

2017-04-30 Thread Mark Thompson
On 26/04/17 07:44, Jun Zhao wrote:
> From f3678e0ceb691b6df5957a2c3d26d4f0d91d4ff5 Mon Sep 17 00:00:00 2001
> From: Jun Zhao 
> Date: Wed, 26 Apr 2017 14:00:56 +0800
> Subject: [PATCH] lavc/vaapi_encode_h265: Suppress the "above array bounds"
>  warning.
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> setting the layer_id_included_flag lead to a potential array out of bounds,
> build warning message as follow:
> libavcodec/vaapi_encode_h265.c: In function
> ‘vaapi_encode_h265_write_sequence_header’:
> libavcodec/vaapi_encode_h265.c:305:49: warning: array subscript is above
> array bounds [-Warray-bounds]

Can you explain what the aim of this is?  You haven't actually set any of the 
layer_id_included_flag in this patch, so is there more to follow dealing with 
the layers / layer sets?

In any case, the dimensions of the array should probably be 
[MAX_LAYER_SETS][MAX_LAYERS] rather than the current values.  (With 
MAX_LAYER_SETS having value 1 currently, but more if you intend to add more.)

> Signed-off-by: Jun Zhao 
> ---
>  libavcodec/vaapi_encode_h265.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
> index 6e008b7b9c..1b2a49806b 100644
> --- a/libavcodec/vaapi_encode_h265.c
> +++ b/libavcodec/vaapi_encode_h265.c
> @@ -66,7 +66,7 @@ typedef struct VAAPIEncodeH265MiscSequenceParams {
>  unsigned int vps_num_layer_sets_minus1;
>  unsigned int sps_max_sub_layers_minus1;
>  char sps_temporal_id_nesting_flag;
> -char layer_id_included_flag[MAX_LAYERS][64];
> +char layer_id_included_flag[MAX_LAYERS+1][64];
>  
>  // Profile/tier/level parameters.
>  char general_profile_compatibility_flag[32];
> -- 
> 2.11.0
> 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2] avcodec/pthread_frame, decode: allow errors to happen on draining

2017-04-30 Thread wm4
On Sun, 30 Apr 2017 06:09:18 +0700
Muhammad Faiz  wrote:

> On Sat, Apr 29, 2017 at 6:18 AM, Muhammad Faiz  wrote:
> > On Sat, Apr 29, 2017 at 6:01 AM, Michael Niedermayer
> >  wrote:  
> >> On Fri, Apr 28, 2017 at 11:23:10PM +0700, Muhammad Faiz wrote:  
> >>> On Fri, Apr 28, 2017 at 5:55 PM, Ronald S. Bultje  
> >>> wrote:  
> >>> > Hi,
> >>> >
> >>> > On Fri, Apr 28, 2017 at 6:19 AM, Muhammad Faiz  
> >>> > wrote:  
> >>> >>
> >>> >> So, all frames and errors are correctly reported in order.
> >>> >> Also limit the numbers of error during draining to prevent infinite 
> >>> >> loop.
> >>> >>
> >>> >> This fix fate failure with THREADS>=4:
> >>> >>   make fate-h264-attachment-631 THREADS=4
> >>> >> This also reverts a755b725ec1d657609c8bd726ce37e7cf193d03f.
> >>> >>
> >>> >> Suggested-by: wm4, Ronald S. Bultje, Marton Balint
> >>> >> Signed-off-by: Muhammad Faiz 
> >>> >> ---
> >>> >>  libavcodec/decode.c| 21 +++--
> >>> >>  libavcodec/internal.h  |  3 +++
> >>> >>  libavcodec/pthread_frame.c | 15 +++
> >>> >>  3 files changed, 29 insertions(+), 10 deletions(-)
> >>> >>
> >>> >> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> >>> >> index 6ff3c40..edfae55 100644
> >>> >> --- a/libavcodec/decode.c
> >>> >> +++ b/libavcodec/decode.c
> >>> >> @@ -568,8 +568,24 @@ FF_ENABLE_DEPRECATION_WARNINGS
> >>> >>  avctx->time_base = av_inv_q(av_mul_q(avctx->framerate,
> >>> >> (AVRational){avctx->ticks_per_frame, 1}));
> >>> >>  #endif
> >>> >>
> >>> >> -if (avctx->internal->draining && !got_frame)
> >>> >> -avci->draining_done = 1;
> >>> >> +/* do not stop draining when got_frame != 0 or ret < 0 */
> >>> >> +if (avctx->internal->draining && !got_frame) {
> >>> >> +if (ret < 0) {
> >>> >> +/* prevent infinite loop if a decoder wrongly always 
> >>> >> return
> >>> >> error on draining */
> >>> >> +/* reasonable nb_errors_max = maximum b frames + thread 
> >>> >> count
> >>> >> */
> >>> >> +int nb_errors_max = 20 + (HAVE_THREADS &&
> >>> >> avctx->active_thread_type & FF_THREAD_FRAME ?
> >>> >> +avctx->thread_count : 1);
> >>> >> +
> >>> >> +if (avci->nb_draining_errors++ >= nb_errors_max) {
> >>> >> +av_log(avctx, AV_LOG_ERROR, "Too many errors when
> >>> >> draining, this is a bug. "
> >>> >> +   "Stop draining and force EOF.\n");
> >>> >> +avci->draining_done = 1;
> >>> >> +ret = AVERROR_BUG;
> >>> >> +}
> >>> >> +} else {
> >>> >> +avci->draining_done = 1;
> >>> >> +}
> >>> >> +}  
> >>> >
> >>> >
> >>> > Hm... I guess this is OK, it would be really nice to have a way of 
> >>> > breaking
> >>> > in developer builds (e.g. av_assert or so, although I guess technically 
> >>> > this
> >>> > could be enabled in prod builds also).  
> >>>
> >>> Add av_assert2().
> >>>  
> >>> >
> >>> > Also, Marton suggested to return AVERROR_EOF, maybe handle that here 
> >>> > also in
> >>> > addition to ret=0?  
> >>>
> >>> Modified.
> >>>
> >>> Updated patch attached.
> >>>
> >>> Thank's  
> >>  
> >>>  decode.c|   23 +--
> >>>  internal.h  |3 +++
> >>>  pthread_frame.c |   15 +++
> >>>  3 files changed, 31 insertions(+), 10 deletions(-)
> >>> d3049c52598070baa9566fc98a089111732595fa  
> >>> 0001-avcodec-pthread_frame-decode-allow-errors-to-happen-.patch
> >>> From f684770e016fa36d458d08383065815882cbc7f8 Mon Sep 17 00:00:00 2001
> >>> From: Muhammad Faiz 
> >>> Date: Fri, 28 Apr 2017 17:08:39 +0700
> >>> Subject: [PATCH v3] avcodec/pthread_frame, decode: allow errors to happen 
> >>> on
> >>>  draining
> >>>
> >>> So, all frames and errors are correctly reported in order.
> >>> Also limit the number of errors during draining to prevent infinite loop.
> >>> Also return AVERROR_EOF directly on EOF instead of only setting 
> >>> draining_done.
> >>>
> >>> This fix fate failure with THREADS>=4:
> >>>   make fate-h264-attachment-631 THREADS=4
> >>> This also reverts a755b725ec1d657609c8bd726ce37e7cf193d03f.
> >>>
> >>> Suggested-by: wm4, Ronald S. Bultje, Marton Balint
> >>> Signed-off-by: Muhammad Faiz 
> >>> ---
> >>>  libavcodec/decode.c| 23 +--
> >>>  libavcodec/internal.h  |  3 +++
> >>>  libavcodec/pthread_frame.c | 15 +++
> >>>  3 files changed, 31 insertions(+), 10 deletions(-)
> >>>
> >>> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> >>> index 6ff3c40..fb4d4af 100644
> >>> --- a/libavcodec/decode.c
> >>> +++ b/libavcodec/decode.c
> >>> @@ -568,8 +568,26 @@ FF_ENABLE_DEPRECATION_WARNINGS
> >>>  avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, 
> >>> (AVRational){avctx->ticks_per_frame, 1}));
> >>>  #endif
> >>>
> >>> -if (avctx->internal->draining && !got_frame)
> >>> -avci->draining_done = 1;
> >>> +/* do not stop draining w

Re: [FFmpeg-devel] [PATCH] avcodec/decode: do not treat discarded frames as eof when draining

2017-04-30 Thread wm4
On Sun, 30 Apr 2017 14:04:33 +0700
Muhammad Faiz  wrote:

> Fix fate failures:
>   make fate-mov THREADS=32
> 
> Signed-off-by: Muhammad Faiz 
> ---
>  libavcodec/decode.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index edfae55..6ec423b 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -557,9 +557,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  avci->showed_multi_packet_warning = 1;
>  }
>  
> -if (!got_frame)
> -av_frame_unref(frame);
> -
>  if (ret >= 0 && avctx->codec->type == AVMEDIA_TYPE_VIDEO && 
> !(avctx->flags & AV_CODEC_FLAG_TRUNCATED))
>  ret = pkt->size;
>  
> @@ -568,8 +565,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, 
> (AVRational){avctx->ticks_per_frame, 1}));
>  #endif
>  
> -/* do not stop draining when got_frame != 0 or ret < 0 */
> -if (avctx->internal->draining && !got_frame) {
> +/* do not stop draining when frame->buf[0] != NULL or ret < 0 */
> +/* at this point, got_frame == 0 when discarding frame */

Does that means the internal API can return got_frame=0 but
frame->buf[0] set or what? That seems like chaos. They're never
supposed to mismatch, and I think the av_frame_unref() you moved
is supposed to keep this consistent to help decoders which allocated
a frame, but did not successfully decode anything to it.

> +if (avctx->internal->draining && !frame->buf[0]) {
>  if (ret < 0) {
>  /* prevent infinite loop if a decoder wrongly always return 
> error on draining */
>  /* reasonable nb_errors_max = maximum b frames + thread count */
> @@ -603,7 +601,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  avci->last_pkt_props->dts = AV_NOPTS_VALUE;
>  }
>  
> -if (got_frame)
> +if (!got_frame)
> +av_frame_unref(frame);
> +else
>  av_assert0(frame->buf[0]);
>  
>  return ret < 0 ? ret : 0;

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


Re: [FFmpeg-devel] libavcodec/exr : fix piz uncompress on big endian

2017-04-30 Thread Martin Vignali
>
> Tested-by: michael on qemu mips
>
> Ping for apply this patch (and the two fate tests)

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


Re: [FFmpeg-devel] Match source video timestamp

2017-04-30 Thread Eran Kornblau
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Carl 
> Eugen Hoyos
> Sent: Sunday, April 30, 2017 2:18 PM
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] Match source video timestamp
> 
> 2017-04-30 13:09 GMT+02:00 Eran Kornblau :
> 
> >> I'm trying to transcode some video file (MP4/h264 baseline vfr/AAC) 
> >> with ffmpeg, and I would like to have the frame timestamps in the 
> >> transcoded file perfectly match the source video.
> 
> Why does this not work with -copyts?
> 
I don't really understand what this setting is supposed to do, it is referenced 
in a few very long ifs...
But what I can say is that it does not affect the encoder time base, and that's 
what's causing the
problem I'm having (the encoder time base is set too low, so that it quantizes 
the timestamp values)
There's also -copytb, but from what I see it is only used in stream copy mode, 
while I'm doing encoding.

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

Thanks!

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


[FFmpeg-devel] [PATCH 1/2] hevcdec: remove HEVCContext usage from hevc_sei

2017-04-30 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/hevc_parser.c |   9 +--
 libavcodec/hevc_refs.c   |   4 +-
 libavcodec/hevc_sei.c| 154 +++
 libavcodec/hevcdec.c |  90 +--
 libavcodec/hevcdec.h |  95 +
 5 files changed, 187 insertions(+), 165 deletions(-)

diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
index 310428d0ff..f82f9fdf5e 100644
--- a/libavcodec/hevc_parser.c
+++ b/libavcodec/hevc_parser.c
@@ -192,6 +192,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, 
const uint8_t *buf,
 GetBitContext  *gb;
 SliceHeader*sh = &h->sh;
 HEVCParamSets *ps = &h->ps;
+HEVCSEIContext *sei = &h->sei;
 H2645Packet   *pkt = &ctx->pkt;
 const uint8_t *buf_end = buf + buf_size;
 int state = -1, i;
@@ -212,7 +213,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, 
const uint8_t *buf,
 
 h->avctx = avctx;
 
-ff_hevc_reset_sei(h);
+ff_hevc_reset_sei(sei);
 
 if (!buf_size)
 return 0;
@@ -265,7 +266,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, 
const uint8_t *buf,
 break;
 case HEVC_NAL_SEI_PREFIX:
 case HEVC_NAL_SEI_SUFFIX:
-ff_hevc_decode_nal_sei(h);
+ff_hevc_decode_nal_sei(gb, avctx, sei, ps, h->nal_unit_type);
 break;
 case HEVC_NAL_TRAIL_N:
 case HEVC_NAL_TRAIL_R:
@@ -290,8 +291,8 @@ static inline int parse_nal_units(AVCodecParserContext *s, 
const uint8_t *buf,
 }
 
 sh->first_slice_in_pic_flag = get_bits1(gb);
-s->picture_structure = h->picture_struct;
-s->field_order = h->picture_struct;
+s->picture_structure = h->sei.picture_timing.picture_struct;
+s->field_order = h->sei.picture_timing.picture_struct;
 
 if (IS_IRAP(h)) {
 s->key_frame = 1;
diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index 9103c84686..6810ffaf17 100644
--- a/libavcodec/hevc_refs.c
+++ b/libavcodec/hevc_refs.c
@@ -109,8 +109,8 @@ static HEVCFrame *alloc_frame(HEVCContext *s)
 for (j = 0; j < frame->ctb_count; j++)
 frame->rpl_tab[j] = (RefPicListTab *)frame->rpl_buf->data;
 
-frame->frame->top_field_first  = s->picture_struct == 
AV_PICTURE_STRUCTURE_TOP_FIELD;
-frame->frame->interlaced_frame = (s->picture_struct == 
AV_PICTURE_STRUCTURE_TOP_FIELD) || (s->picture_struct == 
AV_PICTURE_STRUCTURE_BOTTOM_FIELD);
+frame->frame->top_field_first  = s->sei.picture_timing.picture_struct 
== AV_PICTURE_STRUCTURE_TOP_FIELD;
+frame->frame->interlaced_frame = (s->sei.picture_timing.picture_struct 
== AV_PICTURE_STRUCTURE_TOP_FIELD) || (s->sei.picture_timing.picture_struct == 
AV_PICTURE_STRUCTURE_BOTTOM_FIELD);
 
 if (s->avctx->hwaccel) {
 const AVHWAccel *hwaccel = s->avctx->hwaccel;
diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index bb299d5a9f..1dc0674f81 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -53,13 +53,13 @@ enum HEVC_SEI_TYPE {
 SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO = 144,
 };
 
-static int decode_nal_sei_decoded_picture_hash(HEVCContext *s)
+static int decode_nal_sei_decoded_picture_hash(HEVCSEIPictureHash *s, 
GetBitContext *gb,
+   void *logctx)
 {
 int cIdx, i;
 uint8_t hash_type;
 //uint16_t picture_crc;
 //uint32_t picture_checksum;
-GetBitContext *gb = &s->HEVClc->gb;
 hash_type = get_bits(gb, 8);
 
 for (cIdx = 0; cIdx < 3/*((s->sps->chroma_format_idc == 0) ? 1 : 3)*/; 
cIdx++) {
@@ -78,9 +78,9 @@ static int decode_nal_sei_decoded_picture_hash(HEVCContext *s)
 return 0;
 }
 
-static int decode_nal_sei_mastering_display_info(HEVCContext *s)
+static int decode_nal_sei_mastering_display_info(HEVCSEIMasteringDisplay *s, 
GetBitContext *gb,
+ void *logctx)
 {
-GetBitContext *gb = &s->HEVClc->gb;
 int i;
 // Mastering primaries
 for (i = 0; i < 3; i++) {
@@ -92,38 +92,38 @@ static int 
decode_nal_sei_mastering_display_info(HEVCContext *s)
 s->white_point[1] = get_bits(gb, 16);
 
 // Max and min luminance of mastering display
-s->max_mastering_luminance = get_bits_long(gb, 32);
-s->min_mastering_luminance = get_bits_long(gb, 32);
+s->max_luminance = get_bits_long(gb, 32);
+s->min_luminance = get_bits_long(gb, 32);
 
 // As this SEI message comes before the first frame that references it,
 // initialize the flag to 2 and decrement on IRAP access unit so it
 // persists for the coded video sequence (e.g., between two IRAPs)
-s->sei_mastering_display_info_present = 2;
+s->present = 2;
 return 0;
 }
 
-static int decode_nal_sei_content_light_info(HEVCContext *s)
+static int decode_nal_sei_content_light_info(HEVCSEIContentLight *s, 
G

[FFmpeg-devel] [PATCH 2/2] hevcdec: move SEI message parsing into a separate header

2017-04-30 Thread James Almer
It doesn't depend on hevcdec anymore.

Signed-off-by: James Almer 
---
 libavcodec/hevc_sei.c |  54 ++
 libavcodec/hevc_sei.h | 125 ++
 libavcodec/hevcdec.h  |  66 +-
 3 files changed, 140 insertions(+), 105 deletions(-)
 create mode 100644 libavcodec/hevc_sei.h

diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index 1dc0674f81..1789d4fd4f 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -23,35 +23,8 @@
  */
 
 #include "golomb.h"
-#include "hevcdec.h"
-
-enum HEVC_SEI_TYPE {
-SEI_TYPE_BUFFERING_PERIOD = 0,
-SEI_TYPE_PICTURE_TIMING   = 1,
-SEI_TYPE_PAN_SCAN_RECT= 2,
-SEI_TYPE_FILLER_PAYLOAD   = 3,
-SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35   = 4,
-SEI_TYPE_USER_DATA_UNREGISTERED   = 5,
-SEI_TYPE_RECOVERY_POINT   = 6,
-SEI_TYPE_SCENE_INFO   = 9,
-SEI_TYPE_FULL_FRAME_SNAPSHOT  = 15,
-SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_START = 16,
-SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_END   = 17,
-SEI_TYPE_FILM_GRAIN_CHARACTERISTICS   = 19,
-SEI_TYPE_POST_FILTER_HINT = 22,
-SEI_TYPE_TONE_MAPPING_INFO= 23,
-SEI_TYPE_FRAME_PACKING= 45,
-SEI_TYPE_DISPLAY_ORIENTATION  = 47,
-SEI_TYPE_SOP_DESCRIPTION  = 128,
-SEI_TYPE_ACTIVE_PARAMETER_SETS= 129,
-SEI_TYPE_DECODING_UNIT_INFO   = 130,
-SEI_TYPE_TEMPORAL_LEVEL0_INDEX= 131,
-SEI_TYPE_DECODED_PICTURE_HASH = 132,
-SEI_TYPE_SCALABLE_NESTING = 133,
-SEI_TYPE_REGION_REFRESH_INFO  = 134,
-SEI_TYPE_MASTERING_DISPLAY_INFO   = 137,
-SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO = 144,
-};
+#include "hevc_ps.h"
+#include "hevc_sei.h"
 
 static int decode_nal_sei_decoded_picture_hash(HEVCSEIPictureHash *s, 
GetBitContext *gb,
void *logctx)
@@ -157,8 +130,8 @@ static int 
decode_nal_sei_display_orientation(HEVCSEIDisplayOrientation *s, GetB
 return 0;
 }
 
-static int decode_pic_timing(HEVCSEIContext *s, GetBitContext *gb, void 
*logctx,
- const HEVCParamSets *ps)
+static int decode_pic_timing(HEVCSEIContext *s, GetBitContext *gb,
+ void *logctx, const HEVCParamSets *ps)
 {
 HEVCSEIPictureTiming *h = &s->picture_timing;
 HEVCSPS *sps;
@@ -267,7 +240,8 @@ static int 
decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEIContext *s,
 return 0;
 }
 
-static int active_parameter_sets(HEVCSEIContext *s, GetBitContext *gb, void 
*logctx)
+static int active_parameter_sets(HEVCSEIContext *s, GetBitContext *gb,
+ void *logctx)
 {
 int num_sps_ids_minus1;
 int i;
@@ -302,29 +276,29 @@ static int decode_nal_sei_prefix(GetBitContext *gb, void 
*logctx, HEVCSEIContext
 switch (type) {
 case 256:  // Mismatched value from HM 8.1
 return decode_nal_sei_decoded_picture_hash(&s->picture_hash, gb, 
logctx);
-case SEI_TYPE_FRAME_PACKING:
+case HEVC_SEI_TYPE_FRAME_PACKING:
 return decode_nal_sei_frame_packing_arrangement(&s->frame_packing,
 gb, logctx);
-case SEI_TYPE_DISPLAY_ORIENTATION:
+case HEVC_SEI_TYPE_DISPLAY_ORIENTATION:
 return decode_nal_sei_display_orientation(&s->display_orientation,
   gb, logctx);
-case SEI_TYPE_PICTURE_TIMING:
+case HEVC_SEI_TYPE_PICTURE_TIMING:
 {
 int ret = decode_pic_timing(s, gb, logctx, ps);
 av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
 skip_bits(gb, 8 * size);
 return ret;
 }
-case SEI_TYPE_MASTERING_DISPLAY_INFO:
+case HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO:
 return decode_nal_sei_mastering_display_info(&s->mastering_display,
  gb, logctx);
-case SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO:
+case HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO:
 return decode_nal_sei_content_light_info(&s->content_light, gb, 
logctx);
-case SEI_TYPE_ACTIVE_PARAMETER_SETS:
+case HEVC_SEI_TYPE_ACTIVE_PARAMETER_SETS:
 active_parameter_sets(s, gb, logctx);
 av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
 return 0;
-case SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
+case HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
 return decode_nal_sei_user_data_registered_itu_t_t35(s, gb, logctx, 
size);
 default:
 av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
@@ -337,7 +311,

Re: [FFmpeg-devel] [PATCH v2] avcodec/pthread_frame, decode: allow errors to happen on draining

2017-04-30 Thread Muhammad Faiz
On Sun, Apr 30, 2017 at 8:27 PM, wm4  wrote:
> On Sun, 30 Apr 2017 06:09:18 +0700
> Muhammad Faiz  wrote:
>
>> On Sat, Apr 29, 2017 at 6:18 AM, Muhammad Faiz  wrote:
>> > On Sat, Apr 29, 2017 at 6:01 AM, Michael Niedermayer
>> >  wrote:
>> >> On Fri, Apr 28, 2017 at 11:23:10PM +0700, Muhammad Faiz wrote:
>> >>> On Fri, Apr 28, 2017 at 5:55 PM, Ronald S. Bultje  
>> >>> wrote:
>> >>> > Hi,
>> >>> >
>> >>> > On Fri, Apr 28, 2017 at 6:19 AM, Muhammad Faiz  
>> >>> > wrote:
>> >>> >>
>> >>> >> So, all frames and errors are correctly reported in order.
>> >>> >> Also limit the numbers of error during draining to prevent infinite 
>> >>> >> loop.
>> >>> >>
>> >>> >> This fix fate failure with THREADS>=4:
>> >>> >>   make fate-h264-attachment-631 THREADS=4
>> >>> >> This also reverts a755b725ec1d657609c8bd726ce37e7cf193d03f.
>> >>> >>
>> >>> >> Suggested-by: wm4, Ronald S. Bultje, Marton Balint
>> >>> >> Signed-off-by: Muhammad Faiz 
>> >>> >> ---
>> >>> >>  libavcodec/decode.c| 21 +++--
>> >>> >>  libavcodec/internal.h  |  3 +++
>> >>> >>  libavcodec/pthread_frame.c | 15 +++
>> >>> >>  3 files changed, 29 insertions(+), 10 deletions(-)
>> >>> >>
>> >>> >> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
>> >>> >> index 6ff3c40..edfae55 100644
>> >>> >> --- a/libavcodec/decode.c
>> >>> >> +++ b/libavcodec/decode.c
>> >>> >> @@ -568,8 +568,24 @@ FF_ENABLE_DEPRECATION_WARNINGS
>> >>> >>  avctx->time_base = av_inv_q(av_mul_q(avctx->framerate,
>> >>> >> (AVRational){avctx->ticks_per_frame, 1}));
>> >>> >>  #endif
>> >>> >>
>> >>> >> -if (avctx->internal->draining && !got_frame)
>> >>> >> -avci->draining_done = 1;
>> >>> >> +/* do not stop draining when got_frame != 0 or ret < 0 */
>> >>> >> +if (avctx->internal->draining && !got_frame) {
>> >>> >> +if (ret < 0) {
>> >>> >> +/* prevent infinite loop if a decoder wrongly always 
>> >>> >> return
>> >>> >> error on draining */
>> >>> >> +/* reasonable nb_errors_max = maximum b frames + thread 
>> >>> >> count
>> >>> >> */
>> >>> >> +int nb_errors_max = 20 + (HAVE_THREADS &&
>> >>> >> avctx->active_thread_type & FF_THREAD_FRAME ?
>> >>> >> +avctx->thread_count : 1);
>> >>> >> +
>> >>> >> +if (avci->nb_draining_errors++ >= nb_errors_max) {
>> >>> >> +av_log(avctx, AV_LOG_ERROR, "Too many errors when
>> >>> >> draining, this is a bug. "
>> >>> >> +   "Stop draining and force EOF.\n");
>> >>> >> +avci->draining_done = 1;
>> >>> >> +ret = AVERROR_BUG;
>> >>> >> +}
>> >>> >> +} else {
>> >>> >> +avci->draining_done = 1;
>> >>> >> +}
>> >>> >> +}
>> >>> >
>> >>> >
>> >>> > Hm... I guess this is OK, it would be really nice to have a way of 
>> >>> > breaking
>> >>> > in developer builds (e.g. av_assert or so, although I guess 
>> >>> > technically this
>> >>> > could be enabled in prod builds also).
>> >>>
>> >>> Add av_assert2().
>> >>>
>> >>> >
>> >>> > Also, Marton suggested to return AVERROR_EOF, maybe handle that here 
>> >>> > also in
>> >>> > addition to ret=0?
>> >>>
>> >>> Modified.
>> >>>
>> >>> Updated patch attached.
>> >>>
>> >>> Thank's
>> >>
>> >>>  decode.c|   23 +--
>> >>>  internal.h  |3 +++
>> >>>  pthread_frame.c |   15 +++
>> >>>  3 files changed, 31 insertions(+), 10 deletions(-)
>> >>> d3049c52598070baa9566fc98a089111732595fa  
>> >>> 0001-avcodec-pthread_frame-decode-allow-errors-to-happen-.patch
>> >>> From f684770e016fa36d458d08383065815882cbc7f8 Mon Sep 17 00:00:00 2001
>> >>> From: Muhammad Faiz 
>> >>> Date: Fri, 28 Apr 2017 17:08:39 +0700
>> >>> Subject: [PATCH v3] avcodec/pthread_frame, decode: allow errors to 
>> >>> happen on
>> >>>  draining
>> >>>
>> >>> So, all frames and errors are correctly reported in order.
>> >>> Also limit the number of errors during draining to prevent infinite loop.
>> >>> Also return AVERROR_EOF directly on EOF instead of only setting 
>> >>> draining_done.
>> >>>
>> >>> This fix fate failure with THREADS>=4:
>> >>>   make fate-h264-attachment-631 THREADS=4
>> >>> This also reverts a755b725ec1d657609c8bd726ce37e7cf193d03f.
>> >>>
>> >>> Suggested-by: wm4, Ronald S. Bultje, Marton Balint
>> >>> Signed-off-by: Muhammad Faiz 
>> >>> ---
>> >>>  libavcodec/decode.c| 23 +--
>> >>>  libavcodec/internal.h  |  3 +++
>> >>>  libavcodec/pthread_frame.c | 15 +++
>> >>>  3 files changed, 31 insertions(+), 10 deletions(-)
>> >>>
>> >>> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
>> >>> index 6ff3c40..fb4d4af 100644
>> >>> --- a/libavcodec/decode.c
>> >>> +++ b/libavcodec/decode.c
>> >>> @@ -568,8 +568,26 @@ FF_ENABLE_DEPRECATION_WARNINGS
>> >>>  avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, 
>> >>> (AVRational){avctx->ticks_per_frame, 1}));
>>

Re: [FFmpeg-devel] [PATCH v2] avcodec/pthread_frame, decode: allow errors to happen on draining

2017-04-30 Thread Nicolas George
Le primidi 11 floréal, an CCXXV, Muhammad Faiz a écrit :
> I'm sorry for pushing it too quickly. I refer on
> https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2017-March/208718.html.

This is wrong, do not take it into account.

No objections after one ping and a few days means the patch is OK.
Anything less means nothing.

And you should be careful when putting punctuation after URLs.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH v2] avcodec/pthread_frame, decode: allow errors to happen on draining

2017-04-30 Thread James Almer
On 4/30/2017 12:46 PM, Nicolas George wrote:
> Le primidi 11 floréal, an CCXXV, Muhammad Faiz a écrit :
>> I'm sorry for pushing it too quickly. I refer on
>> https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2017-March/208718.html.
> 
> This is wrong, do not take it into account.
> 
> No objections after one ping and a few days means the patch is OK.
> Anything less means nothing.

I don't think there's any explicit written rule about it, but in any
case, both Ronald and wm4 had given him the ok for the patch he pushed,
so waiting 24 hours after that is fine.

It could have waited a bit mainly because it's delicate code that could
break badly if something is done wrong, so the more testing it's given
the better.

> 
> And you should be careful when putting punctuation after URLs.
> 
> Regards,
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/decode: do not treat discarded frames as eof when draining

2017-04-30 Thread Muhammad Faiz
On Sun, Apr 30, 2017 at 8:31 PM, wm4  wrote:
> On Sun, 30 Apr 2017 14:04:33 +0700
> Muhammad Faiz  wrote:
>
>> Fix fate failures:
>>   make fate-mov THREADS=32
>>
>> Signed-off-by: Muhammad Faiz 
>> ---
>>  libavcodec/decode.c | 12 ++--
>>  1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
>> index edfae55..6ec423b 100644
>> --- a/libavcodec/decode.c
>> +++ b/libavcodec/decode.c
>> @@ -557,9 +557,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>  avci->showed_multi_packet_warning = 1;
>>  }
>>
>> -if (!got_frame)
>> -av_frame_unref(frame);
>> -
>>  if (ret >= 0 && avctx->codec->type == AVMEDIA_TYPE_VIDEO && 
>> !(avctx->flags & AV_CODEC_FLAG_TRUNCATED))
>>  ret = pkt->size;
>>
>> @@ -568,8 +565,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>  avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, 
>> (AVRational){avctx->ticks_per_frame, 1}));
>>  #endif
>>
>> -/* do not stop draining when got_frame != 0 or ret < 0 */
>> -if (avctx->internal->draining && !got_frame) {
>> +/* do not stop draining when frame->buf[0] != NULL or ret < 0 */
>> +/* at this point, got_frame == 0 when discarding frame */
>
> Does that means the internal API can return got_frame=0 but
> frame->buf[0] set or what? That seems like chaos. They're never

No. got_frame is unset in decode_simple_internal() when the frame has
AV_FRAME_FLAG_DISCARD.

> supposed to mismatch, and I think the av_frame_unref() you moved
> is supposed to keep this consistent to help decoders which allocated
> a frame, but did not successfully decode anything to it.

I moved av_frame_unref() to make frame->buf[0] available for eof testing.

>
>> +if (avctx->internal->draining && !frame->buf[0]) {
>>  if (ret < 0) {
>>  /* prevent infinite loop if a decoder wrongly always return 
>> error on draining */
>>  /* reasonable nb_errors_max = maximum b frames + thread count */
>> @@ -603,7 +601,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>  avci->last_pkt_props->dts = AV_NOPTS_VALUE;
>>  }
>>
>> -if (got_frame)
>> +if (!got_frame)
>> +av_frame_unref(frame);
>> +else
>>  av_assert0(frame->buf[0]);
>>
>>  return ret < 0 ? ret : 0;
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2 1/2] avcodec/options: factorize avcodec_copy_context() cleanup code

2017-04-30 Thread James Almer
On 4/24/2017 7:47 PM, James Almer wrote:
> Signed-off-by: James Almer 
> ---
> No changes since last version.
> 
>  libavcodec/options.c | 30 +++---
>  1 file changed, 15 insertions(+), 15 deletions(-)

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


Re: [FFmpeg-devel] [PATCH] avcodec/libmp3lame: properly handle unaligned frame data

2017-04-30 Thread Muhammad Faiz
On Thu, Apr 27, 2017 at 3:51 PM, Nicolas George  wrote:
> L'octidi 8 floréal, an CCXXV, Michael Niedermayer a écrit :
>> I agree
>> in fact i added such a flag in 2011 
>> (4d34b6c1a1254850e39a36f08f4d2730092a54db)
>> within the API of that time to avfilter
>
> It was not a bad idea, but it should not be limited to filters. A few
> comments.
>
> * First, the framequeue framework does not produce unaligned code.
> According to the C standard, the data it handles stay aligned. The
> alignment problems come from non-standard requirements by special
> processor features used by some filters and codecs, but not all.
>
> * That means a lot of the most useful codecs and filters will suffer
> from it, but not all. For many tasks, the alignment is just fine, and
> the extra copy would be wasteful.
>
> * The alignment requirements increase. Before AVX, it was up to 16, now
> it can be 32, and I have no doubt future processor will at some point
> require 64 or 128. But realigning buffers used with SSE to 32 would be
> wasteful too. Thus, we do not require a flag but a full integer.
>
> * The code that does the actual work of realigning a buffer should
> available as a stand-alone API, to be used by applications that work at
> low-level. I suppose something like that would be in order:
>
> int av_frame_realign(AVFrame *frame, unsigned align);
>
> Or maybe:
>
> int av_frame_realign(AVFrame *frame, unsigned align,
>  AVBufferAllocator *alloc);
>
> where AVBufferAllocator is there to allocate possibly hardware or mmaped
> buffers.
>
> * It is another argument for my leitmotiv that filters and codecs are
> actually the same and should be merged API-wise.
>
> * It would be better to have the API just work for everything rather
> than documenting the alignment needs.
>
> As for the actual implementation, I see a lot of different approaches:
>
> - have the framework realing the frame before submitting it to the
>   filters and codecs: costly in malloc() and memcpy() but simple;
>
> - have each filter or codec call av_frame_realign() as needed; it may
>   seem less elegant than the previous proposal, but it may prove a
>   better choice in the light of what follows;
>
> - have each filter or codec copy the unaligned data into a buffer
>   allocated once and for all or on the stack, possibly by small chunks:
>   less costly in malloc() and refcounting overhead, and possibly better
>   cache-locality, but more complex code;
>
> - run the plain C version of the code on unaligned data rather than the
>   vectorized version, or the less-vectorized version (SSE vs AVX) on
>   insufficiently aligned data.
>
> Since all this boils down to a matter of performance and is related to
> the core task of FFmpeg, I think the choice between the various options
> should be done on a case-by-case basis using real benchmarks.

Are you working on these? Because currently I'm not.

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


Re: [FFmpeg-devel] [PATCH v2] avcodec/pthread_frame, decode: allow errors to happen on draining

2017-04-30 Thread Nicolas George
Le primidi 11 floréal, an CCXXV, James Almer a écrit :
> I don't think there's any explicit written rule about it, but in any
> case, both Ronald and wm4 had given him the ok for the patch he pushed,
> so waiting 24 hours after that is fine.
> 
> It could have waited a bit mainly because it's delicate code that could
> break badly if something is done wrong, so the more testing it's given
> the better.

I have not read the specifics of this thread, I do not think that
Muhammad did anything wrong here. I only react to the mail quoted
earlier:

https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2017-March/208718.html

"No objections issues after 24hrs means patch is OK in FFmpeg
development."

This is just not true, and harmfully so.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH] avcodec/libmp3lame: properly handle unaligned frame data

2017-04-30 Thread Nicolas George
Le primidi 11 floréal, an CCXXV, Muhammad Faiz a écrit :
> Are you working on these? Because currently I'm not.

There is nothing to work on yet: the message you answer to is raising a
question about the global design of the internal API. That question
needs an answer before any work can be done, and I can not decide alone.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH 2/2] avcodec/options: do a more thorough clean up in avcodec_copy_context()

2017-04-30 Thread Aaron Levinson

On 4/26/2017 12:47 PM, James Almer wrote:

On 4/26/2017 2:46 AM, Aaron Levinson wrote:

On 4/24/2017 3:47 PM, James Almer wrote:

Free coded_frame, coded_side_data and unref hw_device_ctx to prevent
potential leaks.

Signed-off-by: James Almer 
---
 libavcodec/options.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/libavcodec/options.c b/libavcodec/options.c
index b98da9378a..82e12179a6 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -190,14 +190,26 @@ void avcodec_free_context(AVCodecContext **pavctx)
 #if FF_API_COPY_CONTEXT
 static void copy_context_reset(AVCodecContext *avctx)
 {
+int i;
+
 av_opt_free(avctx);
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
+av_frame_free(&avctx->coded_frame);
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 av_freep(&avctx->rc_override);
 av_freep(&avctx->intra_matrix);
 av_freep(&avctx->inter_matrix);
 av_freep(&avctx->extradata);
 av_freep(&avctx->subtitle_header);
 av_buffer_unref(&avctx->hw_frames_ctx);
+av_buffer_unref(&avctx->hw_device_ctx);
+for (i = 0; i < avctx->nb_coded_side_data; i++)
+av_freep(&avctx->coded_side_data[i].data);
+av_freep(&avctx->coded_side_data);
 avctx->subtitle_header_size = 0;
+avctx->nb_coded_side_data = 0;
 avctx->extradata_size = 0;
 }

@@ -238,11 +250,14 @@ FF_ENABLE_DEPRECATION_WARNINGS

 /* reallocate values that should be allocated separately */
 dest->extradata   = NULL;
+dest->coded_side_data = NULL;
 dest->intra_matrix= NULL;
 dest->inter_matrix= NULL;
 dest->rc_override = NULL;
 dest->subtitle_header = NULL;
 dest->hw_frames_ctx   = NULL;
+dest->hw_device_ctx   = NULL;
+dest->nb_coded_side_data = 0;

 #define alloc_and_copy_or_fail(obj, size, pad) \
 if (src->obj && size > 0) { \



I'm not sure if this patch is intended to be a replacement for your last
"2/2" patch, but this version is missing the the coded_side_data
population code that was in the first version of your "2/2" patch.

Aaron Levinson


It is. I'm keeping the functionality of the function as is, and only
making sure cleanup is complete to prevent leaks.
This function is deprecated and shouldn't be used, so i'm not going to
make it copy even more stuff.


I've reviewed both patches 1 and 2, and both are good to commit.

Technically, the behavior of the code is changed by zeroing out 
coded_side_data and nb_coded_side_data after doing the memcpy() call, 
even though, by not doing a copy of coded_side_data() previously, this 
resulted in the same coded_side_data pointer being owned by two 
AVCodecContext objects (assuming that there is any coded side data in 
the source AVCodecContext object).  This was a bug, but if there is any 
code that depends on there being valid coded side data in the copied 
context, then this could result in problems.  However, I've surveyed the 
code in ffmpeg proper, and I actually can find no uses of 
coded_side_data in AVCodecContext objects other than the code in 
ffmpeg.c to copy coded side data into the stream, and it is the copy of 
the coded side data in the stream that is actually used.  This entire 
procedure of populating coded_side_data in AVCodecContext objects for it 
to be later copied into an AVStream object where it is actually used is 
a bit kludgy and could use some work.


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


Re: [FFmpeg-devel] [PATCH] avcodec/libmp3lame: properly handle unaligned frame data

2017-04-30 Thread wm4
On Sun, 30 Apr 2017 23:55:02 +0700
Muhammad Faiz  wrote:

> On Thu, Apr 27, 2017 at 3:51 PM, Nicolas George  wrote:
> > L'octidi 8 floréal, an CCXXV, Michael Niedermayer a écrit :  
> >> I agree
> >> in fact i added such a flag in 2011 
> >> (4d34b6c1a1254850e39a36f08f4d2730092a54db)
> >> within the API of that time to avfilter  
> >
> > It was not a bad idea, but it should not be limited to filters. A few
> > comments.
> >
> > * First, the framequeue framework does not produce unaligned code.
> > According to the C standard, the data it handles stay aligned. The
> > alignment problems come from non-standard requirements by special
> > processor features used by some filters and codecs, but not all.
> >
> > * That means a lot of the most useful codecs and filters will suffer
> > from it, but not all. For many tasks, the alignment is just fine, and
> > the extra copy would be wasteful.
> >
> > * The alignment requirements increase. Before AVX, it was up to 16, now
> > it can be 32, and I have no doubt future processor will at some point
> > require 64 or 128. But realigning buffers used with SSE to 32 would be
> > wasteful too. Thus, we do not require a flag but a full integer.
> >
> > * The code that does the actual work of realigning a buffer should
> > available as a stand-alone API, to be used by applications that work at
> > low-level. I suppose something like that would be in order:
> >
> > int av_frame_realign(AVFrame *frame, unsigned align);
> >
> > Or maybe:
> >
> > int av_frame_realign(AVFrame *frame, unsigned align,
> >  AVBufferAllocator *alloc);
> >
> > where AVBufferAllocator is there to allocate possibly hardware or mmaped
> > buffers.
> >
> > * It is another argument for my leitmotiv that filters and codecs are
> > actually the same and should be merged API-wise.
> >
> > * It would be better to have the API just work for everything rather
> > than documenting the alignment needs.
> >
> > As for the actual implementation, I see a lot of different approaches:
> >
> > - have the framework realing the frame before submitting it to the
> >   filters and codecs: costly in malloc() and memcpy() but simple;
> >
> > - have each filter or codec call av_frame_realign() as needed; it may
> >   seem less elegant than the previous proposal, but it may prove a
> >   better choice in the light of what follows;
> >
> > - have each filter or codec copy the unaligned data into a buffer
> >   allocated once and for all or on the stack, possibly by small chunks:
> >   less costly in malloc() and refcounting overhead, and possibly better
> >   cache-locality, but more complex code;
> >
> > - run the plain C version of the code on unaligned data rather than the
> >   vectorized version, or the less-vectorized version (SSE vs AVX) on
> >   insufficiently aligned data.
> >
> > Since all this boils down to a matter of performance and is related to
> > the core task of FFmpeg, I think the choice between the various options
> > should be done on a case-by-case basis using real benchmarks.  
> 
> Are you working on these? Because currently I'm not.

I think it's probably ok to push your current patch, since the original
author of the patch who broke this probably won't fix it.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] hevc_parser: use ff_h2645_packet_split() to parse NAL units

2017-04-30 Thread James Almer
This simplifies the code considerably.
---
 libavcodec/hevc_parser.c | 50 ++--
 1 file changed, 10 insertions(+), 40 deletions(-)

diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
index 310428d0ff..5b9cd87d88 100644
--- a/libavcodec/hevc_parser.c
+++ b/libavcodec/hevc_parser.c
@@ -192,11 +192,8 @@ static inline int parse_nal_units(AVCodecParserContext *s, 
const uint8_t *buf,
 GetBitContext  *gb;
 SliceHeader*sh = &h->sh;
 HEVCParamSets *ps = &h->ps;
-H2645Packet   *pkt = &ctx->pkt;
-const uint8_t *buf_end = buf + buf_size;
-int state = -1, i;
-H2645NAL *nal;
 int is_global = buf == avctx->extradata;
+int i, ret;
 
 if (!h->HEVClc)
 h->HEVClc = av_mallocz(sizeof(HEVCLocalContext));
@@ -214,44 +211,18 @@ static inline int parse_nal_units(AVCodecParserContext 
*s, const uint8_t *buf,
 
 ff_hevc_reset_sei(h);
 
-if (!buf_size)
-return 0;
-
-if (pkt->nals_allocated < 1) {
-H2645NAL *tmp = av_realloc_array(pkt->nals, 1, sizeof(*tmp));
-if (!tmp)
-return AVERROR(ENOMEM);
-pkt->nals = tmp;
-memset(pkt->nals, 0, sizeof(*tmp));
-pkt->nals_allocated = 1;
-}
-
-nal = &pkt->nals[0];
+ret = ff_h2645_packet_split(&ctx->pkt, buf, buf_size, avctx, 0, 0,
+AV_CODEC_ID_HEVC, 1);
+if (ret < 0)
+return ret;
 
-for (;;) {
-int src_length, consumed;
-int ret;
+for (i = 0; i < ctx->pkt.nb_nals; i++) {
+H2645NAL *nal = &ctx->pkt.nals[i];
 int num = 0, den = 0;
-buf = avpriv_find_start_code(buf, buf_end, &state);
-if (--buf + 2 >= buf_end)
-break;
-src_length = buf_end - buf;
-
-h->nal_unit_type = (*buf >> 1) & 0x3f;
-h->temporal_id   = (*(buf + 1) & 0x07) - 1;
-if (h->nal_unit_type <= HEVC_NAL_CRA_NUT) {
-// Do not walk the whole buffer just to decode slice segment header
-if (src_length > 20)
-src_length = 20;
-}
-
-consumed = ff_h2645_extract_rbsp(buf, src_length, nal, 1);
-if (consumed < 0)
-return consumed;
 
-ret = init_get_bits8(gb, nal->data + 2, nal->size);
-if (ret < 0)
-return ret;
+h->nal_unit_type = nal->type;
+h->temporal_id   = nal->temporal_id;
+*gb = nal->gb;
 
 switch (h->nal_unit_type) {
 case HEVC_NAL_VPS:
@@ -394,7 +365,6 @@ static inline int parse_nal_units(AVCodecParserContext *s, 
const uint8_t *buf,
 
 return 0; /* no need to evaluate the rest */
 }
-buf += consumed;
 }
 /* didn't find a picture! */
 if (!is_global)
-- 
2.12.1

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


Re: [FFmpeg-devel] [PATCH] Ignore expired cookies

2017-04-30 Thread Micah Galizia
Hi,

This version fixes the cstr leak and explicitly frees tmp when allocating 
cookies fails. Freeing tmp also means we don't need to free *cookies when ret 
is less than zero.

I've also formatted the name properly, so it'll show up as a new thread.

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


[FFmpeg-devel] [PATCH] libavformat/http: Ignore expired cookies

2017-04-30 Thread Micah Galizia
Signed-off-by: Micah Galizia 
---
 libavformat/http.c | 213 +++--
 1 file changed, 156 insertions(+), 57 deletions(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index 293a8a7204..d06103ab6d 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -29,6 +29,7 @@
 #include "libavutil/avstring.h"
 #include "libavutil/opt.h"
 #include "libavutil/time.h"
+#include "libavutil/parseutils.h"
 
 #include "avformat.h"
 #include "http.h"
@@ -48,6 +49,8 @@
 #define MAX_REDIRECTS 8
 #define HTTP_SINGLE   1
 #define HTTP_MUTLI2
+#define MAX_EXPIRY19
+#define WHITESPACES " \n\t\r"
 typedef enum {
 LOWER_PROTO,
 READ_HEADERS,
@@ -680,10 +683,112 @@ static int parse_icy(HTTPContext *s, const char *tag, 
const char *p)
 return 0;
 }
 
+static int parse_set_cookie_expiry_time(const char *exp_str, struct tm *buf)
+{
+char exp_buf[MAX_EXPIRY];
+int i, j, exp_buf_len = MAX_EXPIRY-1;
+char *expiry;
+
+// strip off any punctuation or whitespace
+for (i = 0, j = 0; exp_str[i] != '\0' && j < exp_buf_len; i++) {
+if ((exp_str[i] >= '0' && exp_str[i] <= '9') ||
+(exp_str[i] >= 'A' && exp_str[i] <= 'Z') ||
+(exp_str[i] >= 'a' && exp_str[i] <= 'z')) {
+exp_buf[j] = exp_str[i];
+j++;
+}
+}
+exp_buf[j] = '\0';
+expiry = exp_buf;
+
+// move the string beyond the day of week
+while ((*expiry < '0' || *expiry > '9') && *expiry != '\0')
+expiry++;
+
+return av_small_strptime(expiry, "%d%b%Y%H%M%S", buf) ? 0 : 
AVERROR(EINVAL);
+}
+
+static int parse_set_cookie(const char *set_cookie, AVDictionary **dict)
+{
+char *param, *next_param, *cstr, *back;
+
+if (!(cstr = av_strdup(set_cookie)))
+return AVERROR(EINVAL);
+
+// strip any trailing whitespace
+back = &cstr[strlen(cstr)-1];
+while (strchr(WHITESPACES, *back)) {
+*back='\0';
+back--;
+}
+
+next_param = cstr;
+while ((param = av_strtok(next_param, ";", &next_param))) {
+char *name, *value;
+param += strspn(param, WHITESPACES);
+if ((name = av_strtok(param, "=", &value))) {
+if (av_dict_set(dict, name, value, 0) < 0) {
+av_free(cstr);
+return -1;
+}
+}
+}
+
+av_free(cstr);
+return 0;
+}
+
 static int parse_cookie(HTTPContext *s, const char *p, AVDictionary **cookies)
 {
+AVDictionary *new_params = NULL;
+AVDictionaryEntry *e, *cookie_entry;
 char *eql, *name;
 
+// ensure the cookie is parsable
+if (parse_set_cookie(p, &new_params))
+return -1;
+
+// if there is no cookie value there is nothing to parse
+cookie_entry = av_dict_get(new_params, "", NULL, AV_DICT_IGNORE_SUFFIX);
+if (!cookie_entry || !cookie_entry->value) {
+av_dict_free(&new_params);
+return -1;
+}
+
+// ensure the cookie is not expired or older than an existing value
+if ((e = av_dict_get(new_params, "expires", NULL, 0)) && e->value) {
+struct tm new_tm = {0};
+if (!parse_set_cookie_expiry_time(e->value, &new_tm)) {
+AVDictionaryEntry *e2;
+
+// if the cookie has already expired ignore it
+if (av_timegm(&new_tm) < av_gettime() / 100) {
+av_dict_free(&new_params);
+return -1;
+}
+
+// only replace an older cookie with the same name
+e2 = av_dict_get(*cookies, cookie_entry->key, NULL, 0);
+if (e2 && e2->value) {
+AVDictionary *old_params = NULL;
+if (!parse_set_cookie(p, &old_params)) {
+e2 = av_dict_get(old_params, "expires", NULL, 0);
+if (e2 && e2->value) {
+struct tm old_tm = {0};
+if (!parse_set_cookie_expiry_time(e->value, &old_tm)) {
+if (av_timegm(&new_tm) < av_timegm(&old_tm)) {
+av_dict_free(&new_params);
+av_dict_free(&old_params);
+return -1;
+}
+}
+}
+}
+av_dict_free(&old_params);
+}
+}
+}
+
 // duplicate the cookie name (dict will dupe the value)
 if (!(eql = strchr(p, '='))) return AVERROR(EINVAL);
 if (!(name = av_strndup(p, eql - p))) return AVERROR(ENOMEM);
@@ -868,7 +973,7 @@ static int get_cookies(HTTPContext *s, char **cookies, 
const char *path,
 // cookie strings will look like Set-Cookie header field values.  Multiple
 // Set-Cookie fields will result in multiple values delimited by a newline
 int ret = 0;
-char *next, *cookie, *set_cookies = av_strdup(s->cookies), *cset_cookies = 
set_cookies;
+char *cookie, *set_cookies = av_strdup(s->cookies), *next = set_co

Re: [FFmpeg-devel] [PATCH] This fixes ISO date formatissue when manifest created by this muxer is not playable in most players. This ensures compatibility with dash standard. Tested on many players (d

2017-04-30 Thread Aaron Levinson

On 4/26/2017 4:27 AM, mfojtak wrote:

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

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 6232c70..fe1d6c2 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -433,7 +433,7 @@ static void format_date_now(char *buf, int size)
 struct tm *ptm, tmbuf;
 ptm = gmtime_r(&t, &tmbuf);
 if (ptm) {
-if (!strftime(buf, size, "%Y-%m-%dT%H:%M:%S", ptm))
+if (!strftime(buf, size, "%Y-%m-%dT%H:%M:%SZ", ptm))
 buf[0] = '\0';
 }
 }



This change appears to be correct.  I wasn't previously knowledgeable 
about the 'Z' suffix, but I looked into it and it is documented in ISO 
8601 (https://en.wikipedia.org/wiki/ISO_8601 and also 
http://www.ecma-international.org/ecma-262/5.1/#sec-15.9.1.15 ).


On a separate note, the actual format is:  -MM-DDTHH:mm:ss.sssZ . 
The ".sss" part is missing from this implementation, which represents 
milliseconds.  According to the specification, ".sss" may be absent, but 
maybe it would work with even more players if it were included. 
Technically, the specification states that an absent time-zone offset 
should be treated as 'Z', which indicates that the code was already 
compliant without the 'Z', even if it didn't work with most players. 
strftime() doesn't handle milliseconds, but perhaps it ought to populate 
milliseconds anyway as follows:


if (!strftime(buf, size, "%Y-%m-%dT%H:%M:%S.000Z", ptm))

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


Re: [FFmpeg-devel] [PATCH] avcodec/decode: do not treat discarded frames as eof when draining

2017-04-30 Thread Michael Niedermayer
On Sun, Apr 30, 2017 at 02:04:33PM +0700, Muhammad Faiz wrote:
> Fix fate failures:
>   make fate-mov THREADS=32
> 
> Signed-off-by: Muhammad Faiz 
> ---
>  libavcodec/decode.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)

breaks (infinit loop it seems)
./ffmpeg_g  -i ~/tickets//1873/zygoa8k_q0.mov -f null -

http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket1873/

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

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates


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


[FFmpeg-devel] [PATCH v2 2/7] hevcdec: move SEI message parsing into a separate header

2017-04-30 Thread James Almer
It doesn't depend on hevcdec anymore.

Signed-off-by: James Almer 
---
 libavcodec/hevc_sei.c |  54 ++
 libavcodec/hevc_sei.h | 125 ++
 libavcodec/hevcdec.h  |  66 +-
 3 files changed, 140 insertions(+), 105 deletions(-)
 create mode 100644 libavcodec/hevc_sei.h

diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index 1dc0674f81..1789d4fd4f 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -23,35 +23,8 @@
  */
 
 #include "golomb.h"
-#include "hevcdec.h"
-
-enum HEVC_SEI_TYPE {
-SEI_TYPE_BUFFERING_PERIOD = 0,
-SEI_TYPE_PICTURE_TIMING   = 1,
-SEI_TYPE_PAN_SCAN_RECT= 2,
-SEI_TYPE_FILLER_PAYLOAD   = 3,
-SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35   = 4,
-SEI_TYPE_USER_DATA_UNREGISTERED   = 5,
-SEI_TYPE_RECOVERY_POINT   = 6,
-SEI_TYPE_SCENE_INFO   = 9,
-SEI_TYPE_FULL_FRAME_SNAPSHOT  = 15,
-SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_START = 16,
-SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_END   = 17,
-SEI_TYPE_FILM_GRAIN_CHARACTERISTICS   = 19,
-SEI_TYPE_POST_FILTER_HINT = 22,
-SEI_TYPE_TONE_MAPPING_INFO= 23,
-SEI_TYPE_FRAME_PACKING= 45,
-SEI_TYPE_DISPLAY_ORIENTATION  = 47,
-SEI_TYPE_SOP_DESCRIPTION  = 128,
-SEI_TYPE_ACTIVE_PARAMETER_SETS= 129,
-SEI_TYPE_DECODING_UNIT_INFO   = 130,
-SEI_TYPE_TEMPORAL_LEVEL0_INDEX= 131,
-SEI_TYPE_DECODED_PICTURE_HASH = 132,
-SEI_TYPE_SCALABLE_NESTING = 133,
-SEI_TYPE_REGION_REFRESH_INFO  = 134,
-SEI_TYPE_MASTERING_DISPLAY_INFO   = 137,
-SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO = 144,
-};
+#include "hevc_ps.h"
+#include "hevc_sei.h"
 
 static int decode_nal_sei_decoded_picture_hash(HEVCSEIPictureHash *s, 
GetBitContext *gb,
void *logctx)
@@ -157,8 +130,8 @@ static int 
decode_nal_sei_display_orientation(HEVCSEIDisplayOrientation *s, GetB
 return 0;
 }
 
-static int decode_pic_timing(HEVCSEIContext *s, GetBitContext *gb, void 
*logctx,
- const HEVCParamSets *ps)
+static int decode_pic_timing(HEVCSEIContext *s, GetBitContext *gb,
+ void *logctx, const HEVCParamSets *ps)
 {
 HEVCSEIPictureTiming *h = &s->picture_timing;
 HEVCSPS *sps;
@@ -267,7 +240,8 @@ static int 
decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEIContext *s,
 return 0;
 }
 
-static int active_parameter_sets(HEVCSEIContext *s, GetBitContext *gb, void 
*logctx)
+static int active_parameter_sets(HEVCSEIContext *s, GetBitContext *gb,
+ void *logctx)
 {
 int num_sps_ids_minus1;
 int i;
@@ -302,29 +276,29 @@ static int decode_nal_sei_prefix(GetBitContext *gb, void 
*logctx, HEVCSEIContext
 switch (type) {
 case 256:  // Mismatched value from HM 8.1
 return decode_nal_sei_decoded_picture_hash(&s->picture_hash, gb, 
logctx);
-case SEI_TYPE_FRAME_PACKING:
+case HEVC_SEI_TYPE_FRAME_PACKING:
 return decode_nal_sei_frame_packing_arrangement(&s->frame_packing,
 gb, logctx);
-case SEI_TYPE_DISPLAY_ORIENTATION:
+case HEVC_SEI_TYPE_DISPLAY_ORIENTATION:
 return decode_nal_sei_display_orientation(&s->display_orientation,
   gb, logctx);
-case SEI_TYPE_PICTURE_TIMING:
+case HEVC_SEI_TYPE_PICTURE_TIMING:
 {
 int ret = decode_pic_timing(s, gb, logctx, ps);
 av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
 skip_bits(gb, 8 * size);
 return ret;
 }
-case SEI_TYPE_MASTERING_DISPLAY_INFO:
+case HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO:
 return decode_nal_sei_mastering_display_info(&s->mastering_display,
  gb, logctx);
-case SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO:
+case HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO:
 return decode_nal_sei_content_light_info(&s->content_light, gb, 
logctx);
-case SEI_TYPE_ACTIVE_PARAMETER_SETS:
+case HEVC_SEI_TYPE_ACTIVE_PARAMETER_SETS:
 active_parameter_sets(s, gb, logctx);
 av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
 return 0;
-case SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
+case HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
 return decode_nal_sei_user_data_registered_itu_t_t35(s, gb, logctx, 
size);
 default:
 av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
@@ -337,7 +311,

[FFmpeg-devel] [PATCH 0/7] Removing HEVCContext depencencies

2017-04-30 Thread James Almer
$subject

James Almer (7):
  hevcdec: remove HEVCContext usage from hevc_sei
  hevcdec: move SEI message parsing into a separate header
  hevc_parser: use ff_h2645_packet_split() to parse NAL units
  hevcdec: remove HEVCContext usage from ff_hevc_compute_poc()
  hevcdec: move SliceHeader struct definition to hevc_ps
  hevc_parser: remove HEVCContext usage
  doc/libav_merge: remove line about ADVANCED_PARSER

 doc/libav-merge.txt  |   1 -
 libavcodec/hevc_parser.c | 221 +--
 libavcodec/hevc_ps.c |  23 +
 libavcodec/hevc_ps.h |  88 +++
 libavcodec/hevc_refs.c   |  27 +-
 libavcodec/hevc_sei.c| 204 +++
 libavcodec/hevc_sei.h| 125 +++
 libavcodec/hevcdec.c |  92 ++--
 libavcodec/hevcdec.h | 137 +
 9 files changed, 416 insertions(+), 502 deletions(-)
 create mode 100644 libavcodec/hevc_sei.h

-- 
2.12.1

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


[FFmpeg-devel] [PATCH v2 1/7] hevcdec: remove HEVCContext usage from hevc_sei

2017-04-30 Thread James Almer
Based on the H264 SEI implementation.

Signed-off-by: James Almer 
---
 libavcodec/hevc_parser.c |   9 +--
 libavcodec/hevc_refs.c   |   4 +-
 libavcodec/hevc_sei.c| 154 +++
 libavcodec/hevcdec.c |  90 +--
 libavcodec/hevcdec.h |  95 +
 5 files changed, 187 insertions(+), 165 deletions(-)

diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
index 310428d0ff..f82f9fdf5e 100644
--- a/libavcodec/hevc_parser.c
+++ b/libavcodec/hevc_parser.c
@@ -192,6 +192,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, 
const uint8_t *buf,
 GetBitContext  *gb;
 SliceHeader*sh = &h->sh;
 HEVCParamSets *ps = &h->ps;
+HEVCSEIContext *sei = &h->sei;
 H2645Packet   *pkt = &ctx->pkt;
 const uint8_t *buf_end = buf + buf_size;
 int state = -1, i;
@@ -212,7 +213,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, 
const uint8_t *buf,
 
 h->avctx = avctx;
 
-ff_hevc_reset_sei(h);
+ff_hevc_reset_sei(sei);
 
 if (!buf_size)
 return 0;
@@ -265,7 +266,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, 
const uint8_t *buf,
 break;
 case HEVC_NAL_SEI_PREFIX:
 case HEVC_NAL_SEI_SUFFIX:
-ff_hevc_decode_nal_sei(h);
+ff_hevc_decode_nal_sei(gb, avctx, sei, ps, h->nal_unit_type);
 break;
 case HEVC_NAL_TRAIL_N:
 case HEVC_NAL_TRAIL_R:
@@ -290,8 +291,8 @@ static inline int parse_nal_units(AVCodecParserContext *s, 
const uint8_t *buf,
 }
 
 sh->first_slice_in_pic_flag = get_bits1(gb);
-s->picture_structure = h->picture_struct;
-s->field_order = h->picture_struct;
+s->picture_structure = h->sei.picture_timing.picture_struct;
+s->field_order = h->sei.picture_timing.picture_struct;
 
 if (IS_IRAP(h)) {
 s->key_frame = 1;
diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index 9103c84686..6810ffaf17 100644
--- a/libavcodec/hevc_refs.c
+++ b/libavcodec/hevc_refs.c
@@ -109,8 +109,8 @@ static HEVCFrame *alloc_frame(HEVCContext *s)
 for (j = 0; j < frame->ctb_count; j++)
 frame->rpl_tab[j] = (RefPicListTab *)frame->rpl_buf->data;
 
-frame->frame->top_field_first  = s->picture_struct == 
AV_PICTURE_STRUCTURE_TOP_FIELD;
-frame->frame->interlaced_frame = (s->picture_struct == 
AV_PICTURE_STRUCTURE_TOP_FIELD) || (s->picture_struct == 
AV_PICTURE_STRUCTURE_BOTTOM_FIELD);
+frame->frame->top_field_first  = s->sei.picture_timing.picture_struct 
== AV_PICTURE_STRUCTURE_TOP_FIELD;
+frame->frame->interlaced_frame = (s->sei.picture_timing.picture_struct 
== AV_PICTURE_STRUCTURE_TOP_FIELD) || (s->sei.picture_timing.picture_struct == 
AV_PICTURE_STRUCTURE_BOTTOM_FIELD);
 
 if (s->avctx->hwaccel) {
 const AVHWAccel *hwaccel = s->avctx->hwaccel;
diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index bb299d5a9f..1dc0674f81 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -53,13 +53,13 @@ enum HEVC_SEI_TYPE {
 SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO = 144,
 };
 
-static int decode_nal_sei_decoded_picture_hash(HEVCContext *s)
+static int decode_nal_sei_decoded_picture_hash(HEVCSEIPictureHash *s, 
GetBitContext *gb,
+   void *logctx)
 {
 int cIdx, i;
 uint8_t hash_type;
 //uint16_t picture_crc;
 //uint32_t picture_checksum;
-GetBitContext *gb = &s->HEVClc->gb;
 hash_type = get_bits(gb, 8);
 
 for (cIdx = 0; cIdx < 3/*((s->sps->chroma_format_idc == 0) ? 1 : 3)*/; 
cIdx++) {
@@ -78,9 +78,9 @@ static int decode_nal_sei_decoded_picture_hash(HEVCContext *s)
 return 0;
 }
 
-static int decode_nal_sei_mastering_display_info(HEVCContext *s)
+static int decode_nal_sei_mastering_display_info(HEVCSEIMasteringDisplay *s, 
GetBitContext *gb,
+ void *logctx)
 {
-GetBitContext *gb = &s->HEVClc->gb;
 int i;
 // Mastering primaries
 for (i = 0; i < 3; i++) {
@@ -92,38 +92,38 @@ static int 
decode_nal_sei_mastering_display_info(HEVCContext *s)
 s->white_point[1] = get_bits(gb, 16);
 
 // Max and min luminance of mastering display
-s->max_mastering_luminance = get_bits_long(gb, 32);
-s->min_mastering_luminance = get_bits_long(gb, 32);
+s->max_luminance = get_bits_long(gb, 32);
+s->min_luminance = get_bits_long(gb, 32);
 
 // As this SEI message comes before the first frame that references it,
 // initialize the flag to 2 and decrement on IRAP access unit so it
 // persists for the coded video sequence (e.g., between two IRAPs)
-s->sei_mastering_display_info_present = 2;
+s->present = 2;
 return 0;
 }
 
-static int decode_nal_sei_content_light_info(HEVCContext *s)
+static int decode_nal_sei_conten

[FFmpeg-devel] [PATCH 5/7] hevcdec: move SliceHeader struct definition to hevc_ps

2017-04-30 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/hevc_ps.h | 83 
 libavcodec/hevcdec.h | 83 
 2 files changed, 83 insertions(+), 83 deletions(-)

diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
index 45ef9daf1f..016f0075d4 100644
--- a/libavcodec/hevc_ps.h
+++ b/libavcodec/hevc_ps.h
@@ -39,6 +39,89 @@ typedef struct ShortTermRPS {
 uint8_t used[32];
 } ShortTermRPS;
 
+typedef struct LongTermRPS {
+int poc[32];
+uint8_t used[32];
+uint8_t nb_refs;
+} LongTermRPS;
+
+typedef struct SliceHeader {
+unsigned int pps_id;
+
+///< address (in raster order) of the first block in the current slice 
segment
+unsigned int   slice_segment_addr;
+///< address (in raster order) of the first block in the current slice
+unsigned int   slice_addr;
+
+enum HEVCSliceType slice_type;
+
+int pic_order_cnt_lsb;
+
+uint8_t first_slice_in_pic_flag;
+uint8_t dependent_slice_segment_flag;
+uint8_t pic_output_flag;
+uint8_t colour_plane_id;
+
+///< RPS coded in the slice header itself is stored here
+int short_term_ref_pic_set_sps_flag;
+int short_term_ref_pic_set_size;
+ShortTermRPS slice_rps;
+const ShortTermRPS *short_term_rps;
+int long_term_ref_pic_set_size;
+LongTermRPS long_term_rps;
+unsigned int list_entry_lx[2][32];
+
+uint8_t rpl_modification_flag[2];
+uint8_t no_output_of_prior_pics_flag;
+uint8_t slice_temporal_mvp_enabled_flag;
+
+unsigned int nb_refs[2];
+
+uint8_t slice_sample_adaptive_offset_flag[3];
+uint8_t mvd_l1_zero_flag;
+
+uint8_t cabac_init_flag;
+uint8_t disable_deblocking_filter_flag; ///< 
slice_header_disable_deblocking_filter_flag
+uint8_t slice_loop_filter_across_slices_enabled_flag;
+uint8_t collocated_list;
+
+unsigned int collocated_ref_idx;
+
+int slice_qp_delta;
+int slice_cb_qp_offset;
+int slice_cr_qp_offset;
+
+uint8_t cu_chroma_qp_offset_enabled_flag;
+
+int beta_offset;///< beta_offset_div2 * 2
+int tc_offset;  ///< tc_offset_div2 * 2
+
+unsigned int max_num_merge_cand; ///< 5 - 5_minus_max_num_merge_cand
+
+unsigned *entry_point_offset;
+int * offset;
+int * size;
+int num_entry_point_offsets;
+
+int8_t slice_qp;
+
+uint8_t luma_log2_weight_denom;
+int16_t chroma_log2_weight_denom;
+
+int16_t luma_weight_l0[16];
+int16_t chroma_weight_l0[16][2];
+int16_t chroma_weight_l1[16][2];
+int16_t luma_weight_l1[16];
+
+int16_t luma_offset_l0[16];
+int16_t chroma_offset_l0[16][2];
+
+int16_t luma_offset_l1[16];
+int16_t chroma_offset_l1[16][2];
+
+int slice_ctb_addr_rs;
+} SliceHeader;
+
 typedef struct HEVCWindow {
 unsigned int left_offset;
 unsigned int right_offset;
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index d8494ee6b1..d5d6bbcdb6 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -227,12 +227,6 @@ enum ScanType {
 SCAN_VERT,
 };
 
-typedef struct LongTermRPS {
-int poc[32];
-uint8_t used[32];
-uint8_t nb_refs;
-} LongTermRPS;
-
 typedef struct RefPicList {
 struct HEVCFrame *ref[HEVC_MAX_REFS];
 int list[HEVC_MAX_REFS];
@@ -244,83 +238,6 @@ typedef struct RefPicListTab {
 RefPicList refPicList[2];
 } RefPicListTab;
 
-typedef struct SliceHeader {
-unsigned int pps_id;
-
-///< address (in raster order) of the first block in the current slice 
segment
-unsigned int   slice_segment_addr;
-///< address (in raster order) of the first block in the current slice
-unsigned int   slice_addr;
-
-enum HEVCSliceType slice_type;
-
-int pic_order_cnt_lsb;
-
-uint8_t first_slice_in_pic_flag;
-uint8_t dependent_slice_segment_flag;
-uint8_t pic_output_flag;
-uint8_t colour_plane_id;
-
-///< RPS coded in the slice header itself is stored here
-int short_term_ref_pic_set_sps_flag;
-int short_term_ref_pic_set_size;
-ShortTermRPS slice_rps;
-const ShortTermRPS *short_term_rps;
-int long_term_ref_pic_set_size;
-LongTermRPS long_term_rps;
-unsigned int list_entry_lx[2][32];
-
-uint8_t rpl_modification_flag[2];
-uint8_t no_output_of_prior_pics_flag;
-uint8_t slice_temporal_mvp_enabled_flag;
-
-unsigned int nb_refs[2];
-
-uint8_t slice_sample_adaptive_offset_flag[3];
-uint8_t mvd_l1_zero_flag;
-
-uint8_t cabac_init_flag;
-uint8_t disable_deblocking_filter_flag; ///< 
slice_header_disable_deblocking_filter_flag
-uint8_t slice_loop_filter_across_slices_enabled_flag;
-uint8_t collocated_list;
-
-unsigned int collocated_ref_idx;
-
-int slice_qp_delta;
-int slice_cb_qp_offset;
-int slice_cr_qp_offset;
-
-uint8_t cu_chroma_qp_offset_enabled_flag;
-
-int beta_offset;///< beta_offset_div2 * 2
-int tc_offset;  ///< tc_offset_div2 * 2
-
-unsigned int max_num_merge_

[FFmpeg-devel] [PATCH 4/7] hevcdec: remove HEVCContext usage from ff_hevc_compute_poc()

2017-04-30 Thread James Almer
Move it to hevc_ps as well. This is in preparation for a following patch.

Signed-off-by: James Almer 
---
 libavcodec/hevc_parser.c |  2 +-
 libavcodec/hevc_ps.c | 23 +++
 libavcodec/hevc_ps.h |  5 +
 libavcodec/hevc_refs.c   | 23 ---
 libavcodec/hevcdec.c |  2 +-
 libavcodec/hevcdec.h |  5 -
 6 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
index ac7a1ed78b..501cbc3498 100644
--- a/libavcodec/hevc_parser.c
+++ b/libavcodec/hevc_parser.c
@@ -350,7 +350,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, 
const uint8_t *buf,
 
 if (!IS_IDR(h)) {
 sh->pic_order_cnt_lsb = get_bits(gb, 
ps->sps->log2_max_poc_lsb);
-s->output_picture_number = h->poc = ff_hevc_compute_poc(h, 
sh->pic_order_cnt_lsb);
+s->output_picture_number = h->poc = 
ff_hevc_compute_poc(h->ps.sps, h->pocTid0, sh->pic_order_cnt_lsb, 
h->nal_unit_type);
 } else
 s->output_picture_number = h->poc = 0;
 
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 6d67dd9c69..b5a970e4f7 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -1665,3 +1665,26 @@ err:
 av_buffer_unref(&pps_buf);
 return ret;
 }
+
+int ff_hevc_compute_poc(const HEVCSPS *sps, int pocTid0, int poc_lsb, int 
nal_unit_type)
+{
+int max_poc_lsb  = 1 << sps->log2_max_poc_lsb;
+int prev_poc_lsb = pocTid0 % max_poc_lsb;
+int prev_poc_msb = pocTid0 - prev_poc_lsb;
+int poc_msb;
+
+if (poc_lsb < prev_poc_lsb && prev_poc_lsb - poc_lsb >= max_poc_lsb / 2)
+poc_msb = prev_poc_msb + max_poc_lsb;
+else if (poc_lsb > prev_poc_lsb && poc_lsb - prev_poc_lsb > max_poc_lsb / 
2)
+poc_msb = prev_poc_msb - max_poc_lsb;
+else
+poc_msb = prev_poc_msb;
+
+// For BLA picture types, POCmsb is set to 0.
+if (nal_unit_type == HEVC_NAL_BLA_W_LP   ||
+nal_unit_type == HEVC_NAL_BLA_W_RADL ||
+nal_unit_type == HEVC_NAL_BLA_N_LP)
+poc_msb = 0;
+
+return poc_msb + poc_lsb;
+}
diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
index b0a17bc8f0..45ef9daf1f 100644
--- a/libavcodec/hevc_ps.h
+++ b/libavcodec/hevc_ps.h
@@ -344,4 +344,9 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, 
AVCodecContext *avctx,
 int ff_hevc_encode_nal_vps(HEVCVPS *vps, unsigned int id,
uint8_t *buf, int buf_size);
 
+/**
+ * Compute POC of the current frame and return it.
+ */
+int ff_hevc_compute_poc(const HEVCSPS *sps, int pocTid0, int poc_lsb, int 
nal_unit_type);
+
 #endif /* AVCODEC_HEVC_PS_H */
diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index 6810ffaf17..fc1385ca55 100644
--- a/libavcodec/hevc_refs.c
+++ b/libavcodec/hevc_refs.c
@@ -516,29 +516,6 @@ fail:
 return ret;
 }
 
-int ff_hevc_compute_poc(HEVCContext *s, int poc_lsb)
-{
-int max_poc_lsb  = 1 << s->ps.sps->log2_max_poc_lsb;
-int prev_poc_lsb = s->pocTid0 % max_poc_lsb;
-int prev_poc_msb = s->pocTid0 - prev_poc_lsb;
-int poc_msb;
-
-if (poc_lsb < prev_poc_lsb && prev_poc_lsb - poc_lsb >= max_poc_lsb / 2)
-poc_msb = prev_poc_msb + max_poc_lsb;
-else if (poc_lsb > prev_poc_lsb && poc_lsb - prev_poc_lsb > max_poc_lsb / 
2)
-poc_msb = prev_poc_msb - max_poc_lsb;
-else
-poc_msb = prev_poc_msb;
-
-// For BLA picture types, POCmsb is set to 0.
-if (s->nal_unit_type == HEVC_NAL_BLA_W_LP   ||
-s->nal_unit_type == HEVC_NAL_BLA_W_RADL ||
-s->nal_unit_type == HEVC_NAL_BLA_N_LP)
-poc_msb = 0;
-
-return poc_msb + poc_lsb;
-}
-
 int ff_hevc_frame_nb_refs(HEVCContext *s)
 {
 int ret = 0;
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 2a02edab28..8f235b0be1 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -541,7 +541,7 @@ static int hls_slice_header(HEVCContext *s)
 int poc, pos;
 
 sh->pic_order_cnt_lsb = get_bits(gb, s->ps.sps->log2_max_poc_lsb);
-poc = ff_hevc_compute_poc(s, sh->pic_order_cnt_lsb);
+poc = ff_hevc_compute_poc(s->ps.sps, s->pocTid0, 
sh->pic_order_cnt_lsb, s->nal_unit_type);
 if (!sh->first_slice_in_pic_flag && poc != s->poc) {
 av_log(s->avctx, AV_LOG_WARNING,
"Ignoring POC change between slices: %d -> %d\n", 
s->poc, poc);
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index cc7fc7e35f..d8494ee6b1 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -579,11 +579,6 @@ void ff_hevc_clear_refs(HEVCContext *s);
  */
 void ff_hevc_flush_dpb(HEVCContext *s);
 
-/**
- * Compute POC of the current frame and return it.
- */
-int ff_hevc_compute_poc(HEVCContext *s, int poc_lsb);
-
 RefPicList *ff_hevc_get_ref_list(HEVCContext *s, HEVCFrame *frame,
  int x0, int y0);
 
-- 
2.12.1

_

[FFmpeg-devel] [PATCH v2 3/7] hevc_parser: use ff_h2645_packet_split() to parse NAL units

2017-04-30 Thread James Almer
This simplifies the code considerably.

Signed-off-by: James Almer 
---
 libavcodec/hevc_parser.c | 50 ++--
 1 file changed, 10 insertions(+), 40 deletions(-)

diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
index f82f9fdf5e..ac7a1ed78b 100644
--- a/libavcodec/hevc_parser.c
+++ b/libavcodec/hevc_parser.c
@@ -193,11 +193,8 @@ static inline int parse_nal_units(AVCodecParserContext *s, 
const uint8_t *buf,
 SliceHeader*sh = &h->sh;
 HEVCParamSets *ps = &h->ps;
 HEVCSEIContext *sei = &h->sei;
-H2645Packet   *pkt = &ctx->pkt;
-const uint8_t *buf_end = buf + buf_size;
-int state = -1, i;
-H2645NAL *nal;
 int is_global = buf == avctx->extradata;
+int i, ret;
 
 if (!h->HEVClc)
 h->HEVClc = av_mallocz(sizeof(HEVCLocalContext));
@@ -215,44 +212,18 @@ static inline int parse_nal_units(AVCodecParserContext 
*s, const uint8_t *buf,
 
 ff_hevc_reset_sei(sei);
 
-if (!buf_size)
-return 0;
-
-if (pkt->nals_allocated < 1) {
-H2645NAL *tmp = av_realloc_array(pkt->nals, 1, sizeof(*tmp));
-if (!tmp)
-return AVERROR(ENOMEM);
-pkt->nals = tmp;
-memset(pkt->nals, 0, sizeof(*tmp));
-pkt->nals_allocated = 1;
-}
-
-nal = &pkt->nals[0];
+ret = ff_h2645_packet_split(&ctx->pkt, buf, buf_size, avctx, 0, 0,
+AV_CODEC_ID_HEVC, 1);
+if (ret < 0)
+return ret;
 
-for (;;) {
-int src_length, consumed;
-int ret;
+for (i = 0; i < ctx->pkt.nb_nals; i++) {
+H2645NAL *nal = &ctx->pkt.nals[i];
 int num = 0, den = 0;
-buf = avpriv_find_start_code(buf, buf_end, &state);
-if (--buf + 2 >= buf_end)
-break;
-src_length = buf_end - buf;
-
-h->nal_unit_type = (*buf >> 1) & 0x3f;
-h->temporal_id   = (*(buf + 1) & 0x07) - 1;
-if (h->nal_unit_type <= HEVC_NAL_CRA_NUT) {
-// Do not walk the whole buffer just to decode slice segment header
-if (src_length > 20)
-src_length = 20;
-}
-
-consumed = ff_h2645_extract_rbsp(buf, src_length, nal, 1);
-if (consumed < 0)
-return consumed;
 
-ret = init_get_bits8(gb, nal->data + 2, nal->size);
-if (ret < 0)
-return ret;
+h->nal_unit_type = nal->type;
+h->temporal_id   = nal->temporal_id;
+*gb = nal->gb;
 
 switch (h->nal_unit_type) {
 case HEVC_NAL_VPS:
@@ -395,7 +366,6 @@ static inline int parse_nal_units(AVCodecParserContext *s, 
const uint8_t *buf,
 
 return 0; /* no need to evaluate the rest */
 }
-buf += consumed;
 }
 /* didn't find a picture! */
 if (!is_global)
-- 
2.12.1

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


[FFmpeg-devel] [PATCH 6/7] hevc_parser: remove HEVCContext usage

2017-04-30 Thread James Almer
This gets rid of the duplicate, limited parser.

Signed-off-by: James Almer 
---
 libavcodec/hevc_parser.c | 176 +--
 1 file changed, 32 insertions(+), 144 deletions(-)

diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
index 501cbc3498..aba2fdb607 100644
--- a/libavcodec/hevc_parser.c
+++ b/libavcodec/hevc_parser.c
@@ -24,114 +24,31 @@
 
 #include "golomb.h"
 #include "hevc.h"
-#include "hevcdec.h"
+#include "hevc_ps.h"
+#include "hevc_sei.h"
 #include "h2645_parse.h"
+#include "internal.h"
 #include "parser.h"
 
 #define START_CODE 0x01 ///< start_code_prefix_one_3bytes
 
 #define IS_IRAP_NAL(nal) (nal->type >= 16 && nal->type <= 23)
-
-#define ADVANCED_PARSER CONFIG_HEVC_DECODER
+#define IS_IDR_NAL(nal) (nal->type == HEVC_NAL_IDR_W_RADL || nal->type == 
HEVC_NAL_IDR_N_LP)
 
 typedef struct HEVCParserContext {
 ParseContext pc;
 
 H2645Packet pkt;
 HEVCParamSets ps;
+HEVCSEIContext sei;
+SliceHeader sh;
 
 int parsed_extradata;
 
-#if ADVANCED_PARSER
-HEVCContext h;
-#endif
+int poc;
+int pocTid0;
 } HEVCParserContext;
 
-#if !ADVANCED_PARSER
-static int hevc_parse_slice_header(AVCodecParserContext *s, H2645NAL *nal,
-   AVCodecContext *avctx)
-{
-HEVCParserContext *ctx = s->priv_data;
-GetBitContext *gb = &nal->gb;
-
-HEVCPPS *pps;
-HEVCSPS *sps;
-unsigned int pps_id;
-
-get_bits1(gb);  // first slice in pic
-if (IS_IRAP_NAL(nal))
-get_bits1(gb);  // no output of prior pics
-
-pps_id = get_ue_golomb_long(gb);
-if (pps_id >= HEVC_MAX_PPS_COUNT || !ctx->ps.pps_list[pps_id]) {
-av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id);
-return AVERROR_INVALIDDATA;
-}
-pps = (HEVCPPS*)ctx->ps.pps_list[pps_id]->data;
-sps = (HEVCSPS*)ctx->ps.sps_list[pps->sps_id]->data;
-
-/* export the stream parameters */
-s->coded_width  = sps->width;
-s->coded_height = sps->height;
-s->width= sps->output_width;
-s->height   = sps->output_height;
-s->format   = sps->pix_fmt;
-avctx->profile  = sps->ptl.general_ptl.profile_idc;
-avctx->level= sps->ptl.general_ptl.level_idc;
-
-/* ignore the rest for now*/
-
-return 0;
-}
-
-static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
-   int buf_size, AVCodecContext *avctx)
-{
-HEVCParserContext *ctx = s->priv_data;
-int ret, i;
-
-ret = ff_h2645_packet_split(&ctx->pkt, buf, buf_size, avctx, 0, 0,
-AV_CODEC_ID_HEVC, 1);
-if (ret < 0)
-return ret;
-
-for (i = 0; i < ctx->pkt.nb_nals; i++) {
-H2645NAL *nal = &ctx->pkt.nals[i];
-
-/* ignore everything except parameter sets and VCL NALUs */
-switch (nal->type) {
-case HEVC_NAL_VPS: ff_hevc_decode_nal_vps(&nal->gb, avctx, &ctx->ps);  
  break;
-case HEVC_NAL_SPS: ff_hevc_decode_nal_sps(&nal->gb, avctx, &ctx->ps, 
1); break;
-case HEVC_NAL_PPS: ff_hevc_decode_nal_pps(&nal->gb, avctx, &ctx->ps);  
  break;
-case HEVC_NAL_TRAIL_R:
-case HEVC_NAL_TRAIL_N:
-case HEVC_NAL_TSA_N:
-case HEVC_NAL_TSA_R:
-case HEVC_NAL_STSA_N:
-case HEVC_NAL_STSA_R:
-case HEVC_NAL_BLA_W_LP:
-case HEVC_NAL_BLA_W_RADL:
-case HEVC_NAL_BLA_N_LP:
-case HEVC_NAL_IDR_W_RADL:
-case HEVC_NAL_IDR_N_LP:
-case HEVC_NAL_CRA_NUT:
-case HEVC_NAL_RADL_N:
-case HEVC_NAL_RADL_R:
-case HEVC_NAL_RASL_N:
-case HEVC_NAL_RASL_R:
-if (buf == avctx->extradata) {
-av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit: %d\n", 
nal->type);
-return AVERROR_INVALIDDATA;
-}
-hevc_parse_slice_header(s, nal, avctx);
-break;
-}
-}
-
-return 0;
-}
-#endif
-
 /**
  * Find the end of the current frame in the bitstream.
  * @return the position of the first byte of the next frame, or END_NOT_FOUND
@@ -175,7 +92,6 @@ static int hevc_find_frame_end(AVCodecParserContext *s, 
const uint8_t *buf,
 return END_NOT_FOUND;
 }
 
-#if ADVANCED_PARSER
 /**
  * Parse NAL units of found picture and decode some basic information.
  *
@@ -188,28 +104,18 @@ static inline int parse_nal_units(AVCodecParserContext 
*s, const uint8_t *buf,
int buf_size, AVCodecContext *avctx)
 {
 HEVCParserContext *ctx = s->priv_data;
-HEVCContext   *h   = &ctx->h;
 GetBitContext  *gb;
-SliceHeader*sh = &h->sh;
-HEVCParamSets *ps = &h->ps;
-HEVCSEIContext *sei = &h->sei;
+SliceHeader*sh = &ctx->sh;
+HEVCParamSets *ps = &ctx->ps;
+HEVCSEIContext *sei = &ctx->sei;
 int is_global = buf == avctx->extradata;
 int i, ret;
 
-if (!h->HEVClc)
-h->HEVClc = av_mallocz(sizeof(HEVCLocalContext));
-

[FFmpeg-devel] [PATCH 7/7] doc/libav_merge: remove line about ADVANCED_PARSER

2017-04-30 Thread James Almer
It's been dealt with.

Signed-off-by: James Almer 
---
 doc/libav-merge.txt | 1 -
 1 file changed, 1 deletion(-)

diff --git a/doc/libav-merge.txt b/doc/libav-merge.txt
index 6f052ec2eb..da9e2757f5 100644
--- a/doc/libav-merge.txt
+++ b/doc/libav-merge.txt
@@ -105,7 +105,6 @@ Collateral damage that needs work locally:
 
 - Merge proresdec2.c and proresdec_lgpl.c
 - Merge proresenc_anatoliy.c and proresenc_kostya.c
-- Remove ADVANCED_PARSER in libavcodec/hevc_parser.c
 - Fix MIPS AC3 downmix
 - hlsenc encryption support may need some adjustment (see edc43c571d)
 
-- 
2.12.1

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


[FFmpeg-devel] [PATCH] avfilter: add arbitrary audio FIR filter

2017-04-30 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 doc/filters.texi|   7 +
 libavfilter/Makefile|   1 +
 libavfilter/af_afirfilter.c | 411 
 libavfilter/allfilters.c|   1 +
 4 files changed, 420 insertions(+)
 create mode 100644 libavfilter/af_afirfilter.c

diff --git a/doc/filters.texi b/doc/filters.texi
index 119e747..d0f6cc4 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -878,6 +878,13 @@ afftfilt="1-clip((b/nb)*b,0,1)"
 @end example
 @end itemize
 
+@section afirfilter
+
+Apply an Arbitary Frequency Impulse Response filter.
+
+This filter uses second stream as FIR coefficients.
+Even channels hold real and odds channels hold imaginary coefficients.
+
 @anchor{aformat}
 @section aformat
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 66c36e4..1a0f24b 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -38,6 +38,7 @@ OBJS-$(CONFIG_AEMPHASIS_FILTER)  += af_aemphasis.o
 OBJS-$(CONFIG_AEVAL_FILTER)  += aeval.o
 OBJS-$(CONFIG_AFADE_FILTER)  += af_afade.o
 OBJS-$(CONFIG_AFFTFILT_FILTER)   += af_afftfilt.o window_func.o
+OBJS-$(CONFIG_AFIRFILTER_FILTER) += af_afirfilter.o
 OBJS-$(CONFIG_AFORMAT_FILTER)+= af_aformat.o
 OBJS-$(CONFIG_AGATE_FILTER)  += af_agate.o
 OBJS-$(CONFIG_AINTERLEAVE_FILTER)+= f_interleave.o
diff --git a/libavfilter/af_afirfilter.c b/libavfilter/af_afirfilter.c
new file mode 100644
index 000..e127579
--- /dev/null
+++ b/libavfilter/af_afirfilter.c
@@ -0,0 +1,411 @@
+/*
+ * Copyright (c) 2017 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * An arbitrary audio FIR filter
+ */
+
+#include "libavutil/audio_fifo.h"
+#include "libavutil/avassert.h"
+#include "libavutil/channel_layout.h"
+#include "libavutil/common.h"
+#include "libavutil/opt.h"
+#include "libavcodec/avfft.h"
+
+#include "audio.h"
+#include "avfilter.h"
+#include "formats.h"
+#include "hermite.h"
+#include "internal.h"
+
+typedef struct FIRContext {
+const AVClass *class;
+
+int n;
+int eof_coeffs;
+int have_coeffs;
+int nb_taps;
+int fft_length;
+int nb_channels;
+int one2many;
+
+FFTContext *fft, *ifft;
+FFTComplex **fft_data;
+FFTComplex **fft_coef;
+
+AVAudioFifo *fifo[2];
+AVFrame *in[2];
+AVFrame *buffer;
+int64_t pts;
+int hop_size;
+int start, end;
+} FIRContext;
+
+static int fir_filter(FIRContext *s, AVFilterLink *outlink)
+{
+AVFilterContext *ctx = outlink->src;
+int start = s->start, end = s->end;
+int ret = 0, n, ch, j, k;
+int nb_samples;
+AVFrame *out;
+
+nb_samples = FFMIN(s->fft_length, av_audio_fifo_size(s->fifo[0]));
+
+s->in[0] = ff_get_audio_buffer(ctx->inputs[0], nb_samples);
+if (!s->in[0])
+return AVERROR(ENOMEM);
+av_audio_fifo_peek(s->fifo[0], (void **)s->in[0]->data, nb_samples);
+
+for (ch = 0; ch < outlink->channels; ch++) {
+const float *src = (float *)s->in[0]->extended_data[ch];
+float *buf = (float *)s->buffer->extended_data[ch];
+FFTComplex *fft_data = s->fft_data[ch];
+FFTComplex *fft_coef = s->fft_coef[ch];
+
+memset(fft_data, 0, sizeof(*fft_data) * s->fft_length);
+for (n = 0; n < s->fft_length; n++) {
+fft_data[n].re = src[n];
+fft_data[n].im = 0;
+}
+
+av_fft_permute(s->fft, fft_data);
+av_fft_calc(s->fft, fft_data);
+
+fft_data[0].re *= fft_coef[0].re;
+fft_data[0].im *= fft_coef[0].im;
+for (n = 1; n < s->fft_length; n++) {
+const float re = fft_data[n].re;
+const float im = fft_data[n].im;
+
+fft_data[n].re = re * fft_coef[n].re - im * fft_coef[n].im;
+fft_data[n].im = re * fft_coef[n].im + im * fft_coef[n].re;
+}
+
+av_fft_permute(s->ifft, fft_data);
+av_fft_calc(s->ifft, fft_data);
+
+start = s->start;
+end = s->end;
+k = end;
+
+for (n = 0, j = start; j < k && n < s->fft_length; n++, j++) {
+buf[j] = fft_data[n].re;
+}
+
+for (; n < s->fft_length; n++, j++) {
+bu

Re: [FFmpeg-devel] [PATCH] avformat/matroskadec: export Content Light Level metadata

2017-04-30 Thread James Almer
On 4/25/2017 3:10 PM, James Almer wrote:
> Based on a patch by Hendrik Leppkes
> 
> Signed-off-by: James Almer 
> ---
>  libavformat/matroskadec.c | 15 +++
>  1 file changed, 15 insertions(+)

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


Re: [FFmpeg-devel] [PATCH] avformat/matroskaenc: add support for writing Content Light Level elements

2017-04-30 Thread James Almer
On 4/25/2017 4:15 PM, James Almer wrote:
> Signed-off-by: James Almer 
> ---
>  libavformat/matroskaenc.c | 15 +--
>  1 file changed, 13 insertions(+), 2 deletions(-)

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


[FFmpeg-devel] [PATCH v2] avcodec/decode: do not treat discarded frames as eof when draining

2017-04-30 Thread Muhammad Faiz
Fix fate failures:
make fate-mov THREADS=32

Signed-off-by: Muhammad Faiz 
---
 libavcodec/decode.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index edfae55..e330f14 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -369,7 +369,7 @@ static int decode_simple_internal(AVCodecContext *avctx, 
AVFrame *frame)
 AVPacket   *pkt = ds->in_pkt;
 // copy to ensure we do not change pkt
 AVPacket tmp;
-int got_frame, did_split;
+int got_frame, actual_got_frame, did_split;
 int ret;
 
 if (!pkt->data && !avci->draining) {
@@ -431,6 +431,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 }
 }
 emms_c();
+actual_got_frame = got_frame;
 
 if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
 if (frame->flags & AV_FRAME_FLAG_DISCARD)
@@ -568,8 +569,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
 avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, 
(AVRational){avctx->ticks_per_frame, 1}));
 #endif
 
-/* do not stop draining when got_frame != 0 or ret < 0 */
-if (avctx->internal->draining && !got_frame) {
+/* do not stop draining when actual_got_frame != 0 or ret < 0 */
+/* got_frame == 0 but actual_got_frame != 0 when frame is discarded */
+if (avctx->internal->draining && !actual_got_frame) {
 if (ret < 0) {
 /* prevent infinite loop if a decoder wrongly always return error 
on draining */
 /* reasonable nb_errors_max = maximum b frames + thread count */
-- 
2.9.3

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


Re: [FFmpeg-devel] [PATCH] avfilter: add arbitrary audio FIR filter

2017-04-30 Thread Muhammad Faiz
On Mon, May 1, 2017 at 5:02 AM, Paul B Mahol  wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  doc/filters.texi|   7 +
>  libavfilter/Makefile|   1 +
>  libavfilter/af_afirfilter.c | 411 
> 
>  libavfilter/allfilters.c|   1 +
>  4 files changed, 420 insertions(+)
>  create mode 100644 libavfilter/af_afirfilter.c
>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 119e747..d0f6cc4 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -878,6 +878,13 @@ afftfilt="1-clip((b/nb)*b,0,1)"
>  @end example
>  @end itemize
>
> +@section afirfilter
> +
> +Apply an Arbitary Frequency Impulse Response filter.
> +
> +This filter uses second stream as FIR coefficients.
> +Even channels hold real and odds channels hold imaginary coefficients.
> +
>  @anchor{aformat}
>  @section aformat
>
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index 66c36e4..1a0f24b 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -38,6 +38,7 @@ OBJS-$(CONFIG_AEMPHASIS_FILTER)  += 
> af_aemphasis.o
>  OBJS-$(CONFIG_AEVAL_FILTER)  += aeval.o
>  OBJS-$(CONFIG_AFADE_FILTER)  += af_afade.o
>  OBJS-$(CONFIG_AFFTFILT_FILTER)   += af_afftfilt.o window_func.o
> +OBJS-$(CONFIG_AFIRFILTER_FILTER) += af_afirfilter.o
>  OBJS-$(CONFIG_AFORMAT_FILTER)+= af_aformat.o
>  OBJS-$(CONFIG_AGATE_FILTER)  += af_agate.o
>  OBJS-$(CONFIG_AINTERLEAVE_FILTER)+= f_interleave.o
> diff --git a/libavfilter/af_afirfilter.c b/libavfilter/af_afirfilter.c
> new file mode 100644
> index 000..e127579
> --- /dev/null
> +++ b/libavfilter/af_afirfilter.c
> @@ -0,0 +1,411 @@
> +/*
> + * Copyright (c) 2017 Paul B Mahol
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +/**
> + * @file
> + * An arbitrary audio FIR filter
> + */
> +
> +#include "libavutil/audio_fifo.h"
> +#include "libavutil/avassert.h"
> +#include "libavutil/channel_layout.h"
> +#include "libavutil/common.h"
> +#include "libavutil/opt.h"
> +#include "libavcodec/avfft.h"
> +
> +#include "audio.h"
> +#include "avfilter.h"
> +#include "formats.h"
> +#include "hermite.h"
> +#include "internal.h"
> +
> +typedef struct FIRContext {
> +const AVClass *class;
> +
> +int n;
> +int eof_coeffs;
> +int have_coeffs;
> +int nb_taps;
> +int fft_length;
> +int nb_channels;
> +int one2many;
> +
> +FFTContext *fft, *ifft;
> +FFTComplex **fft_data;
> +FFTComplex **fft_coef;
> +
> +AVAudioFifo *fifo[2];
> +AVFrame *in[2];
> +AVFrame *buffer;
> +int64_t pts;
> +int hop_size;
> +int start, end;
> +} FIRContext;
> +
> +static int fir_filter(FIRContext *s, AVFilterLink *outlink)
> +{
> +AVFilterContext *ctx = outlink->src;
> +int start = s->start, end = s->end;
> +int ret = 0, n, ch, j, k;
> +int nb_samples;
> +AVFrame *out;
> +
> +nb_samples = FFMIN(s->fft_length, av_audio_fifo_size(s->fifo[0]));
> +
> +s->in[0] = ff_get_audio_buffer(ctx->inputs[0], nb_samples);
> +if (!s->in[0])
> +return AVERROR(ENOMEM);
> +av_audio_fifo_peek(s->fifo[0], (void **)s->in[0]->data, nb_samples);
> +
> +for (ch = 0; ch < outlink->channels; ch++) {
> +const float *src = (float *)s->in[0]->extended_data[ch];
> +float *buf = (float *)s->buffer->extended_data[ch];
> +FFTComplex *fft_data = s->fft_data[ch];
> +FFTComplex *fft_coef = s->fft_coef[ch];
> +
> +memset(fft_data, 0, sizeof(*fft_data) * s->fft_length);
> +for (n = 0; n < s->fft_length; n++) {
> +fft_data[n].re = src[n];
> +fft_data[n].im = 0;
> +}
> +
> +av_fft_permute(s->fft, fft_data);
> +av_fft_calc(s->fft, fft_data);
> +
> +fft_data[0].re *= fft_coef[0].re;
> +fft_data[0].im *= fft_coef[0].im;
> +for (n = 1; n < s->fft_length; n++) {
> +const float re = fft_data[n].re;
> +const float im = fft_data[n].im;
> +
> +fft_data[n].re = re * fft_coef[n].re - im * fft_coef[n].im;
> +fft_data[n].im = re * fft_coef[n].im + im * fft_coef[n].re;
> +   

Re: [FFmpeg-devel] [PATCH 2/2] avcodec/options: do a more thorough clean up in avcodec_copy_context()

2017-04-30 Thread Michael Niedermayer
On Sun, Apr 30, 2017 at 10:07:17AM -0700, Aaron Levinson wrote:
> On 4/26/2017 12:47 PM, James Almer wrote:
> >On 4/26/2017 2:46 AM, Aaron Levinson wrote:
> >>On 4/24/2017 3:47 PM, James Almer wrote:
> >>>Free coded_frame, coded_side_data and unref hw_device_ctx to prevent
> >>>potential leaks.
> >>>
> >>>Signed-off-by: James Almer 
> >>>---
> >>> libavcodec/options.c | 15 +++
> >>> 1 file changed, 15 insertions(+)
> >>>
> >>>diff --git a/libavcodec/options.c b/libavcodec/options.c
> >>>index b98da9378a..82e12179a6 100644
> >>>--- a/libavcodec/options.c
> >>>+++ b/libavcodec/options.c
> >>>@@ -190,14 +190,26 @@ void avcodec_free_context(AVCodecContext **pavctx)
> >>> #if FF_API_COPY_CONTEXT
> >>> static void copy_context_reset(AVCodecContext *avctx)
> >>> {
> >>>+int i;
> >>>+
> >>> av_opt_free(avctx);
> >>>+#if FF_API_CODED_FRAME
> >>>+FF_DISABLE_DEPRECATION_WARNINGS
> >>>+av_frame_free(&avctx->coded_frame);
> >>>+FF_ENABLE_DEPRECATION_WARNINGS
> >>>+#endif
> >>> av_freep(&avctx->rc_override);
> >>> av_freep(&avctx->intra_matrix);
> >>> av_freep(&avctx->inter_matrix);
> >>> av_freep(&avctx->extradata);
> >>> av_freep(&avctx->subtitle_header);
> >>> av_buffer_unref(&avctx->hw_frames_ctx);
> >>>+av_buffer_unref(&avctx->hw_device_ctx);
> >>>+for (i = 0; i < avctx->nb_coded_side_data; i++)
> >>>+av_freep(&avctx->coded_side_data[i].data);
> >>>+av_freep(&avctx->coded_side_data);
> >>> avctx->subtitle_header_size = 0;
> >>>+avctx->nb_coded_side_data = 0;
> >>> avctx->extradata_size = 0;
> >>> }
> >>>
> >>>@@ -238,11 +250,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
> >>>
> >>> /* reallocate values that should be allocated separately */
> >>> dest->extradata   = NULL;
> >>>+dest->coded_side_data = NULL;
> >>> dest->intra_matrix= NULL;
> >>> dest->inter_matrix= NULL;
> >>> dest->rc_override = NULL;
> >>> dest->subtitle_header = NULL;
> >>> dest->hw_frames_ctx   = NULL;
> >>>+dest->hw_device_ctx   = NULL;
> >>>+dest->nb_coded_side_data = 0;
> >>>
> >>> #define alloc_and_copy_or_fail(obj, size, pad) \
> >>> if (src->obj && size > 0) { \
> >>>
> >>
> >>I'm not sure if this patch is intended to be a replacement for your last
> >>"2/2" patch, but this version is missing the the coded_side_data
> >>population code that was in the first version of your "2/2" patch.
> >>
> >>Aaron Levinson
> >
> >It is. I'm keeping the functionality of the function as is, and only
> >making sure cleanup is complete to prevent leaks.
> >This function is deprecated and shouldn't be used, so i'm not going to
> >make it copy even more stuff.
> 
> I've reviewed both patches 1 and 2, and both are good to commit.

and i couldnt find a case the patches break

[...]

thx

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Take away the freedom of one citizen and you will be jailed, take away
the freedom of all citizens and you will be congratulated by your peers
in Parliament.


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] avcodec/options: do a more thorough clean up in avcodec_copy_context()

2017-04-30 Thread James Almer
On 4/30/2017 11:10 PM, Michael Niedermayer wrote:
> On Sun, Apr 30, 2017 at 10:07:17AM -0700, Aaron Levinson wrote:
>> On 4/26/2017 12:47 PM, James Almer wrote:
>>> On 4/26/2017 2:46 AM, Aaron Levinson wrote:
 On 4/24/2017 3:47 PM, James Almer wrote:
> Free coded_frame, coded_side_data and unref hw_device_ctx to prevent
> potential leaks.
>
> Signed-off-by: James Almer 
> ---
> libavcodec/options.c | 15 +++
> 1 file changed, 15 insertions(+)
>
> diff --git a/libavcodec/options.c b/libavcodec/options.c
> index b98da9378a..82e12179a6 100644
> --- a/libavcodec/options.c
> +++ b/libavcodec/options.c
> @@ -190,14 +190,26 @@ void avcodec_free_context(AVCodecContext **pavctx)
> #if FF_API_COPY_CONTEXT
> static void copy_context_reset(AVCodecContext *avctx)
> {
> +int i;
> +
> av_opt_free(avctx);
> +#if FF_API_CODED_FRAME
> +FF_DISABLE_DEPRECATION_WARNINGS
> +av_frame_free(&avctx->coded_frame);
> +FF_ENABLE_DEPRECATION_WARNINGS
> +#endif
> av_freep(&avctx->rc_override);
> av_freep(&avctx->intra_matrix);
> av_freep(&avctx->inter_matrix);
> av_freep(&avctx->extradata);
> av_freep(&avctx->subtitle_header);
> av_buffer_unref(&avctx->hw_frames_ctx);
> +av_buffer_unref(&avctx->hw_device_ctx);
> +for (i = 0; i < avctx->nb_coded_side_data; i++)
> +av_freep(&avctx->coded_side_data[i].data);
> +av_freep(&avctx->coded_side_data);
> avctx->subtitle_header_size = 0;
> +avctx->nb_coded_side_data = 0;
> avctx->extradata_size = 0;
> }
>
> @@ -238,11 +250,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
>
> /* reallocate values that should be allocated separately */
> dest->extradata   = NULL;
> +dest->coded_side_data = NULL;
> dest->intra_matrix= NULL;
> dest->inter_matrix= NULL;
> dest->rc_override = NULL;
> dest->subtitle_header = NULL;
> dest->hw_frames_ctx   = NULL;
> +dest->hw_device_ctx   = NULL;
> +dest->nb_coded_side_data = 0;
>
> #define alloc_and_copy_or_fail(obj, size, pad) \
> if (src->obj && size > 0) { \
>

 I'm not sure if this patch is intended to be a replacement for your last
 "2/2" patch, but this version is missing the the coded_side_data
 population code that was in the first version of your "2/2" patch.

 Aaron Levinson
>>>
>>> It is. I'm keeping the functionality of the function as is, and only
>>> making sure cleanup is complete to prevent leaks.
>>> This function is deprecated and shouldn't be used, so i'm not going to
>>> make it copy even more stuff.
>>
>> I've reviewed both patches 1 and 2, and both are good to commit.
> 
> and i couldnt find a case the patches break
> 
> [...]
> 
> thx

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


Re: [FFmpeg-devel] [PATCH] avcodec/libmp3lame: properly handle unaligned frame data

2017-04-30 Thread Muhammad Faiz
On Mon, May 1, 2017 at 12:16 AM, wm4  wrote:
> On Sun, 30 Apr 2017 23:55:02 +0700
> Muhammad Faiz  wrote:
>
>> On Thu, Apr 27, 2017 at 3:51 PM, Nicolas George  wrote:
>> > L'octidi 8 floréal, an CCXXV, Michael Niedermayer a écrit :
>> >> I agree
>> >> in fact i added such a flag in 2011 
>> >> (4d34b6c1a1254850e39a36f08f4d2730092a54db)
>> >> within the API of that time to avfilter
>> >
>> > It was not a bad idea, but it should not be limited to filters. A few
>> > comments.
>> >
>> > * First, the framequeue framework does not produce unaligned code.
>> > According to the C standard, the data it handles stay aligned. The
>> > alignment problems come from non-standard requirements by special
>> > processor features used by some filters and codecs, but not all.
>> >
>> > * That means a lot of the most useful codecs and filters will suffer
>> > from it, but not all. For many tasks, the alignment is just fine, and
>> > the extra copy would be wasteful.
>> >
>> > * The alignment requirements increase. Before AVX, it was up to 16, now
>> > it can be 32, and I have no doubt future processor will at some point
>> > require 64 or 128. But realigning buffers used with SSE to 32 would be
>> > wasteful too. Thus, we do not require a flag but a full integer.
>> >
>> > * The code that does the actual work of realigning a buffer should
>> > available as a stand-alone API, to be used by applications that work at
>> > low-level. I suppose something like that would be in order:
>> >
>> > int av_frame_realign(AVFrame *frame, unsigned align);
>> >
>> > Or maybe:
>> >
>> > int av_frame_realign(AVFrame *frame, unsigned align,
>> >  AVBufferAllocator *alloc);
>> >
>> > where AVBufferAllocator is there to allocate possibly hardware or mmaped
>> > buffers.
>> >
>> > * It is another argument for my leitmotiv that filters and codecs are
>> > actually the same and should be merged API-wise.
>> >
>> > * It would be better to have the API just work for everything rather
>> > than documenting the alignment needs.
>> >
>> > As for the actual implementation, I see a lot of different approaches:
>> >
>> > - have the framework realing the frame before submitting it to the
>> >   filters and codecs: costly in malloc() and memcpy() but simple;
>> >
>> > - have each filter or codec call av_frame_realign() as needed; it may
>> >   seem less elegant than the previous proposal, but it may prove a
>> >   better choice in the light of what follows;
>> >
>> > - have each filter or codec copy the unaligned data into a buffer
>> >   allocated once and for all or on the stack, possibly by small chunks:
>> >   less costly in malloc() and refcounting overhead, and possibly better
>> >   cache-locality, but more complex code;
>> >
>> > - run the plain C version of the code on unaligned data rather than the
>> >   vectorized version, or the less-vectorized version (SSE vs AVX) on
>> >   insufficiently aligned data.
>> >
>> > Since all this boils down to a matter of performance and is related to
>> > the core task of FFmpeg, I think the choice between the various options
>> > should be done on a case-by-case basis using real benchmarks.
>>
>> Are you working on these? Because currently I'm not.
>
> I think it's probably ok to push your current patch, since the original
> author of the patch who broke this probably won't fix it.

As you said before, my patch didn't solve the problem. Here segfault
with volume filter:
./ffmpeg -filter_complex "aevalsrc=0:d=10, aformat=fltp,
firequalizer=fixed=on:delay=0.0013, volume=0.5" -f null -

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


Re: [FFmpeg-devel] [PATCH] avcodec/libmp3lame: properly handle unaligned frame data

2017-04-30 Thread Muhammad Faiz
On Mon, May 1, 2017 at 12:06 AM, Nicolas George  wrote:
> Le primidi 11 floréal, an CCXXV, Muhammad Faiz a écrit :
>> Are you working on these? Because currently I'm not.
>
> There is nothing to work on yet: the message you answer to is raising a
> question about the global design of the internal API. That question
> needs an answer before any work can be done, and I can not decide alone.

Probably, better to post a patch, choosing one of the designs, and
then it will be reviewed
rather than waiting an answer here.

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