[libav-devel] [PATCH 1/2] lavc: export the timestamps when decoding in AVFrame.pts

2016-03-19 Thread Anton Khirnov
Currently it's exported as AVFrame.pkt_pts, which is also the only use
for that field. The reason it is done like this is that lavc used to
export various codec-specific "timing" information in AVFrame.pts, which
is not done anymore.

Since it is confusing to the callers to have a separate field which is
used only for decoder timestamps and nothing else, deprecate pkt_pts and
use just AVFrame.pts everywhere.
---
 doc/APIchanges  |  4 
 libavcodec/libschroedingerdec.c |  7 ++-
 libavcodec/mmaldec.c|  7 ++-
 libavcodec/qsvdec.c |  7 ++-
 libavcodec/utils.c  | 10 ++
 libavcodec/version.h|  2 +-
 libavutil/frame.c   |  4 
 libavutil/frame.h   |  4 
 libavutil/version.h |  3 +++
 9 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index e0c4678..3da6aaf 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,10 @@ libavutil: 2015-08-28
 
 API changes, most recent first:
 
+2016-xx-xx - xxx - lavc 57.15.0 - avcodec.h
+  Decoders now export the frame timestamp as AVFrame.pts. It was
+  previously exported as AVFrame.pkt_pts, which is now deprecated.
+
 2016-xx-xx - xxx - lavfi 6.3.0 - avfilter.h
   Add AVFilterContext.hw_device_ctx.
 
diff --git a/libavcodec/libschroedingerdec.c b/libavcodec/libschroedingerdec.c
index cb7374c..a127ecc 100644
--- a/libavcodec/libschroedingerdec.c
+++ b/libavcodec/libschroedingerdec.c
@@ -330,7 +330,12 @@ static int libschroedinger_decode_frame(AVCodecContext 
*avctx,
framewithpts->frame->components[2].length);
 
 /* Fill frame with current buffer data from Schroedinger. */
-avframe->pkt_pts = framewithpts->pts;
+avframe->pts = framewithpts->pts;
+#if FF_API_PKT_PTS
+FF_DISABLE_DEPRECATION_WARNINGS
+avframe->pkt_pts = avframe->pts;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 avframe->linesize[0] = framewithpts->frame->components[0].stride;
 avframe->linesize[1] = framewithpts->frame->components[1].stride;
 avframe->linesize[2] = framewithpts->frame->components[2].stride;
diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
index 15b887c..5afde75 100644
--- a/libavcodec/mmaldec.c
+++ b/libavcodec/mmaldec.c
@@ -609,7 +609,12 @@ static int ffmal_copy_frame(AVCodecContext *avctx,  
AVFrame *frame,
 }
 }
 
-frame->pkt_pts = buffer->pts == MMAL_TIME_UNKNOWN ? AV_NOPTS_VALUE : 
buffer->pts;
+frame->pts = buffer->pts == MMAL_TIME_UNKNOWN ? AV_NOPTS_VALUE : 
buffer->pts;
+#if FF_API_PKT_PTS
+FF_DISABLE_DEPRECATION_WARNINGS
+frame->pkt_pts = frame->pts;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 frame->pkt_dts = AV_NOPTS_VALUE;
 
 done:
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 1d59e72..c839fc5 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -302,7 +302,12 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q,
 
 outsurf = out_frame->surface;
 
-frame->pkt_pts = frame->pts = outsurf->Data.TimeStamp;
+#if FF_API_PKT_PTS
+FF_DISABLE_DEPRECATION_WARNINGS
+frame->pkt_pts = outsurf->Data.TimeStamp;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+frame->pts = outsurf->Data.TimeStamp;
 
 frame->repeat_pict =
 outsurf->Info.PicStruct & MFX_PICSTRUCT_FRAME_TRIPLING ? 4 :
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 7caa035..1f0bc6d 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -548,11 +548,21 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame 
*frame)
 
 frame->reordered_opaque = avctx->reordered_opaque;
 if (!pkt) {
+#if FF_API_PKT_PTS
+FF_DISABLE_DEPRECATION_WARNINGS
 frame->pkt_pts = AV_NOPTS_VALUE;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+frame->pts = AV_NOPTS_VALUE;
 return 0;
 }
 
+#if FF_API_PKT_PTS
+FF_DISABLE_DEPRECATION_WARNINGS
 frame->pkt_pts = pkt->pts;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+frame->pts = pkt->pts;
 
 for (i = 0; i < FF_ARRAY_ELEMS(sd); i++) {
 int size;
diff --git a/libavcodec/version.h b/libavcodec/version.h
index d247c09..87ac945 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -28,7 +28,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR 57
-#define LIBAVCODEC_VERSION_MINOR 14
+#define LIBAVCODEC_VERSION_MINOR 15
 #define LIBAVCODEC_VERSION_MICRO  0
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
diff --git a/libavutil/frame.c b/libavutil/frame.c
index ae80cee..1c14f5f 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -397,7 +397,11 @@ int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
 dst->palette_has_changed= src->palette_has_changed;
 dst->sample_rate= src->sample_rate;
 dst->opaque = src->opaque;
+#if FF_API_PKT_PTS
+FF_DISABLE_DEPRECATION_WARNINGS
 dst->pkt_pts  

[libav-devel] [PATCH 2/2] Use AVFrame.pts instead of deprecated pkt_pts.

2016-03-19 Thread Anton Khirnov
---
 avconv.c | 2 +-
 avplay.c | 4 ++--
 libavfilter/vsrc_movie.c | 2 --
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/avconv.c b/avconv.c
index d878646..5605c76 100644
--- a/avconv.c
+++ b/avconv.c
@@ -1214,7 +1214,7 @@ static int decode_video(InputStream *ist, AVPacket *pkt, 
int *got_output)
 }
 ist->hwaccel_retrieved_pix_fmt = decoded_frame->format;
 
-decoded_frame->pts = guess_correct_pts(&ist->pts_ctx, 
decoded_frame->pkt_pts,
+decoded_frame->pts = guess_correct_pts(&ist->pts_ctx, decoded_frame->pts,
decoded_frame->pkt_dts);
 pkt->size = 0;
 
diff --git a/avplay.c b/avplay.c
index c8db03f..5d04b24 100644
--- a/avplay.c
+++ b/avplay.c
@@ -1406,9 +1406,9 @@ static int get_video_frame(PlayerState *is, AVFrame 
*frame, int64_t *pts, AVPack
 
 if (got_picture) {
 if (decoder_reorder_pts == -1) {
-*pts = guess_correct_pts(&is->pts_ctx, frame->pkt_pts, 
frame->pkt_dts);
+*pts = guess_correct_pts(&is->pts_ctx, frame->pts, frame->pkt_dts);
 } else if (decoder_reorder_pts) {
-*pts = frame->pkt_pts;
+*pts = frame->pts;
 } else {
 *pts = frame->pkt_dts;
 }
diff --git a/libavfilter/vsrc_movie.c b/libavfilter/vsrc_movie.c
index 95ef4f1..5989a59 100644
--- a/libavfilter/vsrc_movie.c
+++ b/libavfilter/vsrc_movie.c
@@ -228,8 +228,6 @@ static int movie_get_frame(AVFilterLink *outlink)
 avcodec_decode_video2(movie->codec_ctx, movie->frame, 
&frame_decoded, &pkt);
 
 if (frame_decoded) {
-if (movie->frame->pkt_pts != AV_NOPTS_VALUE)
-movie->frame->pts = movie->frame->pkt_pts;
 av_log(outlink->src, AV_LOG_TRACE,
 "movie_get_frame(): file:'%s' pts:%"PRId64" time:%f 
aspect:%d/%d\n",
 movie->file_name, movie->frame->pts,
-- 
2.0.0

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] GIF demuxer

2016-03-19 Thread Vittorio Giovara
From: Vitaliy E Sugrobov 

This demuxer is capable of extracting multiple frames from gif file.
In conjunction with gif decoder it implements support for reading
animated gifs.

Signed-off-by: Vitaliy E Sugrobov 
Signed-off-by: Vittorio Giovara 
---
 Changelog|   1 +
 doc/general.texi |   2 +-
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   2 +-
 libavformat/gifdec.c | 322 +++
 5 files changed, 326 insertions(+), 2 deletions(-)
 create mode 100644 libavformat/gifdec.c

diff --git a/Changelog b/Changelog
index ca9c9b4..71fe9e2 100644
--- a/Changelog
+++ b/Changelog
@@ -52,6 +52,7 @@ version :
 - G.723.1 muxer and encoder
 - compressed SWF
 - G.729 raw demuxer
+- GIF demuxer
 
 
 version 11:
diff --git a/doc/general.texi b/doc/general.texi
index 15e4a66..5f01c50 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -282,7 +282,7 @@ library:
 @item framecrc testing format   @tab X @tab
 @item FunCom ISS@tab   @tab X
 @tab Audio format used in various games from FunCom like The Longest 
Journey.
-@item GIF Animation @tab X @tab
+@item GIF Animation @tab X @tab X
 @item GXF   @tab X @tab X
 @tab General eXchange Format SMPTE 360M, used by Thomson Grass Valley
  playout servers.
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 891a20f..5cd8f8f 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -135,6 +135,7 @@ OBJS-$(CONFIG_FOURXM_DEMUXER)+= 4xm.o
 OBJS-$(CONFIG_FRAMECRC_MUXER)+= framecrcenc.o framehash.o
 OBJS-$(CONFIG_FRAMEMD5_MUXER)+= md5enc.o framehash.o
 OBJS-$(CONFIG_GIF_MUXER) += gif.o
+OBJS-$(CONFIG_GIF_DEMUXER)   += gifdec.o
 OBJS-$(CONFIG_GSM_DEMUXER)   += gsmdec.o
 OBJS-$(CONFIG_GXF_DEMUXER)   += gxf.o
 OBJS-$(CONFIG_GXF_MUXER) += gxfenc.o audiointerleave.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 0f49756..1056d7b 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -106,7 +106,7 @@ void av_register_all(void)
 REGISTER_MUXDEMUX(G722, g722);
 REGISTER_MUXDEMUX(G723_1,   g723_1);
 REGISTER_DEMUXER (G729, g729);
-REGISTER_MUXER   (GIF,  gif);
+REGISTER_MUXDEMUX(GIF,  gif);
 REGISTER_DEMUXER (GSM,  gsm);
 REGISTER_MUXDEMUX(GXF,  gxf);
 REGISTER_MUXDEMUX(H261, h261);
diff --git a/libavformat/gifdec.c b/libavformat/gifdec.c
new file mode 100644
index 000..ed85e86
--- /dev/null
+++ b/libavformat/gifdec.c
@@ -0,0 +1,322 @@
+/*
+ * GIF demuxer
+ * Copyright (c) 2012 Vitaliy E Sugrobov
+ *
+ * This file is part of Libav.
+ *
+ * Libav 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.
+ *
+ * Libav 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 Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * GIF demuxer.
+ *
+ * There are two options available to user: default_delay and min_delay.
+ *
+ * These options are for protection from too rapid gif animations.
+ * In practice it is standard approach to slow down rendering of this
+ * kind of gifs. If you try to play gif with delay between frames of one
+ * hundredth of second (100fps) using one of major web browsers, you get
+ * significantly slower playback, around 10 fps. This is because browser
+ * detects that delay value is less than some threshold (usually 2 hundredths
+ * of second) and reset it to default value (usually 10 hundredths of second,
+ * which corresponds to 10fps). Manipulating these options, user can achieve
+ * the same effect during conversion to some video format. Otherwise user
+ * can set them to not protect from rapid animations at all.
+ *
+ * The other case when these options necessary is for gif images encoded
+ * according to gif87a standard since prior to gif89a there was no delay
+ * information included in file.
+ */
+
+#include "libavutil/intreadwrite.h"
+#include "libavutil/opt.h"
+
+#include "avformat.h"
+#include "internal.h"
+
+#define GIF_SIG_87A "GIF87a"
+#define GIF_SIG_89A "GIF89a"
+
+#define GIF_TRAILER 0x3b
+#define GIF_EXTENSION_INTRODUCER0x21
+#define GIF_IMAGE_SEPARATOR 0x2c
+#define GIF_GCE_EXT_LABEL   0xf9
+
+typedef struct GIFDemuxContext {
+  

[libav-devel] [PATCH] nuv: Use the correct context for av_image_check_size

2016-03-19 Thread Vittorio Giovara
---
 libavformat/nuv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/nuv.c b/libavformat/nuv.c
index 7fc339a..492f68f 100644
--- a/libavformat/nuv.c
+++ b/libavformat/nuv.c
@@ -198,7 +198,7 @@ static int nuv_header(AVFormatContext *s)
 return AVERROR(ENOMEM);
 ctx->v_id = vst->index;
 
-ret = av_image_check_size(width, height, 0, ctx);
+ret = av_image_check_size(width, height, 0, s);
 if (ret < 0)
 return ret;
 
-- 
2.7.3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [FFmpeg-devel] [PATCH] aacpsy: avoid norm_fac becoming NaN

2016-03-19 Thread Vittorio Giovara
On Sat, Mar 19, 2016 at 8:05 PM, Luca Barbato  wrote:
> On 20/03/16 00:48, Luca Barbato wrote:
>> On 19/03/16 21:57, Vittorio Giovara wrote:
>>> On Tue, Apr 21, 2015 at 12:50 PM, Andreas Cadhalpun
>>>  wrote:
 On 21.04.2015 02:20, Claudio Freire wrote:
> On Mon, Apr 20, 2015 at 9:13 PM, Michael Niedermayer  
> wrote:
>> On Mon, Apr 20, 2015 at 09:07:14PM -0300, Claudio Freire wrote:
>>> On Mon, Apr 20, 2015 at 8:59 PM, Claudio Freire 
>>>  wrote:
 On Mon, Apr 20, 2015 at 8:32 PM, Andreas Cadhalpun
  wrote:
 The long version:

 ath should approximate the shape of the absolute hearing 
 threshold, so
 yes, it's best if it really uses the minimum, since that will 
 prevent
 clipping of the ath curve and result in a more accurate threshold
 computation.
>>>
>>> So you agree with my patch fixing minath?
>>> Or would you prefer a version with:
>>> minath = ath(3410 - 0.733 * ATH_ADD, ATH_ADD)
>>
>> Well, that's not really closer to the minimum (a few tests with 
>> gnuplot say).
>
> Are you sure your plots were done correctly?
> Because I'm quite sure this is the correct first order approximation
> of the minimum.
>
> For ATH_ADD = 4 this gives 3407.068, which is quite close to 
> Michael's value
> (3407.080774800152).

 I checked the formula several times, but still, I could have made a 
 mistake.
>>>
>>>
>>> This is what I did if you want to check it out (maybe you spot the 
>>> mistake)
>>>
>>> gnuplot> ath(f,a) = _ath(f/1000.0, a)
>>> gnuplot> _ath(f,a) = 3.64 * f**(-0.8) - 6.8 * exp(-0.6 * (f-3.4) *
>>> (f-3.4)) + 6.0 * exp(-0.15 * (f-8.7) * (f-8.7)) + (0.6 + 0.04 * a) *
>>> 0.001 * f * f * f
>>   ^^
>> missing * f
>
> Much better now :)
>
> So yes. I'd say it's a good change.

 OK, patch attached.

 Best regards,
 Andreas
>>>
>>> Is this patch still needed?
>>>
>>
>> Should be ok to merge it.
>
> Actually it seems in.

Oh right I missed it (110f7f35fb615b97d983b1c6c6a714fddd28bcbe)
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 8/8] unix: Use rw_timeout for setting the connect timeout

2016-03-19 Thread Martin Storsjö
---
 libavformat/unix.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/unix.c b/libavformat/unix.c
index 6bb677d..647e7e8 100644
--- a/libavformat/unix.c
+++ b/libavformat/unix.c
@@ -73,6 +73,9 @@ static int unix_open(URLContext *h, const char *filename, int 
flags)
 if ((fd = ff_socket(AF_UNIX, s->type, 0)) < 0)
 return ff_neterrno();
 
+if (s->timeout < 0 && h->rw_timeout)
+s->timeout = h->rw_timeout / 1000;
+
 if (s->listen) {
 ret = ff_listen_bind(fd, (struct sockaddr *)&s->addr,
  sizeof(s->addr), s->timeout, h);
-- 
2.5.4 (Apple Git-61)

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [FFmpeg-devel] [PATCH] aacpsy: avoid norm_fac becoming NaN

2016-03-19 Thread Luca Barbato
On 20/03/16 00:48, Luca Barbato wrote:
> On 19/03/16 21:57, Vittorio Giovara wrote:
>> On Tue, Apr 21, 2015 at 12:50 PM, Andreas Cadhalpun
>>  wrote:
>>> On 21.04.2015 02:20, Claudio Freire wrote:
 On Mon, Apr 20, 2015 at 9:13 PM, Michael Niedermayer  
 wrote:
> On Mon, Apr 20, 2015 at 09:07:14PM -0300, Claudio Freire wrote:
>> On Mon, Apr 20, 2015 at 8:59 PM, Claudio Freire  
>> wrote:
>>> On Mon, Apr 20, 2015 at 8:32 PM, Andreas Cadhalpun
>>>  wrote:
>>> The long version:
>>>
>>> ath should approximate the shape of the absolute hearing threshold, 
>>> so
>>> yes, it's best if it really uses the minimum, since that will 
>>> prevent
>>> clipping of the ath curve and result in a more accurate threshold
>>> computation.
>>
>> So you agree with my patch fixing minath?
>> Or would you prefer a version with:
>> minath = ath(3410 - 0.733 * ATH_ADD, ATH_ADD)
>
> Well, that's not really closer to the minimum (a few tests with 
> gnuplot say).

 Are you sure your plots were done correctly?
 Because I'm quite sure this is the correct first order approximation
 of the minimum.

 For ATH_ADD = 4 this gives 3407.068, which is quite close to Michael's 
 value
 (3407.080774800152).
>>>
>>> I checked the formula several times, but still, I could have made a 
>>> mistake.
>>
>>
>> This is what I did if you want to check it out (maybe you spot the 
>> mistake)
>>
>> gnuplot> ath(f,a) = _ath(f/1000.0, a)
>> gnuplot> _ath(f,a) = 3.64 * f**(-0.8) - 6.8 * exp(-0.6 * (f-3.4) *
>> (f-3.4)) + 6.0 * exp(-0.15 * (f-8.7) * (f-8.7)) + (0.6 + 0.04 * a) *
>> 0.001 * f * f * f
>   ^^
> missing * f

 Much better now :)

 So yes. I'd say it's a good change.
>>>
>>> OK, patch attached.
>>>
>>> Best regards,
>>> Andreas
>>
>> Is this patch still needed?
>>
> 
> Should be ok to merge it.

Actually it seems in.


___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] avio: Add avio_check2

2016-03-19 Thread Luca Barbato
On 19/03/16 21:38, Vittorio Giovara wrote:
> On Thu, Feb 4, 2016 at 6:56 AM, Vittorio Giovara
>  wrote:
>> On Sun, Nov 8, 2015 at 5:12 PM, Luca Barbato  wrote:
>>> On 08/11/15 16:43, Anton Khirnov wrote:
 Ok, now that sounds like a real use case. But that's really only applies
 to img2dec (which is itself a hack that should go away eventually, but I
 digress), not to avconv. So, unless there are other arguments, I would
 keep this private.
>>>
>>> We should deprecate avio_check or warn that it works only for files then.
>>>
>>> lu
>>
>> what happened to this?
> 
> ping
> 

I'd update it to keep it private, anybody against marking avio_check
deprecated?

lu
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 5/6] avio: Add avio_read wrapper to simplify error checking

2016-03-19 Thread Luca Barbato
On 19/03/16 21:55, Vittorio Giovara wrote:
> On Sun, Jun 7, 2015 at 1:07 PM, Luca Barbato  wrote:
>> On 07/06/15 16:30, Andreas Cadhalpun wrote:
>>> It seems Luca accidentally pushed an old version of this patch.
>>> The pushed version still has the ffio_read_size name and Luca's
>>> comment about the error handling is also not addressed.
>>
>> Good thing it is an internal function and thanks for spotting!
> 
> Should we start coming back to this?
> 

Possibly. =)
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [FFmpeg-devel] [PATCH] aacpsy: avoid norm_fac becoming NaN

2016-03-19 Thread Luca Barbato
On 19/03/16 21:57, Vittorio Giovara wrote:
> On Tue, Apr 21, 2015 at 12:50 PM, Andreas Cadhalpun
>  wrote:
>> On 21.04.2015 02:20, Claudio Freire wrote:
>>> On Mon, Apr 20, 2015 at 9:13 PM, Michael Niedermayer  
>>> wrote:
 On Mon, Apr 20, 2015 at 09:07:14PM -0300, Claudio Freire wrote:
> On Mon, Apr 20, 2015 at 8:59 PM, Claudio Freire  
> wrote:
>> On Mon, Apr 20, 2015 at 8:32 PM, Andreas Cadhalpun
>>  wrote:
>> The long version:
>>
>> ath should approximate the shape of the absolute hearing threshold, 
>> so
>> yes, it's best if it really uses the minimum, since that will prevent
>> clipping of the ath curve and result in a more accurate threshold
>> computation.
>
> So you agree with my patch fixing minath?
> Or would you prefer a version with:
> minath = ath(3410 - 0.733 * ATH_ADD, ATH_ADD)

 Well, that's not really closer to the minimum (a few tests with 
 gnuplot say).
>>>
>>> Are you sure your plots were done correctly?
>>> Because I'm quite sure this is the correct first order approximation
>>> of the minimum.
>>>
>>> For ATH_ADD = 4 this gives 3407.068, which is quite close to Michael's 
>>> value
>>> (3407.080774800152).
>>
>> I checked the formula several times, but still, I could have made a 
>> mistake.
>
>
> This is what I did if you want to check it out (maybe you spot the 
> mistake)
>
> gnuplot> ath(f,a) = _ath(f/1000.0, a)
> gnuplot> _ath(f,a) = 3.64 * f**(-0.8) - 6.8 * exp(-0.6 * (f-3.4) *
> (f-3.4)) + 6.0 * exp(-0.15 * (f-8.7) * (f-8.7)) + (0.6 + 0.04 * a) *
> 0.001 * f * f * f
   ^^
 missing * f
>>>
>>> Much better now :)
>>>
>>> So yes. I'd say it's a good change.
>>
>> OK, patch attached.
>>
>> Best regards,
>> Andreas
> 
> Is this patch still needed?
> 

Should be ok to merge it.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/2] avlanguage: add av_islang

2016-03-19 Thread Luca Barbato
On 24/07/14 09:55, Jan Gerber wrote:
> ---
>  libavformat/avlanguage.c | 14 ++
>  libavformat/avlanguage.h |  5 +
>  2 files changed, 19 insertions(+)
> 

I'd keep it private its usage is _quite_ specific.

lu

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] GIF demuxer

2016-03-19 Thread Luca Barbato
On 19/03/16 22:48, Vittorio Giovara wrote:
> From: Vitaliy E Sugrobov 
> 
> This demuxer is capable of extracting multiple frames from gif file.
> In conjunction with gif decoder it implements support for reading
> animated gifs.
> 
> Signed-off-by: Vitaliy E Sugrobov 
> Signed-off-by: Vittorio Giovara 
> ---
>  Changelog|   1 +
>  doc/general.texi |   2 +-
>  libavformat/Makefile |   1 +
>  libavformat/allformats.c |   2 +-
>  libavformat/gifdec.c | 318 
> +++
>  5 files changed, 322 insertions(+), 2 deletions(-)
>  create mode 100644 libavformat/gifdec.c
> 
> diff --git a/Changelog b/Changelog
> index ca9c9b4..71fe9e2 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -52,6 +52,7 @@ version :
>  - G.723.1 muxer and encoder
>  - compressed SWF
>  - G.729 raw demuxer
> +- GIF demuxer
>  
>  
>  version 11:
> diff --git a/doc/general.texi b/doc/general.texi
> index 15e4a66..5f01c50 100644
> --- a/doc/general.texi
> +++ b/doc/general.texi
> @@ -282,7 +282,7 @@ library:
>  @item framecrc testing format   @tab X @tab
>  @item FunCom ISS@tab   @tab X
>  @tab Audio format used in various games from FunCom like The Longest 
> Journey.
> -@item GIF Animation @tab X @tab
> +@item GIF Animation @tab X @tab X
>  @item GXF   @tab X @tab X
>  @tab General eXchange Format SMPTE 360M, used by Thomson Grass Valley
>   playout servers.
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 891a20f..5cd8f8f 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -135,6 +135,7 @@ OBJS-$(CONFIG_FOURXM_DEMUXER)+= 4xm.o
>  OBJS-$(CONFIG_FRAMECRC_MUXER)+= framecrcenc.o framehash.o
>  OBJS-$(CONFIG_FRAMEMD5_MUXER)+= md5enc.o framehash.o
>  OBJS-$(CONFIG_GIF_MUXER) += gif.o
> +OBJS-$(CONFIG_GIF_DEMUXER)   += gifdec.o
>  OBJS-$(CONFIG_GSM_DEMUXER)   += gsmdec.o
>  OBJS-$(CONFIG_GXF_DEMUXER)   += gxf.o
>  OBJS-$(CONFIG_GXF_MUXER) += gxfenc.o audiointerleave.o
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index 0f49756..1056d7b 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -106,7 +106,7 @@ void av_register_all(void)
>  REGISTER_MUXDEMUX(G722, g722);
>  REGISTER_MUXDEMUX(G723_1,   g723_1);
>  REGISTER_DEMUXER (G729, g729);
> -REGISTER_MUXER   (GIF,  gif);
> +REGISTER_MUXDEMUX(GIF,  gif);
>  REGISTER_DEMUXER (GSM,  gsm);
>  REGISTER_MUXDEMUX(GXF,  gxf);
>  REGISTER_MUXDEMUX(H261, h261);
> diff --git a/libavformat/gifdec.c b/libavformat/gifdec.c
> new file mode 100644
> index 000..cc46716
> --- /dev/null
> +++ b/libavformat/gifdec.c
> @@ -0,0 +1,318 @@
> +/*
> + * GIF demuxer
> + * Copyright (c) 2012 Vitaliy E Sugrobov
> + *
> + * This file is part of Libav.
> + *
> + * Libav 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.
> + *
> + * Libav 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 Libav; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +/**
> + * @file
> + * GIF demuxer.
> + *
> + * There are two options available to user: default_delay and min_delay.
> + *
> + * These options are for protection from too rapid gif animations.
> + * In practice it is standard approach to slow down rendering of this
> + * kind of gifs. If you try to play gif with delay between frames of one
> + * hundredth of second (100fps) using one of major web browsers, you get
> + * significantly slower playback, around 10 fps. This is because browser
> + * detects that delay value is less than some threshold (usually 2 hundredths
> + * of second) and reset it to default value (usually 10 hundredths of second,
> + * which corresponds to 10fps). Manipulating these options, user can achieve
> + * the same effect during conversion to some video format. Otherwise user
> + * can set them to not protect from rapid animations at all.
> + *
> + * The other case when these options necessary is for gif images encoded
> + * according to gif87a standard since prior to gif89a there was no delay
> + * information included in file.
> + */
> +
> +#include "libavutil/intreadwrite.h"
> +#include "libavutil/opt.h"
> +
> +#include "avformat.h"
> +

Re: [libav-devel] [PATCH 01/25] fate: Add test for WMV2 with jframes

2016-03-19 Thread Luca Barbato
On 19/03/16 22:42, Vittorio Giovara wrote:
> ---
>  tests/fate/microsoft.mak|   3 +
>  tests/ref/fate/wmv8-intrax8 | 475 
> 
>  2 files changed, 478 insertions(+)
>  create mode 100644 tests/ref/fate/wmv8-intrax8
> 
> This test breaks on an oracle box with gcc-4.4. I carried out a minimum
> investigation and managed to isolate the issue to optimization level: when
> compiled with -O2 gcc-4.4 produces the expected results, while -O3 generates
> differing hashes. Note that with -O2 and the other 6-7 additional 
> optimizations
> that -O3 enables, the test still works fine, it's something that is triggered
> when -O3 is explicitly passed in.
> 
> I don't have sample code to demonstrate this is a compiler bug, but I would
> rather have this section of the code covered by this test and update
> the gcc version on the oracle box, than trying to isolate the issue more.
> However, I'd be more than happy to help anybody willing to work on this.
> 
> Since I don't want to create controversy, if there is no consensus I'll simply
> drop this patch, and leave this portion of code untested. The changes brought
> in by this set do not affect this test at all.

I'm for adding it and while it is not confirmed it is a compiler bug I
guess enough time had been spent on it by you and is not that you caused
the issue to begin with ^^;

lu
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/2] lavf: Raw G.729 demuxer

2016-03-19 Thread Luca Barbato
On 19/03/16 22:48, Vittorio Giovara wrote:
> From: Vladimir Voroshilov 
> 
> Signed-off-by: Vittorio Giovara 
> ---
>  Changelog|   1 +
>  libavformat/Makefile |   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/g729dec.c| 105 
> +++
>  4 files changed, 108 insertions(+)
>  create mode 100644 libavformat/g729dec.c
> 

Should not hurt.

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] indeo4: Consistently initialize variables

2016-03-19 Thread Luca Barbato
On 19/03/16 23:07, Vittorio Giovara wrote:
> Avoid using multiple variables for the same purpose.
> ---
>  libavcodec/indeo4.c | 9 +++--
>  libavcodec/ivi.h| 3 +--
>  2 files changed, 4 insertions(+), 8 deletions(-)
> 

Ok.


___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 13/14] bitstream_filter: add a compatibility wrapper for the old bsf API

2016-03-19 Thread Luca Barbato
On 04/03/16 09:15, Anton Khirnov wrote:
> ---
>  libavcodec/bitstream_filter.c | 147 
> --
>  1 file changed, 112 insertions(+), 35 deletions(-)
> 

Possibly OK.

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] avconv: switch to the new BSF API

2016-03-19 Thread Luca Barbato
On 04/03/16 19:01, Anton Khirnov wrote:
> ---
> Changed to not send multiple packets at once to the filter
> ---
>  avconv.c | 147 
> +++
>  avconv.h |   6 ++-
>  avconv_opt.c |  22 +
>  cmdutils.c   |   5 +-
>  4 files changed, 129 insertions(+), 51 deletions(-)
> 

Possibly OK.

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] aac_adtstoasc_bsf: convert to the new API

2016-03-19 Thread Luca Barbato
On 19/03/16 17:20, Anton Khirnov wrote:
> ---
>  libavcodec/aac_adtstoasc_bsf.c | 104 
> +++--
>  libavcodec/allcodecs.c |   1 -
>  libavcodec/bitstream_filters.c |   5 ++
>  3 files changed, 74 insertions(+), 36 deletions(-)
> 

OK.

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] indeo4: Consistently initialize variables

2016-03-19 Thread Vittorio Giovara
Avoid using multiple variables for the same purpose.
---
 libavcodec/indeo4.c | 9 +++--
 libavcodec/ivi.h| 3 +--
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/libavcodec/indeo4.c b/libavcodec/indeo4.c
index 4ec09dc..217311f 100644
--- a/libavcodec/indeo4.c
+++ b/libavcodec/indeo4.c
@@ -122,10 +122,7 @@ static int decode_pic_hdr(IVI45DecContext *ctx, 
AVCodecContext *avctx)
 if (ctx->frame_type == IVI4_FRAMETYPE_BIDIR)
 ctx->has_b_frames = 1;
 
-ctx->transp_status = get_bits1(&ctx->gb);
-if (ctx->transp_status) {
-ctx->has_transp = 1;
-}
+ctx->has_transp = get_bits1(&ctx->gb);
 
 /* unknown bit: Mac decoder ignores this bit, XANIM returns error */
 if (get_bits1(&ctx->gb)) {
@@ -159,10 +156,10 @@ static int decode_pic_hdr(IVI45DecContext *ctx, 
AVCodecContext *avctx)
 }
 
 /* Decode tile dimensions. */
-if (get_bits1(&ctx->gb)) {
+ctx->uses_tiling = get_bits1(&ctx->gb);
+if (ctx->uses_tiling) {
 pic_conf.tile_height = scale_tile_size(pic_conf.pic_height, 
get_bits(&ctx->gb, 4));
 pic_conf.tile_width  = scale_tile_size(pic_conf.pic_width,  
get_bits(&ctx->gb, 4));
-ctx->uses_tiling = 1;
 } else {
 pic_conf.tile_height = pic_conf.pic_height;
 pic_conf.tile_width  = pic_conf.pic_width;
diff --git a/libavcodec/ivi.h b/libavcodec/ivi.h
index c403739..9b4824b 100644
--- a/libavcodec/ivi.h
+++ b/libavcodec/ivi.h
@@ -218,7 +218,6 @@ typedef struct IVI45DecContext {
 int prev_frame_type; ///< frame type of the previous frame
 uint32_tdata_size;   ///< size of the frame data in bytes from 
picture header
 int is_scalable;
-int transp_status;   ///< transparency mode status: 1 - enabled
 const uint8_t   *frame_data; ///< input frame data pointer
 int inter_scal;  ///< signals a sequence of scalable inter 
frames
 uint32_tframe_size;  ///< frame size in bytes
@@ -250,7 +249,7 @@ typedef struct IVI45DecContext {
 
 int show_indeo4_info;
 uint8_t has_b_frames;
-uint8_t has_transp;
+uint8_t has_transp;  ///< transparency mode status: 1 - enabled
 uint8_t uses_tiling;
 uint8_t uses_haar;
 uint8_t uses_fullpel;
-- 
2.7.3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 08/25] intrax8: Check and propagate errors from ff_intrax8_common_init

2016-03-19 Thread Vittorio Giovara
This allows dropping an afterwards redundant assert.
---
 libavcodec/intrax8.c | 12 +---
 libavcodec/intrax8.h |  3 ++-
 2 files changed, 11 insertions(+), 4 deletions(-)

Unchanged.

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index bea1b76..0c720b0 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -742,14 +742,18 @@ static void x8_init_block_index(MpegEncContext *s)
 s->dest[2] += (s->mb_y & (~1)) * uvlinesize << 2;
 }
 
-av_cold void ff_intrax8_common_init(IntraX8Context *w, MpegEncContext *const s)
+av_cold int ff_intrax8_common_init(IntraX8Context *w, MpegEncContext *const s)
 {
+int ret = x8_vlc_init();
+if (ret < 0)
+return ret;
+
 w->s = s;
-x8_vlc_init();
-assert(s->mb_width > 0);
 
 // two rows, 2 blocks per cannon mb
 w->prediction_table = av_mallocz(s->mb_width * 2 * 2);
+if (!w->prediction_table)
+return AVERROR(ENOMEM);
 
 ff_init_scantable(s->idsp.idct_permutation, &w->scantable[0],
   ff_wmv1_scantable[0]);
@@ -759,6 +763,8 @@ av_cold void ff_intrax8_common_init(IntraX8Context *w, 
MpegEncContext *const s)
   ff_wmv1_scantable[3]);
 
 ff_intrax8dsp_init(&w->dsp);
+
+return 0;
 }
 
 av_cold void ff_intrax8_common_end(IntraX8Context *w)
diff --git a/libavcodec/intrax8.h b/libavcodec/intrax8.h
index 3339bc6..f69f03e 100644
--- a/libavcodec/intrax8.h
+++ b/libavcodec/intrax8.h
@@ -61,8 +61,9 @@ typedef struct IntraX8Context {
  * Requires valid MpegEncContext with valid s->mb_width before calling.
  * @param w pointer to IntraX8Context
  * @param s pointer to MpegEncContext of the parent codec
+ * @return 0 on success, a negative AVERROR value on error
  */
-void ff_intrax8_common_init(IntraX8Context *w, MpegEncContext *const s);
+int ff_intrax8_common_init(IntraX8Context *w, MpegEncContext *const s);
 
 /**
  * Destroy IntraX8 frame structure.
-- 
2.7.3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 07/25] intrax8: Let x8_vlc_init report errors

2016-03-19 Thread Vittorio Giovara
---
 libavcodec/intrax8.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Unchanged.

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index 3ab2faa..bea1b76 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -45,7 +45,7 @@ static VLC j_ac_vlc[2][2][8];  // [quant < 13], [intra / 
inter], [select]
 static VLC j_dc_vlc[2][8]; // [quant], [select]
 static VLC j_orient_vlc[2][4]; // [quant], [select]
 
-static av_cold void x8_vlc_init(void)
+static av_cold int x8_vlc_init(void)
 {
 int i;
 int offset = 0;
@@ -114,9 +114,13 @@ static av_cold void x8_vlc_init(void)
 init_or_vlc(j_orient_vlc[1][i], x8_orient_lowquant_table[i][0]);
 #undef init_or_vlc
 
-if (offset != sizeof(table) / sizeof(VLC_TYPE) / 2)
+if (offset != sizeof(table) / sizeof(VLC_TYPE) / 2) {
 av_log(NULL, AV_LOG_ERROR, "table size %i does not match needed %i\n",
(int) (sizeof(table) / sizeof(VLC_TYPE) / 2), offset);
+return AVERROR_INVALIDDATA;
+}
+
+return 0;
 }
 
 static void x8_reset_vlc_tables(IntraX8Context *w)
-- 
2.7.3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 20/25] intrax8: Pass macroblock coordinates to ff_intrax8_decode_picture

2016-03-19 Thread Vittorio Giovara
These values need to be updated with the last macroblock position,
so keep them as pointers.
---
 libavcodec/intrax8.c   | 63 +-
 libavcodec/intrax8.h   |  4 +++-
 libavcodec/vc1_block.c |  3 ++-
 libavcodec/wmv2dec.c   |  3 ++-
 4 files changed, 39 insertions(+), 34 deletions(-)

This is a new patch that I have to add, this makes it more consistent
with the rest of the mpegvideo called externally.
Vittorio

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index fe75424..fab25bb 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -382,8 +382,7 @@ static int x8_setup_spatial_predictor(IntraX8Context *const 
w, const int chroma)
 static void x8_update_predictions(IntraX8Context *const w, const int orient,
   const int est_run)
 {
-MpegEncContext *const s = w->s;
-w->prediction_table[s->mb_x * 2 + (s->mb_y & 1)] = (est_run << 2) + 1 * 
(orient == 4) + 2 * (orient == 8);
+w->prediction_table[w->mb_x * 2 + (w->mb_y & 1)] = (est_run << 2) + 1 * 
(orient == 4) + 2 * (orient == 8);
 /*
  * y = 2n + 0 -> // 0 2 4
  * y = 2n + 1 -> // 1 3 5
@@ -392,10 +391,9 @@ static void x8_update_predictions(IntraX8Context *const w, 
const int orient,
 
 static void x8_get_prediction_chroma(IntraX8Context *const w)
 {
-MpegEncContext *const s = w->s;
-w->edges  = 1 * (!(s->mb_x >> 1));
-w->edges |= 2 * (!(s->mb_y >> 1));
-w->edges |= 4 * (s->mb_x >= (2 * w->mb_width - 1)); // mb_x for chroma 
would always be odd
+w->edges  = 1 * (!(w->mb_x >> 1));
+w->edges |= 2 * (!(w->mb_y >> 1));
+w->edges |= 4 * (w->mb_x >= (2 * w->mb_width - 1)); // mb_x for chroma 
would always be odd
 
 w->raw_orient = 0;
 // lut_co[8] = {inv,4,8,8, inv,4,8,8} <- => {1,1,0,0;1,1,0,0} => 0xCC
@@ -404,29 +402,28 @@ static void x8_get_prediction_chroma(IntraX8Context 
*const w)
 return;
 }
 // block[x - 1][y | 1 - 1)]
-w->chroma_orient = (w->prediction_table[2 * s->mb_x - 2] & 0x03) << 2;
+w->chroma_orient = (w->prediction_table[2 * w->mb_x - 2] & 0x03) << 2;
 }
 
 static void x8_get_prediction(IntraX8Context *const w)
 {
-MpegEncContext *const s = w->s;
 int a, b, c, i;
 
-w->edges  = 1 * (!s->mb_x);
-w->edges |= 2 * (!s->mb_y);
-w->edges |= 4 * (s->mb_x >= (2 * w->mb_width - 1));
+w->edges  = 1 * (!w->mb_x);
+w->edges |= 2 * (!w->mb_y);
+w->edges |= 4 * (w->mb_x >= (2 * w->mb_width - 1));
 
 switch (w->edges & 3) {
 case 0:
 break;
 case 1:
 // take the one from the above block[0][y - 1]
-w->est_run = w->prediction_table[!(s->mb_y & 1)] >> 2;
+w->est_run = w->prediction_table[!(w->mb_y & 1)] >> 2;
 w->orient  = 1;
 return;
 case 2:
 // take the one from the previous block[x - 1][0]
-w->est_run = w->prediction_table[2 * s->mb_x - 2] >> 2;
+w->est_run = w->prediction_table[2 * w->mb_x - 2] >> 2;
 w->orient  = 2;
 return;
 case 3:
@@ -435,15 +432,15 @@ static void x8_get_prediction(IntraX8Context *const w)
 return;
 }
 // no edge cases
-b = w->prediction_table[2 * s->mb_x + !(s->mb_y & 1)]; // block[x
][y - 1]
-a = w->prediction_table[2 * s->mb_x - 2 +  (s->mb_y & 1)]; // block[x - 
1][y]
-c = w->prediction_table[2 * s->mb_x - 2 + !(s->mb_y & 1)]; // block[x - 
1][y - 1]
+b = w->prediction_table[2 * w->mb_x + !(w->mb_y & 1)]; // block[x
][y - 1]
+a = w->prediction_table[2 * w->mb_x - 2 +  (w->mb_y & 1)]; // block[x - 
1][y]
+c = w->prediction_table[2 * w->mb_x - 2 + !(w->mb_y & 1)]; // block[x - 
1][y - 1]
 
 w->est_run = FFMIN(b, a);
 /* This condition has nothing to do with w->edges, even if it looks
  * similar it would trigger if e.g. x = 3; y = 2;
  * I guess somebody wrote something wrong and it became standard. */
-if ((s->mb_x & s->mb_y) != 0)
+if ((w->mb_x & w->mb_y) != 0)
 w->est_run = FFMIN(c, w->est_run);
 w->est_run >>= 2;
 
@@ -717,7 +714,7 @@ block_placed:
 }
 
 // FIXME maybe merge with ff_*
-static void x8_init_block_index(IntraX8Context *w, AVFrame *frame, int mb_y)
+static void x8_init_block_index(IntraX8Context *w, AVFrame *frame)
 {
 // not parent codec linesize as this would be wrong for field pics
 // not that IntraX8 has interlacing support ;)
@@ -728,10 +725,10 @@ static void x8_init_block_index(IntraX8Context *w, 
AVFrame *frame, int mb_y)
 w->dest[1] = frame->data[1];
 w->dest[2] = frame->data[2];
 
-w->dest[0] +=  mb_y * linesize << 3;
+w->dest[0] +=  w->mb_y * linesize << 3;
 // chroma blocks are on add rows
-w->dest[1] += (mb_y & (~1)) * uvlinesize << 2;
-w->dest[2] += (mb_y & (~1)) * uvlinesize << 2;
+w->dest[1] += (w->mb_y & (~1)) * uvlinesize << 2;
+w->dest[2] += (w->mb_y & (~1)) * uvlinesize << 2;
 }
 
 av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
@@ 

[libav-devel] [PATCH 15/25] intrax8: Use a constant buffer instead of a ScratchpadContext

2016-03-19 Thread Vittorio Giovara
The size of the block is fixed (8x8 plus padding).
---
 libavcodec/intrax8.c | 5 ++---
 libavcodec/intrax8.h | 1 +
 2 files changed, 3 insertions(+), 3 deletions(-)

Modified according to instructions.

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index 9da6b41f4..fae9bc8 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -328,12 +328,11 @@ static int x8_get_dc_rlf(IntraX8Context *const w,
 
 static int x8_setup_spatial_predictor(IntraX8Context *const w, const int 
chroma)
 {
-MpegEncContext *const s = w->s;
 int range;
 int sum;
 int quant;
 
-w->dsp.setup_spatial_compensation(w->dest[chroma], s->sc.edge_emu_buffer,
+w->dsp.setup_spatial_compensation(w->dest[chroma], w->scratchpad,
   w->frame->linesize[chroma > 0],
   &range, &sum, w->edges);
 if (chroma) {
@@ -698,7 +697,7 @@ static int x8_decode_intra_mb(IntraX8Context *const w, 
const int chroma)
 dsp_x8_put_solidcolor(w->predicted_dc, w->dest[chroma],
   w->frame->linesize[!!chroma]);
 } else {
-w->dsp.spatial_compensation[w->orient](s->sc.edge_emu_buffer,
+w->dsp.spatial_compensation[w->orient](w->scratchpad,
w->dest[chroma],
w->frame->linesize[!!chroma]);
 }
diff --git a/libavcodec/intrax8.h b/libavcodec/intrax8.h
index f087b9f..d268c24 100644
--- a/libavcodec/intrax8.h
+++ b/libavcodec/intrax8.h
@@ -51,6 +51,7 @@ typedef struct IntraX8Context {
 int divide_quant_dc_luma;
 int divide_quant_dc_chroma;
 uint8_t *dest[3];
+uint8_t scratchpad[42]; // answer to everything and size of the block
 
 // changed per block
 int edges;
-- 
2.7.3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 14/25] intrax8: Pass the output frame to the decoding function

2016-03-19 Thread Vittorio Giovara
Helps in decoupling this code from mpegvideo.
---
 libavcodec/intrax8.c   | 21 +++--
 libavcodec/intrax8.h   |  7 +--
 libavcodec/vc1_block.c |  5 +++--
 libavcodec/wmv2dec.c   |  3 ++-
 4 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index dd9c226..9da6b41f4 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -334,7 +334,7 @@ static int x8_setup_spatial_predictor(IntraX8Context *const 
w, const int chroma)
 int quant;
 
 w->dsp.setup_spatial_compensation(w->dest[chroma], s->sc.edge_emu_buffer,
-  s->current_picture.f->linesize[chroma > 
0],
+  w->frame->linesize[chroma > 0],
   &range, &sum, w->edges);
 if (chroma) {
 w->orient = w->chroma_orient;
@@ -670,7 +670,7 @@ static int x8_decode_intra_mb(IntraX8Context *const w, 
const int chroma)
 
 dsp_x8_put_solidcolor(av_clip_uint8((dc_level * dc_quant + 4) >> 
3),
   w->dest[chroma],
-  s->current_picture.f->linesize[!!chroma]);
+  w->frame->linesize[!!chroma]);
 
 goto block_placed;
 }
@@ -696,15 +696,15 @@ static int x8_decode_intra_mb(IntraX8Context *const w, 
const int chroma)
 
 if (w->flat_dc) {
 dsp_x8_put_solidcolor(w->predicted_dc, w->dest[chroma],
-  s->current_picture.f->linesize[!!chroma]);
+  w->frame->linesize[!!chroma]);
 } else {
 w->dsp.spatial_compensation[w->orient](s->sc.edge_emu_buffer,
w->dest[chroma],
-   
s->current_picture.f->linesize[!!chroma]);
+   w->frame->linesize[!!chroma]);
 }
 if (!zeros_only)
 w->idsp.idct_add(w->dest[chroma],
- s->current_picture.f->linesize[!!chroma],
+ w->frame->linesize[!!chroma],
  s->block[0]);
 
 block_placed:
@@ -713,7 +713,7 @@ block_placed:
 
 if (w->loopfilter) {
 uint8_t *ptr = w->dest[chroma];
-int linesize = s->current_picture.f->linesize[!!chroma];
+int linesize = w->frame->linesize[!!chroma];
 
 if (!((w->edges & 2) || (zeros_only && (w->orient | 4) == 4)))
 w->dsp.h_loop_filter(ptr, linesize, w->quant);
@@ -774,8 +774,8 @@ av_cold void ff_intrax8_common_end(IntraX8Context *w)
 av_freep(&w->prediction_table);
 }
 
-int ff_intrax8_decode_picture(IntraX8Context *const w, int dquant,
-  int quant_offset, int loopfilter)
+int ff_intrax8_decode_picture(IntraX8Context *const w, Picture *pict,
+  int dquant, int quant_offset, int loopfilter)
 {
 MpegEncContext *const s = w->s;
 int mb_xy;
@@ -785,6 +785,7 @@ int ff_intrax8_decode_picture(IntraX8Context *const w, int 
dquant,
 w->dquant = dquant;
 w->quant  = dquant >> 1;
 w->qsum   = quant_offset;
+w->frame  = pict->f;
 w->loopfilter = loopfilter;
 
 w->divide_quant_dc_luma = ((1 << 16) + (w->quant >> 1)) / w->quant;
@@ -798,7 +799,7 @@ int ff_intrax8_decode_picture(IntraX8Context *const w, int 
dquant,
 x8_reset_vlc_tables(w);
 
 for (s->mb_y = 0; s->mb_y < s->mb_height * 2; s->mb_y++) {
-x8_init_block_index(w, s->current_picture.f, s->mb_y);
+x8_init_block_index(w, w->frame, s->mb_y);
 mb_xy = (s->mb_y >> 1) * s->mb_stride;
 
 for (s->mb_x = 0; s->mb_x < s->mb_width * 2; s->mb_x++) {
@@ -827,7 +828,7 @@ int ff_intrax8_decode_picture(IntraX8Context *const w, int 
dquant,
 /* emulate MB info in the relevant tables */
 s->mbskip_table[mb_xy] = 0;
 s->mbintra_table[mb_xy]= 1;
-s->current_picture.qscale_table[mb_xy] = w->quant;
+pict->qscale_table[mb_xy] = w->quant;
 mb_xy++;
 }
 w->dest[0] += 8;
diff --git a/libavcodec/intrax8.h b/libavcodec/intrax8.h
index f73cfcd..f087b9f 100644
--- a/libavcodec/intrax8.h
+++ b/libavcodec/intrax8.h
@@ -23,6 +23,7 @@
 #include "mpegvideo.h"
 #include "idctdsp.h"
 #include "intrax8dsp.h"
+#include "mpegpicture.h"
 
 typedef struct IntraX8Context {
 VLC *j_ac_vlc[4]; // they point to the static j_mb_vlc
@@ -43,6 +44,7 @@ typedef struct IntraX8Context {
 int dquant;
 int qsum;
 int loopfilter;
+AVFrame *frame;
 
 // calculated per frame
 int quant_dc_chroma;
@@ -84,11 +86,12 @@ void ff_intrax8_common_end(IntraX8Context *w);
  * The parent codec must call ff_mpv_frame_end() after calling this function.
  * This function does not use ff_mpv_decode_mb().
  * @param w pointer to IntraX8Context
+ * @param pict the output Picture co

[libav-devel] [PATCH 17/25] intrax8: Reference the currect AVCodecContext

2016-03-19 Thread Vittorio Giovara
It will be needed in later commits.
---
 libavcodec/intrax8.c | 4 +++-
 libavcodec/intrax8.h | 5 -
 libavcodec/vc1dec.c  | 2 +-
 libavcodec/wmv2dec.c | 2 +-
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index 336551f..3365995 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -736,13 +736,15 @@ static void x8_init_block_index(IntraX8Context *w, 
AVFrame *frame, int mb_y)
 w->dest[2] += (mb_y & (~1)) * uvlinesize << 2;
 }
 
-av_cold int ff_intrax8_common_init(IntraX8Context *w, IDCTDSPContext *idsp,
+av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
+   IntraX8Context *w, IDCTDSPContext *idsp,
MpegEncContext *const s)
 {
 int ret = x8_vlc_init();
 if (ret < 0)
 return ret;
 
+w->avctx = avctx;
 w->idsp = *idsp;
 w->s = s;
 
diff --git a/libavcodec/intrax8.h b/libavcodec/intrax8.h
index 1a043d4..5b72532 100644
--- a/libavcodec/intrax8.h
+++ b/libavcodec/intrax8.h
@@ -35,6 +35,7 @@ typedef struct IntraX8Context {
 // set by ff_intrax8_common_init
 uint8_t *prediction_table; // 2 * (mb_w * 2)
 ScanTable scantable[3];
+AVCodecContext *avctx;
 
 // set by the caller codec
 MpegEncContext *s;
@@ -67,12 +68,14 @@ typedef struct IntraX8Context {
 /**
  * Initialize IntraX8 frame decoder.
  * Requires valid MpegEncContext with valid s->mb_width before calling.
+ * @param avctx pointer to AVCodecContext
  * @param w pointer to IntraX8Context
  * @param idsp pointer to IDCTDSPContext
  * @param s pointer to MpegEncContext of the parent codec
  * @return 0 on success, a negative AVERROR value on error
  */
-int ff_intrax8_common_init(IntraX8Context *w, IDCTDSPContext *idsp,
+int ff_intrax8_common_init(AVCodecContext *avctx,
+   IntraX8Context *w, IDCTDSPContext *idsp,
MpegEncContext *const s);
 
 /**
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 948626c..cbdd560 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -371,7 +371,7 @@ av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v)
 v->mv_f_next[0] = v->mv_f_next_base + s->b8_stride + 1;
 v->mv_f_next[1] = v->mv_f_next[0] + (s->b8_stride * (mb_height * 2 + 
1) + s->mb_stride * (mb_height + 1) * 2);
 
-ret = ff_intrax8_common_init(&v->x8, &s->idsp, s);
+ret = ff_intrax8_common_init(s->avctx, &v->x8, &s->idsp, s);
 if (ret < 0)
 goto error;
 
diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
index d7828ad..0560d95 100644
--- a/libavcodec/wmv2dec.c
+++ b/libavcodec/wmv2dec.c
@@ -473,7 +473,7 @@ static av_cold int wmv2_decode_init(AVCodecContext *avctx)
 
 ff_wmv2_common_init(w);
 
-return ff_intrax8_common_init(&w->x8, &w->s.idsp, &w->s);
+return ff_intrax8_common_init(avctx, &w->x8, &w->s.idsp, &w->s);
 }
 
 static av_cold int wmv2_decode_end(AVCodecContext *avctx)
-- 
2.7.3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 23/25] intrax8: Keep a reference to the decoder blocks

2016-03-19 Thread Vittorio Giovara
---
 libavcodec/intrax8.c | 31 ---
 libavcodec/intrax8.h |  6 ++
 libavcodec/vc1dec.c  |  1 +
 libavcodec/wmv2dec.c |  1 +
 4 files changed, 24 insertions(+), 15 deletions(-)

As with a previous patch, I prefer to reference the existing fields, to
make sure that it works fine with the rest of mpegvideo code.

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index b4ff800..f67c5e0 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -478,9 +478,8 @@ static void x8_get_prediction(IntraX8Context *const w)
 static void x8_ac_compensation(IntraX8Context *const w, int const direction,
int const dc_level)
 {
-MpegEncContext *const s = w->s;
 int t;
-#define B(x, y) s->block[0][w->idsp.idct_permutation[(x) + (y) * 8]]
+#define B(x, y) w->block[0][w->idsp.idct_permutation[(x) + (y) * 8]]
 #define T(x)  ((x) * dc_level + 0x8000) >> 16;
 switch (direction) {
 case 0:
@@ -524,7 +523,7 @@ static void x8_ac_compensation(IntraX8Context *const w, int 
const direction,
 t= T(1084); // g
 B(1, 1) += t;
 
-s->block_last_index[0] = FFMAX(s->block_last_index[0], 7 * 8);
+w->block_last_index[0] = FFMAX(w->block_last_index[0], 7 * 8);
 break;
 case 1:
 B(0, 1) -= T(6269);
@@ -532,7 +531,7 @@ static void x8_ac_compensation(IntraX8Context *const w, int 
const direction,
 B(0, 5) -= T(172);
 B(0, 7) -= T(73);
 
-s->block_last_index[0] = FFMAX(s->block_last_index[0], 7 * 8);
+w->block_last_index[0] = FFMAX(w->block_last_index[0], 7 * 8);
 break;
 case 2:
 B(1, 0) -= T(6269);
@@ -540,7 +539,7 @@ static void x8_ac_compensation(IntraX8Context *const w, int 
const direction,
 B(5, 0) -= T(172);
 B(7, 0) -= T(73);
 
-s->block_last_index[0] = FFMAX(s->block_last_index[0], 7);
+w->block_last_index[0] = FFMAX(w->block_last_index[0], 7);
 break;
 }
 #undef B
@@ -570,8 +569,6 @@ static const int16_t quant_table[64] = {
 
 static int x8_decode_intra_mb(IntraX8Context *const w, const int chroma)
 {
-MpegEncContext *const s = w->s;
-
 uint8_t *scantable;
 int final, run, level;
 int ac_mode, dc_mode, est_run, dc_level;
@@ -581,7 +578,7 @@ static int x8_decode_intra_mb(IntraX8Context *const w, 
const int chroma)
 int sign;
 
 assert(w->orient < 12);
-w->bdsp.clear_block(s->block[0]);
+w->bdsp.clear_block(w->block[0]);
 
 if (chroma)
 dc_mode = 2;
@@ -642,12 +639,12 @@ static int x8_decode_intra_mb(IntraX8Context *const w, 
const int chroma)
 if (use_quant_matrix) {
 level = (level * quant_table[pos]) >> 8;
 }
-s->block[0][scantable[pos]] = level;
+w->block[0][scantable[pos]] = level;
 } while (!final);
 
-s->block_last_index[0] = pos;
+w->block_last_index[0] = pos;
 } else { // DC only
-s->block_last_index[0] = 0;
+w->block_last_index[0] = 0;
 if (w->flat_dc && ((unsigned) (dc_level + 1)) < 3) { // [-1; 1]
 int32_t divide_quant = !chroma ? w->divide_quant_dc_luma
: w->divide_quant_dc_chroma;
@@ -667,9 +664,9 @@ static int x8_decode_intra_mb(IntraX8Context *const w, 
const int chroma)
 zeros_only = (dc_level == 0);
 }
 if (!chroma) {
-s->block[0][0] = dc_level * w->quant;
+w->block[0][0] = dc_level * w->quant;
 } else {
-s->block[0][0] = dc_level * w->quant_dc_chroma;
+w->block[0][0] = dc_level * w->quant_dc_chroma;
 }
 
 // there is !zero_only check in the original, but dc_level check is enough
@@ -680,7 +677,7 @@ static int x8_decode_intra_mb(IntraX8Context *const w, 
const int chroma)
 direction = (0x6A017C >> (w->orient * 2)) & 3;
 if (direction != 3) {
 // modify block_last[]
-x8_ac_compensation(w, direction, s->block[0][0]);
+x8_ac_compensation(w, direction, w->block[0][0]);
 }
 }
 
@@ -695,7 +692,7 @@ static int x8_decode_intra_mb(IntraX8Context *const w, 
const int chroma)
 if (!zeros_only)
 w->idsp.idct_add(w->dest[chroma],
  w->frame->linesize[!!chroma],
- s->block[0]);
+ w->block[0]);
 
 block_placed:
 if (!chroma)
@@ -734,6 +731,8 @@ static void x8_init_block_index(IntraX8Context *w, AVFrame 
*frame)
 
 av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
IntraX8Context *w, IDCTDSPContext *idsp,
+   int16_t (*block)[64],
+   int block_last_index[12],
int mb_width, int mb_height,
MpegEncContext *const s)
 {
@@ -745,6 +744,8 @@ av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
 w->i

[libav-devel] [PATCH 19/25] intrax8: Pass macroblock size to ff_intrax8_common_init

2016-03-19 Thread Vittorio Giovara
Helps in decoupling this code from mpegvideo.
---
 libavcodec/intrax8.c | 20 +++-
 libavcodec/intrax8.h |  7 +++
 libavcodec/vc1dec.c  |  4 +++-
 libavcodec/wmv2dec.c |  3 ++-
 4 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index c99c4e8..fe75424 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -383,7 +383,6 @@ static void x8_update_predictions(IntraX8Context *const w, 
const int orient,
   const int est_run)
 {
 MpegEncContext *const s = w->s;
-
 w->prediction_table[s->mb_x * 2 + (s->mb_y & 1)] = (est_run << 2) + 1 * 
(orient == 4) + 2 * (orient == 8);
 /*
  * y = 2n + 0 -> // 0 2 4
@@ -394,10 +393,9 @@ static void x8_update_predictions(IntraX8Context *const w, 
const int orient,
 static void x8_get_prediction_chroma(IntraX8Context *const w)
 {
 MpegEncContext *const s = w->s;
-
 w->edges  = 1 * (!(s->mb_x >> 1));
 w->edges |= 2 * (!(s->mb_y >> 1));
-w->edges |= 4 * (s->mb_x >= (2 * s->mb_width - 1)); // mb_x for chroma 
would always be odd
+w->edges |= 4 * (s->mb_x >= (2 * w->mb_width - 1)); // mb_x for chroma 
would always be odd
 
 w->raw_orient = 0;
 // lut_co[8] = {inv,4,8,8, inv,4,8,8} <- => {1,1,0,0;1,1,0,0} => 0xCC
@@ -416,7 +414,7 @@ static void x8_get_prediction(IntraX8Context *const w)
 
 w->edges  = 1 * (!s->mb_x);
 w->edges |= 2 * (!s->mb_y);
-w->edges |= 4 * (s->mb_x >= (2 * s->mb_width - 1));
+w->edges |= 4 * (s->mb_x >= (2 * w->mb_width - 1));
 
 switch (w->edges & 3) {
 case 0:
@@ -738,6 +736,7 @@ static void x8_init_block_index(IntraX8Context *w, AVFrame 
*frame, int mb_y)
 
 av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
IntraX8Context *w, IDCTDSPContext *idsp,
+   int mb_width, int mb_height,
MpegEncContext *const s)
 {
 int ret = x8_vlc_init();
@@ -746,10 +745,14 @@ av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
 
 w->avctx = avctx;
 w->idsp = *idsp;
+s->mb_x = 0;
+s->mb_y = 0;
+w->mb_width  = mb_width;
+w->mb_height = mb_height;
 w->s = s;
 
 // two rows, 2 blocks per cannon mb
-w->prediction_table = av_mallocz(s->mb_width * 2 * 2);
+w->prediction_table = av_mallocz(w->mb_width * 2 * 2);
 if (!w->prediction_table)
 return AVERROR(ENOMEM);
 
@@ -797,11 +800,10 @@ int ff_intrax8_decode_picture(IntraX8Context *const w, 
Picture *pict,
 }
 x8_reset_vlc_tables(w);
 
-for (s->mb_y = 0; s->mb_y < s->mb_height * 2; s->mb_y++) {
+for (s->mb_y = 0; s->mb_y < w->mb_height * 2; s->mb_y++) {
 x8_init_block_index(w, w->frame, s->mb_y);
-mb_xy = (s->mb_y >> 1) * s->mb_stride;
-
-for (s->mb_x = 0; s->mb_x < s->mb_width * 2; s->mb_x++) {
+mb_xy = (s->mb_y >> 1) * (w->mb_width + 1);
+for (s->mb_x = 0; s->mb_x < w->mb_width * 2; s->mb_x++) {
 x8_get_prediction(w);
 if (x8_setup_spatial_predictor(w, 0))
 goto error;
diff --git a/libavcodec/intrax8.h b/libavcodec/intrax8.h
index 93881d0..2e45953 100644
--- a/libavcodec/intrax8.h
+++ b/libavcodec/intrax8.h
@@ -65,6 +65,10 @@ typedef struct IntraX8Context {
 int chroma_orient;
 int orient;
 int est_run;
+
+// block props
+int mb_x, mb_y;
+int mb_width, mb_height;
 } IntraX8Context;
 
 /**
@@ -73,11 +77,14 @@ typedef struct IntraX8Context {
  * @param avctx pointer to AVCodecContext
  * @param w pointer to IntraX8Context
  * @param idsp pointer to IDCTDSPContext
+ * @param mb_width macroblock width
+ * @param mb_height macroblock height
  * @param s pointer to MpegEncContext of the parent codec
  * @return 0 on success, a negative AVERROR value on error
  */
 int ff_intrax8_common_init(AVCodecContext *avctx,
IntraX8Context *w, IDCTDSPContext *idsp,
+   int mb_width, int mb_height,
MpegEncContext *const s);
 
 /**
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index cbdd560..d95f4ea 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -371,7 +371,9 @@ av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v)
 v->mv_f_next[0] = v->mv_f_next_base + s->b8_stride + 1;
 v->mv_f_next[1] = v->mv_f_next[0] + (s->b8_stride * (mb_height * 2 + 
1) + s->mb_stride * (mb_height + 1) * 2);
 
-ret = ff_intrax8_common_init(s->avctx, &v->x8, &s->idsp, s);
+ret = ff_intrax8_common_init(s->avctx, &v->x8, &s->idsp,
+ s->mb_width, s->mb_height,
+ s);
 if (ret < 0)
 goto error;
 
diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
index 0560d95..db32689 100644
--- a/libavcodec/wmv2dec.c
+++ b/libavcodec/wmv2dec.c
@@ -473,7 +473,8 @@ static av_cold int wmv2_decode_init(AVCodecContext *avctx)
 
 ff

[libav-devel] [PATCH 25/25] intrax8: Remove mpegvideo dependency

2016-03-19 Thread Vittorio Giovara
---
 libavcodec/intrax8.c |  7 +--
 libavcodec/intrax8.h | 10 +-
 libavcodec/vc1dec.c  |  3 +--
 libavcodec/wmv2dec.c |  2 +-
 4 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index f538d5d..d9fb34d 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -24,7 +24,6 @@
 #include "avcodec.h"
 #include "get_bits.h"
 #include "idctdsp.h"
-#include "mpegvideo.h"
 #include "msmpeg4data.h"
 #include "intrax8huf.h"
 #include "intrax8.h"
@@ -733,8 +732,7 @@ av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
IntraX8Context *w, IDCTDSPContext *idsp,
int16_t (*block)[64],
int block_last_index[12],
-   int mb_width, int mb_height,
-   MpegEncContext *const s)
+   int mb_width, int mb_height)
 {
 int ret = x8_vlc_init();
 if (ret < 0)
@@ -746,7 +744,6 @@ av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
 w->mb_height = mb_height;
 w->block = block;
 w->block_last_index = block_last_index;
-w->s = s;
 
 // two rows, 2 blocks per cannon mb
 w->prediction_table = av_mallocz(w->mb_width * 2 * 2);
@@ -776,9 +773,7 @@ int ff_intrax8_decode_picture(IntraX8Context *const w, 
Picture *pict,
   int dquant, int quant_offset,
   int loopfilter, int lowdelay)
 {
-MpegEncContext *const s = w->s;
 int mb_xy;
-assert(s);
 
 w->gb = gb;
 w->dquant = dquant;
diff --git a/libavcodec/intrax8.h b/libavcodec/intrax8.h
index a6ad029..4868864 100644
--- a/libavcodec/intrax8.h
+++ b/libavcodec/intrax8.h
@@ -21,7 +21,6 @@
 
 #include "blockdsp.h"
 #include "get_bits.h"
-#include "mpegvideo.h"
 #include "idctdsp.h"
 #include "intrax8dsp.h"
 #include "mpegpicture.h"
@@ -41,7 +40,6 @@ typedef struct IntraX8Context {
 int16_t (*block)[64];
 
 // set by the caller codec
-MpegEncContext *s;
 IntraX8DSPContext dsp;
 IDCTDSPContext idsp;
 BlockDSPContext bdsp;
@@ -75,7 +73,6 @@ typedef struct IntraX8Context {
 
 /**
  * Initialize IntraX8 frame decoder.
- * Requires valid MpegEncContext with valid s->mb_width before calling.
  * @param avctx pointer to AVCodecContext
  * @param w pointer to IntraX8Context
  * @param idsp pointer to IDCTDSPContext
@@ -83,15 +80,13 @@ typedef struct IntraX8Context {
  * @param block_last_index pointer to the array of indexes
  * @param mb_width macroblock width
  * @param mb_height macroblock height
- * @param s pointer to MpegEncContext of the parent codec
  * @return 0 on success, a negative AVERROR value on error
  */
 int ff_intrax8_common_init(AVCodecContext *avctx,
IntraX8Context *w, IDCTDSPContext *idsp,
int16_t (*block)[64],
int block_last_index[12],
-   int mb_width, int mb_height,
-   MpegEncContext *const s);
+   int mb_width, int mb_height);
 
 /**
  * Destroy IntraX8 frame structure.
@@ -101,9 +96,6 @@ void ff_intrax8_common_end(IntraX8Context *w);
 
 /**
  * Decode single IntraX8 frame.
- * The parent codec must call ff_mpv_frame_start() before calling this 
function.
- * The parent codec must call ff_mpv_frame_end() after calling this function.
- * This function does not use ff_mpv_decode_mb().
  * @param w pointer to IntraX8Context
  * @param pict the output Picture containing an AVFrame
  * @param gb open bitstream reader
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 548f885..0ded3a6 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -373,8 +373,7 @@ av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v)
 
 ret = ff_intrax8_common_init(s->avctx, &v->x8, &s->idsp,
  s->block, s->block_last_index,
- s->mb_width, s->mb_height,
- s);
+ s->mb_width, s->mb_height);
 if (ret < 0)
 goto error;
 
diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
index f01a743..e1f86d8 100644
--- a/libavcodec/wmv2dec.c
+++ b/libavcodec/wmv2dec.c
@@ -476,7 +476,7 @@ static av_cold int wmv2_decode_init(AVCodecContext *avctx)
 
 return ff_intrax8_common_init(avctx, &w->x8, &w->s.idsp,
   w->s.block, w->s.block_last_index,
-  w->s.mb_width, w->s.mb_height, &w->s);
+  w->s.mb_width, w->s.mb_height);
 }
 
 static av_cold int wmv2_decode_end(AVCodecContext *avctx)
-- 
2.7.3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 24/25] intrax8: Drop MB emulation code

2016-03-19 Thread Vittorio Giovara
This is already performed in init_context_frame().
---
 libavcodec/intrax8.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index f67c5e0..f538d5d 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -828,8 +828,6 @@ int ff_intrax8_decode_picture(IntraX8Context *const w, 
Picture *pict,
 w->dest[2] += 8;
 
 /* emulate MB info in the relevant tables */
-s->mbskip_table[mb_xy] = 0;
-s->mbintra_table[mb_xy]= 1;
 pict->qscale_table[mb_xy] = w->quant;
 mb_xy++;
 }
-- 
2.7.3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 22/25] intrax8: Use the generic horizband function

2016-03-19 Thread Vittorio Giovara
This is assuming that intrax8 has no support for interlacing
(hence PICT_FRAME is set and last_frame is NULL).
---
 libavcodec/intrax8.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

Modified as discussed with Luca.
Vittorio

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index 996fd7f..b4ff800 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -29,6 +29,7 @@
 #include "intrax8huf.h"
 #include "intrax8.h"
 #include "intrax8dsp.h"
+#include "mpegutils.h"
 
 #define MAX_TABLE_DEPTH(table_bits, max_bits) \
 ((max_bits + table_bits - 1) / table_bits)
@@ -834,7 +835,9 @@ int ff_intrax8_decode_picture(IntraX8Context *const w, 
Picture *pict,
 w->dest[0] += 8;
 }
 if (w->mb_y & 1)
-ff_mpeg_draw_horiz_band(s, (w->mb_y - 1) * 8, 16);
+ff_draw_horiz_band(w->avctx, w->frame, w->frame,
+   (w->mb_y - 1) * 8, 16,
+   PICT_FRAME, 0, lowdelay);
 }
 
 error:
-- 
2.7.3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 21/25] intrax8: Carry over lowdelay value in ff_intrax8_decode_picture

2016-03-19 Thread Vittorio Giovara
Helps in decoupling this code from mpegvideo.
---
 libavcodec/intrax8.c   | 3 ++-
 libavcodec/intrax8.h   | 3 ++-
 libavcodec/vc1_block.c | 2 +-
 libavcodec/wmv2dec.c   | 2 +-
 4 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index fab25bb..996fd7f 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -771,7 +771,8 @@ av_cold void ff_intrax8_common_end(IntraX8Context *w)
 
 int ff_intrax8_decode_picture(IntraX8Context *const w, Picture *pict,
   GetBitContext *gb, int *mb_x, int *mb_y,
-  int dquant, int quant_offset, int loopfilter)
+  int dquant, int quant_offset,
+  int loopfilter, int lowdelay)
 {
 MpegEncContext *const s = w->s;
 int mb_xy;
diff --git a/libavcodec/intrax8.h b/libavcodec/intrax8.h
index c440695..1239109 100644
--- a/libavcodec/intrax8.h
+++ b/libavcodec/intrax8.h
@@ -109,6 +109,7 @@ void ff_intrax8_common_end(IntraX8Context *w);
  */
 int ff_intrax8_decode_picture(IntraX8Context *w, Picture *pict,
   GetBitContext *gb, int *mb_x, int *mb_y,
-  int quant, int halfpq, int loopfilter);
+  int quant, int halfpq,
+  int loopfilter, int lowdelay);
 
 #endif /* AVCODEC_INTRAX8_H */
diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c
index 1fac828..1ce0612 100644
--- a/libavcodec/vc1_block.c
+++ b/libavcodec/vc1_block.c
@@ -3025,7 +3025,7 @@ void ff_vc1_decode_blocks(VC1Context *v)
 ff_intrax8_decode_picture(&v->x8, &v->s.current_picture,
   &v->s.gb, &v->s.mb_x, &v->s.mb_y,
   2 * v->pq + v->halfpq, v->pq * 
!v->pquantizer,
-  v->s.loop_filter);
+  v->s.loop_filter, v->s.low_delay);
 
 ff_er_add_slice(&v->s.er, 0, 0,
 (v->s.mb_x >> 1) - 1, (v->s.mb_y >> 1) - 1,
diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
index 845acf6..7bf8388 100644
--- a/libavcodec/wmv2dec.c
+++ b/libavcodec/wmv2dec.c
@@ -231,7 +231,7 @@ int ff_wmv2_decode_secondary_picture_header(MpegEncContext 
*s)
 ff_intrax8_decode_picture(&w->x8, &s->current_picture,
   &s->gb, &s->mb_x, &s->mb_y,
   2 * s->qscale, (s->qscale - 1) | 1,
-  s->loop_filter);
+  s->loop_filter, s->low_delay);
 
 ff_er_add_slice(&w->s.er, 0, 0,
 (w->s.mb_x >> 1) - 1, (w->s.mb_y >> 1) - 1,
-- 
2.7.3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 18/25] intrax8: Add a local BlockDSPContext and initialize it

2016-03-19 Thread Vittorio Giovara
Helps in decoupling this code from mpegvideo.
---
 configure| 2 +-
 libavcodec/intrax8.c | 3 ++-
 libavcodec/intrax8.h | 2 ++
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 493bbc7..1c2ac71 100755
--- a/configure
+++ b/configure
@@ -1860,7 +1860,7 @@ error_resilience_select="me_cmp"
 faandct_deps="faan fdctdsp"
 faanidct_deps="faan idctdsp"
 h264dsp_select="startcode"
-intrax8_select="idctdsp"
+intrax8_select="blockdsp idctdsp"
 mdct_select="fft"
 rdft_select="fft"
 me_cmp_select="fdctdsp idctdsp pixblockdsp"
diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index 3365995..c99c4e8 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -585,7 +585,7 @@ static int x8_decode_intra_mb(IntraX8Context *const w, 
const int chroma)
 int sign;
 
 assert(w->orient < 12);
-s->bdsp.clear_block(s->block[0]);
+w->bdsp.clear_block(s->block[0]);
 
 if (chroma)
 dc_mode = 2;
@@ -761,6 +761,7 @@ av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
   ff_wmv1_scantable[3]);
 
 ff_intrax8dsp_init(&w->dsp);
+ff_blockdsp_init(&w->bdsp, avctx);
 
 return 0;
 }
diff --git a/libavcodec/intrax8.h b/libavcodec/intrax8.h
index 5b72532..93881d0 100644
--- a/libavcodec/intrax8.h
+++ b/libavcodec/intrax8.h
@@ -19,6 +19,7 @@
 #ifndef AVCODEC_INTRAX8_H
 #define AVCODEC_INTRAX8_H
 
+#include "blockdsp.h"
 #include "get_bits.h"
 #include "mpegvideo.h"
 #include "idctdsp.h"
@@ -41,6 +42,7 @@ typedef struct IntraX8Context {
 MpegEncContext *s;
 IntraX8DSPContext dsp;
 IDCTDSPContext idsp;
+BlockDSPContext bdsp;
 int quant;
 int dquant;
 int qsum;
-- 
2.7.3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 1/2] lavf: Raw G.729 demuxer

2016-03-19 Thread Vittorio Giovara
From: Vladimir Voroshilov 

Signed-off-by: Vittorio Giovara 
---
 Changelog|   1 +
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/g729dec.c| 105 +++
 4 files changed, 108 insertions(+)
 create mode 100644 libavformat/g729dec.c

diff --git a/Changelog b/Changelog
index 92c694bc..ca9c9b4 100644
--- a/Changelog
+++ b/Changelog
@@ -51,6 +51,7 @@ version :
 - support Apple AVFoundation video capture
 - G.723.1 muxer and encoder
 - compressed SWF
+- G.729 raw demuxer
 
 
 version 11:
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 46cf9e0..891a20f 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -142,6 +142,7 @@ OBJS-$(CONFIG_G722_DEMUXER)  += g722.o rawdec.o
 OBJS-$(CONFIG_G722_MUXER)+= rawenc.o
 OBJS-$(CONFIG_G723_1_DEMUXER)+= g723_1.o
 OBJS-$(CONFIG_G723_1_MUXER)  += rawenc.o
+OBJS-$(CONFIG_G729_DEMUXER)  += g729dec.o
 OBJS-$(CONFIG_H261_DEMUXER)  += h261dec.o rawdec.o
 OBJS-$(CONFIG_H261_MUXER)+= rawenc.o
 OBJS-$(CONFIG_H263_DEMUXER)  += h263dec.o rawdec.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 43d0e6d..0f49756 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -105,6 +105,7 @@ void av_register_all(void)
 REGISTER_MUXER   (FRAMEMD5, framemd5);
 REGISTER_MUXDEMUX(G722, g722);
 REGISTER_MUXDEMUX(G723_1,   g723_1);
+REGISTER_DEMUXER (G729, g729);
 REGISTER_MUXER   (GIF,  gif);
 REGISTER_DEMUXER (GSM,  gsm);
 REGISTER_MUXDEMUX(GXF,  gxf);
diff --git a/libavformat/g729dec.c b/libavformat/g729dec.c
new file mode 100644
index 000..c2beb60
--- /dev/null
+++ b/libavformat/g729dec.c
@@ -0,0 +1,105 @@
+/*
+ * G.729 raw format demuxer
+ * Copyright (c) 2011 Vladimir Voroshilov
+ *
+ * This file is part of Libav.
+ *
+ * Libav 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.
+ *
+ * Libav 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 Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/log.h"
+#include "libavutil/opt.h"
+
+#include "avformat.h"
+#include "internal.h"
+
+typedef struct G729DemuxerContext {
+AVClass *class;
+
+int bit_rate;
+} G729DemuxerContext;
+
+static int g729_read_header(AVFormatContext *s)
+{
+AVStream* st;
+G729DemuxerContext *s1 = s->priv_data;
+
+st = avformat_new_stream(s, NULL);
+if (!st)
+return AVERROR(ENOMEM);
+
+st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
+st->codecpar->codec_id= AV_CODEC_ID_G729;
+st->codecpar->sample_rate = 8000;
+st->codecpar->channels= 1;
+
+if (s1 && s1->bit_rate)
+s->bit_rate = s1->bit_rate;
+
+switch(s->bit_rate) {
+case 6400:
+st->codecpar->block_align = 8;
+break;
+case 8000:
+st->codecpar->block_align = 10;
+break;
+default:
+av_log(s, AV_LOG_ERROR, "Invalid bit_rate value %d. "
+   "Only 6400 and 8000 b/s are supported.", s->bit_rate);
+return AVERROR(EINVAL);
+}
+
+avpriv_set_pts_info(st, st->codecpar->block_align << 3, 1,
+st->codecpar->sample_rate);
+
+return 0;
+}
+
+static int g729_read_packet(AVFormatContext *s, AVPacket *pkt)
+{
+AVStream *st = s->streams[0];
+int ret = av_get_packet(s->pb, pkt, st->codecpar->block_align);
+if (ret < 0)
+return ret;
+
+pkt->stream_index = 0;
+pkt->dts = pkt->pts = pkt->pos / st->codecpar->block_align;
+
+return 0;
+}
+
+#define OFFSET(x) offsetof(G729DemuxerContext, x)
+static const AVOption g729_options[] = {
+{ "bit_rate", "", OFFSET(bit_rate), AV_OPT_TYPE_INT, { .i64 = 8000 }, 0, 
INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+{ NULL },
+};
+
+static const AVClass g729_demuxer_class = {
+.class_name = "g729 demuxer",
+.item_name  = av_default_item_name,
+.option = g729_options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
+AVInputFormat ff_g729_demuxer = {
+.name   = "g729",
+.long_name  = NULL_IF_CONFIG_SMALL("G.729 raw format demuxer"),
+.priv_data_size = sizeof(G729DemuxerContext),
+.read_header= g729_read_header,
+.read_packet= g729_read_packet,
+.flags  = AVFMT_GENERIC_IN

[libav-devel] [PATCH 2/2] GIF demuxer

2016-03-19 Thread Vittorio Giovara
From: Vitaliy E Sugrobov 

This demuxer is capable of extracting multiple frames from gif file.
In conjunction with gif decoder it implements support for reading
animated gifs.

Signed-off-by: Vitaliy E Sugrobov 
Signed-off-by: Vittorio Giovara 
---
 Changelog|   1 +
 doc/general.texi |   2 +-
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   2 +-
 libavformat/gifdec.c | 318 +++
 5 files changed, 322 insertions(+), 2 deletions(-)
 create mode 100644 libavformat/gifdec.c

diff --git a/Changelog b/Changelog
index ca9c9b4..71fe9e2 100644
--- a/Changelog
+++ b/Changelog
@@ -52,6 +52,7 @@ version :
 - G.723.1 muxer and encoder
 - compressed SWF
 - G.729 raw demuxer
+- GIF demuxer
 
 
 version 11:
diff --git a/doc/general.texi b/doc/general.texi
index 15e4a66..5f01c50 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -282,7 +282,7 @@ library:
 @item framecrc testing format   @tab X @tab
 @item FunCom ISS@tab   @tab X
 @tab Audio format used in various games from FunCom like The Longest 
Journey.
-@item GIF Animation @tab X @tab
+@item GIF Animation @tab X @tab X
 @item GXF   @tab X @tab X
 @tab General eXchange Format SMPTE 360M, used by Thomson Grass Valley
  playout servers.
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 891a20f..5cd8f8f 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -135,6 +135,7 @@ OBJS-$(CONFIG_FOURXM_DEMUXER)+= 4xm.o
 OBJS-$(CONFIG_FRAMECRC_MUXER)+= framecrcenc.o framehash.o
 OBJS-$(CONFIG_FRAMEMD5_MUXER)+= md5enc.o framehash.o
 OBJS-$(CONFIG_GIF_MUXER) += gif.o
+OBJS-$(CONFIG_GIF_DEMUXER)   += gifdec.o
 OBJS-$(CONFIG_GSM_DEMUXER)   += gsmdec.o
 OBJS-$(CONFIG_GXF_DEMUXER)   += gxf.o
 OBJS-$(CONFIG_GXF_MUXER) += gxfenc.o audiointerleave.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 0f49756..1056d7b 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -106,7 +106,7 @@ void av_register_all(void)
 REGISTER_MUXDEMUX(G722, g722);
 REGISTER_MUXDEMUX(G723_1,   g723_1);
 REGISTER_DEMUXER (G729, g729);
-REGISTER_MUXER   (GIF,  gif);
+REGISTER_MUXDEMUX(GIF,  gif);
 REGISTER_DEMUXER (GSM,  gsm);
 REGISTER_MUXDEMUX(GXF,  gxf);
 REGISTER_MUXDEMUX(H261, h261);
diff --git a/libavformat/gifdec.c b/libavformat/gifdec.c
new file mode 100644
index 000..cc46716
--- /dev/null
+++ b/libavformat/gifdec.c
@@ -0,0 +1,318 @@
+/*
+ * GIF demuxer
+ * Copyright (c) 2012 Vitaliy E Sugrobov
+ *
+ * This file is part of Libav.
+ *
+ * Libav 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.
+ *
+ * Libav 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 Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * GIF demuxer.
+ *
+ * There are two options available to user: default_delay and min_delay.
+ *
+ * These options are for protection from too rapid gif animations.
+ * In practice it is standard approach to slow down rendering of this
+ * kind of gifs. If you try to play gif with delay between frames of one
+ * hundredth of second (100fps) using one of major web browsers, you get
+ * significantly slower playback, around 10 fps. This is because browser
+ * detects that delay value is less than some threshold (usually 2 hundredths
+ * of second) and reset it to default value (usually 10 hundredths of second,
+ * which corresponds to 10fps). Manipulating these options, user can achieve
+ * the same effect during conversion to some video format. Otherwise user
+ * can set them to not protect from rapid animations at all.
+ *
+ * The other case when these options necessary is for gif images encoded
+ * according to gif87a standard since prior to gif89a there was no delay
+ * information included in file.
+ */
+
+#include "libavutil/intreadwrite.h"
+#include "libavutil/opt.h"
+
+#include "avformat.h"
+#include "internal.h"
+
+#define GIF_SIG_87A "GIF87a"
+#define GIF_SIG_89A "GIF89a"
+
+#define GIF_TRAILER 0x3b
+#define GIF_EXTENSION_INTRODUCER0x21
+#define GIF_IMAGE_SEPARATOR 0x2c
+#define GIF_GCE_EXT_LABEL   0xf9
+
+typedef struct GIFDemuxContext {
+  

[libav-devel] [PATCH 06/25] intrax8: Move documentation from implementation to header files

2016-03-19 Thread Vittorio Giovara
---
 libavcodec/intrax8.c | 20 
 libavcodec/intrax8.h | 22 ++
 2 files changed, 22 insertions(+), 20 deletions(-)

Unchanged.

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index 851c434..3ab2faa 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -738,12 +738,6 @@ static void x8_init_block_index(MpegEncContext *s)
 s->dest[2] += (s->mb_y & (~1)) * uvlinesize << 2;
 }
 
-/**
- * Initialize IntraX8 frame decoder.
- * Requires valid MpegEncContext with valid s->mb_width before calling.
- * @param w pointer to IntraX8Context
- * @param s pointer to MpegEncContext of the parent codec
- */
 av_cold void ff_intrax8_common_init(IntraX8Context *w, MpegEncContext *const s)
 {
 w->s = s;
@@ -763,25 +757,11 @@ av_cold void ff_intrax8_common_init(IntraX8Context *w, 
MpegEncContext *const s)
 ff_intrax8dsp_init(&w->dsp);
 }
 
-/**
- * Destroy IntraX8 frame structure.
- * @param w pointer to IntraX8Context
- */
 av_cold void ff_intrax8_common_end(IntraX8Context *w)
 {
 av_freep(&w->prediction_table);
 }
 
-/**
- * Decode single IntraX8 frame.
- * The parent codec must fill s->loopfilter and s->gb (bitstream).
- * The parent codec must call ff_mpv_frame_start() before calling this 
function.
- * The parent codec must call ff_mpv_frame_end() after calling this function.
- * This function does not use ff_mpv_decode_mb().
- * @param w pointer to IntraX8Context
- * @param dquant doubled quantizer, it would be odd in case of VC-1 halfpq==1.
- * @param quant_offset offset away from zero
- */
 int ff_intrax8_decode_picture(IntraX8Context *const w, int dquant,
   int quant_offset)
 {
diff --git a/libavcodec/intrax8.h b/libavcodec/intrax8.h
index 83e984b..3339bc6 100644
--- a/libavcodec/intrax8.h
+++ b/libavcodec/intrax8.h
@@ -56,8 +56,30 @@ typedef struct IntraX8Context {
 int est_run;
 } IntraX8Context;
 
+/**
+ * Initialize IntraX8 frame decoder.
+ * Requires valid MpegEncContext with valid s->mb_width before calling.
+ * @param w pointer to IntraX8Context
+ * @param s pointer to MpegEncContext of the parent codec
+ */
 void ff_intrax8_common_init(IntraX8Context *w, MpegEncContext *const s);
+
+/**
+ * Destroy IntraX8 frame structure.
+ * @param w pointer to IntraX8Context
+ */
 void ff_intrax8_common_end(IntraX8Context *w);
+
+/**
+ * Decode single IntraX8 frame.
+ * The parent codec must fill s->loopfilter and s->gb (bitstream).
+ * The parent codec must call ff_mpv_frame_start() before calling this 
function.
+ * The parent codec must call ff_mpv_frame_end() after calling this function.
+ * This function does not use ff_mpv_decode_mb().
+ * @param w pointer to IntraX8Context
+ * @param dquant doubled quantizer, it would be odd in case of VC-1 halfpq==1.
+ * @param quant_offset offset away from zero
+ */
 int ff_intrax8_decode_picture(IntraX8Context *w, int quant, int halfpq);
 
 #endif /* AVCODEC_INTRAX8_H */
-- 
2.7.3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 02/25] intrax8: Move error resilience out of intrax8

2016-03-19 Thread Vittorio Giovara
The intrax8 decoding process does not imply any kind of error
correction, and the only call present is more related to how mpegvideo
works rather than anything else.

Therefore have the parent decoders carried out er when actually needed.

Drop two variables that were initialized but never used.
Update documentation accordingly.
---
 configure  |  3 +--
 libavcodec/intrax8.c   | 10 ++
 libavcodec/vc1_block.c |  4 
 libavcodec/wmv2dec.c   |  4 
 4 files changed, 11 insertions(+), 10 deletions(-)

Modified as discussed with Diego.
Vittorio

diff --git a/configure b/configure
index 5376e67..56d3bbf 100755
--- a/configure
+++ b/configure
@@ -1860,7 +1860,6 @@ error_resilience_select="me_cmp"
 faandct_deps="faan fdctdsp"
 faanidct_deps="faan idctdsp"
 h264dsp_select="startcode"
-intrax8_select="error_resilience"
 mdct_select="fft"
 rdft_select="fft"
 me_cmp_select="fdctdsp idctdsp pixblockdsp"
@@ -2083,7 +2082,7 @@ wmav2_encoder_select="mdct sinewin wma_freqs"
 wmavoice_decoder_select="lsp rdft dct mdct sinewin"
 wmv1_decoder_select="h263_decoder"
 wmv1_encoder_select="h263_encoder"
-wmv2_decoder_select="blockdsp h263_decoder idctdsp intrax8 videodsp wmv2dsp"
+wmv2_decoder_select="blockdsp error_resilience h263_decoder idctdsp intrax8 
videodsp wmv2dsp"
 wmv2_encoder_select="h263_encoder wmv2dsp"
 wmv3_decoder_select="vc1_decoder"
 wmv3image_decoder_select="wmv3_decoder"
diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index 3cd84dc..45fff96 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -22,7 +22,6 @@
  */
 
 #include "avcodec.h"
-#include "error_resilience.h"
 #include "get_bits.h"
 #include "idctdsp.h"
 #include "mpegvideo.h"
@@ -718,8 +717,8 @@ av_cold void ff_intrax8_common_end(IntraX8Context * w)
 /**
  * Decode single IntraX8 frame.
  * The parent codec must fill s->loopfilter and s->gb (bitstream).
- * The parent codec must call ff_mpv_frame_start(), ff_er_frame_start() before 
calling this function.
- * The parent codec must call ff_er_frame_end(), ff_mpv_frame_end() after 
calling this function.
+ * The parent codec must call ff_mpv_frame_start() before calling this 
function.
+ * The parent codec must call ff_mpv_frame_end() after calling this function.
  * This function does not use ff_mpv_decode_mb().
  * @param w pointer to IntraX8Context
  * @param dquant doubled quantizer, it would be odd in case of VC-1 halfpq==1.
@@ -745,8 +744,6 @@ int ff_intrax8_decode_picture(IntraX8Context * const w, int 
dquant, int quant_of
 }
 x8_reset_vlc_tables(w);
 
-s->resync_mb_x=0;
-s->resync_mb_y=0;
 
 for(s->mb_y=0; s->mb_y < s->mb_height*2; s->mb_y++){
 x8_init_block_index(s);
@@ -785,8 +782,5 @@ int ff_intrax8_decode_picture(IntraX8Context * const w, int 
dquant, int quant_of
 }
 
 error:
-ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y,
-(s->mb_x>>1)-1, (s->mb_y>>1)-1,
-ER_MB_END );
 return 0;
 }
diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c
index 4588af4..8b46260 100644
--- a/libavcodec/vc1_block.c
+++ b/libavcodec/vc1_block.c
@@ -3023,6 +3023,10 @@ void ff_vc1_decode_blocks(VC1Context *v)
 v->s.esc3_level_length = 0;
 if (v->x8_type) {
 ff_intrax8_decode_picture(&v->x8, 2*v->pq + v->halfpq, v->pq * 
!v->pquantizer);
+
+ff_er_add_slice(&v->s.er, 0, 0,
+(v->s.mb_x >> 1) - 1, (v->s.mb_y >> 1) - 1,
+ER_MB_END);
 } else {
 v->cur_blk_idx =  0;
 v->left_blk_idx= -1;
diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
index c71fd3d..ca8afe6 100644
--- a/libavcodec/wmv2dec.c
+++ b/libavcodec/wmv2dec.c
@@ -229,6 +229,10 @@ int ff_wmv2_decode_secondary_picture_header(MpegEncContext 
*s)
 
 if (w->j_type) {
 ff_intrax8_decode_picture(&w->x8, 2 * s->qscale, (s->qscale - 1) | 1);
+
+ff_er_add_slice(&w->s.er, 0, 0,
+(w->s.mb_x >> 1) - 1, (w->s.mb_y >> 1) - 1,
+ER_MB_END);
 return 1;
 }
 
-- 
2.7.3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 09/25] vc1dec: wmv2dec: Validate ff_intrax8_common_init return value

2016-03-19 Thread Vittorio Giovara
---
 libavcodec/vc1dec.c  | 8 +---
 libavcodec/wmv2dec.c | 4 +---
 2 files changed, 6 insertions(+), 6 deletions(-)

Unchanged.

diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 51f5c42..76f3591 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -314,7 +314,7 @@ static void vc1_sprite_flush(AVCodecContext *avctx)
 av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v)
 {
 MpegEncContext *s = &v->s;
-int i;
+int i, ret = AVERROR(ENOMEM);
 int mb_height = FFALIGN(s->mb_height, 2);
 
 /* Allocate mb bitplanes */
@@ -371,7 +371,9 @@ av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v)
 v->mv_f_next[0] = v->mv_f_next_base + s->b8_stride + 1;
 v->mv_f_next[1] = v->mv_f_next[0] + (s->b8_stride * (mb_height * 2 + 
1) + s->mb_stride * (mb_height + 1) * 2);
 
-ff_intrax8_common_init(&v->x8,s);
+ret = ff_intrax8_common_init(&v->x8,s);
+if (ret < 0)
+goto error;
 
 if (s->avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || s->avctx->codec_id == 
AV_CODEC_ID_VC1IMAGE) {
 for (i = 0; i < 4; i++) {
@@ -385,7 +387,7 @@ av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v)
 
 error:
 ff_vc1_decode_end(s->avctx);
-return AVERROR(ENOMEM);
+return ret;
 }
 
 av_cold void ff_vc1_init_transposed_scantables(VC1Context *v)
diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
index ca8afe6..5bfedbd 100644
--- a/libavcodec/wmv2dec.c
+++ b/libavcodec/wmv2dec.c
@@ -471,9 +471,7 @@ static av_cold int wmv2_decode_init(AVCodecContext *avctx)
 
 ff_wmv2_common_init(w);
 
-ff_intrax8_common_init(&w->x8, &w->s);
-
-return 0;
+return ff_intrax8_common_init(&w->x8, &w->s);
 }
 
 static av_cold int wmv2_decode_end(AVCodecContext *avctx)
-- 
2.7.3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 03/25] intrax8: Wrap multiline macros in do{}while(0) clauses

2016-03-19 Thread Vittorio Giovara
These macros are treated like functions, the wrapping simplifies error
checking and avoids deep nested if in the following commit.
---
 libavcodec/intrax8.c | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

Unchanged.
Vittorio

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index 45fff96..4887643 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -61,7 +61,7 @@ static av_cold void x8_vlc_init(void){
 
 static VLC_TYPE table[28150][2];
 
-#define  init_ac_vlc(dst,src) \
+#define  init_ac_vlc(dst,src) do { \
 dst.table = &table[offset]; \
 dst.table_allocated = sizes[sizeidx]; \
 offset += sizes[sizeidx++]; \
@@ -69,7 +69,8 @@ static av_cold void x8_vlc_init(void){
   AC_VLC_BITS,77, \
   &src[1],4,2, \
   &src[0],4,2, \
-  INIT_VLC_USE_NEW_STATIC)
+  INIT_VLC_USE_NEW_STATIC); \
+} while(0)
 //set ac tables
 for(i=0;i<8;i++){
 init_ac_vlc( j_ac_vlc[0][0][i], x8_ac0_highquant_table[i][0] );
@@ -80,7 +81,7 @@ static av_cold void x8_vlc_init(void){
 #undef init_ac_vlc
 
 //set dc tables
-#define init_dc_vlc(dst,src) \
+#define init_dc_vlc(dst,src) do { \
 dst.table = &table[offset]; \
 dst.table_allocated = sizes[sizeidx]; \
 offset += sizes[sizeidx++]; \
@@ -88,7 +89,8 @@ static av_cold void x8_vlc_init(void){
 DC_VLC_BITS,34, \
 &src[1],4,2, \
 &src[0],4,2, \
-INIT_VLC_USE_NEW_STATIC);
+INIT_VLC_USE_NEW_STATIC); \
+} while(0)
 for(i=0;i<8;i++){
 init_dc_vlc( j_dc_vlc[0][i], x8_dc_highquant_table[i][0]);
 init_dc_vlc( j_dc_vlc[1][i], x8_dc_lowquant_table [i][0]);
@@ -96,7 +98,7 @@ static av_cold void x8_vlc_init(void){
 #undef init_dc_vlc
 
 //set orient tables
-#define init_or_vlc(dst,src) \
+#define init_or_vlc(dst,src) do { \
 dst.table = &table[offset]; \
 dst.table_allocated = sizes[sizeidx]; \
 offset += sizes[sizeidx++]; \
@@ -104,12 +106,13 @@ static av_cold void x8_vlc_init(void){
 OR_VLC_BITS,12, \
 &src[1],4,2, \
 &src[0],4,2, \
-INIT_VLC_USE_NEW_STATIC);
+INIT_VLC_USE_NEW_STATIC); \
+} while(0)
 for(i=0;i<2;i++){
 init_or_vlc( j_orient_vlc[0][i], x8_orient_highquant_table[i][0]);
 }
 for(i=0;i<4;i++){
-init_or_vlc( j_orient_vlc[1][i], x8_orient_lowquant_table [i][0])
+init_or_vlc( j_orient_vlc[1][i], x8_orient_lowquant_table [i][0]);
 }
 if (offset != sizeof(table)/sizeof(VLC_TYPE)/2)
 av_log(NULL, AV_LOG_ERROR, "table size %i does not match needed %i\n", 
(int)(sizeof(table)/sizeof(VLC_TYPE)/2), offset);
-- 
2.7.3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 12/25] intrax8: Keep a reference to the context idctdsp

2016-03-19 Thread Vittorio Giovara
Use it instead of the embedded mpegvideo one. Update init function
signature to load it directly from the callers.
---
 configure|  1 +
 libavcodec/intrax8.c | 14 --
 libavcodec/intrax8.h |  6 +-
 libavcodec/vc1dec.c  |  2 +-
 libavcodec/wmv2dec.c |  2 +-
 5 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/configure b/configure
index 56d3bbf..493bbc7 100755
--- a/configure
+++ b/configure
@@ -1860,6 +1860,7 @@ error_resilience_select="me_cmp"
 faandct_deps="faan fdctdsp"
 faanidct_deps="faan idctdsp"
 h264dsp_select="startcode"
+intrax8_select="idctdsp"
 mdct_select="fft"
 rdft_select="fft"
 me_cmp_select="fdctdsp idctdsp pixblockdsp"
diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index bb2ee8f..b1933a5 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -490,7 +490,7 @@ static void x8_ac_compensation(IntraX8Context *const w, int 
const direction,
 {
 MpegEncContext *const s = w->s;
 int t;
-#define B(x, y) s->block[0][s->idsp.idct_permutation[(x) + (y) * 8]]
+#define B(x, y) s->block[0][w->idsp.idct_permutation[(x) + (y) * 8]]
 #define T(x)  ((x) * dc_level + 0x8000) >> 16;
 switch (direction) {
 case 0:
@@ -703,7 +703,7 @@ static int x8_decode_intra_mb(IntraX8Context *const w, 
const int chroma)

s->current_picture.f->linesize[!!chroma]);
 }
 if (!zeros_only)
-s->idsp.idct_add(w->dest[chroma],
+w->idsp.idct_add(w->dest[chroma],
  s->current_picture.f->linesize[!!chroma],
  s->block[0]);
 
@@ -742,12 +742,14 @@ static void x8_init_block_index(IntraX8Context *w, 
AVFrame *frame, int mb_y)
 w->dest[2] += (mb_y & (~1)) * uvlinesize << 2;
 }
 
-av_cold int ff_intrax8_common_init(IntraX8Context *w, MpegEncContext *const s)
+av_cold int ff_intrax8_common_init(IntraX8Context *w, IDCTDSPContext *idsp,
+   MpegEncContext *const s)
 {
 int ret = x8_vlc_init();
 if (ret < 0)
 return ret;
 
+w->idsp = *idsp;
 w->s = s;
 
 // two rows, 2 blocks per cannon mb
@@ -755,11 +757,11 @@ av_cold int ff_intrax8_common_init(IntraX8Context *w, 
MpegEncContext *const s)
 if (!w->prediction_table)
 return AVERROR(ENOMEM);
 
-ff_init_scantable(s->idsp.idct_permutation, &w->scantable[0],
+ff_init_scantable(w->idsp.idct_permutation, &w->scantable[0],
   ff_wmv1_scantable[0]);
-ff_init_scantable(s->idsp.idct_permutation, &w->scantable[1],
+ff_init_scantable(w->idsp.idct_permutation, &w->scantable[1],
   ff_wmv1_scantable[2]);
-ff_init_scantable(s->idsp.idct_permutation, &w->scantable[2],
+ff_init_scantable(w->idsp.idct_permutation, &w->scantable[2],
   ff_wmv1_scantable[3]);
 
 ff_intrax8dsp_init(&w->dsp);
diff --git a/libavcodec/intrax8.h b/libavcodec/intrax8.h
index e2532f8..ef88d83 100644
--- a/libavcodec/intrax8.h
+++ b/libavcodec/intrax8.h
@@ -21,6 +21,7 @@
 
 #include "get_bits.h"
 #include "mpegvideo.h"
+#include "idctdsp.h"
 #include "intrax8dsp.h"
 
 typedef struct IntraX8Context {
@@ -37,6 +38,7 @@ typedef struct IntraX8Context {
 // set by the caller codec
 MpegEncContext *s;
 IntraX8DSPContext dsp;
+IDCTDSPContext idsp;
 int quant;
 int dquant;
 int qsum;
@@ -61,10 +63,12 @@ typedef struct IntraX8Context {
  * Initialize IntraX8 frame decoder.
  * Requires valid MpegEncContext with valid s->mb_width before calling.
  * @param w pointer to IntraX8Context
+ * @param idsp pointer to IDCTDSPContext
  * @param s pointer to MpegEncContext of the parent codec
  * @return 0 on success, a negative AVERROR value on error
  */
-int ff_intrax8_common_init(IntraX8Context *w, MpegEncContext *const s);
+int ff_intrax8_common_init(IntraX8Context *w, IDCTDSPContext *idsp,
+   MpegEncContext *const s);
 
 /**
  * Destroy IntraX8 frame structure.
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 76f3591..948626c 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -371,7 +371,7 @@ av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v)
 v->mv_f_next[0] = v->mv_f_next_base + s->b8_stride + 1;
 v->mv_f_next[1] = v->mv_f_next[0] + (s->b8_stride * (mb_height * 2 + 
1) + s->mb_stride * (mb_height + 1) * 2);
 
-ret = ff_intrax8_common_init(&v->x8,s);
+ret = ff_intrax8_common_init(&v->x8, &s->idsp, s);
 if (ret < 0)
 goto error;
 
diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
index 5bfedbd..03b949e 100644
--- a/libavcodec/wmv2dec.c
+++ b/libavcodec/wmv2dec.c
@@ -471,7 +471,7 @@ static av_cold int wmv2_decode_init(AVCodecContext *avctx)
 
 ff_wmv2_common_init(w);
 
-return ff_intrax8_common_init(&w->x8, &w->s);
+return ff_intrax8_common_init(&w->x8, &w->s.idsp, &w->s);
 }
 
 static av_cold int wmv2_decode_end(AVCodecContext *avctx)
-- 
2.7.3

___

[libav-devel] [PATCH 13/25] intrax8: Carry over the loopfilter value in ff_intrax8_decode_picture

2016-03-19 Thread Vittorio Giovara
Helps in decoupling this code from mpegvideo.
---
 libavcodec/intrax8.c   | 5 +++--
 libavcodec/intrax8.h   | 7 +--
 libavcodec/vc1_block.c | 3 ++-
 libavcodec/wmv2dec.c   | 3 ++-
 4 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index b1933a5..dd9c226 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -711,7 +711,7 @@ block_placed:
 if (!chroma)
 x8_update_predictions(w, w->orient, n);
 
-if (s->loop_filter) {
+if (w->loopfilter) {
 uint8_t *ptr = w->dest[chroma];
 int linesize = s->current_picture.f->linesize[!!chroma];
 
@@ -775,7 +775,7 @@ av_cold void ff_intrax8_common_end(IntraX8Context *w)
 }
 
 int ff_intrax8_decode_picture(IntraX8Context *const w, int dquant,
-  int quant_offset)
+  int quant_offset, int loopfilter)
 {
 MpegEncContext *const s = w->s;
 int mb_xy;
@@ -785,6 +785,7 @@ int ff_intrax8_decode_picture(IntraX8Context *const w, int 
dquant,
 w->dquant = dquant;
 w->quant  = dquant >> 1;
 w->qsum   = quant_offset;
+w->loopfilter = loopfilter;
 
 w->divide_quant_dc_luma = ((1 << 16) + (w->quant >> 1)) / w->quant;
 if (w->quant < 5) {
diff --git a/libavcodec/intrax8.h b/libavcodec/intrax8.h
index ef88d83..f73cfcd 100644
--- a/libavcodec/intrax8.h
+++ b/libavcodec/intrax8.h
@@ -42,6 +42,7 @@ typedef struct IntraX8Context {
 int quant;
 int dquant;
 int qsum;
+int loopfilter;
 
 // calculated per frame
 int quant_dc_chroma;
@@ -78,14 +79,16 @@ void ff_intrax8_common_end(IntraX8Context *w);
 
 /**
  * Decode single IntraX8 frame.
- * The parent codec must fill s->loopfilter and s->gb (bitstream).
+ * The parent codec must fill s->gb (bitstream).
  * The parent codec must call ff_mpv_frame_start() before calling this 
function.
  * The parent codec must call ff_mpv_frame_end() after calling this function.
  * This function does not use ff_mpv_decode_mb().
  * @param w pointer to IntraX8Context
  * @param dquant doubled quantizer, it would be odd in case of VC-1 halfpq==1.
  * @param quant_offset offset away from zero
+ * @param loopfilter enable filter after decoding a block
  */
-int ff_intrax8_decode_picture(IntraX8Context *w, int quant, int halfpq);
+int ff_intrax8_decode_picture(IntraX8Context *w, int quant, int halfpq,
+  int loopfilter);
 
 #endif /* AVCODEC_INTRAX8_H */
diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c
index 8b46260..4dab0ef 100644
--- a/libavcodec/vc1_block.c
+++ b/libavcodec/vc1_block.c
@@ -3022,7 +3022,8 @@ void ff_vc1_decode_blocks(VC1Context *v)
 
 v->s.esc3_level_length = 0;
 if (v->x8_type) {
-ff_intrax8_decode_picture(&v->x8, 2*v->pq + v->halfpq, v->pq * 
!v->pquantizer);
+ff_intrax8_decode_picture(&v->x8, 2 * v->pq + v->halfpq,
+  v->pq * !v->pquantizer, v->s.loop_filter);
 
 ff_er_add_slice(&v->s.er, 0, 0,
 (v->s.mb_x >> 1) - 1, (v->s.mb_y >> 1) - 1,
diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
index 03b949e..738d33d 100644
--- a/libavcodec/wmv2dec.c
+++ b/libavcodec/wmv2dec.c
@@ -228,7 +228,8 @@ int ff_wmv2_decode_secondary_picture_header(MpegEncContext 
*s)
 s->picture_number++; // FIXME ?
 
 if (w->j_type) {
-ff_intrax8_decode_picture(&w->x8, 2 * s->qscale, (s->qscale - 1) | 1);
+ff_intrax8_decode_picture(&w->x8, 2 * s->qscale, (s->qscale - 1) | 1,
+  s->loop_filter);
 
 ff_er_add_slice(&w->s.er, 0, 0,
 (w->s.mb_x >> 1) - 1, (w->s.mb_y >> 1) - 1,
-- 
2.7.3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 11/25] intrax8: Make x8_init_block_index not use mpegvideo fields

2016-03-19 Thread Vittorio Giovara
---
 libavcodec/intrax8.c | 23 +++
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index 3993c57..bb2ee8f 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -725,22 +725,21 @@ block_placed:
 }
 
 // FIXME maybe merge with ff_*
-static void x8_init_block_index(IntraX8Context *w)
+static void x8_init_block_index(IntraX8Context *w, AVFrame *frame, int mb_y)
 {
-MpegEncContext *const s = w->s;
-// not s->linesize as this would be wrong for field pics
+// not parent codec linesize as this would be wrong for field pics
 // not that IntraX8 has interlacing support ;)
-const int linesize   = s->current_picture.f->linesize[0];
-const int uvlinesize = s->current_picture.f->linesize[1];
+const int linesize   = frame->linesize[0];
+const int uvlinesize = frame->linesize[1];
 
-w->dest[0] = s->current_picture.f->data[0];
-w->dest[1] = s->current_picture.f->data[1];
-w->dest[2] = s->current_picture.f->data[2];
+w->dest[0] = frame->data[0];
+w->dest[1] = frame->data[1];
+w->dest[2] = frame->data[2];
 
-w->dest[0] +=  s->mb_y * linesize << 3;
+w->dest[0] +=  mb_y * linesize << 3;
 // chroma blocks are on add rows
-w->dest[1] += (s->mb_y & (~1)) * uvlinesize << 2;
-w->dest[2] += (s->mb_y & (~1)) * uvlinesize << 2;
+w->dest[1] += (mb_y & (~1)) * uvlinesize << 2;
+w->dest[2] += (mb_y & (~1)) * uvlinesize << 2;
 }
 
 av_cold int ff_intrax8_common_init(IntraX8Context *w, MpegEncContext *const s)
@@ -796,7 +795,7 @@ int ff_intrax8_decode_picture(IntraX8Context *const w, int 
dquant,
 x8_reset_vlc_tables(w);
 
 for (s->mb_y = 0; s->mb_y < s->mb_height * 2; s->mb_y++) {
-x8_init_block_index(w);
+x8_init_block_index(w, s->current_picture.f, s->mb_y);
 mb_xy = (s->mb_y >> 1) * s->mb_stride;
 
 for (s->mb_x = 0; s->mb_x < s->mb_width * 2; s->mb_x++) {
-- 
2.7.3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 04/25] intrax8: Split one comment on multiple lines where it applies

2016-03-19 Thread Vittorio Giovara
---
 libavcodec/intrax8.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

Taken out of the k&r patch.

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index 4887643..b951684 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -152,11 +152,11 @@ static inline int x8_get_orient_vlc(IntraX8Context * w){
 return get_vlc2(&s->gb, w->j_orient_vlc->table, OR_VLC_BITS, OR_VLC_MTD);
 }
 
-#define extra_bits(eb) (eb)
-#define extra_run   (0xFF<<8)
-#define extra_level (0x00<<8)
-#define   run_offset(r)((r)<<16)
-#define level_offset(l)((l)<<24)
+#define extra_bits(eb)  (eb)// 3 bits
+#define extra_run   (0xFF << 8) // 1 bit
+#define extra_level (0x00 << 8) // 1 bit
+#define run_offset(r)   ((r) << 16) // 6 bits
+#define level_offset(l) ((l) << 24) // 5 bits
 static const uint32_t ac_decode_table[]={
 /*46*/ extra_bits(3) |  extra_run  | run_offset(16) | level_offset( 0),
 /*47*/ extra_bits(3) |  extra_run  | run_offset(24) | level_offset( 0),
@@ -193,7 +193,6 @@ static const uint32_t ac_decode_table[]={
 /*71*/ extra_bits(2) | extra_level | run_offset( 1) | level_offset( 3),
 /*72*/ extra_bits(3) | extra_level | run_offset( 1) | level_offset( 7),
 };
-//extra_bits = 3bits; extra_run/level = 1 bit; run_offset = 6bits; 
level_offset = 5 bits;
 #undef extra_bits
 #undef extra_run
 #undef extra_level
-- 
2.7.3

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 10/25] intrax8: Use local destination buffers

2016-03-19 Thread Vittorio Giovara
These buffers are just a way to store frame pointers and be able to
modify them without touching the original ones.

The two dependent decoders (WMV2 and VC1) do not need special care for
these fields: the former does not seem to use the dest buffers, while
the latter reinits them every time to the current frame data buffers.

So only keep a local copy rather than the one from mpegvideo.
---
 libavcodec/intrax8.c | 35 ++-
 libavcodec/intrax8.h |  1 +
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index 0c720b0..3993c57 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -333,7 +333,7 @@ static int x8_setup_spatial_predictor(IntraX8Context *const 
w, const int chroma)
 int sum;
 int quant;
 
-w->dsp.setup_spatial_compensation(s->dest[chroma], s->sc.edge_emu_buffer,
+w->dsp.setup_spatial_compensation(w->dest[chroma], s->sc.edge_emu_buffer,
   s->current_picture.f->linesize[chroma > 
0],
   &range, &sum, w->edges);
 if (chroma) {
@@ -669,7 +669,7 @@ static int x8_decode_intra_mb(IntraX8Context *const w, 
const int chroma)
 dc_level += (w->predicted_dc * divide_quant + (1 << 12)) >> 13;
 
 dsp_x8_put_solidcolor(av_clip_uint8((dc_level * dc_quant + 4) >> 
3),
-  s->dest[chroma],
+  w->dest[chroma],
   s->current_picture.f->linesize[!!chroma]);
 
 goto block_placed;
@@ -695,15 +695,15 @@ static int x8_decode_intra_mb(IntraX8Context *const w, 
const int chroma)
 }
 
 if (w->flat_dc) {
-dsp_x8_put_solidcolor(w->predicted_dc, s->dest[chroma],
+dsp_x8_put_solidcolor(w->predicted_dc, w->dest[chroma],
   s->current_picture.f->linesize[!!chroma]);
 } else {
 w->dsp.spatial_compensation[w->orient](s->sc.edge_emu_buffer,
-   s->dest[chroma],
+   w->dest[chroma],

s->current_picture.f->linesize[!!chroma]);
 }
 if (!zeros_only)
-s->idsp.idct_add(s->dest[chroma],
+s->idsp.idct_add(w->dest[chroma],
  s->current_picture.f->linesize[!!chroma],
  s->block[0]);
 
@@ -712,7 +712,7 @@ block_placed:
 x8_update_predictions(w, w->orient, n);
 
 if (s->loop_filter) {
-uint8_t *ptr = s->dest[chroma];
+uint8_t *ptr = w->dest[chroma];
 int linesize = s->current_picture.f->linesize[!!chroma];
 
 if (!((w->edges & 2) || (zeros_only && (w->orient | 4) == 4)))
@@ -725,21 +725,22 @@ block_placed:
 }
 
 // FIXME maybe merge with ff_*
-static void x8_init_block_index(MpegEncContext *s)
+static void x8_init_block_index(IntraX8Context *w)
 {
+MpegEncContext *const s = w->s;
 // not s->linesize as this would be wrong for field pics
 // not that IntraX8 has interlacing support ;)
 const int linesize   = s->current_picture.f->linesize[0];
 const int uvlinesize = s->current_picture.f->linesize[1];
 
-s->dest[0] = s->current_picture.f->data[0];
-s->dest[1] = s->current_picture.f->data[1];
-s->dest[2] = s->current_picture.f->data[2];
+w->dest[0] = s->current_picture.f->data[0];
+w->dest[1] = s->current_picture.f->data[1];
+w->dest[2] = s->current_picture.f->data[2];
 
-s->dest[0] +=  s->mb_y * linesize << 3;
+w->dest[0] +=  s->mb_y * linesize << 3;
 // chroma blocks are on add rows
-s->dest[1] += (s->mb_y & (~1)) * uvlinesize << 2;
-s->dest[2] += (s->mb_y & (~1)) * uvlinesize << 2;
+w->dest[1] += (s->mb_y & (~1)) * uvlinesize << 2;
+w->dest[2] += (s->mb_y & (~1)) * uvlinesize << 2;
 }
 
 av_cold int ff_intrax8_common_init(IntraX8Context *w, MpegEncContext *const s)
@@ -795,7 +796,7 @@ int ff_intrax8_decode_picture(IntraX8Context *const w, int 
dquant,
 x8_reset_vlc_tables(w);
 
 for (s->mb_y = 0; s->mb_y < s->mb_height * 2; s->mb_y++) {
-x8_init_block_index(s);
+x8_init_block_index(w);
 mb_xy = (s->mb_y >> 1) * s->mb_stride;
 
 for (s->mb_x = 0; s->mb_x < s->mb_width * 2; s->mb_x++) {
@@ -818,8 +819,8 @@ int ff_intrax8_decode_picture(IntraX8Context *const w, int 
dquant,
 if (x8_decode_intra_mb(w, 2))
 goto error;
 
-s->dest[1] += 8;
-s->dest[2] += 8;
+w->dest[1] += 8;
+w->dest[2] += 8;
 
 /* emulate MB info in the relevant tables */
 s->mbskip_table[mb_xy] = 0;
@@ -827,7 +828,7 @@ int ff_intrax8_decode_picture(IntraX8Context *const w, int 
dquant,
 s->current_picture.qscale_table[mb_xy] = w->quant;
 mb_xy++;
  

[libav-devel] [PATCH 01/25] fate: Add test for WMV2 with jframes

2016-03-19 Thread Vittorio Giovara
---
 tests/fate/microsoft.mak|   3 +
 tests/ref/fate/wmv8-intrax8 | 475 
 2 files changed, 478 insertions(+)
 create mode 100644 tests/ref/fate/wmv8-intrax8

This test breaks on an oracle box with gcc-4.4. I carried out a minimum
investigation and managed to isolate the issue to optimization level: when
compiled with -O2 gcc-4.4 produces the expected results, while -O3 generates
differing hashes. Note that with -O2 and the other 6-7 additional optimizations
that -O3 enables, the test still works fine, it's something that is triggered
when -O3 is explicitly passed in.

I don't have sample code to demonstrate this is a compiler bug, but I would
rather have this section of the code covered by this test and update
the gcc version on the oracle box, than trying to isolate the issue more.
However, I'd be more than happy to help anybody willing to work on this.

Since I don't want to create controversy, if there is no consensus I'll simply
drop this patch, and leave this portion of code untested. The changes brought
in by this set do not affect this test at all.

Vittorio

diff --git a/tests/fate/microsoft.mak b/tests/fate/microsoft.mak
index 30bd35a..4a67468 100644
--- a/tests/fate/microsoft.mak
+++ b/tests/fate/microsoft.mak
@@ -38,6 +38,9 @@ fate-wmv8-drm-nodec: CMD = framecrc -cryptokey 
137381538c84c068111902a59c5cf6c34
 FATE_SAMPLES_AVCONV-$(call DEMDEC, ASF, WMV3) += $(FATE_WMV8_DRM)
 fate-wmv8_drm: $(FATE_WMV8_DRM)
 
+FATE_SAMPLES_AVCONV-$(call DEMDEC, ASF, WMV2) += fate-wmv8-intrax8
+fate-wmv8-intrax8: CMD = framecrc -flags +bitexact -i 
$(TARGET_SAMPLES)/wmv8/wmv8_x8intra.wmv -an
+
 FATE_VC1-$(CONFIG_VC1_DEMUXER) += fate-vc1_sa00040
 fate-vc1_sa00040: CMD = framecrc -i $(TARGET_SAMPLES)/vc1/SA00040.vc1
 
diff --git a/tests/ref/fate/wmv8-intrax8 b/tests/ref/fate/wmv8-intrax8
new file mode 100644
index 000..103e8da
--- /dev/null
+++ b/tests/ref/fate/wmv8-intrax8
@@ -0,0 +1,475 @@
+#tb 0: 1/1000
+0,  0,  0,0,   115200, 0x03fbd838
+0,200,200,0,   115200, 0x8911d86f
+0,266,266,0,   115200, 0x7c5dd82e
+0,333,333,0,   115200, 0x7c5ed82e
+0,   2000,   2000,0,   115200, 0xd323d838
+0,   2066,   2066,0,   115200, 0x6e7479ab
+0,   2133,   2133,0,   115200, 0x14674bf6
+0,   2200,   2200,0,   115200, 0x074c2e3d
+0,   2266,   2266,0,   115200, 0x9b3025ef
+0,   2333,   2333,0,   115200, 0x76882dae
+0,   2400,   2400,0,   115200, 0xedf3421b
+0,   2466,   2466,0,   115200, 0xb5378486
+0,   2533,   2533,0,   115200, 0xc4a53420
+0,   2600,   2600,0,   115200, 0x559cb60f
+0,   2666,   2666,0,   115200, 0xcc034ddd
+0,   2733,   2733,0,   115200, 0xb77b7779
+0,   2800,   2800,0,   115200, 0x0ad9c3e6
+0,   2866,   2866,0,   115200, 0x4e673027
+0,   2933,   2933,0,   115200, 0x54717979
+0,   3000,   3000,0,   115200, 0xf9e557c9
+0,   3066,   3066,0,   115200, 0xbdcf6358
+0,   3133,   3133,0,   115200, 0xd55c7bb7
+0,   3200,   3200,0,   115200, 0x78d171e7
+0,   3266,   3266,0,   115200, 0x28715816
+0,   ,   ,0,   115200, 0x58740b8a
+0,   3400,   3400,0,   115200, 0x86c10f18
+0,   3466,   3466,0,   115200, 0x903918f9
+0,   3533,   3533,0,   115200, 0x7f742394
+0,   3600,   3600,0,   115200, 0xd3a91d44
+0,   3666,   3666,0,   115200, 0x24452563
+0,   3733,   3733,0,   115200, 0x1b0c320e
+0,   3800,   3800,0,   115200, 0x3a493c8e
+0,   3866,   3866,0,   115200, 0xebe445ec
+0,   3933,   3933,0,   115200, 0xd2c54c8c
+0,   4000,   4000,0,   115200, 0x4aa15593
+0,   4066,   4066,0,   115200, 0x19a35cc1
+0,   4133,   4133,0,   115200, 0x968c6ee7
+0,   4200,   4200,0,   115200, 0x9f7c7808
+0,   4266,   4266,0,   115200, 0xa23980ee
+0,   4333,   4333,0,   115200, 0xcf3089c3
+0,   4400,   4400,0,   115200, 0x43f78d5c
+0,   4466,   4466,0,   115200, 0x43caa1d4
+0,   4533,   4533,0,   115200, 0x025594c3
+0,   4600,   4600,0,   115200, 0x5ec8a11c
+0,   4666,   4666,0,   115200, 0x7f2a959b
+0,   4733,   4733,0,   115200, 0xc602852d
+0,   4800,   4800,0,   115200, 0x67737ef5
+0,   4866,   4866,0,   115200, 0x81e06efe
+0,   4933,   4933,0,   115200, 0xdb0a484f
+0,   5000,   5000,0,   115200, 0xf30e4418
+0,   5066,   5066,0,   115200, 0xbdd1310d
+0,  

[libav-devel] [PATCH 16/25] intrax8: Keep a reference to the GetBitContext reader

2016-03-19 Thread Vittorio Giovara
Helps in decoupling this code from mpegvideo.
---
 libavcodec/intrax8.c   | 35 ---
 libavcodec/intrax8.h   |  4 +++-
 libavcodec/vc1_block.c |  2 +-
 libavcodec/wmv2dec.c   |  2 +-
 4 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index fae9bc8..336551f 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -132,7 +132,6 @@ static void x8_reset_vlc_tables(IntraX8Context *w)
 
 static inline void x8_select_ac_table(IntraX8Context *const w, int mode)
 {
-MpegEncContext *const s = w->s;
 int table_index;
 
 assert(mode < 4);
@@ -140,7 +139,7 @@ static inline void x8_select_ac_table(IntraX8Context *const 
w, int mode)
 if (w->j_ac_vlc[mode])
 return;
 
-table_index   = get_bits(&s->gb, 3);
+table_index   = get_bits(w->gb, 3);
 // 2 modes use same tables
 w->j_ac_vlc[mode] = &j_ac_vlc[w->quant < 13][mode >> 1][table_index];
 
@@ -149,16 +148,14 @@ static inline void x8_select_ac_table(IntraX8Context 
*const w, int mode)
 
 static inline int x8_get_orient_vlc(IntraX8Context *w)
 {
-MpegEncContext *const s = w->s;
-
 if (!w->j_orient_vlc) {
-int table_index = get_bits(&s->gb, 1 + (w->quant < 13));
+int table_index = get_bits(w->gb, 1 + (w->quant < 13));
 w->j_orient_vlc = &j_orient_vlc[w->quant < 13][table_index];
 }
 assert(w->j_orient_vlc);
 assert(w->j_orient_vlc->table);
 
-return get_vlc2(&s->gb, w->j_orient_vlc->table, OR_VLC_BITS, OR_VLC_MTD);
+return get_vlc2(w->gb, w->j_orient_vlc->table, OR_VLC_BITS, OR_VLC_MTD);
 }
 
 #define extra_bits(eb)  (eb)// 3 bits
@@ -211,11 +208,10 @@ static const uint32_t ac_decode_table[] = {
 static void x8_get_ac_rlf(IntraX8Context *const w, const int mode,
   int *const run, int *const level, int *const final)
 {
-MpegEncContext *const s = w->s;
 int i, e;
 
 //x8_select_ac_table(w,mode);
-i = get_vlc2(&s->gb, w->j_ac_vlc[mode]->table, AC_VLC_BITS, AC_VLC_MTD);
+i = get_vlc2(w->gb, w->j_ac_vlc[mode]->table, AC_VLC_BITS, AC_VLC_MTD);
 
 if (i < 46) { // [0-45]
 int t, l;
@@ -252,7 +248,7 @@ static void x8_get_ac_rlf(IntraX8Context *const w, const 
int mode,
 i -= 46;
 sm = ac_decode_table[i];
 
-e= get_bits(&s->gb, sm & 0xF);
+e= get_bits(w->gb, sm & 0xF);
 sm >>= 8;// 3bits
 mask = sm & 0xff;
 sm >>= 8;// 1bit
@@ -269,13 +265,13 @@ static void x8_get_ac_rlf(IntraX8Context *const w, const 
int mode,
 };
 
 (*final) = !(i & 1);
-e= get_bits(&s->gb, 5); // get the extra bits
+e= get_bits(w->gb, 5); // get the extra bits
 (*run)   = crazy_mix_runlevel[e] >> 4;
 (*level) = crazy_mix_runlevel[e] & 0x0F;
 } else {
-(*level) = get_bits(&s->gb, 7 - 3 * (i & 1));
-(*run)   = get_bits(&s->gb, 6);
-(*final) = get_bits1(&s->gb);
+(*level) = get_bits(w->gb, 7 - 3 * (i & 1));
+(*run)   = get_bits(w->gb, 6);
+(*final) = get_bits1(w->gb);
 }
 return;
 }
@@ -290,19 +286,18 @@ static const uint8_t dc_index_offset[] = {
 static int x8_get_dc_rlf(IntraX8Context *const w,
  int const mode, int *const level, int *const final)
 {
-MpegEncContext *const s = w->s;
 int i, e, c;
 
 assert(mode < 3);
 if (!w->j_dc_vlc[mode]) {
-int table_index = get_bits(&s->gb, 3);
+int table_index = get_bits(w->gb, 3);
 // 4 modes, same table
 w->j_dc_vlc[mode] = &j_dc_vlc[w->quant < 13][table_index];
 }
 assert(w->j_dc_vlc);
 assert(w->j_dc_vlc[mode]->table);
 
-i = get_vlc2(&s->gb, w->j_dc_vlc[mode]->table, DC_VLC_BITS, DC_VLC_MTD);
+i = get_vlc2(w->gb, w->j_dc_vlc[mode]->table, DC_VLC_BITS, DC_VLC_MTD);
 
 /* (i >= 17) { i -= 17; final =1; } */
 c= i > 16;
@@ -316,7 +311,7 @@ static int x8_get_dc_rlf(IntraX8Context *const w,
 c  = (i + 1) >> 1; // hackish way to calculate dc_extra_sbits[]
 c -= c > 1;
 
-e = get_bits(&s->gb, c); // get the extra bits
+e = get_bits(w->gb, c); // get the extra bits
 i = dc_index_offset[i] + (e >> 1);
 
 e= -(e & 1); // 0, 0xff
@@ -645,7 +640,7 @@ static int x8_decode_intra_mb(IntraX8Context *const w, 
const int chroma)
 level  = (level + 1) * w->dquant;
 level += w->qsum;
 
-sign  = -get_bits1(&s->gb);
+sign  = -get_bits1(w->gb);
 level = (level ^ sign) - sign;
 
 if (use_quant_matrix) {
@@ -774,18 +769,20 @@ av_cold void ff_intrax8_common_end(IntraX8Context *w)
 }
 
 int ff_intrax8_decode_picture(IntraX8Context *const w, Picture *pict,
+  GetBitContext *gb,
   int dquant, int quant_offset, int loopfilter)
 {
 MpegEnc

[libav-devel] [PATCH 6/8] RFC: avio: Copy URLContext generic options into child URLContexts

2016-03-19 Thread Martin Storsjö
Since all URLContexts have the same AVOptions, such AVOptions
will be applied on the outermost context only and removed from the
dict, while they probably make sense on all contexts.

This makes sure that rw_timeout gets propagated to the innermost
URLContext (to make sure it gets passed to the tcp protocol, when
opening a http connection for instance).

Alternatively, such matching options would be kept in the dict
and only removed after the ffurl_connect call.
---
Suggestions on how to do this better are welcome.
---
 libavformat/avio.c   |  5 -
 libavformat/aviobuf.c|  2 +-
 libavformat/concat.c |  2 +-
 libavformat/crypto.c |  2 +-
 libavformat/gopher.c |  2 +-
 libavformat/hlsproto.c   |  2 +-
 libavformat/http.c   |  4 ++--
 libavformat/icecast.c|  2 +-
 libavformat/md5proto.c   |  2 +-
 libavformat/mmst.c   |  2 +-
 libavformat/rtmpcrypt.c  |  2 +-
 libavformat/rtmpproto.c  |  4 ++--
 libavformat/rtpproto.c   |  4 ++--
 libavformat/rtsp.c   | 10 +-
 libavformat/rtspdec.c|  4 ++--
 libavformat/sapdec.c |  2 +-
 libavformat/sapenc.c |  4 ++--
 libavformat/smoothstreamingenc.c |  6 +++---
 libavformat/srtpproto.c  |  2 +-
 libavformat/tls.c|  2 +-
 libavformat/url.h|  4 +++-
 21 files changed, 37 insertions(+), 32 deletions(-)

diff --git a/libavformat/avio.c b/libavformat/avio.c
index 6039990..1692f1b 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -174,11 +174,14 @@ int ffurl_alloc(URLContext **puc, const char *filename, 
int flags,
 
 int ffurl_open(URLContext **puc, const char *filename, int flags,
const AVIOInterruptCB *int_cb, AVDictionary **options,
-   const URLProtocol **protocols)
+   const URLProtocol **protocols,
+   URLContext *parent)
 {
 int ret = ffurl_alloc(puc, filename, flags, int_cb, protocols);
 if (ret)
 return ret;
+if (parent)
+av_opt_copy(*puc, parent);
 if (options &&
 (ret = av_opt_set_dict(*puc, options)) < 0)
 goto fail;
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index a2edb74..29fccbe 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -905,7 +905,7 @@ int avio_open2(AVIOContext **s, const char *filename, int 
flags,
 if (!protocols)
 return AVERROR(ENOMEM);
 
-err = ffurl_open(&h, filename, flags, int_cb, options, protocols);
+err = ffurl_open(&h, filename, flags, int_cb, options, protocols, NULL);
 if (err < 0) {
 av_freep(&protocols);
 return err;
diff --git a/libavformat/concat.c b/libavformat/concat.c
index ecdf5df..a338df6 100644
--- a/libavformat/concat.c
+++ b/libavformat/concat.c
@@ -95,7 +95,7 @@ static av_cold int concat_open(URLContext *h, const char 
*uri, int flags)
 
 /* creating URLContext */
 if ((err = ffurl_open(&uc, node_uri, flags,
-  &h->interrupt_callback, NULL, h->protocols)) < 0)
+  &h->interrupt_callback, NULL, h->protocols, h)) 
< 0)
 break;
 
 /* creating size */
diff --git a/libavformat/crypto.c b/libavformat/crypto.c
index a364dc0..55430c4 100644
--- a/libavformat/crypto.c
+++ b/libavformat/crypto.c
@@ -83,7 +83,7 @@ static int crypto_open(URLContext *h, const char *uri, int 
flags)
 goto err;
 }
 if ((ret = ffurl_open(&c->hd, nested_url, AVIO_FLAG_READ,
-  &h->interrupt_callback, NULL, h->protocols)) < 0) {
+  &h->interrupt_callback, NULL, h->protocols, h)) < 0) 
{
 av_log(h, AV_LOG_ERROR, "Unable to open input\n");
 goto err;
 }
diff --git a/libavformat/gopher.c b/libavformat/gopher.c
index afa2b7d..6d9fc38 100644
--- a/libavformat/gopher.c
+++ b/libavformat/gopher.c
@@ -94,7 +94,7 @@ static int gopher_open(URLContext *h, const char *uri, int 
flags)
 
 s->hd = NULL;
 err = ffurl_open(&s->hd, buf, AVIO_FLAG_READ_WRITE,
- &h->interrupt_callback, NULL, h->protocols);
+ &h->interrupt_callback, NULL, h->protocols, h);
 if (err < 0)
 goto fail;
 
diff --git a/libavformat/hlsproto.c b/libavformat/hlsproto.c
index b01cef0..4c3048a 100644
--- a/libavformat/hlsproto.c
+++ b/libavformat/hlsproto.c
@@ -304,7 +304,7 @@ retry:
 url = s->segments[s->cur_seq_no - s->start_seq_no]->url,
 av_log(h, AV_LOG_DEBUG, "opening %s\n", url);
 ret = ffurl_open(&s->seg_hd, url, AVIO_FLAG_READ,
- &h->interrupt_callback, NULL, h->protocols);
+ &h->interrupt_callback, NULL, h->protocols, h);
 if (ret < 0) {
 if (ff_check_interrupt(&h->interrupt_callback))
 return AVERROR_EXIT;
diff --git a/libavformat/http.c b/libavformat/http.c
index 4830390..8fe8d11 100

[libav-devel] [PATCH] indeo4: Rework stream analysis report

2016-03-19 Thread Vittorio Giovara
* Change log level from error to debug
* Print report  after the first decoded frame, not at the end of decoding
* Drop macro guard and use a context variable instead

Signed-off-by: Vittorio Giovara 
---
 libavcodec/indeo4.c | 11 +--
 libavcodec/ivi.c| 33 -
 libavcodec/ivi.h|  4 +---
 3 files changed, 18 insertions(+), 30 deletions(-)

diff --git a/libavcodec/indeo4.c b/libavcodec/indeo4.c
index 64ed8cd..4ec09dc 100644
--- a/libavcodec/indeo4.c
+++ b/libavcodec/indeo4.c
@@ -119,17 +119,13 @@ static int decode_pic_hdr(IVI45DecContext *ctx, 
AVCodecContext *avctx)
 return AVERROR_INVALIDDATA;
 }
 
-#if IVI4_STREAM_ANALYSER
 if (ctx->frame_type == IVI4_FRAMETYPE_BIDIR)
 ctx->has_b_frames = 1;
-#endif
 
 ctx->transp_status = get_bits1(&ctx->gb);
-#if IVI4_STREAM_ANALYSER
 if (ctx->transp_status) {
 ctx->has_transp = 1;
 }
-#endif
 
 /* unknown bit: Mac decoder ignores this bit, XANIM returns error */
 if (get_bits1(&ctx->gb)) {
@@ -166,9 +162,7 @@ static int decode_pic_hdr(IVI45DecContext *ctx, 
AVCodecContext *avctx)
 if (get_bits1(&ctx->gb)) {
 pic_conf.tile_height = scale_tile_size(pic_conf.pic_height, 
get_bits(&ctx->gb, 4));
 pic_conf.tile_width  = scale_tile_size(pic_conf.pic_width,  
get_bits(&ctx->gb, 4));
-#if IVI4_STREAM_ANALYSER
 ctx->uses_tiling = 1;
-#endif
 } else {
 pic_conf.tile_height = pic_conf.pic_height;
 pic_conf.tile_width  = pic_conf.pic_width;
@@ -293,10 +287,8 @@ static int decode_band_hdr(IVI45DecContext *ctx, 
IVIBandDesc *band,
band->is_halfpel);
 return AVERROR_INVALIDDATA;
 }
-#if IVI4_STREAM_ANALYSER
 if (!band->is_halfpel)
 ctx->uses_fullpel = 1;
-#endif
 
 band->checksum_present = get_bits1(&ctx->gb);
 if (band->checksum_present)
@@ -328,10 +320,8 @@ static int decode_band_hdr(IVI45DecContext *ctx, 
IVIBandDesc *band,
 return AVERROR_PATCHWELCOME;
 }
 
-#if IVI4_STREAM_ANALYSER
 if ((transform_id >= 0 && transform_id <= 2) || transform_id == 10)
 ctx->uses_haar = 1;
-#endif
 
 band->inv_transform = transforms[transform_id].inv_trans;
 band->dc_transform  = transforms[transform_id].dc_trans;
@@ -640,6 +630,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
 ctx->is_nonnull_frame = is_nonnull_frame;
 
 ctx->is_indeo4 = 1;
+ctx->show_indeo4_info = 1;
 
 ctx->dst_buf   = 0;
 ctx->ref_buf   = 1;
diff --git a/libavcodec/ivi.c b/libavcodec/ivi.c
index 9762eeb..caa3fe6 100644
--- a/libavcodec/ivi.c
+++ b/libavcodec/ivi.c
@@ -1133,6 +1133,22 @@ int ff_ivi_decode_frame(AVCodecContext *avctx, void 
*data, int *got_frame,
 }
 }
 
+if (ctx->show_indeo4_info) {
+if (ctx->is_scalable)
+av_log(avctx, AV_LOG_DEBUG, "This video uses scalability mode\n");
+if (ctx->uses_tiling)
+av_log(avctx, AV_LOG_DEBUG, "This video uses local decoding\n");
+if (ctx->has_b_frames)
+av_log(avctx, AV_LOG_DEBUG, "This video contains B-frames\n");
+if (ctx->has_transp)
+av_log(avctx, AV_LOG_DEBUG, "Transparency mode is enabled\n");
+if (ctx->uses_haar)
+av_log(avctx, AV_LOG_DEBUG, "This video uses Haar transform\n");
+if (ctx->uses_fullpel)
+av_log(avctx, AV_LOG_DEBUG, "This video uses fullpel motion 
vectors\n");
+ctx->show_indeo4_info = 0;
+}
+
 return buf_size;
 }
 
@@ -1148,23 +1164,6 @@ av_cold int ff_ivi_decode_close(AVCodecContext *avctx)
 if (ctx->mb_vlc.cust_tab.table)
 ff_free_vlc(&ctx->mb_vlc.cust_tab);
 
-#if IVI4_STREAM_ANALYSER
-if (ctx->is_indeo4) {
-if (ctx->is_scalable)
-av_log(avctx, AV_LOG_ERROR, "This video uses scalability mode!\n");
-if (ctx->uses_tiling)
-av_log(avctx, AV_LOG_ERROR, "This video uses local decoding!\n");
-if (ctx->has_b_frames)
-av_log(avctx, AV_LOG_ERROR, "This video contains B-frames!\n");
-if (ctx->has_transp)
-av_log(avctx, AV_LOG_ERROR, "Transparency mode is enabled!\n");
-if (ctx->uses_haar)
-av_log(avctx, AV_LOG_ERROR, "This video uses Haar transform!\n");
-if (ctx->uses_fullpel)
-av_log(avctx, AV_LOG_ERROR, "This video uses fullpel motion 
vectors!\n");
-}
-#endif
-
 av_frame_free(&ctx->p_frame);
 
 return 0;
diff --git a/libavcodec/ivi.h b/libavcodec/ivi.h
index 5dadd9f..c403739 100644
--- a/libavcodec/ivi.h
+++ b/libavcodec/ivi.h
@@ -47,7 +47,6 @@ enum {
 };
 
 #define IVI_VLC_BITS 13 ///< max number of bits of the ivi's huffman codes
-#define IVI4_STREAM_ANALYSER0
 #define IVI5_IS_PROTECTED   0x20
 
 /**
@@ -249,13 +248,12 @@ typedef struct IVI45DecContext {
 uint8_t gop_flags;
 uint32_tlock_word;
 
-#if IVI4_STREAM_ANALYSER
+int show_indeo4_inf

Re: [libav-devel] [PATCH 2/2] vda_h264: Use av_buffer to manage buffers

2016-03-19 Thread Vittorio Giovara
On Tue, Mar 4, 2014 at 7:30 PM, Luca Barbato  wrote:
> From: Sebastien Zwickert 
>
> Fix a buffer leak when seeking occurs.
>
> Signed-off-by: Luca Barbato 
> ---
>  libavcodec/vda_h264.c | 25 -
>  libavcodec/version.h  |  4 ++--
>  2 files changed, 26 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/vda_h264.c b/libavcodec/vda_h264.c
> index e9c4af6..a7183c6 100644
> --- a/libavcodec/vda_h264.c
> +++ b/libavcodec/vda_h264.c
> @@ -107,6 +107,12 @@ static int vda_h264_decode_slice(AVCodecContext *avctx,
>  return 0;
>  }
>
> +static void vda_h264_release_buffer(void *opaque, uint8_t *data)
> +{
> +CVPixelBufferRef cv_buffer = opaque;
> +CVPixelBufferRelease(cv_buffer);
> +}
> +
>  static int vda_h264_end_frame(AVCodecContext *avctx)
>  {
>  H264Context *h  = avctx->priv_data;
> @@ -120,8 +126,25 @@ static int vda_h264_end_frame(AVCodecContext *avctx)
>  status = vda_sync_decode(vda_ctx);
>  frame->data[3] = (void*)vda_ctx->cv_buffer;
>
> -if (status)
> +if (status) {
>  av_log(avctx, AV_LOG_ERROR, "Failed to decode frame (%d)\n", status);
> +return status;
> +}
> +
> +/* VDA workaround to release properly each core video buffer:
> + * we need to create an extra av_buffer with a custom freeing callback
> + * to avoid potential memory leaks. */
> +h->cur_pic_ptr->hwaccel_priv_buf = av_buffer_create(frame->data[0],
> +0,
> +
> vda_h264_release_buffer,
> +vda_ctx->cv_buffer,
> +0);
> +if (!h->cur_pic_ptr->hwaccel_priv_buf) {
> +CVPixelBufferRelease(vda_ctx->cv_buffer);
> +return AVERROR(ENOMEM);
> +}
> +
> +h->cur_pic_ptr->hwaccel_picture_private = 
> h->cur_pic_ptr->hwaccel_priv_buf->data;
>
>  return status;
>  }
> diff --git a/libavcodec/version.h b/libavcodec/version.h
> index cdd5a61..a813fc9 100644
> --- a/libavcodec/version.h
> +++ b/libavcodec/version.h
> @@ -29,8 +29,8 @@
>  #include "libavutil/version.h"
>
>  #define LIBAVCODEC_VERSION_MAJOR 55
> -#define LIBAVCODEC_VERSION_MINOR 34
> -#define LIBAVCODEC_VERSION_MICRO  1
> +#define LIBAVCODEC_VERSION_MINOR 35
> +#define LIBAVCODEC_VERSION_MICRO  0
>
>  #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
> LIBAVCODEC_VERSION_MINOR, \
> --

Is this patch still needed?
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] matroskaenc: Don't set language to empty string, use "und"

2016-03-19 Thread Vittorio Giovara
On Wed, Jul 23, 2014 at 7:03 AM, Anton Khirnov  wrote:
>
> On Tue, 22 Jul 2014 09:38:42 +0200, j...@v2v.cc wrote:
>> On 07/21/2014 09:35 PM, Anton Khirnov wrote:
>> >
>> > On Sun, 20 Jul 2014 15:28:36 +0200, j...@v2v.cc wrote:
>> >> On 07/20/2014 03:13 PM, Anton Khirnov wrote:
>> >>> Could you share the sample?
>> >>> This really sounds like a bug elsewhere that should be fixed.
>> >>
>> >> Here a short clip http://v2v.cc/~j/samples/emtpy_language.mpg
>> >>
>> >
>> > Then your patch does not seem to work.
>> > This was the source of my initial confusion, since in the patch you're 
>> > testing
>> > for a NULL pointer in the tag value, but the dict API should not allow 
>> > that to
>> > happen ever. But in this sample, the value is not a NULL pointer, but an 
>> > empty
>> > string (i.e. a valid pointer pointing to a zero byte), which is a perfectly
>> > valid dictionary entry (though admittedly not a valid language 
>> > description).
>>
>> you are right, not sure why my test did not fail with the first patch.
>> the second patch to mpegts.js works as expected though.
>>
>> > Perhaps we could use the table from libavformat/avlanguage.c to actually 
>> > check
>> > whether the language is valid.
>>
>> that might be a good idea too, do you know if this kind of thing is done
>> somehere else in libav already?
>
> Does not seem so.
>
> But adding a function for checking whether a given string is in the given
> codespace in the table should be simple enough.
>

(this should just provide some context for the previous two pings)
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] mpegts: use av_islang before setting language

2016-03-19 Thread Vittorio Giovara
On Thu, Jul 24, 2014 at 3:55 AM, Jan Gerber  wrote:
> ---
>  libavformat/mpegts.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> index 5d8b08c..fa784ac 100644
> --- a/libavformat/mpegts.c
> +++ b/libavformat/mpegts.c
> @@ -29,6 +29,7 @@
> #include "libavcodec/bytestream.h"
> #include "libavcodec/get_bits.h"
> #include "avformat.h"
>+#include "avlanguage.h"
> #include "mpegts.h"
> #include "internal.h"
> #include "avio_internal.h"
> @@ -1414,7 +1415,9 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, 
> AVStream *st, int stream_type
> }
> if (i) {
> language[i - 1] = 0;
> -av_dict_set(&st->metadata, "language", language, 0);
> +if (av_islang(language)) {
> +av_dict_set(&st->metadata, "language", language, 0);
> +}
>  }
>  break;
> case 0x05: /* registration descriptor */

also this one needs review
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/2] avlanguage: add av_islang

2016-03-19 Thread Vittorio Giovara
On Thu, Jul 24, 2014 at 3:55 AM, Jan Gerber  wrote:
> ---
>  libavformat/avlanguage.c | 14 ++
>  libavformat/avlanguage.h |  5 +
>  2 files changed, 19 insertions(+)
>
> diff --git a/libavformat/avlanguage.c b/libavformat/avlanguage.c
> index e606ef2..a4b916f 100644
> --- a/libavformat/avlanguage.c
> +++ b/libavformat/avlanguage.c
> @@ -763,3 +763,17 @@ const char *av_convert_lang_to(const char *lang, enum 
> AVLangCodespace target_cod
>
> return NULL;
>  }
> +
> +int av_islang(const char *lang)
> +{
> +const LangEntry *entry = NULL;
> +const int NB_LANGENTRIES = FF_ARRAY_ELEMS(lang_table);
> +
> +entry = bsearch(lang,
> +lang_table,
> +NB_LANGENTRIES,
> +sizeof(LangEntry),
> +lang_table_compare);
> +
> +return entry != NULL;
> +}
> diff --git a/libavformat/avlanguage.h b/libavformat/avlanguage.h
> index 2ec3e2d..24f3187 100644
> --- a/libavformat/avlanguage.h
> +++ b/libavformat/avlanguage.h
> @@ -36,4 +36,9 @@ enum AVLangCodespace {
> */
> const char *av_convert_lang_to(const char *lang, enum AVLangCodespace 
> target_codespace);
>
> +/**
> + * Check if lang is a valid language.
> + */
> +int av_islang(const char *lang);
> +
> #endif /* AVFORMAT_AVLANGUAGE_H */

ping, needs review
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [RFC] no longer marking native aac encoder as experimental

2016-03-19 Thread Vittorio Giovara
On Sun, Nov 30, 2014 at 6:06 PM, Luca Barbato  wrote:
> On 30/11/14 23:43, Andreas Cadhalpun wrote:
>>
>> On 20.11.2014 17:59, Andreas Cadhalpun wrote:
>>>
>>> Hi,
>>>
>>> currently the native aac encoder is marked as experimental, while the
>>> libvo_aacenc encoder is not.
>>>
>>> However, after reading the wiki [1] and especially the mentioned mail
>>> [2], it seems the native encoder is better.
>>>
>>> Thus I'm wondering if it would make sense to no longer mark the native
>>> aac encoder as experimental.
>>>
>>> This would also solve problems like [3].
>>>
>>> Please comment.
>>
>>
>> Since nobody complained about the idea, I'm attaching a patch for this.
>>
>
> Let me 2 days next week to check if I can reproduce and fix a bug I noticed
> when testing it.
>
> lu

incredibly old ping
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [FFmpeg-devel] [PATCH] aacpsy: avoid norm_fac becoming NaN

2016-03-19 Thread Vittorio Giovara
On Tue, Apr 21, 2015 at 12:50 PM, Andreas Cadhalpun
 wrote:
> On 21.04.2015 02:20, Claudio Freire wrote:
>> On Mon, Apr 20, 2015 at 9:13 PM, Michael Niedermayer  
>> wrote:
>>> On Mon, Apr 20, 2015 at 09:07:14PM -0300, Claudio Freire wrote:
 On Mon, Apr 20, 2015 at 8:59 PM, Claudio Freire  
 wrote:
> On Mon, Apr 20, 2015 at 8:32 PM, Andreas Cadhalpun
>  wrote:
> The long version:
>
> ath should approximate the shape of the absolute hearing threshold, so
> yes, it's best if it really uses the minimum, since that will prevent
> clipping of the ath curve and result in a more accurate threshold
> computation.

 So you agree with my patch fixing minath?
 Or would you prefer a version with:
 minath = ath(3410 - 0.733 * ATH_ADD, ATH_ADD)
>>>
>>> Well, that's not really closer to the minimum (a few tests with gnuplot 
>>> say).
>>
>> Are you sure your plots were done correctly?
>> Because I'm quite sure this is the correct first order approximation
>> of the minimum.
>>
>> For ATH_ADD = 4 this gives 3407.068, which is quite close to Michael's 
>> value
>> (3407.080774800152).
>
> I checked the formula several times, but still, I could have made a 
> mistake.


 This is what I did if you want to check it out (maybe you spot the mistake)

 gnuplot> ath(f,a) = _ath(f/1000.0, a)
 gnuplot> _ath(f,a) = 3.64 * f**(-0.8) - 6.8 * exp(-0.6 * (f-3.4) *
 (f-3.4)) + 6.0 * exp(-0.15 * (f-8.7) * (f-8.7)) + (0.6 + 0.04 * a) *
 0.001 * f * f * f
>>>   ^^
>>> missing * f
>>
>> Much better now :)
>>
>> So yes. I'd say it's a good change.
>
> OK, patch attached.
>
> Best regards,
> Andreas

Is this patch still needed?
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] takdec: ensure chan2 is a valid channel index

2016-03-19 Thread Vittorio Giovara
On Tue, Jun 9, 2015 at 8:26 PM, Luca Barbato  wrote:
> On 10/06/15 00:12, Andreas Cadhalpun wrote:
>> If chan2 is not smaller than the number of channels, it can cause
>> segmentation faults due to dereferencing a NULL pointer.
>>
>> Signed-off-by: Andreas Cadhalpun 
>> ---
>>  libavcodec/takdec.c | 6 ++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/libavcodec/takdec.c b/libavcodec/takdec.c
>> index a453da8..4225030 100644
>> --- a/libavcodec/takdec.c
>> +++ b/libavcodec/takdec.c
>> @@ -801,6 +801,12 @@ static int tak_decode_frame(AVCodecContext *avctx, void 
>> *data,
>>  if (s->mcdparams[i].present) {
>>  s->mcdparams[i].index = get_bits(gb, 2);
>>  s->mcdparams[i].chan2 = get_bits(gb, 4);
>> +if (s->mcdparams[i].chan2 >= avctx->channels) {
>> +av_log(avctx, AV_LOG_ERROR,
>> +   "invalid channel 2 (%d) for %d 
>> channel(s)\n",
>> +   s->mcdparams[i].chan2, avctx->channels);
>> +return AVERROR_INVALIDDATA;
>> +}
>>  if (s->mcdparams[i].index == 1) {
>>  if ((nbit == s->mcdparams[i].chan2) ||
>>  (ch_mask & 1 << s->mcdparams[i].chan2))
>>
>
> Looks fine to me.

Correct me if I'm wrong but I think this wasn't applied to the tree.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 5/6] avio: Add avio_read wrapper to simplify error checking

2016-03-19 Thread Vittorio Giovara
On Sun, Jun 7, 2015 at 1:07 PM, Luca Barbato  wrote:
> On 07/06/15 16:30, Andreas Cadhalpun wrote:
>> It seems Luca accidentally pushed an old version of this patch.
>> The pushed version still has the ffio_read_size name and Luca's
>> comment about the error handling is also not addressed.
>
> Good thing it is an internal function and thanks for spotting!

Should we start coming back to this?
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] img2: Provide an option take the path verbatim

2016-03-19 Thread Vittorio Giovara
On Sat, Feb 7, 2015 at 8:22 AM, Luca Barbato  wrote:
> On 02/02/15 01:36, Luca Barbato wrote:
>> There can be valid files path sporting %-sequences or have
>> files ending with .V in the the same directory but not related.
>> ---
>>
>> Mainly an rfc and pro-memoria.
>>
>
> Derek does it work for your use-case?
>
> lu

Maybe this could go in as is.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] lavf: add a format flag for separate carriers, and an event for detecting carrier presence.

2016-03-19 Thread Vittorio Giovara
On Mon, Jun 8, 2015 at 5:28 AM, John Högberg  wrote:
> Luca Barbato wrote:
>> Please do. I thought about the alternative to support your scenario (beside
>> having a callback API that I'll blog about soonish) and another way to do 
>> that
>> is to have an AVSTREAM_EVENT_FLAG_LOST to signal that the stream is gone and
>> an AVFMT_EVENT_FLAG_ACTIVE_STREAM_CHANGED to signal the fact the number of
>> active stream changed.
>>
>> The semantics compared to metadata update is changed slightly, since we want
>> to keep the AVSTREAM_EVENT_FLAG_LOST as they are until they change while
>> wiping the AVFMT_EVENT_FLAG_ACTIVE_STREAM_CHANGED.
>>
>> This should be enough to avoid to introduce a function to explicitly to check
>> and reset even if I'd consider adding it nonetheless.
>
> A general notification above stream level would be useful, yes. As an aside,
> the new semantics are "present" rather than "lost" as per Anton's feedback. It
> feels like I've submitted every possible way of implementing this right now. 
> :|
>
>> Another option is having a generic AVFMT_EVENT_FLAG_STREAM_EVENT to signal
>> that the stream event flags had been set (and spare some iterations over the
>> stream list).
>>
>> How does it sound?
>
> I'd prefer the generic solution. There's little to be gained by "inheriting" 
> the
> specific flags of the underlying streams since you'll need to check them all
> anyway.
>
>> lu

Is this patch still needed?
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [FFmpeg-devel] [PATCH 2/2] matroskadec: validate audio channels and bitdepth

2016-03-19 Thread Vittorio Giovara
On Tue, Jun 16, 2015 at 3:55 PM, Andreas Cadhalpun
 wrote:
> On 16.06.2015 00:37, Luca Barbato wrote:
>> On 16/06/15 00:14, Andreas Cadhalpun wrote:
 I wonder if the sanity check in the decoder would be enough to not have
 other problems down the line.
>>>
>>> No, because the problem is in the two lines below the check.
>>
>> Not here =)
>
> The avio_wl16 calls are also present in Libav and writing something larger
> than 16bit with them is a bug. The av_assert2 in FFmpeg is only a means
> to detect such a bug.
>
 I'd provide an explode mode and as best effort mode I'd just mark the
 data as corrupted.
>>>
>>> What do you mean with marking the data as corrupted?
>>
>> There is a packet flag, AV_PKT_FLAG_CORRUPT, to mark the data that
>> shouldn't be trusted.
>
> This flag is used rather rarely. I'm not convinced that it would be
> particularly useful for this corner case.
>
> Best regards,
> Andreas

Any update about this patch?
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] x86: Add SSSE3_SLOW CPU flag and related convenience macros

2016-03-19 Thread Vittorio Giovara
On Tue, Jan 19, 2016 at 7:55 AM, Diego Biurrun  wrote:
> ---
>
> Fixed FAST_SLOW typo.
>
>  doc/APIchanges  | 3 +++
>  libavutil/cpu.h | 1 +
>  libavutil/version.h | 2 +-
>  libavutil/x86/cpu.h | 6 ++
>  4 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/doc/APIchanges b/doc/APIchanges
> index ffa270e..f2e6bea 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -13,6 +13,9 @@ libavutil: 2015-08-28
>
>  API changes, most recent first:
>
> +2016-01-19 - xxx - lavu 55.6.0 - cpu.h
> +  Add AV_CPU_FLAG_SSSE3SLOW.
> +
>  2015-xx-xx - xxx - lavc 57.12.0 - avcodec.h
>Add AVCodecDescriptor.profiles and avcodec_profile_name().
>
> diff --git a/libavutil/cpu.h b/libavutil/cpu.h
> index d640e79..deff4cc 100644
> --- a/libavutil/cpu.h
> +++ b/libavutil/cpu.h
> @@ -38,6 +38,7 @@
>  #define AV_CPU_FLAG_SSE3SLOW 0x2000 ///< SSE3 supported, but usually not 
> faster
>  ///< than regular MMX/SSE (e.g. 
> Core1)
>  #define AV_CPU_FLAG_SSSE30x0080 ///< Conroe SSSE3 functions
> +#define AV_CPU_FLAG_SSSE3SLOW 0x400 ///< SSSE3 supported, but usually 
> not faster
>  #define AV_CPU_FLAG_ATOM 0x1000 ///< Atom processor, some SSSE3 
> instructions are slower
>  #define AV_CPU_FLAG_SSE4 0x0100 ///< Penryn SSE4.1 functions
>  #define AV_CPU_FLAG_SSE420x0200 ///< Nehalem SSE4.2 functions
> diff --git a/libavutil/version.h b/libavutil/version.h
> index 25457ac..ebd548f 100644
> --- a/libavutil/version.h
> +++ b/libavutil/version.h
> @@ -54,7 +54,7 @@
>   */
>
>  #define LIBAVUTIL_VERSION_MAJOR 55
> -#define LIBAVUTIL_VERSION_MINOR  5
> +#define LIBAVUTIL_VERSION_MINOR  6
>  #define LIBAVUTIL_VERSION_MICRO  0
>
>  #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
> diff --git a/libavutil/x86/cpu.h b/libavutil/x86/cpu.h
> index 0695436..c0a525d 100644
> --- a/libavutil/x86/cpu.h
> +++ b/libavutil/x86/cpu.h
> @@ -38,6 +38,8 @@
>  #define X86_SSE3_FAST(flags)CPUEXT_FAST(flags, SSE3)
>  #define X86_SSE3_SLOW(flags)CPUEXT_SLOW(flags, SSE3)
>  #define X86_SSSE3(flags)CPUEXT(flags, SSSE3)
> +#define X86_SSSE3_FAST(flags)   CPUEXT_FAST(flags, SSSE3)
> +#define X86_SSSE3_SLOW(flags)   CPUEXT_SLOW(flags, SSSE3)
>  #define X86_SSE4(flags) CPUEXT(flags, SSE4)
>  #define X86_SSE42(flags)CPUEXT(flags, SSE42)
>  #define X86_AVX(flags)  CPUEXT(flags, AVX)
> @@ -60,6 +62,8 @@
>  #define EXTERNAL_SSE3_FAST(flags)   CPUEXT_SUFFIX_FAST(flags, _EXTERNAL, 
> SSE3)
>  #define EXTERNAL_SSE3_SLOW(flags)   CPUEXT_SUFFIX_SLOW(flags, _EXTERNAL, 
> SSE3)
>  #define EXTERNAL_SSSE3(flags)   CPUEXT_SUFFIX(flags, _EXTERNAL, SSSE3)
> +#define EXTERNAL_SSSE3_FAST(flags)  CPUEXT_SUFFIX_FAST(flags, _EXTERNAL, 
> SSSE3)
> +#define EXTERNAL_SSSE3_SLOW(flags)  CPUEXT_SUFFIX_SLOW(flags, _EXTERNAL, 
> SSSE3)
>  #define EXTERNAL_SSE4(flags)CPUEXT_SUFFIX(flags, _EXTERNAL, SSE4)
>  #define EXTERNAL_SSE42(flags)   CPUEXT_SUFFIX(flags, _EXTERNAL, SSE42)
>  #define EXTERNAL_AVX(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, AVX)
> @@ -82,6 +86,8 @@
>  #define INLINE_SSE3_FAST(flags) CPUEXT_SUFFIX_FAST(flags, _INLINE, SSE3)
>  #define INLINE_SSE3_SLOW(flags) CPUEXT_SUFFIX_SLOW(flags, _INLINE, SSE3)
>  #define INLINE_SSSE3(flags) CPUEXT_SUFFIX(flags, _INLINE, SSSE3)
> +#define INLINE_SSSE3_FAST(flags)CPUEXT_SUFFIX_FAST(flags, _INLINE, SSSE3)
> +#define INLINE_SSSE3_SLOW(flags)CPUEXT_SUFFIX_SLOW(flags, _INLINE, SSSE3)
>  #define INLINE_SSE4(flags)  CPUEXT_SUFFIX(flags, _INLINE, SSE4)
>  #define INLINE_SSE42(flags) CPUEXT_SUFFIX(flags, _INLINE, SSE42)
>  #define INLINE_AVX(flags)   CPUEXT_SUFFIX(flags, _INLINE, AVX)

ping on the set
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] movenc: check for the error in the AVIOContext and write

2016-03-19 Thread Vittorio Giovara
On Thu, Aug 27, 2015 at 7:20 AM, Luca Barbato  wrote:
> On 27/08/15 13:10, Martin Storsjö wrote:
>> On Thu, 27 Aug 2015, Alexandra Hájková wrote:
>>
>>> the error message if there is some error. MOV has its header
>>> at the end of the file so the output will be corrupted if
>>> writing to the output will fail before header is written.
>>
>> This isn't true for all mov modes, only the non-fragmented ones.
>>
>>> Bug-Id: 881
>>> ---
>>> libavformat/movenc.c | 5 +
>>> 1 file changed, 5 insertions(+)
>>>
>>> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
>>> index ee2f089..a6436e6 100644
>>> --- a/libavformat/movenc.c
>>> +++ b/libavformat/movenc.c
>>> @@ -3559,6 +3559,11 @@ int ff_mov_write_packet(AVFormatContext *s,
>>> AVPacket *pkt)
>>> if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams)
>>> ff_mov_add_hinted_packet(s, pkt, trk->hint_track, trk->entry,
>>>  reformatted_data, size);
>>> +if (pb->error < 0) {
>>> +av_log(s, AV_LOG_ERROR, "Error while writing mov packet, "
>>> +   "the output will be corrupted. \n");
>>
>> Stray space before the newline
>>
>>> +ret = pb->error;
>>> +}
>>
>> The message isn't completely true if mov->flags & FF_MOV_FLAG_FRAGMENT
>> is set. I guess it still makes sense to return the error code though,
>> but the file won't be corrupted, only truncated.
>>
>> Even though this might be important for fixing this particular bug,
>> wouldn't it make more sense to do this generically like in Sean's patch?
>> Does this add anything else than just the message?
>>
>
> I'd keep some error message mov-specific and have it also in the generic
> path (in which it would be less problematic).
>
> lu

Any update on this patch?
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] hevc: Parse the encoder info SEI

2016-03-19 Thread Vittorio Giovara
On Sat, Oct 17, 2015 at 6:25 PM, Luca Barbato  wrote:
> On 16/10/15 19:46, Anton Khirnov wrote:
>>
>> If the block above got executed, won't it attemp to skip it again?
>
>
> it starts skipping from whenever `i` was before, alternatively I can just
> process all the buffer and not just the first arbitrary amount of it.
>
> lu

Ping on this patch. I had a comment too that got lost

> +for (i = 0; i < sizeof(info) - 1 && i < size; i++) {
> +int byte = get_bits(gb, 8);
> +if (isprint(byte))
> +info[i] = byte;

this if is not useful, skipping a byte here will set info[i] to 0,
making it end the string on printing.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] asfdec: hadle invalid Object size properly

2016-03-19 Thread Vittorio Giovara
On Mon, Feb 8, 2016 at 3:12 PM, Vittorio Giovara
 wrote:
> On Tue, Jun 30, 2015 at 5:19 AM, Luca Barbato  wrote:
>> On 30/06/15 11:35, Alexandra Hájková wrote:
>>> ---
>>>  libavformat/asfdec.c | 12 ++--
>>>  1 file changed, 10 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
>>> index 8f46098..cf0b3a5 100644
>>> --- a/libavformat/asfdec.c
>>> +++ b/libavformat/asfdec.c
>>> @@ -904,7 +904,7 @@ static int asf_read_data(AVFormatContext *s, const 
>>> GUIDParseTable *g)
>>>  uint64_t size   = asf->data_size = avio_rl64(pb);
>>>  int i;
>>>
>>> -if (!asf->data_reached && pb->seekable) {
>>> +if (!asf->data_reached) {
>>>  asf->data_reached   = 1;
>>>  asf->data_offset= asf->offset;
>>>  }
>>> @@ -1660,7 +1660,15 @@ static int asf_read_header(AVFormatContext *s)
>>>  return ret;
>>>  } else {
>>>  size = avio_rl64(pb);
>>> -align_position(pb, asf->offset, size);
>>> +if (size < INT64_MAX)
>>> +align_position(pb, asf->offset, size);
>>> +else {
>>> +if (asf->data_reached) {
>>> +avio_seek(pb, asf->first_packet_offset, SEEK_SET);
>>> +break;
>>> +} else
>>> +return AVERROR_INVALIDDATA;
>>> +}
>>>  }
>>>  if (asf->data_reached && !pb->seekable)
>>>  break;
>>>
>>
>> Seems quite ok. I'd fix the subject with the missing n in handle and
>> push later.
>
> What happened to this patch? Is it still needed?

ping
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] libavcodec/util: Fix timebase overflow check

2016-03-19 Thread Vittorio Giovara
On Wed, Jan 27, 2016 at 5:19 PM, Derek Buitenhuis
 wrote:
> On 1/27/2016 10:16 PM, Luca Barbato wrote:
>> When it is zero? (isn't there a check before to sanitize the time_base ?)
>
> I only see a check for audio.

What happened to this patch?
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] avconv: Move the reporting in a separate thread

2016-03-19 Thread Vittorio Giovara
On Thu, Feb 4, 2016 at 7:07 AM, Luca Barbato  wrote:
> On 04/02/16 12:52, Vittorio Giovara wrote:
>> is this still needed?
>
> Yes, I'll send and update on this Friday.
>
> lu

I might have forgotten to check, and couldn't find it in the tree,
where is the new version?
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] diracdec: Move strides to bytes, and pointer types to uint8_t.

2016-03-19 Thread Vittorio Giovara
On Sun, Dec 6, 2015 at 8:57 AM, Diego Biurrun  wrote:
> On Sun, Dec 06, 2015 at 12:36:24PM +, Kieran Kunhya wrote:
>> Start templating functions for move to support 10-bit
>> Parts of this patch were written by Rostislav Pehlivanov
>> --- a/libavcodec/diracdec.c
>> +++ b/libavcodec/diracdec.c
>> @@ -507,6 +479,38 @@ static inline int coeff_unpack_golomb(GetBitContext 
>> *gb, int qfactor, int qoffse
>>  return coeff;
>>  }
>>
>> +#define UNPACK_ARITH(n, type) \
>> +static inline void coeff_unpack_arith_##n(DiracArith *c, int qfactor, 
>> int qoffset, \
>> +  SubBand *b, type *buf, int x, 
>> int y) \
>
> I'd suggest dropping the indentation here, we do that for function macros
> in other places.
>
>> @@ -554,41 +558,69 @@ static inline void codeblock(DiracContext *s, SubBand 
>> *b,
>>
>> +#define PARSE_VALUES(type, gb, ebits, buf1, buf2) \
>
> This is used much later (~250 lines), I'd move it directly above its usage.
>
>> +*(type *)buf1 = coeff_unpack_golomb(gb, qfactor, qoffset); \
>
> Ugh, pointer type punning :-/
>
> Diego

ping
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] opus_silk: fix out of array read in silk_lsf2lpc

2016-03-19 Thread Vittorio Giovara
On Sat, Mar 19, 2016 at 4:44 PM, Vittorio Giovara
 wrote:
> On Tue, Dec 15, 2015 at 4:41 PM, Andreas Cadhalpun
>  wrote:
>> On 15.12.2015 08:17, Anton Khirnov wrote:
>>> Can you share the sample that shows the problem?
>>
>> I could, but it's of no use for comparing with libopus, because their
>> decoder errors out in an unrelated check.
>>
>>> From what I can see, libopus does not do any clipping at that point, so
>>> something else must ensure that there is no overflow.
>>
>> Indeed, the real problem is just a silly typo...
>> It might have been caused by the fact that the specification uses
>> i and k in exactly the opposite way than the code.
>>
>> New patch attached.
>
> This patch might have been forgotten, ping reviewers.
> --
> Vittorio

never mind, found it (17776638c392d104975aba169e17b186490e1d5e)
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] avio: Add avio_check2

2016-03-19 Thread Vittorio Giovara
On Thu, Feb 4, 2016 at 6:56 AM, Vittorio Giovara
 wrote:
> On Sun, Nov 8, 2015 at 5:12 PM, Luca Barbato  wrote:
>> On 08/11/15 16:43, Anton Khirnov wrote:
>>> Ok, now that sounds like a real use case. But that's really only applies
>>> to img2dec (which is itself a hack that should go away eventually, but I
>>> digress), not to avconv. So, unless there are other arguments, I would
>>> keep this private.
>>
>> We should deprecate avio_check or warn that it works only for files then.
>>
>> lu
>
> what happened to this?

ping
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/3] x264: Optionally forward the input frame type

2016-03-19 Thread Vittorio Giovara
On Sat, Feb 6, 2016 at 6:02 AM, Luca Barbato  wrote:
> On 04/02/16 13:09, Vittorio Giovara wrote:
>> On Tue, Sep 1, 2015 at 12:50 AM, Luca Barbato  wrote:
>>> On 31/08/15 20:55, Anton Khirnov wrote:
 Looks like a hack to me. If you don't want to force the frame type,
 just don't set it.
>>>
>>> So I should move that on an option that does selectively forward only
>>> some kind of the information... Feasible I guess.
>>>
>>> lu
>>
>> any update on this?
>>
>
> I'll rethink that later I guess.

ping
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] opus_silk: fix out of array read in silk_lsf2lpc

2016-03-19 Thread Vittorio Giovara
On Tue, Dec 15, 2015 at 4:41 PM, Andreas Cadhalpun
 wrote:
> On 15.12.2015 08:17, Anton Khirnov wrote:
>> Can you share the sample that shows the problem?
>
> I could, but it's of no use for comparing with libopus, because their
> decoder errors out in an unrelated check.
>
>> From what I can see, libopus does not do any clipping at that point, so
>> something else must ensure that there is no overflow.
>
> Indeed, the real problem is just a silly typo...
> It might have been caused by the fact that the specification uses
> i and k in exactly the opposite way than the code.
>
> New patch attached.

This patch might have been forgotten, ping reviewers.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] rtsp: Factor out the rtp stream opening

2016-03-19 Thread Vittorio Giovara
On Thu, Feb 4, 2016 at 7:08 AM, Luca Barbato  wrote:
> On 04/02/16 12:54, Vittorio Giovara wrote:
>
>> is this still needed?
>>
>
> Yes.

so.. any reason it's not pushed?
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 6/7] avio: Disable incompatible pointer type warnings

2016-03-19 Thread Vittorio Giovara
On Sat, Feb 6, 2016 at 6:09 AM, Luca Barbato  wrote:
> On 04/02/16 13:04, Vittorio Giovara wrote:
>> On Thu, Nov 26, 2015 at 5:17 PM, Luca Barbato  wrote:
>>> ---
>>>  libavformat/avio.c | 3 +++
>>>  1 file changed, 3 insertions(+)
>>>
>>> diff --git a/libavformat/avio.c b/libavformat/avio.c
>>> index ff740a2..359371c 100644
>>> --- a/libavformat/avio.c
>>> +++ b/libavformat/avio.c
>>> @@ -21,6 +21,7 @@
>>>
>>>  #include "libavutil/avstring.h"
>>>  #include "libavutil/dict.h"
>>> +#include "libavutil/internal.h"
>>>  #include "libavutil/opt.h"
>>>  #include "libavutil/time.h"
>>>  #include "os_support.h"
>>> @@ -281,9 +282,11 @@ int ffurl_write(URLContext *h, const unsigned char 
>>> *buf, int size)
>>>  if (h->max_packet_size && size > h->max_packet_size)
>>>  return AVERROR(EIO);
>>>
>>> +FF_DISABLE_POINTER_TYPES_WARNINGS
>>>  return retry_transfer_wrapper(h, buf, size, size,
>>>(int (*)(struct URLContext *, uint8_t *, 
>>> int))
>>>h->prot->url_write);
>>> +FF_ENABLE_POINTER_TYPES_WARNINGS
>>>  }
>>>
>>>  int64_t ffurl_seek(URLContext *h, int64_t pos, int whence)
>>> --
>>> 2.6.1
>>
>> what happened to this set?
>>
>
> Diego took it over.

ping I guess
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] h264: Use isprint to sanitize the SEI debug message

2016-03-19 Thread Vittorio Giovara
On Sat, Feb 6, 2016 at 3:22 PM, Luca Barbato  wrote:
> On 06/02/16 19:39, Henrik Gramner wrote:
>> On Sat, Feb 6, 2016 at 7:34 PM, Luca Barbato  wrote:
>>> Give how this function is used it is not really important, its purpose
>>> is to not break the terminal printing garbage.
>>
>> That's true I guess.
>>
>>> Do you have time to get me a function that is local independent?
>>
>> static inline av_const int av_isprint(int c)
>> {
>> return c > 31 && c < 127;
>> }
>
> fine for me =) Anybody has a different preference?

Any status update for this patch? If not, it could be probably applied.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mpegts: Forward the errors on mpeg4 objects parsing

2016-03-19 Thread Vittorio Giovara
On Tue, Feb 16, 2016 at 8:23 PM, Luca Barbato  wrote:
> ---
>  libavformat/mpegts.c | 25 -
>  1 file changed, 16 insertions(+), 9 deletions(-)

This patch is approved but not applied, what's the hold up?
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 4/8] opt: Add const to av_opt_next

2016-03-19 Thread Martin Storsjö
From: Lukasz Marek 

Also add const to pointers in static functions within opt.c where
possible/necessary.
---
Now adding it immediately instead of after the next bump, added a
micro bump.
---
 libavutil/opt.c | 4 ++--
 libavutil/opt.h | 2 +-
 libavutil/version.h | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index b3435e0..d816faa 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -34,7 +34,7 @@
 #include "log.h"
 #include "mathematics.h"
 
-const AVOption *av_opt_next(void *obj, const AVOption *last)
+const AVOption *av_opt_next(const void *obj, const AVOption *last)
 {
 AVClass *class = *(AVClass**)obj;
 if (!last && class->option && class->option[0].name)
@@ -44,7 +44,7 @@ const AVOption *av_opt_next(void *obj, const AVOption *last)
 return NULL;
 }
 
-static int read_number(const AVOption *o, void *dst, double *num, int *den, 
int64_t *intnum)
+static int read_number(const AVOption *o, const void *dst, double *num, int 
*den, int64_t *intnum)
 {
 switch (o->type) {
 case AV_OPT_TYPE_FLAGS: *intnum = *(unsigned int*)dst;return 0;
diff --git a/libavutil/opt.h b/libavutil/opt.h
index 8413206..99d727c 100644
--- a/libavutil/opt.h
+++ b/libavutil/opt.h
@@ -448,7 +448,7 @@ const AVOption *av_opt_find2(void *obj, const char *name, 
const char *unit,
  * or NULL
  * @return next AVOption or NULL
  */
-const AVOption *av_opt_next(void *obj, const AVOption *prev);
+const AVOption *av_opt_next(const void *obj, const AVOption *prev);
 
 /**
  * Iterate over AVOptions-enabled children of obj.
diff --git a/libavutil/version.h b/libavutil/version.h
index ebd548f..612dc46 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -55,7 +55,7 @@
 
 #define LIBAVUTIL_VERSION_MAJOR 55
 #define LIBAVUTIL_VERSION_MINOR  6
-#define LIBAVUTIL_VERSION_MICRO  0
+#define LIBAVUTIL_VERSION_MICRO  1
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
-- 
2.5.4 (Apple Git-61)

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 2/8] avio: Add an option 'rw_timeout'

2016-03-19 Thread Martin Storsjö
From: Andrey Utkin 

If set non-zero, this limits duration of the retry_transfer_wrapper()
loop, thus affecting ffurl_read*(), ffurl_write(). As soon as
one single byte is successfully received/transmitted, the timer
restarts.

This has further changes by Michael Niedermayer and Martin Storsjö.
---
Andrey's original version didn't reset the timer on successful
transfers, but I think this is closer to how most people may
want it to work.

I also added an AVOption for setting this, to allow it to be set
generically for any URLProtocol.

Changes since last round: Fixed the unit name in the doxy, added
an entry to protcols.texi, added a micro bump.
---
 doc/protocols.texi|  8 
 libavformat/avio.c| 21 +
 libavformat/url.h |  1 +
 libavformat/version.h |  2 +-
 4 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/doc/protocols.texi b/doc/protocols.texi
index f30567d..c0663ac 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -17,6 +17,14 @@ particular protocol using the option
 The option "-protocols" of the av* tools will display the list of
 supported protocols.
 
+All protocols accept the following options:
+
+@table @option
+@item rw_timeout
+Maximum time to wait for (network) read/write operations to complete,
+in microseconds.
+@end table
+
 A description of the currently available protocols follows.
 
 @section concat
diff --git a/libavformat/avio.c b/libavformat/avio.c
index 4da6b74..6039990 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -49,7 +49,10 @@ static void *urlcontext_child_next(void *obj, void *prev)
 return NULL;
 }
 
-static const AVOption options[] = { { NULL } };
+static const AVOption options[] = {
+{ "rw_timeout", "Timeout for IO operations (in microseconds)", 
offsetof(URLContext, rw_timeout), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, 
INT64_MAX, AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_DECODING_PARAM },
+{ NULL }
+};
 const AVClass ffurl_context_class = {
 .class_name   = "URLContext",
 .item_name= urlcontext_to_name,
@@ -199,6 +202,7 @@ static inline int retry_transfer_wrapper(URLContext *h, 
uint8_t *buf,
 {
 int ret, len;
 int fast_retries = 5;
+int64_t wait_since = 0;
 
 len = 0;
 while (len < size_min) {
@@ -209,14 +213,23 @@ static inline int retry_transfer_wrapper(URLContext *h, 
uint8_t *buf,
 return ret;
 if (ret == AVERROR(EAGAIN)) {
 ret = 0;
-if (fast_retries)
+if (fast_retries) {
 fast_retries--;
-else
+} else {
+if (h->rw_timeout) {
+if (!wait_since)
+wait_since = av_gettime_relative();
+else if (av_gettime_relative() > wait_since + 
h->rw_timeout)
+return AVERROR(EIO);
+}
 av_usleep(1000);
+}
 } else if (ret < 1)
 return (ret < 0 && ret != AVERROR_EOF) ? ret : len;
-if (ret)
+if (ret) {
 fast_retries = FFMAX(fast_retries, 2);
+wait_since = 0;
+}
 len += ret;
 if (ff_check_interrupt(&h->interrupt_callback))
 return AVERROR_EXIT;
diff --git a/libavformat/url.h b/libavformat/url.h
index 482658b..408c674 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -49,6 +49,7 @@ typedef struct URLContext {
 int is_streamed;/**< true if streamed (no seek possible), 
default = false */
 int is_connected;
 AVIOInterruptCB interrupt_callback;
+int64_t rw_timeout; /**< maximum time to wait for (network) 
read/write operation completion, in microseconds */
 } URLContext;
 
 typedef struct URLProtocol {
diff --git a/libavformat/version.h b/libavformat/version.h
index f264076..75d765b 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -31,7 +31,7 @@
 
 #define LIBAVFORMAT_VERSION_MAJOR 57
 #define LIBAVFORMAT_VERSION_MINOR  5
-#define LIBAVFORMAT_VERSION_MICRO  0
+#define LIBAVFORMAT_VERSION_MICRO  1
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
-- 
2.5.4 (Apple Git-61)

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 5/8] opt: Add av_opt_copy()

2016-03-19 Thread Martin Storsjö
From: Michael Niedermayer 

This includes documentation and other modifications by
Lukasz Marek and Martin Storsjö.
---
Changed things according to Anton's suggestions.
---
 doc/APIchanges  |  3 +++
 libavutil/opt.c | 66 +
 libavutil/opt.h | 13 +++
 libavutil/version.h |  4 ++--
 4 files changed, 84 insertions(+), 2 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 20fecb9..aa6f004 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil: 2015-08-28
 
 API changes, most recent first:
 
+2016-xx-xx - xxx - lavu 55.7.0 - opt.h
+  Add av_opt_copy().
+
 2016-02-23 - 9200514 - lavf 57.5.0 - avformat.h
   Add AVStream.codecpar, deprecate AVStream.codec.
 
diff --git a/libavutil/opt.c b/libavutil/opt.c
index d816faa..104dd63 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -757,6 +757,72 @@ const AVClass *av_opt_child_class_next(const AVClass 
*parent, const AVClass *pre
 return NULL;
 }
 
+static int opt_size(enum AVOptionType type)
+{
+switch(type) {
+case AV_OPT_TYPE_INT:
+case AV_OPT_TYPE_FLAGS: return sizeof(int);
+case AV_OPT_TYPE_INT64: return sizeof(int64_t);
+case AV_OPT_TYPE_DOUBLE:return sizeof(double);
+case AV_OPT_TYPE_FLOAT: return sizeof(float);
+case AV_OPT_TYPE_STRING:return sizeof(uint8_t*);
+case AV_OPT_TYPE_RATIONAL:  return sizeof(AVRational);
+case AV_OPT_TYPE_BINARY:return sizeof(uint8_t*) + sizeof(int);
+}
+return AVERROR(EINVAL);
+}
+
+int av_opt_copy(void *dst, const void *src)
+{
+const AVOption *o = NULL;
+const AVClass *c;
+int ret = 0;
+
+if (!src)
+return AVERROR(EINVAL);
+
+c = *(AVClass**)src;
+if (!c || c != *(AVClass**)dst)
+return AVERROR(EINVAL);
+
+while ((o = av_opt_next(src, o))) {
+void *field_dst = ((uint8_t*)dst) + o->offset;
+void *field_src = ((uint8_t*)src) + o->offset;
+uint8_t **field_dst8 = (uint8_t**)field_dst;
+uint8_t **field_src8 = (uint8_t**)field_src;
+
+if (o->type == AV_OPT_TYPE_STRING) {
+set_string(dst, o, *field_src8, field_dst8);
+if (*field_src8 && !*field_dst8)
+ret = AVERROR(ENOMEM);
+} else if (o->type == AV_OPT_TYPE_BINARY) {
+int len = *(int*)(field_src8 + 1);
+if (*field_dst8 != *field_src8)
+av_freep(field_dst8);
+if (len) {
+*field_dst8 = av_malloc(len);
+if (!*field_dst8) {
+ret = AVERROR(ENOMEM);
+len = 0;
+}
+memcpy(*field_dst8, *field_src8, len);
+} else {
+*field_dst8 = NULL;
+}
+*(int*)(field_dst8 + 1) = len;
+} else if (o->type == AV_OPT_TYPE_CONST) {
+// do nothing
+} else {
+int size = opt_size(o->type);
+if (size < 0)
+ret = size;
+else
+memcpy(field_dst, field_src, size);
+}
+}
+return ret;
+}
+
 #ifdef TEST
 
 typedef struct TestContext
diff --git a/libavutil/opt.h b/libavutil/opt.h
index 99d727c..906b869 100644
--- a/libavutil/opt.h
+++ b/libavutil/opt.h
@@ -530,6 +530,19 @@ int av_opt_get_q   (void *obj, const char *name, int 
search_flags, AVRationa
  * be freed with av_dict_free() by the caller
  */
 int av_opt_get_dict_val(void *obj, const char *name, int search_flags, 
AVDictionary **out_val);
+
+/**
+ * Copy options from src object into dest object.
+ *
+ * Options that require memory allocation (e.g. string or binary) are 
malloc'ed in dest object.
+ * Original memory allocated for such options is freed unless both src and 
dest options points to the same memory.
+ *
+ * @param dest Object to copy from
+ * @param src  Object to copy into
+ * @return 0 on success, negative on error
+ */
+int av_opt_copy(void *dest, const void *src);
+
 /**
  * @}
  * @}
diff --git a/libavutil/version.h b/libavutil/version.h
index 612dc46..b102e93 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -54,8 +54,8 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR 55
-#define LIBAVUTIL_VERSION_MINOR  6
-#define LIBAVUTIL_VERSION_MICRO  1
+#define LIBAVUTIL_VERSION_MINOR  7
+#define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
-- 
2.5.4 (Apple Git-61)

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 6/8] RFC: avio: Copy URLContext generic options into child URLContexts

2016-03-19 Thread Martin Storsjö

On Sat, 19 Mar 2016, Martin Storsjö wrote:


Since all URLContexts have the same AVOptions, such AVOptions
will be applied on the outermost context only and removed from the
dict, while they probably make sense on all contexts.

This makes sure that rw_timeout gets propagated to the innermost
URLContext (to make sure it gets passed to the tcp protocol, when
opening a http connection for instance).

Alternatively, such matching options would be kept in the dict
and only removed after the ffurl_connect call.
---
Unchanged, approved in the previous round.


I forgot to amend the commit message, this is no longer an RFC.

// Martin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 7/8] tcp: Use rw_timeout for setting the connect/listen timeouts

2016-03-19 Thread Martin Storsjö
Apply the default value for timeout in code instead of via the
avoption, to allow distinguishing the default value from the user
not setting anything at all.
---
Previously approved.
---
 libavformat/tcp.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index f211142..1498c26 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -43,7 +43,7 @@ typedef struct TCPContext {
 #define E AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
 { "listen",  "Listen for incoming connections",  OFFSET(listen),   
  AV_OPT_TYPE_INT, { .i64 = 0 }, 0,   1,   .flags = D|E },
-{ "timeout", "Connection timeout (in milliseconds)", 
OFFSET(timeout),AV_OPT_TYPE_INT, { .i64 = 1 }, INT_MIN, INT_MAX, .flags 
= D|E },
+{ "timeout", "Connection timeout (in milliseconds)", 
OFFSET(timeout),AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, .flags = 
D|E },
 { "listen_timeout",  "Bind timeout (in milliseconds)",   
OFFSET(listen_timeout), AV_OPT_TYPE_INT, { .i64 = -1 },INT_MIN, INT_MAX, 
.flags = D|E },
 { NULL }
 };
@@ -86,6 +86,10 @@ static int tcp_open(URLContext *h, const char *uri, int 
flags)
 s->listen_timeout = strtol(buf, NULL, 10);
 }
 }
+if (!s->timeout)
+s->timeout = h->rw_timeout ? h->rw_timeout / 1000 : 1;
+if (h->rw_timeout && s->listen_timeout < 0)
+s->listen_timeout = h->rw_timeout / 1000;
 hints.ai_family = AF_UNSPEC;
 hints.ai_socktype = SOCK_STREAM;
 snprintf(portstr, sizeof(portstr), "%d", port);
-- 
2.5.4 (Apple Git-61)

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 3/8] file: Add an option for following a file that is being written

2016-03-19 Thread Martin Storsjö
Using this requires setting the rw_timeout option to make it
terminate, alternatively using the interrupt callback (if used via
the API).
---
Added documentation, added a micro bump.
---
 doc/protocols.texi| 11 +++
 libavformat/file.c|  4 
 libavformat/version.h |  2 +-
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/doc/protocols.texi b/doc/protocols.texi
index c0663ac..c136c74 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -69,6 +69,17 @@ The av* tools default to the file protocol, that is a 
resource
 specified with the name "FILE.mpeg" is interpreted as the URL
 "file:FILE.mpeg".
 
+This protocol accepts the following options:
+
+@table @option
+@item follow
+If set to 1, the protocol will retry reading at the end of the file, allowing
+reading files that still are being written. In order for this to terminate,
+you either need to use the rw_timeout option, or use the interrupt callback
+(for API users).
+
+@end table
+
 @section gopher
 
 Gopher protocol.
diff --git a/libavformat/file.c b/libavformat/file.c
index 4f581cf..8683c1b 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -42,10 +42,12 @@ typedef struct FileContext {
 const AVClass *class;
 int fd;
 int trunc;
+int follow;
 } FileContext;
 
 static const AVOption file_options[] = {
 { "truncate", "Truncate existing files on write", offsetof(FileContext, 
trunc), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
+{ "follow", "Follow a file as it is being written", offsetof(FileContext, 
follow), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM },
 { NULL }
 };
 
@@ -60,6 +62,8 @@ static int file_read(URLContext *h, unsigned char *buf, int 
size)
 {
 FileContext *c = h->priv_data;
 int ret = read(c->fd, buf, size);
+if (ret == 0 && c->follow)
+return AVERROR(EAGAIN);
 return (ret == -1) ? AVERROR(errno) : ret;
 }
 
diff --git a/libavformat/version.h b/libavformat/version.h
index 75d765b..aae1e23 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -31,7 +31,7 @@
 
 #define LIBAVFORMAT_VERSION_MAJOR 57
 #define LIBAVFORMAT_VERSION_MINOR  5
-#define LIBAVFORMAT_VERSION_MICRO  1
+#define LIBAVFORMAT_VERSION_MICRO  2
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
-- 
2.5.4 (Apple Git-61)

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 1/8] avio: Apply avoptions on the URLContext itself as well

2016-03-19 Thread Martin Storsjö
Currently the list of avoptions for URLContext is empty though,
but such options will be added.
---
This one didn't receive any comments in the previous round.
---
 libavformat/avio.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/avio.c b/libavformat/avio.c
index 668e5ea..4da6b74 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -176,6 +176,9 @@ int ffurl_open(URLContext **puc, const char *filename, int 
flags,
 int ret = ffurl_alloc(puc, filename, flags, int_cb, protocols);
 if (ret)
 return ret;
+if (options &&
+(ret = av_opt_set_dict(*puc, options)) < 0)
+goto fail;
 if (options && (*puc)->prot->priv_data_class &&
 (ret = av_opt_set_dict((*puc)->priv_data, options)) < 0)
 goto fail;
-- 
2.5.4 (Apple Git-61)

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 8/8] unix: Use rw_timeout for setting the connect timeout

2016-03-19 Thread Martin Storsjö
---
Previously approved.
---
 libavformat/unix.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/unix.c b/libavformat/unix.c
index 6bb677d..647e7e8 100644
--- a/libavformat/unix.c
+++ b/libavformat/unix.c
@@ -73,6 +73,9 @@ static int unix_open(URLContext *h, const char *filename, int 
flags)
 if ((fd = ff_socket(AF_UNIX, s->type, 0)) < 0)
 return ff_neterrno();
 
+if (s->timeout < 0 && h->rw_timeout)
+s->timeout = h->rw_timeout / 1000;
+
 if (s->listen) {
 ret = ff_listen_bind(fd, (struct sockaddr *)&s->addr,
  sizeof(s->addr), s->timeout, h);
-- 
2.5.4 (Apple Git-61)

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 6/8] RFC: avio: Copy URLContext generic options into child URLContexts

2016-03-19 Thread Martin Storsjö
Since all URLContexts have the same AVOptions, such AVOptions
will be applied on the outermost context only and removed from the
dict, while they probably make sense on all contexts.

This makes sure that rw_timeout gets propagated to the innermost
URLContext (to make sure it gets passed to the tcp protocol, when
opening a http connection for instance).

Alternatively, such matching options would be kept in the dict
and only removed after the ffurl_connect call.
---
Unchanged, approved in the previous round.
---
 libavformat/avio.c   |  5 -
 libavformat/aviobuf.c|  2 +-
 libavformat/concat.c |  2 +-
 libavformat/crypto.c |  2 +-
 libavformat/gopher.c |  2 +-
 libavformat/hlsproto.c   |  2 +-
 libavformat/http.c   |  4 ++--
 libavformat/icecast.c|  2 +-
 libavformat/md5proto.c   |  2 +-
 libavformat/mmst.c   |  2 +-
 libavformat/rtmpcrypt.c  |  2 +-
 libavformat/rtmpproto.c  |  4 ++--
 libavformat/rtpproto.c   |  4 ++--
 libavformat/rtsp.c   | 10 +-
 libavformat/rtspdec.c|  4 ++--
 libavformat/sapdec.c |  2 +-
 libavformat/sapenc.c |  4 ++--
 libavformat/smoothstreamingenc.c |  6 +++---
 libavformat/srtpproto.c  |  2 +-
 libavformat/tls.c|  2 +-
 libavformat/url.h|  4 +++-
 21 files changed, 37 insertions(+), 32 deletions(-)

diff --git a/libavformat/avio.c b/libavformat/avio.c
index 6039990..1692f1b 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -174,11 +174,14 @@ int ffurl_alloc(URLContext **puc, const char *filename, 
int flags,
 
 int ffurl_open(URLContext **puc, const char *filename, int flags,
const AVIOInterruptCB *int_cb, AVDictionary **options,
-   const URLProtocol **protocols)
+   const URLProtocol **protocols,
+   URLContext *parent)
 {
 int ret = ffurl_alloc(puc, filename, flags, int_cb, protocols);
 if (ret)
 return ret;
+if (parent)
+av_opt_copy(*puc, parent);
 if (options &&
 (ret = av_opt_set_dict(*puc, options)) < 0)
 goto fail;
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index a2edb74..29fccbe 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -905,7 +905,7 @@ int avio_open2(AVIOContext **s, const char *filename, int 
flags,
 if (!protocols)
 return AVERROR(ENOMEM);
 
-err = ffurl_open(&h, filename, flags, int_cb, options, protocols);
+err = ffurl_open(&h, filename, flags, int_cb, options, protocols, NULL);
 if (err < 0) {
 av_freep(&protocols);
 return err;
diff --git a/libavformat/concat.c b/libavformat/concat.c
index ecdf5df..a338df6 100644
--- a/libavformat/concat.c
+++ b/libavformat/concat.c
@@ -95,7 +95,7 @@ static av_cold int concat_open(URLContext *h, const char 
*uri, int flags)
 
 /* creating URLContext */
 if ((err = ffurl_open(&uc, node_uri, flags,
-  &h->interrupt_callback, NULL, h->protocols)) < 0)
+  &h->interrupt_callback, NULL, h->protocols, h)) 
< 0)
 break;
 
 /* creating size */
diff --git a/libavformat/crypto.c b/libavformat/crypto.c
index a364dc0..55430c4 100644
--- a/libavformat/crypto.c
+++ b/libavformat/crypto.c
@@ -83,7 +83,7 @@ static int crypto_open(URLContext *h, const char *uri, int 
flags)
 goto err;
 }
 if ((ret = ffurl_open(&c->hd, nested_url, AVIO_FLAG_READ,
-  &h->interrupt_callback, NULL, h->protocols)) < 0) {
+  &h->interrupt_callback, NULL, h->protocols, h)) < 0) 
{
 av_log(h, AV_LOG_ERROR, "Unable to open input\n");
 goto err;
 }
diff --git a/libavformat/gopher.c b/libavformat/gopher.c
index afa2b7d..6d9fc38 100644
--- a/libavformat/gopher.c
+++ b/libavformat/gopher.c
@@ -94,7 +94,7 @@ static int gopher_open(URLContext *h, const char *uri, int 
flags)
 
 s->hd = NULL;
 err = ffurl_open(&s->hd, buf, AVIO_FLAG_READ_WRITE,
- &h->interrupt_callback, NULL, h->protocols);
+ &h->interrupt_callback, NULL, h->protocols, h);
 if (err < 0)
 goto fail;
 
diff --git a/libavformat/hlsproto.c b/libavformat/hlsproto.c
index b01cef0..4c3048a 100644
--- a/libavformat/hlsproto.c
+++ b/libavformat/hlsproto.c
@@ -304,7 +304,7 @@ retry:
 url = s->segments[s->cur_seq_no - s->start_seq_no]->url,
 av_log(h, AV_LOG_DEBUG, "opening %s\n", url);
 ret = ffurl_open(&s->seg_hd, url, AVIO_FLAG_READ,
- &h->interrupt_callback, NULL, h->protocols);
+ &h->interrupt_callback, NULL, h->protocols, h);
 if (ret < 0) {
 if (ff_check_interrupt(&h->interrupt_callback))
 return AVERROR_EXIT;
diff --git a/libavformat/http.c b/libavformat/http.c
index 4830390..8fe8d11 100644
---

Re: [libav-devel] [PATCH 5/8] opt: Add av_opt_copy()

2016-03-19 Thread Martin Storsjö

On Sat, 19 Mar 2016, Anton Khirnov wrote:


Quoting Martin Storsjö (2016-03-19 20:01:15)

On Sat, 19 Mar 2016, Anton Khirnov wrote:

> Quoting Martin Storsjö (2016-03-18 13:01:39)
>> From: Michael Niedermayer 
>> 
>> This includes documentation and other modifications by

>> Lukasz Marek.
>> ---
>>  doc/APIchanges  |  3 +++
>>  libavutil/opt.c | 58 
+
>>  libavutil/opt.h | 13 
>>  libavutil/version.h |  2 +-
>>  4 files changed, 75 insertions(+), 1 deletion(-)
>> 
>> diff --git a/doc/APIchanges b/doc/APIchanges

>> index 20fecb9..aa6f004 100644
>> --- a/doc/APIchanges
>> +++ b/doc/APIchanges
>> @@ -13,6 +13,9 @@ libavutil: 2015-08-28
>>
>>  API changes, most recent first:
>> 
>> +2016-xx-xx - xxx - lavu 55.7.0 - opt.h

>> +  Add av_opt_copy().
>> +
>>  2016-02-23 - 9200514 - lavf 57.5.0 - avformat.h
>>Add AVStream.codecpar, deprecate AVStream.codec.
>> 
>> diff --git a/libavutil/opt.c b/libavutil/opt.c

>> index 5825a72..75e8970 100644
>> --- a/libavutil/opt.c
>> +++ b/libavutil/opt.c
>> @@ -757,6 +757,64 @@ const AVClass *av_opt_child_class_next(const AVClass 
*parent, const AVClass *pre
>>  return NULL;
>>  }
>> 
>> +static int opt_size(enum AVOptionType type)

>> +{
>> +switch(type) {
>> +case AV_OPT_TYPE_INT:
>> +case AV_OPT_TYPE_FLAGS: return sizeof(int);
>> +case AV_OPT_TYPE_INT64: return sizeof(int64_t);
>> +case AV_OPT_TYPE_DOUBLE:return sizeof(double);
>> +case AV_OPT_TYPE_FLOAT: return sizeof(float);
>> +case AV_OPT_TYPE_STRING:return sizeof(uint8_t*);
>> +case AV_OPT_TYPE_RATIONAL:  return sizeof(AVRational);
>> +case AV_OPT_TYPE_BINARY:return sizeof(uint8_t*) + sizeof(int);
>> +}
>> +return 0;
>
> This should return an error that should be checked by the caller.

Sure

>> +}
>> +
>> +int av_opt_copy(void *dst, const void *src)
>> +{
>> +const AVOption *o = NULL;
>> +const AVClass *c;
>> +int ret = 0;
>> +
>> +if (!src)
>> +return 0;
>
> I'm not sure about this, it looks invalid.

Invalid in which sense? That this function shouldn't ever have to care 
about that case, that it should be the caller's duty to never try that?


Either that, or keep the check but return an error. But behaving as if
everything went fine does not look right to me.


Sure, I'll change it into AVERROR(EINVAL)



>> +
>> +c = *(AVClass**)src;
>> +if (*(AVClass**)dst && c != *(AVClass**)dst)
>
> Why the first check? dst is assumed to be non-NULL anyway, and if it is
> NULL, the code lower down will explode.

It's not about whether dst is null or not, but whether the AVClass pointer 
in dst has been set or not. If it hasn't been set, we don't need to see if 
it matches the source class.


Ah right, I cannot read. But then if it's NULL it continues normally?
That also seems wrong.


Sure, I'll change it to require dst to be set to the same as src, and both 
to be non-null.


// Martin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 5/8] opt: Add av_opt_copy()

2016-03-19 Thread Anton Khirnov
Quoting Martin Storsjö (2016-03-19 20:01:15)
> On Sat, 19 Mar 2016, Anton Khirnov wrote:
> 
> > Quoting Martin Storsjö (2016-03-18 13:01:39)
> >> From: Michael Niedermayer 
> >> 
> >> This includes documentation and other modifications by
> >> Lukasz Marek.
> >> ---
> >>  doc/APIchanges  |  3 +++
> >>  libavutil/opt.c | 58 
> >> +
> >>  libavutil/opt.h | 13 
> >>  libavutil/version.h |  2 +-
> >>  4 files changed, 75 insertions(+), 1 deletion(-)
> >> 
> >> diff --git a/doc/APIchanges b/doc/APIchanges
> >> index 20fecb9..aa6f004 100644
> >> --- a/doc/APIchanges
> >> +++ b/doc/APIchanges
> >> @@ -13,6 +13,9 @@ libavutil: 2015-08-28
> >>
> >>  API changes, most recent first:
> >> 
> >> +2016-xx-xx - xxx - lavu 55.7.0 - opt.h
> >> +  Add av_opt_copy().
> >> +
> >>  2016-02-23 - 9200514 - lavf 57.5.0 - avformat.h
> >>Add AVStream.codecpar, deprecate AVStream.codec.
> >> 
> >> diff --git a/libavutil/opt.c b/libavutil/opt.c
> >> index 5825a72..75e8970 100644
> >> --- a/libavutil/opt.c
> >> +++ b/libavutil/opt.c
> >> @@ -757,6 +757,64 @@ const AVClass *av_opt_child_class_next(const AVClass 
> >> *parent, const AVClass *pre
> >>  return NULL;
> >>  }
> >> 
> >> +static int opt_size(enum AVOptionType type)
> >> +{
> >> +switch(type) {
> >> +case AV_OPT_TYPE_INT:
> >> +case AV_OPT_TYPE_FLAGS: return sizeof(int);
> >> +case AV_OPT_TYPE_INT64: return sizeof(int64_t);
> >> +case AV_OPT_TYPE_DOUBLE:return sizeof(double);
> >> +case AV_OPT_TYPE_FLOAT: return sizeof(float);
> >> +case AV_OPT_TYPE_STRING:return sizeof(uint8_t*);
> >> +case AV_OPT_TYPE_RATIONAL:  return sizeof(AVRational);
> >> +case AV_OPT_TYPE_BINARY:return sizeof(uint8_t*) + sizeof(int);
> >> +}
> >> +return 0;
> >
> > This should return an error that should be checked by the caller.
> 
> Sure
> 
> >> +}
> >> +
> >> +int av_opt_copy(void *dst, const void *src)
> >> +{
> >> +const AVOption *o = NULL;
> >> +const AVClass *c;
> >> +int ret = 0;
> >> +
> >> +if (!src)
> >> +return 0;
> >
> > I'm not sure about this, it looks invalid.
> 
> Invalid in which sense? That this function shouldn't ever have to care 
> about that case, that it should be the caller's duty to never try that?

Either that, or keep the check but return an error. But behaving as if
everything went fine does not look right to me.

> 
> >> +
> >> +c = *(AVClass**)src;
> >> +if (*(AVClass**)dst && c != *(AVClass**)dst)
> >
> > Why the first check? dst is assumed to be non-NULL anyway, and if it is
> > NULL, the code lower down will explode.
> 
> It's not about whether dst is null or not, but whether the AVClass pointer 
> in dst has been set or not. If it hasn't been set, we don't need to see if 
> it matches the source class.

Ah right, I cannot read. But then if it's NULL it continues normally?
That also seems wrong.


-- 
Anton Khirnov
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 4/8] opt: Add const to av_opt_next in the next major bump

2016-03-19 Thread Martin Storsjö

On Sat, 19 Mar 2016, Anton Khirnov wrote:


Quoting Martin Storsjö (2016-03-18 13:01:38)

From: Lukasz Marek 

Also add const to pointers in static functions within opt.c where
possible.
---
Or can we freely add const here without waiting for a major bump?
I don't see any case where adding const actually would break third
party code.


Maybe some c++ wrappers would complain about this?


I don't think so; C++ mainly dislikes implicit casts from void* to foo* 
(which is explicitly ok within C), but the const correctness is pretty 
similar in C++ and modern C.


// Martin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 6/8] RFC: avio: Copy URLContext generic options into child URLContexts

2016-03-19 Thread Martin Storsjö

On Sat, 19 Mar 2016, Anton Khirnov wrote:


Quoting Martin Storsjö (2016-03-18 13:01:40)

Since all URLContexts have the same AVOptions, such AVOptions
will be applied on the outermost context only and removed from the
dict, while they probably make sense on all contexts.

This makes sure that rw_timeout gets propagated to the innermost
URLContext (to make sure it gets passed to the tcp protocol, when
opening a http connection for instance).

Alternatively, such matching options would be kept in the dict
and only removed after the ffurl_connect call.
---
Suggestions on how to do this better are welcome.
---


FWIW this looks reasonable to me.


I'm not entirely happy about it, e.g. the fact that in most cases, you 
pass "h->protocols, h" as the last two parameters. But in e.g. rtsp.c, 
just passing the parent pointer wouldn't work. So I guess it's ok, in case 
you find it useful enough to pollute this function with yet another 
parameter.


// Martin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 5/8] opt: Add av_opt_copy()

2016-03-19 Thread Martin Storsjö

On Sat, 19 Mar 2016, Anton Khirnov wrote:


Quoting Martin Storsjö (2016-03-18 13:01:39)

From: Michael Niedermayer 

This includes documentation and other modifications by
Lukasz Marek.
---
 doc/APIchanges  |  3 +++
 libavutil/opt.c | 58 +
 libavutil/opt.h | 13 
 libavutil/version.h |  2 +-
 4 files changed, 75 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 20fecb9..aa6f004 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil: 2015-08-28

 API changes, most recent first:

+2016-xx-xx - xxx - lavu 55.7.0 - opt.h
+  Add av_opt_copy().
+
 2016-02-23 - 9200514 - lavf 57.5.0 - avformat.h
   Add AVStream.codecpar, deprecate AVStream.codec.

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 5825a72..75e8970 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -757,6 +757,64 @@ const AVClass *av_opt_child_class_next(const AVClass 
*parent, const AVClass *pre
 return NULL;
 }

+static int opt_size(enum AVOptionType type)
+{
+switch(type) {
+case AV_OPT_TYPE_INT:
+case AV_OPT_TYPE_FLAGS: return sizeof(int);
+case AV_OPT_TYPE_INT64: return sizeof(int64_t);
+case AV_OPT_TYPE_DOUBLE:return sizeof(double);
+case AV_OPT_TYPE_FLOAT: return sizeof(float);
+case AV_OPT_TYPE_STRING:return sizeof(uint8_t*);
+case AV_OPT_TYPE_RATIONAL:  return sizeof(AVRational);
+case AV_OPT_TYPE_BINARY:return sizeof(uint8_t*) + sizeof(int);
+}
+return 0;


This should return an error that should be checked by the caller.


Sure


+}
+
+int av_opt_copy(void *dst, const void *src)
+{
+const AVOption *o = NULL;
+const AVClass *c;
+int ret = 0;
+
+if (!src)
+return 0;


I'm not sure about this, it looks invalid.


Invalid in which sense? That this function shouldn't ever have to care 
about that case, that it should be the caller's duty to never try that?



+
+c = *(AVClass**)src;
+if (*(AVClass**)dst && c != *(AVClass**)dst)


Why the first check? dst is assumed to be non-NULL anyway, and if it is
NULL, the code lower down will explode.


It's not about whether dst is null or not, but whether the AVClass pointer 
in dst has been set or not. If it hasn't been set, we don't need to see if 
it matches the source class.



+return AVERROR(EINVAL);
+
+while ((o = av_opt_next(src, o))) {
+void *field_dst = ((uint8_t*)dst) + o->offset;
+void *field_src = ((uint8_t*)src) + o->offset;
+uint8_t **field_dst8 = (uint8_t**)field_dst;
+uint8_t **field_src8 = (uint8_t**)field_src;
+
+if (o->type == AV_OPT_TYPE_STRING) {
+set_string(dst, o, *field_src8, field_dst8);
+if (*field_src8 && !*field_dst8)
+ret = AVERROR(ENOMEM);
+} else if (o->type == AV_OPT_TYPE_BINARY) {
+int len = *(int*)(field_src8 + 1);
+if (*field_dst8 != *field_src8)
+av_freep(field_dst8);
+*field_dst8 = av_malloc(len);


Didn't we have some objections to zero-size mallocs?


They're kinda icky, yes. In this case, the code is ok (we only check it 
for being non-null if len as nonzero), but we could avoid it altogether.


// Martin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 3/8] file: Add an option for following a file that is being written

2016-03-19 Thread Martin Storsjö

On Sat, 19 Mar 2016, Anton Khirnov wrote:


Quoting Martin Storsjö (2016-03-18 13:01:37)

Using this requires setting the rw_timeout option to make it
terminate, alternatively using the interrupt callback (if used via
the API).
---
 libavformat/file.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavformat/file.c b/libavformat/file.c
index 4f581cf..8683c1b 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -42,10 +42,12 @@ typedef struct FileContext {
 const AVClass *class;
 int fd;
 int trunc;
+int follow;
 } FileContext;

 static const AVOption file_options[] = {
 { "truncate", "Truncate existing files on write", offsetof(FileContext, 
trunc), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
+{ "follow", "Follow a file as it is being written", offsetof(FileContext, 
follow), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM },


Hmm, that's a rather creative use of the word "follow". I must say it
wouldn't be clear to me what this does without reading the code. Perhaps
you could add more detail to demuxers.texi?


I'm open to suggestions for a single word (or at least not too long option 
name) that is more self-descriptive. Otherwise I guess we can expand on 
docs, but if there's a better name that's obviously the best approach.


// Martin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 2/8] avio: Add an option 'rw_timeout'

2016-03-19 Thread Martin Storsjö

On Sat, 19 Mar 2016, Anton Khirnov wrote:


Quoting Martin Storsjö (2016-03-18 13:01:36)

From: Andrey Utkin 

If set non-zero, this limits duration of the retry_transfer_wrapper()
loop, thus affecting ffurl_read*(), ffurl_write(). As soon as
one single byte is successfully received/transmitted, the timer
restarts.

This has further changes by Michael Niedermayer and Martin Storsjö.
---
Andrey's original version didn't reset the timer on successful
transfers, but I think this is closer to how most people may
want it to work.

I also added an AVOption for setting this, to allow it to be set
generically for any URLProtocol.
---
 libavformat/avio.c | 21 +
 libavformat/url.h  |  1 +
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/libavformat/avio.c b/libavformat/avio.c
index 4da6b74..6039990 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -49,7 +49,10 @@ static void *urlcontext_child_next(void *obj, void *prev)
 return NULL;
 }

-static const AVOption options[] = { { NULL } };
+static const AVOption options[] = {
+{ "rw_timeout", "Timeout for IO operations (in microseconds)", 
offsetof(URLContext, rw_timeout), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, INT64_MAX, 
AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_DECODING_PARAM },
+{ NULL }
+};
 const AVClass ffurl_context_class = {
 .class_name   = "URLContext",
 .item_name= urlcontext_to_name,
@@ -199,6 +202,7 @@ static inline int retry_transfer_wrapper(URLContext *h, 
uint8_t *buf,
 {
 int ret, len;
 int fast_retries = 5;
+int64_t wait_since = 0;

 len = 0;
 while (len < size_min) {
@@ -209,14 +213,23 @@ static inline int retry_transfer_wrapper(URLContext *h, 
uint8_t *buf,
 return ret;
 if (ret == AVERROR(EAGAIN)) {
 ret = 0;
-if (fast_retries)
+if (fast_retries) {
 fast_retries--;
-else
+} else {
+if (h->rw_timeout) {
+if (!wait_since)
+wait_since = av_gettime_relative();
+else if (av_gettime_relative() > wait_since + 
h->rw_timeout)
+return AVERROR(EIO);


ETIMEDOUT might be more appropriate perhaps?


Possibly, except I don't think all systems we support have got ETIMEDOUT. 
(In practice we use a narrow range of errno codes, and that doesn't seem 
to be one of the common ones. In network.h, we have a fallback definition 
of ETIMEDOUT for winsock, but I don't think we should rely on having 
winsock and network.h included everywhere.)



+}
 av_usleep(1000);
+}
 } else if (ret < 1)
 return (ret < 0 && ret != AVERROR_EOF) ? ret : len;
-if (ret)
+if (ret) {
 fast_retries = FFMAX(fast_retries, 2);
+wait_since = 0;
+}
 len += ret;
 if (ff_check_interrupt(&h->interrupt_callback))
 return AVERROR_EXIT;
diff --git a/libavformat/url.h b/libavformat/url.h
index 482658b..5ae6cf2 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -49,6 +49,7 @@ typedef struct URLContext {
 int is_streamed;/**< true if streamed (no seek possible), 
default = false */
 int is_connected;
 AVIOInterruptCB interrupt_callback;
+int64_t rw_timeout; /**< maximum time to wait for (network) 
read/write operation completion, in mcs */


^
c?


I'll expand it into "microseconds".

// Martin
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 4/8] opt: Add const to av_opt_next in the next major bump

2016-03-19 Thread Vittorio Giovara
On Sat, Mar 19, 2016 at 11:14 AM, Anton Khirnov  wrote:
> Quoting Martin Storsjö (2016-03-18 13:01:38)
>> From: Lukasz Marek 
>>
>> Also add const to pointers in static functions within opt.c where
>> possible.
>> ---
>> Or can we freely add const here without waiting for a major bump?
>> I don't see any case where adding const actually would break third
>> party code.
>
> Maybe some c++ wrappers would complain about this?

I'm pretty sure we did add const to function parameters in the past
with no problem.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 2/9] lavf: generic hardware surface upload and download

2016-03-19 Thread Vittorio Giovara
On Tue, Mar 15, 2016 at 6:57 PM, Mark Thompson  wrote:
> ---
>  libavfilter/Makefile|   2 +
>  libavfilter/allfilters.c|   2 +
>  libavfilter/avfilter.c  |   2 +
>  libavfilter/avfilter.h  |   9 ++
>  libavfilter/vf_hwdownload.c | 212 ++
>  libavfilter/vf_hwupload.c   | 241 
> 
>  6 files changed, 468 insertions(+)
>  create mode 100644 libavfilter/vf_hwdownload.c
>  create mode 100644 libavfilter/vf_hwupload.c

Note to the committer: please use lavfi for libavfilter tags, as lavf
generally refers to libavformat.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 0/9] Generic hw filter support + VAAPI hwcontext and encoders

2016-03-19 Thread Luca Barbato
On 15/03/16 23:55, Mark Thompson wrote:
> Hi all,
> 
> Whole series follows again.
> 
> Changes since last time:
> 
> * APIchanges added where appropriate.
> 
> * Memory allocation cleaned up; now valgrind-clean for normal use (might 
> still be some leaks in error cases).
> 
> * Some compatibility fixes for older libva (tested on 1.3.0 in Ubuntu 14.04 
> LTS).
> 
> * goto labels moved to the first column.
> 

Looks quite nice =) Thank you a lot !

lu

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 4/8] opt: Add const to av_opt_next in the next major bump

2016-03-19 Thread Luca Barbato
On 18/03/16 13:01, Martin Storsjö wrote:
> From: Lukasz Marek 
> 
> Also add const to pointers in static functions within opt.c where
> possible.
> ---
> Or can we freely add const here without waiting for a major bump?
> I don't see any case where adding const actually would break third
> party code.

It is the other way round that is problematic, so yes adding const is
quite ok.

lu

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] aac_adtstoasc_bsf: convert to the new API

2016-03-19 Thread Anton Khirnov
---
 libavcodec/aac_adtstoasc_bsf.c | 104 +++--
 libavcodec/allcodecs.c |   1 -
 libavcodec/bitstream_filters.c |   5 ++
 3 files changed, 74 insertions(+), 36 deletions(-)

diff --git a/libavcodec/aac_adtstoasc_bsf.c b/libavcodec/aac_adtstoasc_bsf.c
index d3cbeae..9168e2b 100644
--- a/libavcodec/aac_adtstoasc_bsf.c
+++ b/libavcodec/aac_adtstoasc_bsf.c
@@ -21,6 +21,7 @@
 
 #include "avcodec.h"
 #include "aacadtsdec.h"
+#include "bsf.h"
 #include "put_bits.h"
 #include "get_bits.h"
 #include "mpeg4audio.h"
@@ -34,65 +35,76 @@ typedef struct AACBSFContext {
  * This filter creates an MPEG-4 AudioSpecificConfig from an MPEG-2/4
  * ADTS header and removes the ADTS header.
  */
-static int aac_adtstoasc_filter(AVBitStreamFilterContext *bsfc,
-AVCodecContext *avctx, const char *args,
-uint8_t  **poutbuf, int *poutbuf_size,
-const uint8_t *buf, int  buf_size,
-int keyframe)
+static int aac_adtstoasc_filter(AVBSFContext *bsfc, AVPacket *out)
 {
+AACBSFContext *ctx = bsfc->priv_data;
+
 GetBitContext gb;
 PutBitContext pb;
 AACADTSHeaderInfo hdr;
+AVPacket *in;
+int ret;
 
-AACBSFContext *ctx = bsfc->priv_data;
+ret = ff_bsf_get_packet(bsfc, &in);
+if (ret < 0)
+return ret;
 
-init_get_bits(&gb, buf, AAC_ADTS_HEADER_SIZE*8);
+if (in->size < AAC_ADTS_HEADER_SIZE)
+goto packet_too_small;
 
-*poutbuf = (uint8_t*) buf;
-*poutbuf_size = buf_size;
+init_get_bits(&gb, in->data, AAC_ADTS_HEADER_SIZE * 8);
 
-if (avctx->extradata)
-if (show_bits(&gb, 12) != 0xfff)
-return 0;
+if (bsfc->par_in->extradata && show_bits(&gb, 12) != 0xfff)
+goto finish;
 
 if (avpriv_aac_parse_header(&gb, &hdr) < 0) {
-av_log(avctx, AV_LOG_ERROR, "Error parsing ADTS frame header!\n");
-return AVERROR_INVALIDDATA;
+av_log(bsfc, AV_LOG_ERROR, "Error parsing ADTS frame header!\n");
+ret = AVERROR_INVALIDDATA;
+goto fail;
 }
 
 if (!hdr.crc_absent && hdr.num_aac_frames > 1) {
-avpriv_report_missing_feature(avctx,
+avpriv_report_missing_feature(bsfc,
   "Multiple RDBs per frame with CRC");
-return AVERROR_PATCHWELCOME;
+ret = AVERROR_PATCHWELCOME;
+goto fail;
 }
 
-buf  += AAC_ADTS_HEADER_SIZE + 2*!hdr.crc_absent;
-buf_size -= AAC_ADTS_HEADER_SIZE + 2*!hdr.crc_absent;
+in->size -= AAC_ADTS_HEADER_SIZE + 2 * !hdr.crc_absent;
+if (in->size <= 0)
+goto packet_too_small;
+in->data += AAC_ADTS_HEADER_SIZE + 2 * !hdr.crc_absent;
 
 if (!ctx->first_frame_done) {
 intpce_size = 0;
 uint8_tpce_data[MAX_PCE_SIZE];
+uint8_t   *extradata;
+
 if (!hdr.chan_config) {
-init_get_bits(&gb, buf, buf_size * 8);
+init_get_bits(&gb, in->data, in->size * 8);
 if (get_bits(&gb, 3) != 5) {
-avpriv_report_missing_feature(avctx,
+avpriv_report_missing_feature(bsfc,
   "PCE-based channel configuration 
"
   "without PCE as first syntax "
   "element");
-return AVERROR_PATCHWELCOME;
+ret = AVERROR_PATCHWELCOME;
+goto fail;
 }
 init_put_bits(&pb, pce_data, MAX_PCE_SIZE);
 pce_size = avpriv_copy_pce_data(&pb, &gb)/8;
 flush_put_bits(&pb);
-buf_size -= get_bits_count(&gb)/8;
-buf  += get_bits_count(&gb)/8;
+in->size -= get_bits_count(&gb)/8;
+in->data += get_bits_count(&gb)/8;
 }
-avctx->extradata_size = 2 + pce_size;
-avctx->extradata = av_mallocz(avctx->extradata_size + 
AV_INPUT_BUFFER_PADDING_SIZE);
-if (!avctx->extradata)
-return AVERROR(ENOMEM);
 
-init_put_bits(&pb, avctx->extradata, avctx->extradata_size);
+extradata = av_packet_new_side_data(in, AV_PKT_DATA_NEW_EXTRADATA,
+2 + pce_size);
+if (!extradata) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
+
+init_put_bits(&pb, extradata, 2 + pce_size);
 put_bits(&pb, 5, hdr.object_type);
 put_bits(&pb, 4, hdr.sampling_index);
 put_bits(&pb, 4, hdr.chan_config);
@@ -101,20 +113,42 @@ static int aac_adtstoasc_filter(AVBitStreamFilterContext 
*bsfc,
 put_bits(&pb, 1, 0); //is not extension
 flush_put_bits(&pb);
 if (pce_size) {
-memcpy(avctx->extradata + 2, pce_data, pce_size);
+memcpy(extradata + 2, pce_data, pce_size);
 }
 
 ctx->first_frame_done = 1;
 }

Re: [libav-devel] [PATCH] New BSF API v2

2016-03-19 Thread Anton Khirnov
ping on the last two patches  in the set.

-- 
Anton Khirnov
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 02/14] aac_adtstoasc_bsf: convert to the new API

2016-03-19 Thread Anton Khirnov
Quoting Luca Barbato (2016-03-07 09:10:14)
> On 07/03/16 08:59, Luca Barbato wrote:
> > On 04/03/16 09:15, Anton Khirnov wrote:
> >> ---
> >>  libavcodec/aac_adtstoasc_bsf.c | 95 
> >> ++
> >>  libavcodec/allcodecs.c |  1 -
> >>  libavcodec/bitstream_filters.c |  5 +++
> >>  3 files changed, 65 insertions(+), 36 deletions(-)
> >>
> > 
> > Possibly Ok.
> > 
> 
> Reading the others, why the par_out->extradata is not set?

Because it's set as side data in the first packet. Actually it should be
actively unset from the output parameters.

-- 
Anton Khirnov
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 7/8] tcp: Use rw_timeout for setting the connect/listen timeouts

2016-03-19 Thread Anton Khirnov
Quoting Martin Storsjö (2016-03-18 13:01:41)
> Apply the default value for timeout in code instead of via the
> avoption, to allow distinguishing the default value from the user
> not setting anything at all.
> ---
>  libavformat/tcp.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/tcp.c b/libavformat/tcp.c
> index f211142..1498c26 100644
> --- a/libavformat/tcp.c
> +++ b/libavformat/tcp.c
> @@ -43,7 +43,7 @@ typedef struct TCPContext {
>  #define E AV_OPT_FLAG_ENCODING_PARAM
>  static const AVOption options[] = {
>  { "listen",  "Listen for incoming connections",  OFFSET(listen), 
> AV_OPT_TYPE_INT, { .i64 = 0 }, 0,   1,   .flags = D|E },
> -{ "timeout", "Connection timeout (in milliseconds)", 
> OFFSET(timeout),AV_OPT_TYPE_INT, { .i64 = 1 }, INT_MIN, INT_MAX, 
> .flags = D|E },
> +{ "timeout", "Connection timeout (in milliseconds)", 
> OFFSET(timeout),AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, .flags = 
> D|E },
>  { "listen_timeout",  "Bind timeout (in milliseconds)",   
> OFFSET(listen_timeout), AV_OPT_TYPE_INT, { .i64 = -1 },INT_MIN, INT_MAX, 
> .flags = D|E },
>  { NULL }
>  };
> @@ -86,6 +86,10 @@ static int tcp_open(URLContext *h, const char *uri, int 
> flags)
>  s->listen_timeout = strtol(buf, NULL, 10);
>  }
>  }
> +if (!s->timeout)
> +s->timeout = h->rw_timeout ? h->rw_timeout / 1000 : 1;
> +if (h->rw_timeout && s->listen_timeout < 0)
> +s->listen_timeout = h->rw_timeout / 1000;
>  hints.ai_family = AF_UNSPEC;
>  hints.ai_socktype = SOCK_STREAM;
>  snprintf(portstr, sizeof(portstr), "%d", port);
> -- 
> 2.5.4 (Apple Git-61)

Looks ok.

-- 
Anton Khirnov
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 8/8] unix: Use rw_timeout for setting the connect timeout

2016-03-19 Thread Anton Khirnov
Quoting Martin Storsjö (2016-03-18 13:01:42)
> ---
>  libavformat/unix.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libavformat/unix.c b/libavformat/unix.c
> index 6bb677d..647e7e8 100644
> --- a/libavformat/unix.c
> +++ b/libavformat/unix.c
> @@ -73,6 +73,9 @@ static int unix_open(URLContext *h, const char *filename, 
> int flags)
>  if ((fd = ff_socket(AF_UNIX, s->type, 0)) < 0)
>  return ff_neterrno();
>  
> +if (s->timeout < 0 && h->rw_timeout)
> +s->timeout = h->rw_timeout / 1000;
> +
>  if (s->listen) {
>  ret = ff_listen_bind(fd, (struct sockaddr *)&s->addr,
>   sizeof(s->addr), s->timeout, h);
> -- 
> 2.5.4 (Apple Git-61)

Looks ok.

-- 
Anton Khirnov
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 6/8] RFC: avio: Copy URLContext generic options into child URLContexts

2016-03-19 Thread Anton Khirnov
Quoting Martin Storsjö (2016-03-18 13:01:40)
> Since all URLContexts have the same AVOptions, such AVOptions
> will be applied on the outermost context only and removed from the
> dict, while they probably make sense on all contexts.
> 
> This makes sure that rw_timeout gets propagated to the innermost
> URLContext (to make sure it gets passed to the tcp protocol, when
> opening a http connection for instance).
> 
> Alternatively, such matching options would be kept in the dict
> and only removed after the ffurl_connect call.
> ---
> Suggestions on how to do this better are welcome.
> ---

FWIW this looks reasonable to me.

-- 
Anton Khirnov
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 5/8] opt: Add av_opt_copy()

2016-03-19 Thread Anton Khirnov
Quoting Martin Storsjö (2016-03-18 13:01:39)
> From: Michael Niedermayer 
> 
> This includes documentation and other modifications by
> Lukasz Marek.
> ---
>  doc/APIchanges  |  3 +++
>  libavutil/opt.c | 58 
> +
>  libavutil/opt.h | 13 
>  libavutil/version.h |  2 +-
>  4 files changed, 75 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 20fecb9..aa6f004 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -13,6 +13,9 @@ libavutil: 2015-08-28
>  
>  API changes, most recent first:
>  
> +2016-xx-xx - xxx - lavu 55.7.0 - opt.h
> +  Add av_opt_copy().
> +
>  2016-02-23 - 9200514 - lavf 57.5.0 - avformat.h
>Add AVStream.codecpar, deprecate AVStream.codec.
>  
> diff --git a/libavutil/opt.c b/libavutil/opt.c
> index 5825a72..75e8970 100644
> --- a/libavutil/opt.c
> +++ b/libavutil/opt.c
> @@ -757,6 +757,64 @@ const AVClass *av_opt_child_class_next(const AVClass 
> *parent, const AVClass *pre
>  return NULL;
>  }
>  
> +static int opt_size(enum AVOptionType type)
> +{
> +switch(type) {
> +case AV_OPT_TYPE_INT:
> +case AV_OPT_TYPE_FLAGS: return sizeof(int);
> +case AV_OPT_TYPE_INT64: return sizeof(int64_t);
> +case AV_OPT_TYPE_DOUBLE:return sizeof(double);
> +case AV_OPT_TYPE_FLOAT: return sizeof(float);
> +case AV_OPT_TYPE_STRING:return sizeof(uint8_t*);
> +case AV_OPT_TYPE_RATIONAL:  return sizeof(AVRational);
> +case AV_OPT_TYPE_BINARY:return sizeof(uint8_t*) + sizeof(int);
> +}
> +return 0;

This should return an error that should be checked by the caller.

> +}
> +
> +int av_opt_copy(void *dst, const void *src)
> +{
> +const AVOption *o = NULL;
> +const AVClass *c;
> +int ret = 0;
> +
> +if (!src)
> +return 0;

I'm not sure about this, it looks invalid.

> +
> +c = *(AVClass**)src;
> +if (*(AVClass**)dst && c != *(AVClass**)dst)

Why the first check? dst is assumed to be non-NULL anyway, and if it is
NULL, the code lower down will explode.

> +return AVERROR(EINVAL);
> +
> +while ((o = av_opt_next(src, o))) {
> +void *field_dst = ((uint8_t*)dst) + o->offset;
> +void *field_src = ((uint8_t*)src) + o->offset;
> +uint8_t **field_dst8 = (uint8_t**)field_dst;
> +uint8_t **field_src8 = (uint8_t**)field_src;
> +
> +if (o->type == AV_OPT_TYPE_STRING) {
> +set_string(dst, o, *field_src8, field_dst8);
> +if (*field_src8 && !*field_dst8)
> +ret = AVERROR(ENOMEM);
> +} else if (o->type == AV_OPT_TYPE_BINARY) {
> +int len = *(int*)(field_src8 + 1);
> +if (*field_dst8 != *field_src8)
> +av_freep(field_dst8);
> +*field_dst8 = av_malloc(len);

Didn't we have some objections to zero-size mallocs?

-- 
Anton Khirnov
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

  1   2   >