Re: [FFmpeg-devel] [PATCH] Add SUP/PGS subtitle demuxer

2014-08-31 Thread Reimar Döffinger
On 30.08.2014, at 15:38, wm4 nfx...@googlemail.com wrote:
 +// The packet-size is stored as part of the packet.
 +if ((ret = avio_read(s-pb, tmp, 3))  0)
 +return ret;
 +
 +len = AV_RB16(tmp + 1);
 +
 +if ((ret = av_new_packet(pkt, len + 3))  0)
 +return ret;
 +
 +memcpy(pkt-data, tmp, 3);
 +
 +if ((ret = avio_read(s-pb, pkt-data + 3, len))  0) {
 +av_free_packet(pkt);
 +return ret;
 +}

I think this will not handle short reads correctly, retuning uninitialised data.
My suggestion would be to read the length, then seek back (buffering should 
ensure this is no issue even if we read from stdin) and then use the functions 
to read the full packet with all the proper error handling.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]Clean up if filter initialisation failed

2014-08-31 Thread Carl Eugen Hoyos
Nicolas George george at nsup.org writes:

 Please mention in the commit short message that it 
 is about the command-line tools and not the library; 
 maybe ffmpeg: clean up if

Merged by Michael with that change.

Thank you, Carl Eugen

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


Re: [FFmpeg-devel] [PATCH] Add SUP/PGS subtitle demuxer

2014-08-31 Thread Hendrik Leppkes
On Sun, Aug 31, 2014 at 9:41 AM, Reimar Döffinger
reimar.doeffin...@gmx.de wrote:
 On 30.08.2014, at 15:38, wm4 nfx...@googlemail.com wrote:
 +// The packet-size is stored as part of the packet.
 +if ((ret = avio_read(s-pb, tmp, 3))  0)
 +return ret;
 +
 +len = AV_RB16(tmp + 1);
 +
 +if ((ret = av_new_packet(pkt, len + 3))  0)
 +return ret;
 +
 +memcpy(pkt-data, tmp, 3);
 +
 +if ((ret = avio_read(s-pb, pkt-data + 3, len))  0) {
 +av_free_packet(pkt);
 +return ret;
 +}

 I think this will not handle short reads correctly, retuning uninitialised 
 data.
 My suggestion would be to read the length, then seek back (buffering should 
 ensure this is no issue even if we read from stdin) and then use the 
 functions to read the full packet with all the proper error handling.


I don't see a problem in the code he proposed. It seems to handle
every read with an error check, without relying on potential buffering
of data to allow a seek backwards.
This is assuming avio_read does return an error if it runs against
EOF, which I assume it does? I didn't double check that.

What exactly do you think is wrong here?

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


Re: [FFmpeg-devel] [PATCH] Add SUP/PGS subtitle demuxer

2014-08-31 Thread Reimar Döffinger
On Sun, Aug 31, 2014 at 10:15:56AM +0200, Hendrik Leppkes wrote:
 On Sun, Aug 31, 2014 at 9:41 AM, Reimar Döffinger
 reimar.doeffin...@gmx.de wrote:
  On 30.08.2014, at 15:38, wm4 nfx...@googlemail.com wrote:
  +// The packet-size is stored as part of the packet.
  +if ((ret = avio_read(s-pb, tmp, 3))  0)
  +return ret;
  +
  +len = AV_RB16(tmp + 1);
  +
  +if ((ret = av_new_packet(pkt, len + 3))  0)
  +return ret;
  +
  +memcpy(pkt-data, tmp, 3);
  +
  +if ((ret = avio_read(s-pb, pkt-data + 3, len))  0) {
  +av_free_packet(pkt);
  +return ret;
  +}
 
  I think this will not handle short reads correctly, retuning uninitialised 
  data.
  My suggestion would be to read the length, then seek back (buffering should 
  ensure this is no issue even if we read from stdin) and then use the 
  functions to read the full packet with all the proper error handling.
 
 
 I don't see a problem in the code he proposed. It seems to handle
 every read with an error check, without relying on potential buffering
 of data to allow a seek backwards.
 This is assuming avio_read does return an error if it runs against
 EOF, which I assume it does? I didn't double check that.

Why would it? That would make it a huge pain to read formats where
you don't know ahead of time how long they are (e.g. streaming
TS files via stdin).

 What exactly do you think is wrong here?

The code does not handle 0  ret  len (I think 0 should not be
possible), plus it is complex and I am not at all confident it's
the only case it misses.
There is a reason we have helper functions.
If you absolutely do not want to seek back, there is also the
option of reading a 3-byte packet (but then like now you have
to add handling getting fewer than that) and then use the function
to expand the packet to read the rest.
However there is a good reason why seeking back small amounts is
_supposed_ to work always, 100% reliable, and it should be fine
to take advantage of it.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/6] fft: add ff_ prefix to some global arrays.

2014-08-31 Thread Reimar Döffinger
On Sat, Aug 30, 2014 at 04:43:39PM +0200, Reimar Döffinger wrote:
 Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de

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


Re: [FFmpeg-devel] [PATCH] cabac: initialize all of ff_h264_cabac_tables programmatically.

2014-08-31 Thread Reimar Döffinger
On Sat, Aug 30, 2014 at 06:18:41PM +0200, Reimar Döffinger wrote:
 Moves it from .data to .bss, slightly reducing binary size.

Any other comments?
Should I write more in the commit message?
It's obviously not a big deal, I just thought the code to be overall
better this way.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavu/hash.c: Add missing static const.

2014-08-31 Thread Reimar Döffinger
On Sat, Aug 30, 2014 at 11:23:52PM +0200, Reimar Döffinger wrote:
 On 30.08.2014, at 21:50, Clément Bœsch u...@pkh.me wrote:
  On Sat, Aug 30, 2014 at 04:36:57PM +0200, Reimar Döffinger wrote:
  On Fri, Aug 29, 2014 at 09:29:46PM +0200, Clément Bœsch wrote:
  On Fri, Aug 29, 2014 at 06:34:52PM +0200, Reimar Döffinger wrote:
  Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de
  ---
  libavutil/hash.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
  
  diff --git a/libavutil/hash.c b/libavutil/hash.c
  index 773f29e..979fdd9 100644
  --- a/libavutil/hash.c
  +++ b/libavutil/hash.c
  @@ -63,7 +63,7 @@ typedef struct AVHashContext {
  struct {
  const char *name;
  int size;
  -} hashdesc[] = {
  +} static const hashdesc[] = {
  [MD5] = {MD5, 16},
  [MURMUR3] = {murmur3, 16},
  [RIPEMD128] = {RIPEMD128, 16},
  
  shouldn't that be static const struct { } hashdesc[] = { ... }
  
  as in static const type foo[] = { ... };
  
  Reason I prefer this one is that if the struct becomes
  large it because very non-obvious that the array actually is
  static const.
  It also is much harder to check/filter with grep.
  So for practical reasons I think it is better to place it here,
  or alternatively to name the struct and split them...
  But mostly I care about having it in .rodata, everything else
  I'm willing to adapt to what others prefer.
  
  I'm mostly concerned about consistency. Except the one you added in
  drawtext, this form is never used:
 
 Hm, ok. I'll change it then.

Pushed with that change, made drawtext match with the rest.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add av_cold to table generation functions.

2014-08-31 Thread Reimar Döffinger
On Sat, Aug 30, 2014 at 06:15:46PM +0200, Michael Niedermayer wrote:
 On Sat, Aug 30, 2014 at 06:00:43PM +0200, Reimar Döffinger wrote:
  Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de
  ---
   libavcodec/aac_tablegen.h  | 2 +-
   libavcodec/aacps_tablegen.h| 4 ++--
   libavcodec/aacsbr_tablegen.h   | 2 +-
   libavcodec/cbrt_tablegen.h | 3 ++-
   libavcodec/dv_tablegen.h   | 3 ++-
   libavcodec/motionpixels_tablegen.h | 7 ---
   libavcodec/mpegaudio_tablegen.h| 3 ++-
   7 files changed, 14 insertions(+), 10 deletions(-)
 
 probably ok

Pushed, thanks.
(except for the aacsbr change which I moved into the patch
that adds that file)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] WMA: add const to avoid warnings with hardcoded tables.

2014-08-31 Thread Reimar Döffinger
On Sat, Aug 30, 2014 at 06:14:59PM +0200, Michael Niedermayer wrote:
 On Sat, Aug 30, 2014 at 06:00:20PM +0200, Reimar Döffinger wrote:
  Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de
  ---
   libavcodec/wma.h   | 2 +-
   libavcodec/wmaprodec.c | 4 ++--
   2 files changed, 3 insertions(+), 3 deletions(-)
 
 LGTM
 
 thanks

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


Re: [FFmpeg-devel] [PATCH] lavu/hash.c: Add missing static const.

2014-08-31 Thread Clément Bœsch
On Sun, Aug 31, 2014 at 10:46:29AM +0200, Reimar Döffinger wrote:
 On Sat, Aug 30, 2014 at 11:23:52PM +0200, Reimar Döffinger wrote:
  On 30.08.2014, at 21:50, Clément Bœsch u...@pkh.me wrote:
   On Sat, Aug 30, 2014 at 04:36:57PM +0200, Reimar Döffinger wrote:
   On Fri, Aug 29, 2014 at 09:29:46PM +0200, Clément Bœsch wrote:
   On Fri, Aug 29, 2014 at 06:34:52PM +0200, Reimar Döffinger wrote:
   Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de
   ---
   libavutil/hash.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
   
   diff --git a/libavutil/hash.c b/libavutil/hash.c
   index 773f29e..979fdd9 100644
   --- a/libavutil/hash.c
   +++ b/libavutil/hash.c
   @@ -63,7 +63,7 @@ typedef struct AVHashContext {
   struct {
   const char *name;
   int size;
   -} hashdesc[] = {
   +} static const hashdesc[] = {
   [MD5] = {MD5, 16},
   [MURMUR3] = {murmur3, 16},
   [RIPEMD128] = {RIPEMD128, 16},
   
   shouldn't that be static const struct { } hashdesc[] = { ... }
   
   as in static const type foo[] = { ... };
   
   Reason I prefer this one is that if the struct becomes
   large it because very non-obvious that the array actually is
   static const.
   It also is much harder to check/filter with grep.
   So for practical reasons I think it is better to place it here,
   or alternatively to name the struct and split them...
   But mostly I care about having it in .rodata, everything else
   I'm willing to adapt to what others prefer.
   
   I'm mostly concerned about consistency. Except the one you added in
   drawtext, this form is never used:
  
  Hm, ok. I'll change it then.
 
 Pushed with that change, made drawtext match with the rest.

Thanks

As a side note, this fixes the following warning:
  warning: ‘static’ is not at beginning of declaration [-Wold-style-declaration]

(but it's not enabled by default in FFmpeg tree, it's part of -Wextra)

-- 
Clément B.


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


Re: [FFmpeg-devel] [PATCH] Add SUP/PGS subtitle demuxer

2014-08-31 Thread wm4
On Sun, 31 Aug 2014 10:24:13 +0200
Reimar Döffinger reimar.doeffin...@gmx.de wrote:

 On Sun, Aug 31, 2014 at 10:15:56AM +0200, Hendrik Leppkes wrote:
  On Sun, Aug 31, 2014 at 9:41 AM, Reimar Döffinger
  reimar.doeffin...@gmx.de wrote:
   On 30.08.2014, at 15:38, wm4 nfx...@googlemail.com wrote:
   +// The packet-size is stored as part of the packet.
   +if ((ret = avio_read(s-pb, tmp, 3))  0)
   +return ret;
   +
   +len = AV_RB16(tmp + 1);
   +
   +if ((ret = av_new_packet(pkt, len + 3))  0)
   +return ret;
   +
   +memcpy(pkt-data, tmp, 3);
   +
   +if ((ret = avio_read(s-pb, pkt-data + 3, len))  0) {
   +av_free_packet(pkt);
   +return ret;
   +}
  
   I think this will not handle short reads correctly, retuning 
   uninitialised data.
   My suggestion would be to read the length, then seek back (buffering 
   should ensure this is no issue even if we read from stdin) and then use 
   the functions to read the full packet with all the proper error handling.
  
  
  I don't see a problem in the code he proposed. It seems to handle
  every read with an error check, without relying on potential buffering
  of data to allow a seek backwards.
  This is assuming avio_read does return an error if it runs against
  EOF, which I assume it does? I didn't double check that.
 
 Why would it? That would make it a huge pain to read formats where
 you don't know ahead of time how long they are (e.g. streaming
 TS files via stdin).
 
  What exactly do you think is wrong here?
 
 The code does not handle 0  ret  len (I think 0 should not be
 possible), plus it is complex and I am not at all confident it's
 the only case it misses.
 There is a reason we have helper functions.
 If you absolutely do not want to seek back, there is also the
 option of reading a 3-byte packet (but then like now you have
 to add handling getting fewer than that) and then use the function
 to expand the packet to read the rest.
 However there is a good reason why seeking back small amounts is
 _supposed_ to work always, 100% reliable, and it should be fine
 to take advantage of it.

When I looked at avio_read, it seemed like it doesn't allow short
reads, so I simplified the error checks.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] Add SUP/PGS subtitle demuxer

2014-08-31 Thread wm4
---
I got the semantics of avio_read wrong: short reads on EOF are in
fact allowed and don't return an error. Hopefully this is correct now...
---
 libavformat/Makefile |  1 +
 libavformat/allformats.c |  1 +
 libavformat/supdec.c | 92 
 3 files changed, 94 insertions(+)
 create mode 100644 libavformat/supdec.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 3d124fb..b4965fe 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -405,6 +405,7 @@ OBJS-$(CONFIG_SRT_MUXER) += srtenc.o
 OBJS-$(CONFIG_STR_DEMUXER)   += psxstr.o
 OBJS-$(CONFIG_SUBVIEWER1_DEMUXER)+= subviewer1dec.o subtitles.o
 OBJS-$(CONFIG_SUBVIEWER_DEMUXER) += subviewerdec.o subtitles.o
+OBJS-$(CONFIG_SUP_DEMUXER)   += supdec.o
 OBJS-$(CONFIG_SWF_DEMUXER)   += swfdec.o swf.o
 OBJS-$(CONFIG_SWF_MUXER) += swfenc.o swf.o
 OBJS-$(CONFIG_TAK_DEMUXER)   += takdec.o apetag.o img2.o rawdec.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 8f70c4b..e6c0e5f 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -280,6 +280,7 @@ void av_register_all(void)
 REGISTER_DEMUXER (STR,  str);
 REGISTER_DEMUXER (SUBVIEWER1,   subviewer1);
 REGISTER_DEMUXER (SUBVIEWER,subviewer);
+REGISTER_DEMUXER (SUP,  sup);
 REGISTER_MUXDEMUX(SWF,  swf);
 REGISTER_DEMUXER (TAK,  tak);
 REGISTER_MUXER   (TEE,  tee);
diff --git a/libavformat/supdec.c b/libavformat/supdec.c
new file mode 100644
index 000..1b4ebb1
--- /dev/null
+++ b/libavformat/supdec.c
@@ -0,0 +1,92 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include avformat.h
+#include internal.h
+#include libavutil/intreadwrite.h
+
+#define SUP_PGS_MAGIC 0x5047 /* PG, big endian */
+
+static int sup_read_header(AVFormatContext *s)
+{
+AVStream *st = avformat_new_stream(s, NULL);
+if (!st)
+return AVERROR(ENOMEM);
+st-codec-codec_type = AVMEDIA_TYPE_SUBTITLE;
+st-codec-codec_id = AV_CODEC_ID_HDMV_PGS_SUBTITLE;
+avpriv_set_pts_info(st, 32, 1, 9);
+
+return 0;
+}
+
+static int sup_read_packet(struct AVFormatContext *s, AVPacket *pkt)
+{
+char tmp[3];
+size_t len;
+int64_t pts, pos;
+int ret;
+
+pos = avio_tell(s-pb);
+
+if (avio_rb16(s-pb) != SUP_PGS_MAGIC)
+return avio_feof(s-pb) ? AVERROR_EOF : AVERROR_INVALIDDATA;
+
+pts = avio_rb32(s-pb);
+avio_rb32(s-pb); /* discard DTS (usually 0, and useless) */
+
+// The packet-size is stored as part of the packet.
+if ((ret = avio_read(s-pb, tmp, 3))  3)
+return ret  0 ? ret : AVERROR_INVALIDDATA;
+
+len = AV_RB16(tmp + 1);
+
+if ((ret = av_new_packet(pkt, len + 3))  0)
+return ret;
+
+memcpy(pkt-data, tmp, 3);
+
+if ((ret = avio_read(s-pb, pkt-data + 3, len))  len) {
+av_free_packet(pkt);
+return ret  0 ? ret : AVERROR_INVALIDDATA;
+}
+
+pkt-stream_index = 0;
+pkt-flags |= AV_PKT_FLAG_KEY;
+pkt-pos = pos;
+pkt-pts = pts;
+
+return 0;
+}
+
+static int sup_probe(AVProbeData *p)
+{
+if (p-buf_size  2 || memcmp(p-buf, PG, 2))
+return 0;
+return AVPROBE_SCORE_EXTENSION;
+}
+
+AVInputFormat ff_sup_demuxer = {
+.name   = sup,
+.long_name  = NULL_IF_CONFIG_SMALL(raw HDMV Presentation Graphic 
Stream subtitles),
+.extensions = sup,
+.mime_type  = application/x-pgs,
+.read_probe = sup_probe,
+.read_header= sup_read_header,
+.read_packet= sup_read_packet,
+.flags  = AVFMT_GENERIC_INDEX,
+};
-- 
2.1.0

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


Re: [FFmpeg-devel] [PATCH] Add SUP/PGS subtitle demuxer

2014-08-31 Thread Michael Niedermayer
On Sun, Aug 31, 2014 at 09:41:49AM +0200, Reimar Döffinger wrote:
 On 30.08.2014, at 15:38, wm4 nfx...@googlemail.com wrote:
  +// The packet-size is stored as part of the packet.
  +if ((ret = avio_read(s-pb, tmp, 3))  0)
  +return ret;
  +
  +len = AV_RB16(tmp + 1);
  +
  +if ((ret = av_new_packet(pkt, len + 3))  0)
  +return ret;
  +
  +memcpy(pkt-data, tmp, 3);
  +
  +if ((ret = avio_read(s-pb, pkt-data + 3, len))  0) {
  +av_free_packet(pkt);
  +return ret;
  +}
 
 I think this will not handle short reads correctly, retuning uninitialised 
 data.

 My suggestion would be to read the length, then seek back (buffering should 
 ensure this is no issue even if we read from stdin) and then use the 
 functions to read the full packet with all the proper error handling.

note, for guranteed seekback on non seekable input
ffio_ensure_seekback() is needed


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

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact


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


Re: [FFmpeg-devel] [PATCH] Add SUP/PGS subtitle demuxer

2014-08-31 Thread wm4
On Sun, 31 Aug 2014 11:50:36 +0200
Reimar Döffinger reimar.doeffin...@gmx.de wrote:

 On Sun, Aug 31, 2014 at 11:39:16AM +0200, wm4 wrote:
  I got the semantics of avio_read wrong: short reads on EOF are in
  fact allowed and don't return an error. Hopefully this is correct now...
 
 What I _really_ dislike about these approaches is that we hard-code EOF
 behaviour in every single demuxer.
 So some will return partial packets some won't.
 And if we wanted to make that behaviour configurable we'd have to add
 options to every single one instead of changing the code in one single
 place.
 Not to mention all the other optimizations, just look how much e.g.
 av_get_packet actually does!
 Why do you absolutely want to handle this manually via avio_read?
 You can just use av_get_packet + av_append_packet, then you only need
 to check the size once, and you also don't have to set pkt-pos
 manually and you still don't have to do seekback.

I wasn't aware of av_get/append_packet() (sorry if it was mentioned
before and I ignored it) - it looks nice. I'll try to use it and send a
patch again later. It's a bit not-nice that it reallocs the packet, but
there's probably no way it matters in this case at all.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add SUP/PGS subtitle demuxer

2014-08-31 Thread Reimar Döffinger
On Sun, Aug 31, 2014 at 12:00:13PM +0200, wm4 wrote:
 On Sun, 31 Aug 2014 11:50:36 +0200
 Reimar Döffinger reimar.doeffin...@gmx.de wrote:
 
  On Sun, Aug 31, 2014 at 11:39:16AM +0200, wm4 wrote:
   I got the semantics of avio_read wrong: short reads on EOF are in
   fact allowed and don't return an error. Hopefully this is correct now...
  
  What I _really_ dislike about these approaches is that we hard-code EOF
  behaviour in every single demuxer.
  So some will return partial packets some won't.
  And if we wanted to make that behaviour configurable we'd have to add
  options to every single one instead of changing the code in one single
  place.
  Not to mention all the other optimizations, just look how much e.g.
  av_get_packet actually does!
  Why do you absolutely want to handle this manually via avio_read?
  You can just use av_get_packet + av_append_packet, then you only need
  to check the size once, and you also don't have to set pkt-pos
  manually and you still don't have to do seekback.
 
 I wasn't aware of av_get/append_packet() (sorry if it was mentioned
 before and I ignored it)

I mentioned it but was too lazy to find out the exact function names.
So I'll take part of the blame if you missed it :)

 - it looks nice. I'll try to use it and send a
 patch again later. It's a bit not-nice that it reallocs the packet, but
 there's probably no way it matters in this case at all.

I agree. _If_ it mattered at some point it would be possible to have a variant
that specifies an initial allocation size - for many cases it would be
possible to reasonably estimate the final packet size.
Though especially for this case that would be just overkill anyway and I think 
going
for as simple as possible is best.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] intmath.h: Remove duplicated ARM include.

2014-08-31 Thread Reimar Döffinger
Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de
---
 libavutil/intmath.h | 4 
 1 file changed, 4 deletions(-)

diff --git a/libavutil/intmath.h b/libavutil/intmath.h
index e140d82..8f7a69e 100644
--- a/libavutil/intmath.h
+++ b/libavutil/intmath.h
@@ -35,10 +35,6 @@
  * @{
  */
 
-#if   ARCH_ARM
-#   include arm/intmath.h
-#endif
-
 #if HAVE_FAST_CLZ  AV_GCC_VERSION_AT_LEAST(3,4)
 
 #ifndef ff_log2
-- 
2.1.0

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


[FFmpeg-devel] [PATCH] aacps_tablegen: replace TABLE_CONST by const.

2014-08-31 Thread Reimar Döffinger
Doesn't change generated code, just is more consistent
and a bit less error-prone.

Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de
---
 libavcodec/aacps_tablegen.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/aacps_tablegen.c b/libavcodec/aacps_tablegen.c
index 47d4205..f56930b 100644
--- a/libavcodec/aacps_tablegen.c
+++ b/libavcodec/aacps_tablegen.c
@@ -82,7 +82,7 @@ int main(void)
 write_float_3d_array(f34_2_4, 4, 8, 2);
 printf(};\n);
 
-printf(static TABLE_CONST DECLARE_ALIGNED(16, float, 
Q_fract_allpass)[2][50][3][2] = {\n);
+printf(static const DECLARE_ALIGNED(16, float, 
Q_fract_allpass)[2][50][3][2] = {\n);
 write_float_4d_array(Q_fract_allpass, 2, 50, 3, 2);
 printf(};\n);
 printf(static const DECLARE_ALIGNED(16, float, phi_fract)[2][50][2] = 
{\n);
-- 
2.1.0

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


[FFmpeg-devel] [PATCH] cabac: Allow hardcoding CABAC table.

2014-08-31 Thread Reimar Döffinger
Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de
---
 libavcodec/Makefile  |   4 +-
 libavcodec/cabac.c   |  74 +
 libavcodec/cabac.h   |   7 ++-
 libavcodec/cabac_functions.h |   8 ++--
 libavcodec/cabac_tablegen.c  |  41 
 libavcodec/cabac_tablegen.h  | 108 +++
 6 files changed, 164 insertions(+), 78 deletions(-)
 create mode 100644 libavcodec/cabac_tablegen.c
 create mode 100644 libavcodec/cabac_tablegen.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 0ed5478..28ae252 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -872,6 +872,7 @@ TOOLS = fourcc2pixfmt
 HOSTPROGS = aac_tablegen\
 aacps_tablegen  \
 aacsbr_tablegen \
+cabac_tablegen  \
 cbrt_tablegen   \
 cos_tablegen\
 dsd_tablegen\
@@ -899,7 +900,7 @@ else
 $(SUBDIR)%_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DCONFIG_SMALL=0
 endif
 
-GEN_HEADERS = cbrt_tables.h aacps_tables.h aacsbr_tables.h aac_tables.h 
dsd_tables.h dv_tables.h \
+GEN_HEADERS = cabac_tables.h cbrt_tables.h aacps_tables.h aacsbr_tables.h 
aac_tables.h dsd_tables.h dv_tables.h \
   sinewin_tables.h mpegaudio_tables.h motionpixels_tables.h \
   pcm_tables.h qdm2_tables.h
 GEN_HEADERS := $(addprefix $(SUBDIR), $(GEN_HEADERS))
@@ -912,6 +913,7 @@ $(SUBDIR)aacdec.o: $(SUBDIR)cbrt_tables.h
 $(SUBDIR)aacps.o: $(SUBDIR)aacps_tables.h
 $(SUBDIR)aacsbr.o: $(SUBDIR)aacsbr_tables.h
 $(SUBDIR)aactab.o: $(SUBDIR)aac_tables.h
+$(SUBDIR)cabac.o: $(SUBDIR)cabac_tables.h
 $(SUBDIR)dsddec.o: $(SUBDIR)dsd_tables.h
 $(SUBDIR)dvenc.o: $(SUBDIR)dv_tables.h
 $(SUBDIR)sinewin.o: $(SUBDIR)sinewin_tables.h
diff --git a/libavcodec/cabac.c b/libavcodec/cabac.c
index 803c81c..81a75dd 100644
--- a/libavcodec/cabac.c
+++ b/libavcodec/cabac.c
@@ -32,55 +32,7 @@
 #include cabac.h
 #include cabac_functions.h
 
-uint8_t ff_h264_cabac_tables[512 + 4*2*64 + 4*64 + 63];
-
-static const uint8_t lps_range[64][4]= {
-{128,176,208,240}, {128,167,197,227}, {128,158,187,216}, {123,150,178,205},
-{116,142,169,195}, {111,135,160,185}, {105,128,152,175}, {100,122,144,166},
-{ 95,116,137,158}, { 90,110,130,150}, { 85,104,123,142}, { 81, 99,117,135},
-{ 77, 94,111,128}, { 73, 89,105,122}, { 69, 85,100,116}, { 66, 80, 95,110},
-{ 62, 76, 90,104}, { 59, 72, 86, 99}, { 56, 69, 81, 94}, { 53, 65, 77, 89},
-{ 51, 62, 73, 85}, { 48, 59, 69, 80}, { 46, 56, 66, 76}, { 43, 53, 63, 72},
-{ 41, 50, 59, 69}, { 39, 48, 56, 65}, { 37, 45, 54, 62}, { 35, 43, 51, 59},
-{ 33, 41, 48, 56}, { 32, 39, 46, 53}, { 30, 37, 43, 50}, { 29, 35, 41, 48},
-{ 27, 33, 39, 45}, { 26, 31, 37, 43}, { 24, 30, 35, 41}, { 23, 28, 33, 39},
-{ 22, 27, 32, 37}, { 21, 26, 30, 35}, { 20, 24, 29, 33}, { 19, 23, 27, 31},
-{ 18, 22, 26, 30}, { 17, 21, 25, 28}, { 16, 20, 23, 27}, { 15, 19, 22, 25},
-{ 14, 18, 21, 24}, { 14, 17, 20, 23}, { 13, 16, 19, 22}, { 12, 15, 18, 21},
-{ 12, 14, 17, 20}, { 11, 14, 16, 19}, { 11, 13, 15, 18}, { 10, 12, 15, 17},
-{ 10, 12, 14, 16}, {  9, 11, 13, 15}, {  9, 11, 12, 14}, {  8, 10, 12, 14},
-{  8,  9, 11, 13}, {  7,  9, 11, 12}, {  7,  9, 10, 12}, {  7,  8, 10, 11},
-{  6,  8,  9, 11}, {  6,  7,  9, 10}, {  6,  7,  8,  9}, {  2,  2,  2,  2},
-};
-
-static const uint8_t mps_state[64]= {
-  1, 2, 3, 4, 5, 6, 7, 8,
-  9,10,11,12,13,14,15,16,
- 17,18,19,20,21,22,23,24,
- 25,26,27,28,29,30,31,32,
- 33,34,35,36,37,38,39,40,
- 41,42,43,44,45,46,47,48,
- 49,50,51,52,53,54,55,56,
- 57,58,59,60,61,62,62,63,
-};
-
-static const uint8_t lps_state[64]= {
-  0, 0, 1, 2, 2, 4, 4, 5,
-  6, 7, 8, 9, 9,11,11,12,
- 13,13,15,15,16,16,18,18,
- 19,19,21,21,22,22,23,24,
- 24,25,26,26,27,27,28,29,
- 29,30,30,30,31,32,32,33,
- 33,33,34,34,35,35,35,36,
- 36,36,37,37,37,38,38,63,
-};
-
-static const uint8_t last_coeff_flag_offset_8x8[63] = {
- 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
- 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8
-};
+#include cabac_tablegen.h
 
 /**
  *
@@ -116,34 +68,12 @@ void ff_init_cabac_decoder(CABACContext *c, const uint8_t 
*buf, int buf_size){
 
 void ff_init_cabac_states(void)
 {
-int i, j;
 static int initialized = 0;
 
 if (initialized)
 return;
 
-for (i = 0; i  512; i++)
-ff_h264_norm_shift[i] = i ? 8 - av_log2(i) : 9;
-
-for(i=0; i64; i++){
-for(j=0; j4; j++){ //FIXME check if this is worth the 1 shift we save
-ff_h264_lps_range[j*2*64+2*i+0]=
-ff_h264_lps_range[j*2*64+2*i+1]= lps_range[i][j];
-}
-

[FFmpeg-devel] [PATCH] Add SUP/PGS subtitle demuxer

2014-08-31 Thread wm4
---
Following the advice to use av_get_packet() etc.

Tese functions still return partial packets, but mark them as
corrupted - so returning them should be fine.
---
 libavformat/Makefile |  1 +
 libavformat/allformats.c |  1 +
 libavformat/supdec.c | 85 
 3 files changed, 87 insertions(+)
 create mode 100644 libavformat/supdec.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 3d124fb..b4965fe 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -405,6 +405,7 @@ OBJS-$(CONFIG_SRT_MUXER) += srtenc.o
 OBJS-$(CONFIG_STR_DEMUXER)   += psxstr.o
 OBJS-$(CONFIG_SUBVIEWER1_DEMUXER)+= subviewer1dec.o subtitles.o
 OBJS-$(CONFIG_SUBVIEWER_DEMUXER) += subviewerdec.o subtitles.o
+OBJS-$(CONFIG_SUP_DEMUXER)   += supdec.o
 OBJS-$(CONFIG_SWF_DEMUXER)   += swfdec.o swf.o
 OBJS-$(CONFIG_SWF_MUXER) += swfenc.o swf.o
 OBJS-$(CONFIG_TAK_DEMUXER)   += takdec.o apetag.o img2.o rawdec.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 8f70c4b..e6c0e5f 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -280,6 +280,7 @@ void av_register_all(void)
 REGISTER_DEMUXER (STR,  str);
 REGISTER_DEMUXER (SUBVIEWER1,   subviewer1);
 REGISTER_DEMUXER (SUBVIEWER,subviewer);
+REGISTER_DEMUXER (SUP,  sup);
 REGISTER_MUXDEMUX(SWF,  swf);
 REGISTER_DEMUXER (TAK,  tak);
 REGISTER_MUXER   (TEE,  tee);
diff --git a/libavformat/supdec.c b/libavformat/supdec.c
new file mode 100644
index 000..920a7a0
--- /dev/null
+++ b/libavformat/supdec.c
@@ -0,0 +1,85 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include avformat.h
+#include internal.h
+#include libavutil/intreadwrite.h
+
+#define SUP_PGS_MAGIC 0x5047 /* PG, big endian */
+
+static int sup_read_header(AVFormatContext *s)
+{
+AVStream *st = avformat_new_stream(s, NULL);
+if (!st)
+return AVERROR(ENOMEM);
+st-codec-codec_type = AVMEDIA_TYPE_SUBTITLE;
+st-codec-codec_id = AV_CODEC_ID_HDMV_PGS_SUBTITLE;
+avpriv_set_pts_info(st, 32, 1, 9);
+
+return 0;
+}
+
+static int sup_read_packet(struct AVFormatContext *s, AVPacket *pkt)
+{
+int64_t pts, pos;
+int ret;
+
+pos = avio_tell(s-pb);
+
+if (avio_rb16(s-pb) != SUP_PGS_MAGIC)
+return avio_feof(s-pb) ? AVERROR_EOF : AVERROR_INVALIDDATA;
+
+pts = avio_rb32(s-pb);
+avio_rb32(s-pb); /* discard DTS (usually 0, and useless) */
+
+if ((ret = av_get_packet(s-pb, pkt, 3))  0)
+return ret;
+
+pkt-stream_index = 0;
+pkt-flags |= AV_PKT_FLAG_KEY;
+pkt-pos = pos;
+pkt-pts = pts;
+
+if (pkt-size = 3) {
+// The full packet size is stored as part of the packet.
+size_t len = AV_RB16(pkt-data + 1);
+
+if ((ret = av_append_packet(s-pb, pkt, len))  0)
+return ret;
+}
+
+return 0;
+}
+
+static int sup_probe(AVProbeData *p)
+{
+if (p-buf_size  2 || memcmp(p-buf, PG, 2))
+return 0;
+return AVPROBE_SCORE_EXTENSION;
+}
+
+AVInputFormat ff_sup_demuxer = {
+.name   = sup,
+.long_name  = NULL_IF_CONFIG_SMALL(raw HDMV Presentation Graphic 
Stream subtitles),
+.extensions = sup,
+.mime_type  = application/x-pgs,
+.read_probe = sup_probe,
+.read_header= sup_read_header,
+.read_packet= sup_read_packet,
+.flags  = AVFMT_GENERIC_INDEX,
+};
-- 
2.1.0

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


Re: [FFmpeg-devel] [PATCH] Add SUP/PGS subtitle demuxer

2014-08-31 Thread compn
On Sun, 31 Aug 2014 00:33:58 +0200
wm4 nfx...@googlemail.com wrote:

 On Sat, 30 Aug 2014 18:16:27 -0400
 Marcus Johnson bumblebritche...@gmail.com wrote:
 
  Here's a PGS subtitle sample from Eac3to:
  https://dl.dropboxusercontent.com/u/52358991/English.zip

you saw the few samples we have in the repo, right?
http://samples.ffmpeg.org/sub/BluRay/
http://samples.ffmpeg.org/mplayer-bugs/bug2176/

will try to dig some more.

-compn

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


[FFmpeg-devel] [PATCH 2/2] rl.h: Use deprecated attribute for deprecated field.

2014-08-31 Thread Reimar Döffinger
---
 libavcodec/rl.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/rl.h b/libavcodec/rl.h
index c80283d..5a90167 100644
--- a/libavcodec/rl.h
+++ b/libavcodec/rl.h
@@ -44,7 +44,7 @@ typedef struct RLTable {
 uint8_t *index_run[2]; /// encoding only
 int8_t *max_level[2];  /// encoding  decoding
 int8_t *max_run[2];/// encoding  decoding
-VLC vlc;   /// decoding only deprecated FIXME remove
+attribute_deprecated VLC vlc;  /// decoding only deprecated FIXME remove
 RL_VLC_ELEM *rl_vlc[32];   /// decoding only
 } RLTable;
 
-- 
2.1.0

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


[FFmpeg-devel] [PATCH 1/2] h261, h263 decoders: convert to RL_VLC.

2014-08-31 Thread Reimar Döffinger
This has a few TODOs like adjusting the run tables instead
of having a -1 in the decode loop.
But please review the general idea.

Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de
---
 libavcodec/flv.h|  1 -
 libavcodec/flvdec.c | 12 ---
 libavcodec/h261dec.c| 27 +++-
 libavcodec/ituh263dec.c | 55 +++--
 4 files changed, 57 insertions(+), 38 deletions(-)

diff --git a/libavcodec/flv.h b/libavcodec/flv.h
index 16bc88b..df50820 100644
--- a/libavcodec/flv.h
+++ b/libavcodec/flv.h
@@ -28,6 +28,5 @@ void ff_flv_encode_picture_header(MpegEncContext * s, int 
picture_number);
 void ff_flv2_encode_ac_esc(PutBitContext *pb, int slevel, int level, int run, 
int last);
 
 int ff_flv_decode_picture_header(MpegEncContext *s);
-void ff_flv2_decode_ac_esc(GetBitContext *gb, int *level, int *run, int *last);
 
 #endif /* AVCODEC_FLV_H */
diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c
index 3b048f6..db413f2 100644
--- a/libavcodec/flvdec.c
+++ b/libavcodec/flvdec.c
@@ -22,18 +22,6 @@
 #include flv.h
 #include libavutil/imgutils.h
 
-void ff_flv2_decode_ac_esc(GetBitContext *gb, int *level, int *run, int *last)
-{
-int is11 = get_bits1(gb);
-*last = get_bits1(gb);
-*run  = get_bits(gb, 6);
-if (is11) {
-*level = get_sbits(gb, 11);
-} else {
-*level = get_sbits(gb, 7);
-}
-}
-
 int ff_flv_decode_picture_header(MpegEncContext *s)
 {
 int format, width, height;
diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 301ecc1..5f0eb59 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -258,7 +258,7 @@ static int decode_mv_component(GetBitContext *gb, int v)
 static int h261_decode_block(H261Context *h, int16_t *block, int n, int coded)
 {
 MpegEncContext *const s = h-s;
-int code, level, i, j, run;
+int level, i, j, run;
 RLTable *rl = ff_h261_rl_tcoeff;
 const uint8_t *scan_table;
 
@@ -303,27 +303,32 @@ static int h261_decode_block(H261Context *h, int16_t 
*block, int n, int coded)
 s-block_last_index[n] = i - 1;
 return 0;
 }
+{
+OPEN_READER(re, s-gb);
 for (;;) {
-code = get_vlc2(s-gb, rl-vlc.table, TCOEFF_VLC_BITS, 2);
-if (code  0) {
+UPDATE_CACHE(re, s-gb);
+GET_RL_VLC(level, run, re, s-gb, rl-rl_vlc[0], TCOEFF_VLC_BITS, 2, 
0);
+if (run == 66  level) {
 av_log(s-avctx, AV_LOG_ERROR, illegal ac vlc code at %dx%d\n,
s-mb_x, s-mb_y);
 return -1;
 }
-if (code == rl-n) {
+if (run == 66) {
 /* escape */
 /* The remaining combinations of (run, level) are encoded with a
  * 20-bit word consisting of 6 bits escape, 6 bits run and 8 bits
  * level. */
-run   = get_bits(s-gb, 6);
-level = get_sbits(s-gb, 8);
-} else if (code == 0) {
+run   = SHOW_UBITS(re, s-gb, 6);
+SKIP_CACHE(re, s-gb, 6);
+level = SHOW_SBITS(re, s-gb, 8);
+SKIP_COUNTER(re, s-gb, 6 + 8);
+} else if (level == 0) {
 break;
 } else {
-run   = rl-table_run[code];
-level = rl-table_level[code];
-if (get_bits1(s-gb))
+run--;
+if (SHOW_UBITS(re, s-gb, 1))
 level = -level;
+SKIP_COUNTER(re, s-gb, 1);
 }
 i += run;
 if (i = 64) {
@@ -335,6 +340,8 @@ static int h261_decode_block(H261Context *h, int16_t 
*block, int n, int coded)
 block[j] = level;
 i++;
 }
+CLOSE_READER(re, s-gb);
+}
 s-block_last_index[n] = i - 1;
 return 0;
 }
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index ce454c3..9078c9e 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -418,7 +418,7 @@ static void h263_decode_dquant(MpegEncContext *s){
 static int h263_decode_block(MpegEncContext * s, int16_t * block,
  int n, int coded)
 {
-int code, level, i, j, last, run;
+int level, i, j, last, run;
 RLTable *rl = ff_h263_rl_inter;
 const uint8_t *scan_table;
 GetBitContext gb= s-gb;
@@ -479,36 +479,59 @@ static int h263_decode_block(MpegEncContext * s, int16_t 
* block,
 return 0;
 }
 retry:
+{
+OPEN_READER(re, s-gb);
 for(;;) {
-code = get_vlc2(s-gb, rl-vlc.table, TEX_VLC_BITS, 2);
-if (code  0){
+UPDATE_CACHE(re, s-gb);
+GET_RL_VLC(level, run, re, s-gb, rl-rl_vlc[0], TEX_VLC_BITS, 2, 0);
+if (run == 66  level){
 av_log(s-avctx, AV_LOG_ERROR, illegal ac vlc code at %dx%d\n, 
s-mb_x, s-mb_y);
 return -1;
 }
-if (code == rl-n) {
+if (run == 66) {
 /* escape */
 if (CONFIG_FLV_DECODER  s-h263_flv  1) {
-ff_flv2_decode_ac_esc(s-gb, level, run, last);
+  

Re: [FFmpeg-devel] [PATCH] Add SUP/PGS subtitle demuxer

2014-08-31 Thread Reimar Döffinger
On Sun, Aug 31, 2014 at 01:04:29PM +0200, wm4 wrote:
 +static int sup_probe(AVProbeData *p)
 +{
 +if (p-buf_size  2 || memcmp(p-buf, PG, 2))
 +return 0;
 +return AVPROBE_SCORE_EXTENSION;

I understand if you consider it not worth the effort,
but ideally this would scan ahead several packets,
and if it all matches up return a higher score.
The MP3 probe function is possibly a good reference (though
this one should be bit simpler).
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] h261, h263 decoders: convert to RL_VLC.

2014-08-31 Thread Reimar Döffinger
On Sun, Aug 31, 2014 at 02:21:46PM +0200, Reimar Döffinger wrote:
 This has a few TODOs like adjusting the run tables instead
 of having a -1 in the decode loop.
 But please review the general idea.

I forgot to say: this is the first time I use this API,
and I was quite confused.
And in particular I am not sure how much I can safely read
from the cache without updating...
So I might be doing some fairly stupid things.
Still, it passes make fate.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] libavdevice/v4l2: fix of crash caused by assert

2014-08-31 Thread Dmitry Volyntsev
why is this condition true ?

I tried several configuration and problem occurred only under certain
circumstances:
1.  webcam type:  Logitech C310 (tried also: C350)
2. capturing settings: 640*480, 422p
3.  simultaneous capturing from two webcams
4. relatively old laptop (Lenovo Z470, Z570, L420)

I think it somehow relate to usb hub bandwidth and laptop performance
issue (and maybe length of usb cable?)

I use my own app (24/7 surveillance home recording) which depends on
libavdevice and prefer to ignore AVERROR_INVALIDDATA in this case
(just skip the broken frame and continue) because reconnect to devices
required more than a half of second. With my patch everything goes
fine (more than 2 week of continuous recording)

logs:
  [video4linux2,v4l2 @ 0x2efec00]The v4l2 frame is 614396 bytes, but
614400 bytes are expected
  [video4linux2,v4l2 @ 0x2efec00]The v4l2 frame is 614396 bytes, but
614400 bytes are expected



On Sat, Aug 30, 2014 at 9:17 PM, Michael Niedermayer michae...@gmx.at wrote:
 On Sat, Aug 30, 2014 at 08:19:37PM +0400, Dmitry Volyntsev wrote:
 To understand the problem one needs to see the original code around
 and to think what would happen if from time to time while capturing
 condition (s-frame_size  0  buf.bytesused != s-frame_size)
 happens to be true (this is not critical error so capturing would
 continue). It is obvious that eventually buffers_queued would become 
 1.

 why is this condition true, what are these mismatching buffers ?



 static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt)
 {
   ...
 if (buf.index = s-buffers) {
 av_log(ctx, AV_LOG_ERROR, Invalid buffer index received.\n);

 return AVERROR(EINVAL);
 }

 avpriv_atomic_int_add_and_fetch(s-buffers_queued, -1);
 // always keep at least one buffer queued
 av_assert0(avpriv_atomic_int_get(s-buffers_queued) = 1);

 if (s-frame_size  0  buf.bytesused != s-frame_size) {
av_log(ctx, AV_LOG_ERROR,
The v4l2 frame is %d bytes, but %d bytes are expected\n,
buf.bytesused, s-frame_size);
 return AVERROR_INVALIDDATA;

 }

 So my solution:  we should make all checks here before decrementing
 buffers_queued

 On Wed, Aug 27, 2014 at 1:20 AM, Michael Niedermayer michae...@gmx.at 
 wrote:
  On Wed, Aug 13, 2014 at 07:04:01PM +0400, Dmitry Volyntsev wrote:
  From: Dmitry Volyntsev xeioexcept...@gmail.com
 
  s-buffers_queued constantly decremented and not incremented
  in case of (s-frame_size  0  buf.bytesused != s-frame_size)
  condition (caught on long run capture of Logitech C310)
 
  can you explain why this happens ? where do this misatching
  bufs come from ?
  why is droping them correct ?
 
 
  [...]
  --
  Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
 
  Dictatorship naturally arises out of democracy, and the most aggravated
  form of tyranny and slavery out of the most extreme liberty. -- Plato



 --
 Be happy,
 Best regards,
 Dmitry Volyntsev
 ___
 ffmpeg-devel mailing list
 ffmpeg-devel@ffmpeg.org
 http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


 --
 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

 In a rich man's house there is no place to spit but his face.
 -- Diogenes of Sinope



-- 
Be happy,
Best regards,
Dmitry Volyntsev
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] h261, h263 decoders: convert to RL_VLC.

2014-08-31 Thread Ronald S. Bultje
Hi,

On Sun, Aug 31, 2014 at 8:27 AM, Reimar Döffinger reimar.doeffin...@gmx.de
wrote:

 On Sun, Aug 31, 2014 at 02:21:46PM +0200, Reimar Döffinger wrote:
  This has a few TODOs like adjusting the run tables instead
  of having a -1 in the decode loop.
  But please review the general idea.

 I forgot to say: this is the first time I use this API,
 and I was quite confused.
 And in particular I am not sure how much I can safely read
 from the cache without updating...


25, right? Anything less, we'd advance a byte in update.

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


Re: [FFmpeg-devel] [PATCH 1/2] h261, h263 decoders: convert to RL_VLC.

2014-08-31 Thread Reimar Döffinger
On Sun, Aug 31, 2014 at 08:37:56AM -0400, Ronald S. Bultje wrote:
 Hi,
 
 On Sun, Aug 31, 2014 at 8:27 AM, Reimar Döffinger reimar.doeffin...@gmx.de
 wrote:
 
  On Sun, Aug 31, 2014 at 02:21:46PM +0200, Reimar Döffinger wrote:
   This has a few TODOs like adjusting the run tables instead
   of having a -1 in the decode loop.
   But please review the general idea.
 
  I forgot to say: this is the first time I use this API,
  and I was quite confused.
  And in particular I am not sure how much I can safely read
  from the cache without updating...
 
 25, right? Anything less, we'd advance a byte in update.

Well, but then there is the question how many GET_VL_RLC
may end up using at most.
And that will depend on even more, for example, how much will
it have used at most when you get into the escape path?
I think this is quite tricky if you want to do it optimally,
so I just guessed so far...
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add SUP/PGS subtitle demuxer

2014-08-31 Thread wm4
On Sun, 31 Aug 2014 14:25:21 +0200
Reimar Döffinger reimar.doeffin...@gmx.de wrote:

 On Sun, Aug 31, 2014 at 01:04:29PM +0200, wm4 wrote:
  +static int sup_probe(AVProbeData *p)
  +{
  +if (p-buf_size  2 || memcmp(p-buf, PG, 2))
  +return 0;
  +return AVPROBE_SCORE_EXTENSION;
 
 I understand if you consider it not worth the effort,
 but ideally this would scan ahead several packets,
 and if it all matches up return a higher score.
 The MP3 probe function is possibly a good reference (though
 this one should be bit simpler).

Other formats are also relatively lazy and just check the magic atthe
start of the file and call it a day (e.g. flac, some img2dec probers).
Of course it's possible that 2 bytes (and ASCII) is a bit too prone to
false positives, so maybe it should be improved.

Since PGS packets can be only at most ~64KB big, I guess it would be
feasible to check whether there is a second PGS packet after the first
one. Would that be sufficient?

In theory, it would be nice if the general probe code could jzst try to
read a few packets...
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add SUP/PGS subtitle demuxer

2014-08-31 Thread Reimar Döffinger
On Sun, Aug 31, 2014 at 02:57:54PM +0200, wm4 wrote:
 On Sun, 31 Aug 2014 14:25:21 +0200
 Reimar Döffinger reimar.doeffin...@gmx.de wrote:
 
  On Sun, Aug 31, 2014 at 01:04:29PM +0200, wm4 wrote:
   +static int sup_probe(AVProbeData *p)
   +{
   +if (p-buf_size  2 || memcmp(p-buf, PG, 2))
   +return 0;
   +return AVPROBE_SCORE_EXTENSION;
  
  I understand if you consider it not worth the effort,
  but ideally this would scan ahead several packets,
  and if it all matches up return a higher score.
  The MP3 probe function is possibly a good reference (though
  this one should be bit simpler).
 
 Other formats are also relatively lazy and just check the magic atthe
 start of the file and call it a day (e.g. flac, some img2dec probers).
 Of course it's possible that 2 bytes (and ASCII) is a bit too prone to
 false positives, so maybe it should be improved.
 
 Since PGS packets can be only at most ~64KB big, I guess it would be
 feasible to check whether there is a second PGS packet after the first
 one. Would that be sufficient?

Ideally it would scan the whole probe buffer, and return a score based
on how many consecutive packets it found compared to the probe size
(more or less).
tools/probetest is a useful tool, but so far it will only check if
the score is above MAX/4, so demuxers (needlessly) crappy probe but
also low score get a pass...

 In theory, it would be nice if the general probe code could jzst try to
 read a few packets...

Probing is quite performance critical, especially since fringe formats
can even impact the major ones (unless we start sorting them by how
common they are and abort early - but that has its own long list of
issues).
So I think specialized code will remain necessary.
However it might be possible to factor out common approaches, but that
would need some careful checking.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] h261, h263 decoders: convert to RL_VLC.

2014-08-31 Thread Ronald S. Bultje
Hi,

On Sun, Aug 31, 2014 at 8:54 AM, Reimar Döffinger reimar.doeffin...@gmx.de
wrote:

 On Sun, Aug 31, 2014 at 08:37:56AM -0400, Ronald S. Bultje wrote:
  On Sun, Aug 31, 2014 at 8:27 AM, Reimar Döffinger 
 reimar.doeffin...@gmx.de
  wrote:
   On Sun, Aug 31, 2014 at 02:21:46PM +0200, Reimar Döffinger wrote:
This has a few TODOs like adjusting the run tables instead
of having a -1 in the decode loop.
But please review the general idea.
  
   I forgot to say: this is the first time I use this API,
   and I was quite confused.
   And in particular I am not sure how much I can safely read
   from the cache without updating...
 
  25, right? Anything less, we'd advance a byte in update.

 Well, but then there is the question how many GET_VL_RLC
 may end up using at most.
 And that will depend on even more, for example, how much will
 it have used at most when you get into the escape path?
 I think this is quite tricky if you want to do it optimally,
 so I just guessed so far...


I'm not sure that's a good idea. So, basically, you want to make
pessimistic assumptions, not 90% worst or anything, just worst-possible
case. Because after all, any bitstream that did decode correctly before
should still decode correctly after.

So If you want to use GET_VL_RLC, just assume it'll consume the max number
bits within its vlc code set. Once every 1/n_entries times, it actually
will (assuming random input), and you want to keep handling that case. If
you want to specifically optimize short codes, make a branch (i.e. if
code_len  .. or if code_prefix  ... or whatever).

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


Re: [FFmpeg-devel] [PATCH 1/2] h261, h263 decoders: convert to RL_VLC.

2014-08-31 Thread Reimar Döffinger
On Sun, Aug 31, 2014 at 09:24:24AM -0400, Ronald S. Bultje wrote:
 Hi,
 
 On Sun, Aug 31, 2014 at 8:54 AM, Reimar Döffinger reimar.doeffin...@gmx.de
 wrote:
 
  On Sun, Aug 31, 2014 at 08:37:56AM -0400, Ronald S. Bultje wrote:
   On Sun, Aug 31, 2014 at 8:27 AM, Reimar Döffinger 
  reimar.doeffin...@gmx.de
   wrote:
On Sun, Aug 31, 2014 at 02:21:46PM +0200, Reimar Döffinger wrote:
 This has a few TODOs like adjusting the run tables instead
 of having a -1 in the decode loop.
 But please review the general idea.
   
I forgot to say: this is the first time I use this API,
and I was quite confused.
And in particular I am not sure how much I can safely read
from the cache without updating...
  
   25, right? Anything less, we'd advance a byte in update.
 
  Well, but then there is the question how many GET_VL_RLC
  may end up using at most.
  And that will depend on even more, for example, how much will
  it have used at most when you get into the escape path?
  I think this is quite tricky if you want to do it optimally,
  so I just guessed so far...
 
 
 I'm not sure that's a good idea. So, basically, you want to make
 pessimistic assumptions, not 90% worst or anything, just worst-possible
 case. Because after all, any bitstream that did decode correctly before
 should still decode correctly after.
 
 So If you want to use GET_VL_RLC, just assume it'll consume the max number
 bits within its vlc code set. Once every 1/n_entries times, it actually
 will (assuming random input), and you want to keep handling that case. If
 you want to specifically optimize short codes, make a branch (i.e. if
 code_len  .. or if code_prefix  ... or whatever).

The point is we already _have_ those branches.
And the escape code is one specific VLC code.
So we should know _exactly_ how much we consumed, and can rely on that.
You just have to find all the proper information.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add SUP/PGS subtitle demuxer

2014-08-31 Thread wm4
On Sun, 31 Aug 2014 15:16:49 +0200
Reimar Döffinger reimar.doeffin...@gmx.de wrote:

 On Sun, Aug 31, 2014 at 02:57:54PM +0200, wm4 wrote:
  On Sun, 31 Aug 2014 14:25:21 +0200
  Reimar Döffinger reimar.doeffin...@gmx.de wrote:
  
   On Sun, Aug 31, 2014 at 01:04:29PM +0200, wm4 wrote:
+static int sup_probe(AVProbeData *p)
+{
+if (p-buf_size  2 || memcmp(p-buf, PG, 2))
+return 0;
+return AVPROBE_SCORE_EXTENSION;
   
   I understand if you consider it not worth the effort,
   but ideally this would scan ahead several packets,
   and if it all matches up return a higher score.
   The MP3 probe function is possibly a good reference (though
   this one should be bit simpler).
  
  Other formats are also relatively lazy and just check the magic atthe
  start of the file and call it a day (e.g. flac, some img2dec probers).
  Of course it's possible that 2 bytes (and ASCII) is a bit too prone to
  false positives, so maybe it should be improved.
  
  Since PGS packets can be only at most ~64KB big, I guess it would be
  feasible to check whether there is a second PGS packet after the first
  one. Would that be sufficient?
 
 Ideally it would scan the whole probe buffer, and return a score based
 on how many consecutive packets it found compared to the probe size
 (more or less).
 tools/probetest is a useful tool, but so far it will only check if
 the score is above MAX/4, so demuxers (needlessly) crappy probe but
 also low score get a pass...

Well yes, it would be possible to loop over the entire probe buffer,
until it ends on a packet boundary, or there's a partial cut-off
packet. How exactly would you suggest the probe score?

Personally, I'd probably do the following: if the header of the first
packet is available (i.e. PG magic), then return SCORE_EXTENSION-1.
If the probe buffer is large enough to include the header of the next
packet, and the next packet has no magic (i.e. probably invalid),
return 0. Otherwise, return SCORE_EXTENSION+1.

Suggestions?

  In theory, it would be nice if the general probe code could jzst try to
  read a few packets...
 
 Probing is quite performance critical, especially since fringe formats
 can even impact the major ones (unless we start sorting them by how
 common they are and abort early - but that has its own long list of
 issues).
 So I think specialized code will remain necessary.
 However it might be possible to factor out common approaches, but that
 would need some careful checking.

Possibly it would make sense to provide a generic function, that
creates an in-memory aviobuf, and lets the demuxer read packets from
it. Demuxers which need it could use it in the probe function. But
yeah, that probably is a bit out of the scope of this tiny patch.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 3/4] ituh263dec: Optimize new RL_VLC based decoding.

2014-08-31 Thread Reimar Döffinger
Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de
---
 libavcodec/ituh263dec.c | 39 ++-
 1 file changed, 18 insertions(+), 21 deletions(-)

diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index 26f0ec5..083f5ae 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -418,7 +418,7 @@ static void h263_decode_dquant(MpegEncContext *s){
 static int h263_decode_block(MpegEncContext * s, int16_t * block,
  int n, int coded)
 {
-int level, i, j, last, run;
+int level, i, j, run;
 RLTable *rl = ff_h263_rl_inter;
 const uint8_t *scan_table;
 GetBitContext gb= s-gb;
@@ -493,26 +493,22 @@ retry:
 if (CONFIG_FLV_DECODER  s-h263_flv  1) {
 int is11 = SHOW_UBITS(re, s-gb, 1);
 SKIP_CACHE(re, s-gb, 1);
-last = SHOW_UBITS(re, s-gb, 1);
-SKIP_CACHE(re, s-gb, 1);
-run = SHOW_UBITS(re, s-gb, 6);
+run = SHOW_UBITS(re, s-gb, 7) + 1;
 if (is11) {
-SKIP_COUNTER(re, s-gb, 6);
+SKIP_COUNTER(re, s-gb, 1 + 7);
 UPDATE_CACHE(re, s-gb);
 level = SHOW_SBITS(re, s-gb, 11);
-SKIP_COUNTER(re, s-gb, 1 + 1 + 6 + 11);
+SKIP_COUNTER(re, s-gb, 11);
 } else {
-SKIP_CACHE(re, s-gb, 6);
+SKIP_CACHE(re, s-gb, 7);
 level = SHOW_SBITS(re, s-gb, 7);
-SKIP_COUNTER(re, s-gb, 1 + 1 + 6 + 7);
+SKIP_COUNTER(re, s-gb, 1 + 7 + 7);
 }
 } else {
-last = SHOW_UBITS(re, s-gb, 1);
-SKIP_CACHE(re, s-gb, 1);
-run = SHOW_UBITS(re, s-gb, 6);
-SKIP_CACHE(re, s-gb, 6);
+run = SHOW_UBITS(re, s-gb, 7) + 1;
+SKIP_CACHE(re, s-gb, 7);
 level = (int8_t)SHOW_UBITS(re, s-gb, 8);
-SKIP_COUNTER(re, s-gb, 1 + 6 + 8);
+SKIP_COUNTER(re, s-gb, 7 + 8);
 if(level == -128){
 UPDATE_CACHE(re, s-gb);
 if (s-codec_id == AV_CODEC_ID_RV10) {
@@ -528,15 +524,19 @@ retry:
 }
 }
 } else {
-run--;
-last = run = 192;
-run = 63;
 if (SHOW_UBITS(re, s-gb, 1))
 level = -level;
 SKIP_COUNTER(re, s-gb, 1);
 }
 i += run;
-if (i = 64){
+if (i  64){
+// redo update without last flag
+i = i - run + ((run-1)63);
+if (i  64) {
+// only last marker, no overrun
+block[scan_table[i]] = level;
+break;
+}
 if(s-alt_inter_vlc  rl == ff_h263_rl_inter  !s-mb_intra){
 CLOSE_READER(re, s-gb);
 //Looks like a hack but no, it's the way it is supposed to 
work ...
@@ -549,11 +549,8 @@ retry:
 av_log(s-avctx, AV_LOG_ERROR, run overflow at %dx%d i:%d\n, 
s-mb_x, s-mb_y, s-mb_intra);
 return -1;
 }
-j = scan_table[i];
+j = scan_table[i-1];
 block[j] = level;
-if (last)
-break;
-i++;
 }
 CLOSE_READER(re, s-gb);
 }
-- 
2.1.0

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


[FFmpeg-devel] [PATCH 2/4] h261dec: Optimize new RL_VLC decoding.

2014-08-31 Thread Reimar Döffinger
Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de
---
 libavcodec/h261dec.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 5f0eb59..f286d23 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -318,27 +318,25 @@ static int h261_decode_block(H261Context *h, int16_t 
*block, int n, int coded)
 /* The remaining combinations of (run, level) are encoded with a
  * 20-bit word consisting of 6 bits escape, 6 bits run and 8 bits
  * level. */
-run   = SHOW_UBITS(re, s-gb, 6);
+run   = SHOW_UBITS(re, s-gb, 6) + 1;
 SKIP_CACHE(re, s-gb, 6);
 level = SHOW_SBITS(re, s-gb, 8);
 SKIP_COUNTER(re, s-gb, 6 + 8);
 } else if (level == 0) {
 break;
 } else {
-run--;
 if (SHOW_UBITS(re, s-gb, 1))
 level = -level;
 SKIP_COUNTER(re, s-gb, 1);
 }
 i += run;
-if (i = 64) {
+if (i  64) {
 av_log(s-avctx, AV_LOG_ERROR, run overflow at %dx%d\n,
s-mb_x, s-mb_y);
 return -1;
 }
-j= scan_table[i];
+j= scan_table[i-1];
 block[j] = level;
-i++;
 }
 CLOSE_READER(re, s-gb);
 }
-- 
2.1.0

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


[FFmpeg-devel] [PATCH 1/4] h261, h263 decoders: convert to RL_VLC.

2014-08-31 Thread Reimar Döffinger
Some additional optimizations in following patch.

Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de
---
 libavcodec/flv.h|  1 -
 libavcodec/flvdec.c | 12 --
 libavcodec/h261dec.c| 27 ++-
 libavcodec/ituh263dec.c | 58 -
 4 files changed, 60 insertions(+), 38 deletions(-)

diff --git a/libavcodec/flv.h b/libavcodec/flv.h
index 16bc88b..df50820 100644
--- a/libavcodec/flv.h
+++ b/libavcodec/flv.h
@@ -28,6 +28,5 @@ void ff_flv_encode_picture_header(MpegEncContext * s, int 
picture_number);
 void ff_flv2_encode_ac_esc(PutBitContext *pb, int slevel, int level, int run, 
int last);
 
 int ff_flv_decode_picture_header(MpegEncContext *s);
-void ff_flv2_decode_ac_esc(GetBitContext *gb, int *level, int *run, int *last);
 
 #endif /* AVCODEC_FLV_H */
diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c
index 3b048f6..db413f2 100644
--- a/libavcodec/flvdec.c
+++ b/libavcodec/flvdec.c
@@ -22,18 +22,6 @@
 #include flv.h
 #include libavutil/imgutils.h
 
-void ff_flv2_decode_ac_esc(GetBitContext *gb, int *level, int *run, int *last)
-{
-int is11 = get_bits1(gb);
-*last = get_bits1(gb);
-*run  = get_bits(gb, 6);
-if (is11) {
-*level = get_sbits(gb, 11);
-} else {
-*level = get_sbits(gb, 7);
-}
-}
-
 int ff_flv_decode_picture_header(MpegEncContext *s)
 {
 int format, width, height;
diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 301ecc1..5f0eb59 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -258,7 +258,7 @@ static int decode_mv_component(GetBitContext *gb, int v)
 static int h261_decode_block(H261Context *h, int16_t *block, int n, int coded)
 {
 MpegEncContext *const s = h-s;
-int code, level, i, j, run;
+int level, i, j, run;
 RLTable *rl = ff_h261_rl_tcoeff;
 const uint8_t *scan_table;
 
@@ -303,27 +303,32 @@ static int h261_decode_block(H261Context *h, int16_t 
*block, int n, int coded)
 s-block_last_index[n] = i - 1;
 return 0;
 }
+{
+OPEN_READER(re, s-gb);
 for (;;) {
-code = get_vlc2(s-gb, rl-vlc.table, TCOEFF_VLC_BITS, 2);
-if (code  0) {
+UPDATE_CACHE(re, s-gb);
+GET_RL_VLC(level, run, re, s-gb, rl-rl_vlc[0], TCOEFF_VLC_BITS, 2, 
0);
+if (run == 66  level) {
 av_log(s-avctx, AV_LOG_ERROR, illegal ac vlc code at %dx%d\n,
s-mb_x, s-mb_y);
 return -1;
 }
-if (code == rl-n) {
+if (run == 66) {
 /* escape */
 /* The remaining combinations of (run, level) are encoded with a
  * 20-bit word consisting of 6 bits escape, 6 bits run and 8 bits
  * level. */
-run   = get_bits(s-gb, 6);
-level = get_sbits(s-gb, 8);
-} else if (code == 0) {
+run   = SHOW_UBITS(re, s-gb, 6);
+SKIP_CACHE(re, s-gb, 6);
+level = SHOW_SBITS(re, s-gb, 8);
+SKIP_COUNTER(re, s-gb, 6 + 8);
+} else if (level == 0) {
 break;
 } else {
-run   = rl-table_run[code];
-level = rl-table_level[code];
-if (get_bits1(s-gb))
+run--;
+if (SHOW_UBITS(re, s-gb, 1))
 level = -level;
+SKIP_COUNTER(re, s-gb, 1);
 }
 i += run;
 if (i = 64) {
@@ -335,6 +340,8 @@ static int h261_decode_block(H261Context *h, int16_t 
*block, int n, int coded)
 block[j] = level;
 i++;
 }
+CLOSE_READER(re, s-gb);
+}
 s-block_last_index[n] = i - 1;
 return 0;
 }
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index ce454c3..26f0ec5 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -418,7 +418,7 @@ static void h263_decode_dquant(MpegEncContext *s){
 static int h263_decode_block(MpegEncContext * s, int16_t * block,
  int n, int coded)
 {
-int code, level, i, j, last, run;
+int level, i, j, last, run;
 RLTable *rl = ff_h263_rl_inter;
 const uint8_t *scan_table;
 GetBitContext gb= s-gb;
@@ -479,40 +479,66 @@ static int h263_decode_block(MpegEncContext * s, int16_t 
* block,
 return 0;
 }
 retry:
+{
+OPEN_READER(re, s-gb);
 for(;;) {
-code = get_vlc2(s-gb, rl-vlc.table, TEX_VLC_BITS, 2);
-if (code  0){
+UPDATE_CACHE(re, s-gb);
+GET_RL_VLC(level, run, re, s-gb, rl-rl_vlc[0], TEX_VLC_BITS, 2, 0);
+if (run == 66  level){
 av_log(s-avctx, AV_LOG_ERROR, illegal ac vlc code at %dx%d\n, 
s-mb_x, s-mb_y);
 return -1;
 }
-if (code == rl-n) {
+if (run == 66) {
 /* escape */
 if (CONFIG_FLV_DECODER  s-h263_flv  1) {
-ff_flv2_decode_ac_esc(s-gb, level, run, last);
+int is11 = SHOW_UBITS(re, s-gb, 1);
+SKIP_CACHE(re, 

[FFmpeg-devel] [PATCH 4/4] rl.h: remove deprecated and now unused vlc member.

2014-08-31 Thread Reimar Döffinger
---
 libavcodec/mpeg12.c| 13 +++--
 libavcodec/mpegvideo.c |  8 
 libavcodec/rl.h|  8 
 3 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index 27d680f..cb00baf 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -70,21 +70,22 @@ static const uint8_t table_mb_btype[11][2] = {
 #define INIT_2D_VLC_RL(rl, static_size)\
 {\
 static RL_VLC_ELEM rl_vlc_table[static_size];\
-INIT_VLC_STATIC(rl.vlc, TEX_VLC_BITS, rl.n + 2,\
+VLC tmp_vlc;\
+INIT_VLC_STATIC(tmp_vlc, TEX_VLC_BITS, rl.n + 2,\
 rl.table_vlc[0][1], 4, 2,\
 rl.table_vlc[0][0], 4, 2, static_size);\
 \
 rl.rl_vlc[0] = rl_vlc_table;\
-init_2d_vlc_rl(rl);\
+init_2d_vlc_rl(rl, tmp_vlc);\
 }
 
-static av_cold void init_2d_vlc_rl(RLTable *rl)
+static av_cold void init_2d_vlc_rl(RLTable *rl, const VLC *vlc)
 {
 int i;
 
-for (i = 0; i  rl-vlc.table_size; i++) {
-int code = rl-vlc.table[i][0];
-int len  = rl-vlc.table[i][1];
+for (i = 0; i  vlc-table_size; i++) {
+int code = vlc-table[i][0];
+int len  = vlc-table[i][1];
 int level, run;
 
 if (len == 0) { // illegal code
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 3ec81ce..748dbc8 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1618,7 +1618,7 @@ av_cold void ff_init_rl(RLTable *rl,
 }
 }
 
-av_cold void ff_init_vlc_rl(RLTable *rl)
+av_cold void ff_init_vlc_rl(RLTable *rl, const VLC *vlc)
 {
 int i, q;
 
@@ -1630,9 +1630,9 @@ av_cold void ff_init_vlc_rl(RLTable *rl)
 qmul = 1;
 qadd = 0;
 }
-for (i = 0; i  rl-vlc.table_size; i++) {
-int code = rl-vlc.table[i][0];
-int len  = rl-vlc.table[i][1];
+for (i = 0; i  vlc-table_size; i++) {
+int code = vlc-table[i][0];
+int len  = vlc-table[i][1];
 int level, run;
 
 if (len == 0) { // illegal code
diff --git a/libavcodec/rl.h b/libavcodec/rl.h
index c80283d..3cef366 100644
--- a/libavcodec/rl.h
+++ b/libavcodec/rl.h
@@ -44,7 +44,6 @@ typedef struct RLTable {
 uint8_t *index_run[2]; /// encoding only
 int8_t *max_level[2];  /// encoding  decoding
 int8_t *max_run[2];/// encoding  decoding
-VLC vlc;   /// decoding only deprecated FIXME remove
 RL_VLC_ELEM *rl_vlc[32];   /// decoding only
 } RLTable;
 
@@ -54,13 +53,14 @@ typedef struct RLTable {
  * the level and run tables, if this is NULL av_malloc() 
will be used
  */
 void ff_init_rl(RLTable *rl, uint8_t static_store[2][2*MAX_RUN + MAX_LEVEL + 
3]);
-void ff_init_vlc_rl(RLTable *rl);
+void ff_init_vlc_rl(RLTable *rl, const VLC *vlc);
 
 #define INIT_VLC_RL(rl, static_size)\
 {\
 int q;\
 static RL_VLC_ELEM rl_vlc_table[32][static_size];\
-INIT_VLC_STATIC(rl.vlc, 9, rl.n + 1,\
+VLC tmp_vlc;\
+INIT_VLC_STATIC(tmp_vlc, 9, rl.n + 1,\
  rl.table_vlc[0][1], 4, 2,\
  rl.table_vlc[0][0], 4, 2, static_size);\
 \
@@ -68,7 +68,7 @@ void ff_init_vlc_rl(RLTable *rl);
 for(q=0; q32; q++)\
 rl.rl_vlc[q]= rl_vlc_table[q];\
 \
-ff_init_vlc_rl(rl);\
+ff_init_vlc_rl(rl, tmp_vlc);\
 }\
 }
 
-- 
2.1.0

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


Re: [FFmpeg-devel] [PATCH 1/2] h261, h263 decoders: convert to RL_VLC.

2014-08-31 Thread Ronald S. Bultje
Hi,

On Sun, Aug 31, 2014 at 9:38 AM, Reimar Döffinger reimar.doeffin...@gmx.de
wrote:

 On Sun, Aug 31, 2014 at 09:24:24AM -0400, Ronald S. Bultje wrote:
  On Sun, Aug 31, 2014 at 8:54 AM, Reimar Döffinger 
 reimar.doeffin...@gmx.de
  wrote:
   On Sun, Aug 31, 2014 at 08:37:56AM -0400, Ronald S. Bultje wrote:
On Sun, Aug 31, 2014 at 8:27 AM, Reimar Döffinger 
   reimar.doeffin...@gmx.de
wrote:
 On Sun, Aug 31, 2014 at 02:21:46PM +0200, Reimar Döffinger wrote:
  This has a few TODOs like adjusting the run tables instead
  of having a -1 in the decode loop.
  But please review the general idea.

 I forgot to say: this is the first time I use this API,
 and I was quite confused.
 And in particular I am not sure how much I can safely read
 from the cache without updating...
   
25, right? Anything less, we'd advance a byte in update.
  
   Well, but then there is the question how many GET_VL_RLC
   may end up using at most.
   And that will depend on even more, for example, how much will
   it have used at most when you get into the escape path?
   I think this is quite tricky if you want to do it optimally,
   so I just guessed so far...
 
 
  I'm not sure that's a good idea. So, basically, you want to make
  pessimistic assumptions, not 90% worst or anything, just worst-possible
  case. Because after all, any bitstream that did decode correctly before
  should still decode correctly after.
 
  So If you want to use GET_VL_RLC, just assume it'll consume the max
 number
  bits within its vlc code set. Once every 1/n_entries times, it actually
  will (assuming random input), and you want to keep handling that case. If
  you want to specifically optimize short codes, make a branch (i.e. if
  code_len  .. or if code_prefix  ... or whatever).

 The point is we already _have_ those branches.
 And the escape code is one specific VLC code.
 So we should know _exactly_ how much we consumed, and can rely on that.
 You just have to find all the proper information.


Ah, ok, then it's fine, cool.

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


Re: [FFmpeg-devel] [PATCH 1/2] h261, h263 decoders: convert to RL_VLC.

2014-08-31 Thread Reimar Döffinger
On Sun, Aug 31, 2014 at 03:38:21PM +0200, Reimar Döffinger wrote:
 On Sun, Aug 31, 2014 at 09:24:24AM -0400, Ronald S. Bultje wrote:
  On Sun, Aug 31, 2014 at 8:54 AM, Reimar Döffinger reimar.doeffin...@gmx.de
  wrote:
 I forgot to say: this is the first time I use this API,
 and I was quite confused.
 And in particular I am not sure how much I can safely read
 from the cache without updating...
   
25, right? Anything less, we'd advance a byte in update.
  
   Well, but then there is the question how many GET_VL_RLC
   may end up using at most.
   And that will depend on even more, for example, how much will
   it have used at most when you get into the escape path?
   I think this is quite tricky if you want to do it optimally,
   so I just guessed so far...
  
  
  I'm not sure that's a good idea. So, basically, you want to make
  pessimistic assumptions, not 90% worst or anything, just worst-possible
  case. Because after all, any bitstream that did decode correctly before
  should still decode correctly after.
  
  So If you want to use GET_VL_RLC, just assume it'll consume the max number
  bits within its vlc code set. Once every 1/n_entries times, it actually
  will (assuming random input), and you want to keep handling that case. If
  you want to specifically optimize short codes, make a branch (i.e. if
  code_len  .. or if code_prefix  ... or whatever).
 
 The point is we already _have_ those branches.
 And the escape code is one specific VLC code.
 So we should know _exactly_ how much we consumed, and can rely on that.
 You just have to find all the proper information.

If I checked things correctly, luckily that makes no difference.
The escape code is 7 bits, the full one is 9 bits.
However we either read 15 or 19 additional bits, so we do
not need to update in the 15 bit and we need to in the 19 bit case
no matter what.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add SUP/PGS subtitle demuxer

2014-08-31 Thread wm4
On Sun, 31 Aug 2014 15:06:08 + (UTC)
Carl Eugen Hoyos ceho...@ag.or.at wrote:

 wm4 nfxjfg at googlemail.com writes:
 
+return AVPROBE_SCORE_EXTENSION;
   
   I understand if you consider it not worth the effort,
   but ideally this would scan ahead several packets,
   and if it all matches up return a higher score.
   The MP3 probe function is possibly a good reference 
   (though this one should be bit simpler).
 
 I have written such a patch some time ago, so you can 
 commit with AVPROBE_SCORE_EXTENSION / 2 (or / 4), I 
 will try to improve using my older work if you want.
 (It was too slow so it has to be changed.)

That would potentially be helpful, but I think I can
finish this patch without it.

  Other formats are also relatively lazy
 
 Please point me to such a format, I would like to 
 fix it.
 EXTENSION is ok for 32 bit, MAX is ok for 64bit.
 I think there is one bad example, but I cannot 
 find it atm.

E.g pictor_probe in img2dec.c. Though that returns
AVPROBE_SCORE_EXTENSION / 4, which is certainly low
enough (it's = AVPROBE_SCORE_RETRY, so the API user
knows that it's unreliable).
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/4] h261, h263 decoders: convert to RL_VLC.

2014-08-31 Thread Michael Niedermayer
On Sun, Aug 31, 2014 at 04:48:41PM +0200, Reimar Döffinger wrote:
 Some additional optimizations in following patch.

what effect on speed do these patches have ?

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

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle


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


Re: [FFmpeg-devel] [PATCH 1/4] h261, h263 decoders: convert to RL_VLC.

2014-08-31 Thread Reimar Döffinger
On Sun, Aug 31, 2014 at 05:44:09PM +0200, Michael Niedermayer wrote:
 On Sun, Aug 31, 2014 at 04:48:41PM +0200, Reimar Döffinger wrote:
  Some additional optimizations in following patch.
 
 what effect on speed do these patches have ?

No idea at this point. If someone else feels like benchmarking that is
welcome, since I usually mess it up.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] intmath.h: Remove duplicated ARM include.

2014-08-31 Thread Michael Niedermayer
On Sun, Aug 31, 2014 at 12:29:04PM +0200, Reimar Döffinger wrote:
 Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de
 ---
  libavutil/intmath.h | 4 
  1 file changed, 4 deletions(-)

LGTM

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

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


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


Re: [FFmpeg-devel] [PATCH 1/4] h261, h263 decoders: convert to RL_VLC.

2014-08-31 Thread Reimar Döffinger
On Sun, Aug 31, 2014 at 06:28:24PM +0200, Reimar Döffinger wrote:
 On Sun, Aug 31, 2014 at 05:44:09PM +0200, Michael Niedermayer wrote:
  On Sun, Aug 31, 2014 at 04:48:41PM +0200, Reimar Döffinger wrote:
   Some additional optimizations in following patch.
  
  what effect on speed do these patches have ?
 
 With high error bars, with vsynth1 file, median of 3 runs, only around
 changed code:
 h261:
 4447 decicycles in a, 65532 runs, 4 skips
 to
 3894 decicycles in a, 65534 runs, 2 skips
 
 h263:
 5072 decicycles in a, 65532 runs, 4 skips
 to
 3502 decicycles in a, 65533 runs, 3 skips
 
 h263p:
 5257 decicycles in a, 65533 runs, 3 skips
 to
 7880 decicycles in a, 65532 runs, 4 skips
 
 flv:
 5291 decicycles in a, 65532 runs, 4 skips
 to
 3609 decicycles in a, 65531 runs, 5 skips
 
 Did not test the pure RL_VLC without optimizations.
 I guess the H263P one really doesn't like the close and reopen (?)

Nope, just me sucking at testing (copy-pasted wrong line)
Should read:
h263p:
11460 decicycles in a, 65533 runs, 3 skips
to
7880 decicycles in a, 65532 runs, 4 skips
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] intmath.h: Remove duplicated ARM include.

2014-08-31 Thread Reimar Döffinger
On Sun, Aug 31, 2014 at 06:18:14PM +0200, Michael Niedermayer wrote:
 On Sun, Aug 31, 2014 at 12:29:04PM +0200, Reimar Döffinger wrote:
  Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de
  ---
   libavutil/intmath.h | 4 
   1 file changed, 4 deletions(-)
 
 LGTM

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


Re: [FFmpeg-devel] [PATCH] aacps_tablegen: replace TABLE_CONST by const.

2014-08-31 Thread Reimar Döffinger
On Sun, Aug 31, 2014 at 06:19:37PM +0200, Michael Niedermayer wrote:
 On Sun, Aug 31, 2014 at 12:42:15PM +0200, Reimar Döffinger wrote:
  Doesn't change generated code, just is more consistent
  and a bit less error-prone.
  
  Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de
  ---
   libavcodec/aacps_tablegen.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
 
 should be ok

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


Re: [FFmpeg-devel] [PATCH 1/4] h261, h263 decoders: convert to RL_VLC.

2014-08-31 Thread Michael Niedermayer
On Sun, Aug 31, 2014 at 06:31:30PM +0200, Reimar Döffinger wrote:
 On Sun, Aug 31, 2014 at 06:28:24PM +0200, Reimar Döffinger wrote:
  On Sun, Aug 31, 2014 at 05:44:09PM +0200, Michael Niedermayer wrote:
   On Sun, Aug 31, 2014 at 04:48:41PM +0200, Reimar Döffinger wrote:
Some additional optimizations in following patch.
   
   what effect on speed do these patches have ?
  
  With high error bars, with vsynth1 file, median of 3 runs, only around
  changed code:
  h261:
  4447 decicycles in a, 65532 runs, 4 skips
  to
  3894 decicycles in a, 65534 runs, 2 skips
  
  h263:
  5072 decicycles in a, 65532 runs, 4 skips
  to
  3502 decicycles in a, 65533 runs, 3 skips
  
  h263p:
  5257 decicycles in a, 65533 runs, 3 skips
  to
  7880 decicycles in a, 65532 runs, 4 skips
  
  flv:
  5291 decicycles in a, 65532 runs, 4 skips
  to
  3609 decicycles in a, 65531 runs, 5 skips
  
  Did not test the pure RL_VLC without optimizations.
  I guess the H263P one really doesn't like the close and reopen (?)
 
 Nope, just me sucking at testing (copy-pasted wrong line)
 Should read:
 h263p:
 11460 decicycles in a, 65533 runs, 3 skips
 to
 7880 decicycles in a, 65532 runs, 4 skips

i can confirm that with medium to high bitrate flv theres a nice
speedup, for low bitrate there is no difference


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

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


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


Re: [FFmpeg-devel] [PATCH 3/4] ituh263dec: Optimize new RL_VLC based decoding.

2014-08-31 Thread Michael Niedermayer
On Sun, Aug 31, 2014 at 04:48:43PM +0200, Reimar Döffinger wrote:
 Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de
 ---
  libavcodec/ituh263dec.c | 39 ++-
  1 file changed, 18 insertions(+), 21 deletions(-)
 
 diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
 index 26f0ec5..083f5ae 100644
 --- a/libavcodec/ituh263dec.c
 +++ b/libavcodec/ituh263dec.c
 @@ -418,7 +418,7 @@ static void h263_decode_dquant(MpegEncContext *s){
  static int h263_decode_block(MpegEncContext * s, int16_t * block,
   int n, int coded)
  {
 -int level, i, j, last, run;
 +int level, i, j, run;
  RLTable *rl = ff_h263_rl_inter;
  const uint8_t *scan_table;
  GetBitContext gb= s-gb;
 @@ -493,26 +493,22 @@ retry:
  if (CONFIG_FLV_DECODER  s-h263_flv  1) {
  int is11 = SHOW_UBITS(re, s-gb, 1);
  SKIP_CACHE(re, s-gb, 1);
 -last = SHOW_UBITS(re, s-gb, 1);
 -SKIP_CACHE(re, s-gb, 1);
 -run = SHOW_UBITS(re, s-gb, 6);
 +run = SHOW_UBITS(re, s-gb, 7) + 1;
  if (is11) {
 -SKIP_COUNTER(re, s-gb, 6);
 +SKIP_COUNTER(re, s-gb, 1 + 7);
  UPDATE_CACHE(re, s-gb);
  level = SHOW_SBITS(re, s-gb, 11);
 -SKIP_COUNTER(re, s-gb, 1 + 1 + 6 + 11);
 +SKIP_COUNTER(re, s-gb, 11);
  } else {
 -SKIP_CACHE(re, s-gb, 6);
 +SKIP_CACHE(re, s-gb, 7);
  level = SHOW_SBITS(re, s-gb, 7);
 -SKIP_COUNTER(re, s-gb, 1 + 1 + 6 + 7);
 +SKIP_COUNTER(re, s-gb, 1 + 7 + 7);
  }
  } else {
 -last = SHOW_UBITS(re, s-gb, 1);
 -SKIP_CACHE(re, s-gb, 1);
 -run = SHOW_UBITS(re, s-gb, 6);
 -SKIP_CACHE(re, s-gb, 6);
 +run = SHOW_UBITS(re, s-gb, 7) + 1;
 +SKIP_CACHE(re, s-gb, 7);
  level = (int8_t)SHOW_UBITS(re, s-gb, 8);
 -SKIP_COUNTER(re, s-gb, 1 + 6 + 8);
 +SKIP_COUNTER(re, s-gb, 7 + 8);
  if(level == -128){
  UPDATE_CACHE(re, s-gb);
  if (s-codec_id == AV_CODEC_ID_RV10) {
 @@ -528,15 +524,19 @@ retry:
  }
  }
  } else {
 -run--;
 -last = run = 192;
 -run = 63;
  if (SHOW_UBITS(re, s-gb, 1))
  level = -level;
  SKIP_COUNTER(re, s-gb, 1);
  }
  i += run;
 -if (i = 64){
 +if (i  64){
 +// redo update without last flag
 +i = i - run + ((run-1)63);
 +if (i  64) {
 +// only last marker, no overrun
 +block[scan_table[i]] = level;
 +break;
 +}
  if(s-alt_inter_vlc  rl == ff_h263_rl_inter  !s-mb_intra){
  CLOSE_READER(re, s-gb);
  //Looks like a hack but no, it's the way it is supposed to 
 work ...

 @@ -549,11 +549,8 @@ retry:
  av_log(s-avctx, AV_LOG_ERROR, run overflow at %dx%d i:%d\n, 
 s-mb_x, s-mb_y, s-mb_intra);
  return -1;
  }
 -j = scan_table[i];
 +j = scan_table[i-1];

the - 1 feels avoidable

patch should be ok


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have often repented speaking, but never of holding my tongue.
-- Xenocrates


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


Re: [FFmpeg-devel] [PATCH] Add SUP/PGS subtitle demuxer

2014-08-31 Thread Carl Eugen Hoyos
compn tempn at mi.rr.com writes:

 will try to dig some more.

sup samples are attached to ticket #2208, the original file 
is in http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket2208/

Carl Eugen

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


Re: [FFmpeg-devel] [PATCH] add silenceremove filter

2014-08-31 Thread Clément Bœsch
On Fri, Aug 29, 2014 at 06:22:36PM +, Paul B Mahol wrote:
 Signed-off-by: Paul B Mahol one...@gmail.com
 ---
  doc/filters.texi   |  62 ++
  libavfilter/Makefile   |   1 +
  libavfilter/af_silenceremove.c | 478 
 +
  libavfilter/allfilters.c   |   1 +
  4 files changed, 542 insertions(+)
  create mode 100644 libavfilter/af_silenceremove.c
 
 diff --git a/doc/filters.texi b/doc/filters.texi
 index cca15fc..ea7da88 100644
 --- a/doc/filters.texi
 +++ b/doc/filters.texi
 @@ -1881,6 +1881,68 @@ ffmpeg -i silence.mp3 -af silencedetect=noise=0.0001 
 -f null -
  @end example
  @end itemize
  
 +@section silenceremove
 +
 +Removes silence from the beginning, middle or end of the audio.

We tend to use the Remove silence ... form (no 's').

Also, what is exactly the meaning of from here? Shouldn't it be at the
beginning, in the middle or at the end of...? (Note: as you know, I'm not
a native English speaker).

 +
 +The filter accepts the following options:
 +
 +@table @option
 +@item start_periods
 +This value is used to indicate if audio should be trimmed at beginning of
 +the audio. A value of zero indicates no silence should be trimmed from the
 +beginning. When specifying an non-zero value, it trims audio up until it

*a* non-zero value?

 +finds non-silence. Normally, when trimming silence from beginning of audio
 +the @var{start_periods} will be @code{1} but it can be increased to higher
 +values to trim all audio up to specific count of non-silence periods.
 +

Please specify the default value, ditto below

 +@item start_duration
 +Specify amount of time that non-silence must be detected before it stops

Specify *the* amount of time

 +trimming audio. By increasing the duration, burst of noise can be treated
 +as silence and trimmed off.
 +
 +@item start_threshold
 +This indicate what sample value should be treated as silence. For digital
 +audio, a value of @code{0} may be fine but for audio recorded from analog,
 +you may wish to increase the value to account for background noise.
 +
 +@item stop_periods
 +Set the count for trimming silence from the end of audio.
 +To remove silence from the middle of a file, specify a @var{stop_periods}
 +that is negative. This value is the threated as a positive value and is also

is *then* *treated*?

drop the also maybe

 +used to indicate the effect should restart processing as specified by
 +@var{start_periods}, making it suitable for removing periods of silence
 +in the middle of the audio.
 +
 +@item stop_duration
 +Specify a duration of silence that must exist before audio is not copied any
 +more. By specifying a higher duration, silence that is wanted can be left
 +in the audio.
 +
 +@item stop_threshold
 +This indicate what sample value should be treated as silence but for
 +trimming silence from the end of audio.
 +
 +@item leave_silence
 +This indicate that @var{stop_duration} length of audio should be left intact
 +at the beginning of each period of silence.
 +For example, if you want to remove long pauses between words but do not want
 +to remove the pauses completely.
 +
 +@end table
 +

I must say I'm extremely confused at all of this; more examples would be
welcome if you don't mind.

 +@subsection Examples
 +
 +@itemize
 +@item
 +The following example shows how this filter can be used to start recording

*a* recording?

 +that does not contain the delay at the start which usually occurs between

 +pressing the record button and the star of the performance:

start?

[...]
 +typedef struct SilenceRemoveContext {
 +const AVClass *class;
 +

 +int mode;

Could be made an enum

[...]
 +static const AVOption silenceremove_options[] = {
 +{ start_periods,   NULL, OFFSET(start_periods),   AV_OPT_TYPE_INT, 
  {.i64=0}, 0, 9000, FLAGS },
 +{ start_duration,  NULL, OFFSET(start_duration),  
 AV_OPT_TYPE_DURATION, {.i64=0}, 0, 9000, FLAGS },
 +{ start_threshold, NULL, OFFSET(start_threshold), AV_OPT_TYPE_DOUBLE,  
  {.dbl=0}, 0,1, FLAGS },
 +{ stop_periods,NULL, OFFSET(stop_periods),AV_OPT_TYPE_INT, 
  {.i64=0}, -9000, 9000, FLAGS },
 +{ stop_duration,   NULL, OFFSET(stop_duration),   
 AV_OPT_TYPE_DURATION, {.i64=0}, 0, 9000, FLAGS },
 +{ stop_threshold,  NULL, OFFSET(stop_threshold),  AV_OPT_TYPE_DOUBLE,  
  {.dbl=0}, 0,1, FLAGS },
 +{ leave_silence,   NULL, OFFSET(leave_silence),   AV_OPT_TYPE_INT, 
  {.i64=0}, 0,1, FLAGS },

this column makes me sad :(

 +{ NULL }
 +};
 +
 +AVFILTER_DEFINE_CLASS(silenceremove);
 +
 +#define SILENCE_TRIM0
 +#define SILENCE_TRIM_FLUSH  1
 +#define SILENCE_COPY2
 +#define SILENCE_COPY_FLUSH  3
 +#define SILENCE_STOP4
 +
[...]
 +static int config_input(AVFilterLink *inlink)
 +{
 +AVFilterContext *ctx = inlink-dst;
 +SilenceRemoveContext *s = ctx-priv;
 +

 +s-window_size = 

Re: [FFmpeg-devel] [PATCH 3/4] ituh263dec: Optimize new RL_VLC based decoding.

2014-08-31 Thread Reimar Döffinger
On Sun, Aug 31, 2014 at 07:09:13PM +0200, Michael Niedermayer wrote:
 On Sun, Aug 31, 2014 at 04:48:43PM +0200, Reimar Döffinger wrote:
  @@ -549,11 +549,8 @@ retry:
   av_log(s-avctx, AV_LOG_ERROR, run overflow at %dx%d i:%d\n, 
  s-mb_x, s-mb_y, s-mb_intra);
   return -1;
   }
  -j = scan_table[i];
  +j = scan_table[i-1];
 
 the - 1 feels avoidable

I have no good idea how so far.
Note that it is not really an extra cost: we save on a i++ at this place
exchange...
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avutil/pixelutils: add small buffers tests

2014-08-31 Thread Clément Bœsch
On Sun, Aug 31, 2014 at 07:45:24PM +0200, Michael Niedermayer wrote:
 On Sun, Aug 31, 2014 at 06:04:21PM +0200, Clément Bœsch wrote:
  ---
   libavutil/pixelutils.c| 98 
  +--
   tests/ref/fate/pixelutils | 12 ++
   2 files changed, 89 insertions(+), 21 deletions(-)
 
 tested on mips  arm qemu   x86, all passed
 

Yes, for now. But unfortunately on PPC the optimizations I'm trying to add
will probably break this; the 8x8 seems to actually be reading 16x8. Maybe
I'll make it read 16x7 and 8 byte-per-byte...

Will push in a moment, thanks.

-- 
Clément B.


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


Re: [FFmpeg-devel] [PATCH 3/4] ituh263dec: Optimize new RL_VLC based decoding.

2014-08-31 Thread Michael Niedermayer
On Sun, Aug 31, 2014 at 08:06:54PM +0200, Reimar Döffinger wrote:
 On Sun, Aug 31, 2014 at 07:09:13PM +0200, Michael Niedermayer wrote:
  On Sun, Aug 31, 2014 at 04:48:43PM +0200, Reimar Döffinger wrote:
   @@ -549,11 +549,8 @@ retry:
av_log(s-avctx, AV_LOG_ERROR, run overflow at %dx%d 
   i:%d\n, s-mb_x, s-mb_y, s-mb_intra);
return -1;
}
   -j = scan_table[i];
   +j = scan_table[i-1];
  
  the - 1 feels avoidable
 
 I have no good idea how so far.

cant i be offset at entry  exit of the loop ?
or
scan_table be offset by -1 ?

anyway not really important, its faster as is than before so this is
maybe better in a seperate later patch


 Note that it is not really an extra cost: we save on a i++ at this place
 exchange...
 ___
 ffmpeg-devel mailing list
 ffmpeg-devel@ffmpeg.org
 http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

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


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


Re: [FFmpeg-devel] [PATCH 3/4] ituh263dec: Optimize new RL_VLC based decoding.

2014-08-31 Thread Reimar Döffinger
On Sun, Aug 31, 2014 at 08:14:04PM +0200, Michael Niedermayer wrote:
 On Sun, Aug 31, 2014 at 08:06:54PM +0200, Reimar Döffinger wrote:
  On Sun, Aug 31, 2014 at 07:09:13PM +0200, Michael Niedermayer wrote:
   On Sun, Aug 31, 2014 at 04:48:43PM +0200, Reimar Döffinger wrote:
@@ -549,11 +549,8 @@ retry:
 av_log(s-avctx, AV_LOG_ERROR, run overflow at %dx%d 
i:%d\n, s-mb_x, s-mb_y, s-mb_intra);
 return -1;
 }
-j = scan_table[i];
+j = scan_table[i-1];
   
   the - 1 feels avoidable
  
  I have no good idea how so far.
 
 cant i be offset at entry  exit of the loop ?
 or
 scan_table be offset by -1 ?

*facepalm*. Yes, something like that should be possible.

 anyway not really important, its faster as is than before so this is
 maybe better in a seperate later patch

Considering how many bugs I had in this one, yes,
I rather have this one out and tested before I break
it again :)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] rl.h: Allocate temporary VLC tables instead of having them static.

2014-08-31 Thread Reimar Döffinger
Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de
---
 libavcodec/mpeg12.c| 23 ---
 libavcodec/mpegvideo.c | 14 ++
 libavcodec/rl.h|  8 ++--
 3 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index cb00baf..769bed7 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -70,22 +70,22 @@ static const uint8_t table_mb_btype[11][2] = {
 #define INIT_2D_VLC_RL(rl, static_size)\
 {\
 static RL_VLC_ELEM rl_vlc_table[static_size];\
-VLC tmp_vlc;\
-INIT_VLC_STATIC(tmp_vlc, TEX_VLC_BITS, rl.n + 2,\
-rl.table_vlc[0][1], 4, 2,\
-rl.table_vlc[0][0], 4, 2, static_size);\
-\
 rl.rl_vlc[0] = rl_vlc_table;\
-init_2d_vlc_rl(rl, tmp_vlc);\
+init_2d_vlc_rl(rl, static_size);\
 }
 
-static av_cold void init_2d_vlc_rl(RLTable *rl, const VLC *vlc)
+static av_cold void init_2d_vlc_rl(RLTable *rl, unsigned static_size)
 {
 int i;
-
-for (i = 0; i  vlc-table_size; i++) {
-int code = vlc-table[i][0];
-int len  = vlc-table[i][1];
+VLC vlc;
+init_vlc(vlc, TEX_VLC_BITS, rl-n + 2, rl-table_vlc[0][1], 4, 2, 
rl-table_vlc[0][0], 4, 2, 0);
+av_assert0(vlc.table_size = static_size);
+if (vlc.table_size != static_size)
+av_log(NULL, AV_LOG_ERROR, needed %d had %d\n, vlc.table_size, 
static_size);
+
+for (i = 0; i  vlc.table_size; i++) {
+int code = vlc.table[i][0];
+int len  = vlc.table[i][1];
 int level, run;
 
 if (len == 0) { // illegal code
@@ -110,6 +110,7 @@ static av_cold void init_2d_vlc_rl(RLTable *rl, const VLC 
*vlc)
 rl-rl_vlc[0][i].level = level;
 rl-rl_vlc[0][i].run   = run;
 }
+ff_free_vlc(vlc);
 }
 
 av_cold void ff_mpeg12_common_init(MpegEncContext *s)
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 748dbc8..94e000f 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1618,9 +1618,14 @@ av_cold void ff_init_rl(RLTable *rl,
 }
 }
 
-av_cold void ff_init_vlc_rl(RLTable *rl, const VLC *vlc)
+av_cold void ff_init_vlc_rl(RLTable *rl, unsigned static_size)
 {
 int i, q;
+VLC vlc;
+init_vlc(vlc, 9, rl-n + 1, rl-table_vlc[0][1], 4, 2, 
rl-table_vlc[0][0], 4, 2, 0);
+av_assert0(vlc.table_size = static_size);
+if (vlc.table_size != static_size)
+av_log(NULL, AV_LOG_ERROR, needed %d had %d\n, vlc.table_size, 
static_size);
 
 for (q = 0; q  32; q++) {
 int qmul = q * 2;
@@ -1630,9 +1635,9 @@ av_cold void ff_init_vlc_rl(RLTable *rl, const VLC *vlc)
 qmul = 1;
 qadd = 0;
 }
-for (i = 0; i  vlc-table_size; i++) {
-int code = vlc-table[i][0];
-int len  = vlc-table[i][1];
+for (i = 0; i  vlc.table_size; i++) {
+int code = vlc.table[i][0];
+int len  = vlc.table[i][1];
 int level, run;
 
 if (len == 0) { // illegal code
@@ -1656,6 +1661,7 @@ av_cold void ff_init_vlc_rl(RLTable *rl, const VLC *vlc)
 rl-rl_vlc[q][i].run   = run;
 }
 }
+ff_free_vlc(vlc);
 }
 
 static void release_unused_pictures(MpegEncContext *s)
diff --git a/libavcodec/rl.h b/libavcodec/rl.h
index 3cef366..2897ec5 100644
--- a/libavcodec/rl.h
+++ b/libavcodec/rl.h
@@ -53,22 +53,18 @@ typedef struct RLTable {
  * the level and run tables, if this is NULL av_malloc() 
will be used
  */
 void ff_init_rl(RLTable *rl, uint8_t static_store[2][2*MAX_RUN + MAX_LEVEL + 
3]);
-void ff_init_vlc_rl(RLTable *rl, const VLC *vlc);
+void ff_init_vlc_rl(RLTable *rl, unsigned static_size);
 
 #define INIT_VLC_RL(rl, static_size)\
 {\
 int q;\
 static RL_VLC_ELEM rl_vlc_table[32][static_size];\
-VLC tmp_vlc;\
-INIT_VLC_STATIC(tmp_vlc, 9, rl.n + 1,\
- rl.table_vlc[0][1], 4, 2,\
- rl.table_vlc[0][0], 4, 2, static_size);\
 \
 if(!rl.rl_vlc[0]){\
 for(q=0; q32; q++)\
 rl.rl_vlc[q]= rl_vlc_table[q];\
 \
-ff_init_vlc_rl(rl, tmp_vlc);\
+ff_init_vlc_rl(rl, static_size);\
 }\
 }
 
-- 
2.1.0

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


Re: [FFmpeg-devel] [PATCH] rl.h: Allocate temporary VLC tables instead of having them static.

2014-08-31 Thread Reimar Döffinger
On Sun, Aug 31, 2014 at 08:27:17PM +0200, Reimar Döffinger wrote:
 Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de

This was intended to come out under rl.h: remove deprecated and now unused vlc 
member.,
as that one needs to be applied first.
I can merge them though if desired.
I by accident typed -1 when I had wanted to type --help...
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] h261dec, ituh263dec: Avoid unnecessary -1 inside inner loop.

2014-08-31 Thread Reimar Döffinger
3646 - 3597 decicycles in inner loop when decoding
vsynth1-flv.

Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de
---
 libavcodec/h261dec.c| 7 ---
 libavcodec/ituh263dec.c | 9 +
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index f286d23..c9470b1 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -305,6 +305,7 @@ static int h261_decode_block(H261Context *h, int16_t 
*block, int n, int coded)
 }
 {
 OPEN_READER(re, s-gb);
+i--; // offset by -1 to allow direct indexing of scan_table
 for (;;) {
 UPDATE_CACHE(re, s-gb);
 GET_RL_VLC(level, run, re, s-gb, rl-rl_vlc[0], TCOEFF_VLC_BITS, 2, 
0);
@@ -330,17 +331,17 @@ static int h261_decode_block(H261Context *h, int16_t 
*block, int n, int coded)
 SKIP_COUNTER(re, s-gb, 1);
 }
 i += run;
-if (i  64) {
+if (i = 64) {
 av_log(s-avctx, AV_LOG_ERROR, run overflow at %dx%d\n,
s-mb_x, s-mb_y);
 return -1;
 }
-j= scan_table[i-1];
+j= scan_table[i];
 block[j] = level;
 }
 CLOSE_READER(re, s-gb);
 }
-s-block_last_index[n] = i - 1;
+s-block_last_index[n] = i;
 return 0;
 }
 
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index 083f5ae..bea4d5a 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -481,6 +481,7 @@ static int h263_decode_block(MpegEncContext * s, int16_t * 
block,
 retry:
 {
 OPEN_READER(re, s-gb);
+i--; // offset by -1 to allow direct indexing of scan_table
 for(;;) {
 UPDATE_CACHE(re, s-gb);
 GET_RL_VLC(level, run, re, s-gb, rl-rl_vlc[0], TEX_VLC_BITS, 2, 0);
@@ -529,9 +530,9 @@ retry:
 SKIP_COUNTER(re, s-gb, 1);
 }
 i += run;
-if (i  64){
-// redo update without last flag
-i = i - run + ((run-1)63);
+if (i = 64){
+// redo update without last flag, revert -1 offset
+i = i - run + ((run-1)63) + 1;
 if (i  64) {
 // only last marker, no overrun
 block[scan_table[i]] = level;
@@ -549,7 +550,7 @@ retry:
 av_log(s-avctx, AV_LOG_ERROR, run overflow at %dx%d i:%d\n, 
s-mb_x, s-mb_y, s-mb_intra);
 return -1;
 }
-j = scan_table[i-1];
+j = scan_table[i];
 block[j] = level;
 }
 CLOSE_READER(re, s-gb);
-- 
2.1.0

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


Re: [FFmpeg-devel] [PATCH] add silenceremove filter

2014-08-31 Thread Timothy Gu
On Aug 29, 2014 11:23 AM, Paul B Mahol one...@gmail.com wrote:

 Signed-off-by: Paul B Mahol one...@gmail.com
 ---
  doc/filters.texi   |  62 ++
  libavfilter/Makefile   |   1 +
  libavfilter/af_silenceremove.c | 478
+
  libavfilter/allfilters.c   |   1 +
  4 files changed, 542 insertions(+)
  create mode 100644 libavfilter/af_silenceremove.c

 diff --git a/doc/filters.texi b/doc/filters.texi
 index cca15fc..ea7da88 100644
 --- a/doc/filters.texi
 +++ b/doc/filters.texi
 @@ -1881,6 +1881,68 @@ ffmpeg -i silence.mp3 -af
silencedetect=noise=0.0001 -f null -
  @end example
  @end itemize

 +@section silenceremove
 +
 +Removes silence from the beginning, middle or end of the audio.
 +

@subsection Options

 +The filter accepts the following options:
 +
 +@table @option
 +@item start_periods

 +This value is used to indicate if audio should be trimmed at beginning of
 +the audio.

... and how much silence to trim.

 A value of zero indicates no silence should be trimmed from the
 +beginning.

 When specifying an non-zero value, it trims audio up until it
 +finds non-silence. Normally, when trimming silence from beginning of
audio
 +the @var{start_periods} will be @code{1} but it can be increased to
higher
 +values to trim all audio up to specific count of non-silence periods.

Is this better?

---
When a nonzero value is specified, audio is trimmed until the specified
count of non-silence periods is reached.

Normally you would use 1 which means that trimming is stopped as soon as
non-silence is reached.
---

What if I have an audio segment like this, with start_periods==2 and
start_duration==4? What will get trimmed and what will not?

Silence5sec Noise1sec Silence2sec Noise5sec Silence5sec Noise5sec
Silence1sec NoiseForever

 +
 +@item start_duration
 +Specify amount of time that non-silence must be detected before it stops

 +trimming audio. By increasing the duration, burst of noise can be treated

bursts of noises

 +as silence and trimmed off.
 +

 +@item start_threshold

 +This indicate what sample value should be treated as silence. For digital

indicate_s_ how silent a segment must be to be treated as silence.

 +audio, a value of @code{0} may be fine but for audio recorded from
analog,
 +you may wish to increase the value to account for background noise.

 +
 +@item stop_periods
 +Set the count for trimming silence from the end of audio.
 +To remove silence from the middle of a file, specify a @var{stop_periods}

 +that is negative. This value is the threated as a positive value and is
also

threated

 +used to indicate the effect should restart processing as specified by
 +@var{start_periods}, making it suitable for removing periods of silence
 +in the middle of the audio.
 +
 +@item stop_duration
 +Specify a duration of silence that must exist before audio is not copied
any
 +more. By specifying a higher duration, silence that is wanted can be left
 +in the audio.
 +
 +@item stop_threshold

 +This indicate what sample value should be treated as silence but for
 +trimming silence from the end of audio.

This the same as @option {start_threshold} but for trimming...

 +
 +@item leave_silence
 +This indicate that @var{stop_duration} length of audio should be left
intact
 +at the beginning of each period of silence.
 +For example, if you want to remove long pauses between words but do not
want
 +to remove the pauses completely.
 +
 +@end table
 +
 +@subsection Examples
 +
 +@itemize
 +@item
 +The following example shows how this filter can be used to start
recording
 +that does not contain the delay at the start which usually occurs between

 +pressing the record button and the star of the performance:

start

 +@example
 +silenceremove=1:5:0.02

What are these values? I.e. can you show is in a named form too?

 +@end example
 +@end itemize
 +

More review might follow if you answer my question above.

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


Re: [FFmpeg-devel] [PATCH] h261dec, ituh263dec: Avoid unnecessary -1 inside inner loop.

2014-08-31 Thread Timothy Gu
On Aug 31, 2014 11:36 AM, Reimar Döffinger reimar.doeffin...@gmx.de
wrote:

 3646 - 3597 decicycles in inner loop when decoding
 vsynth1-flv.

Wow.

[...]

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


Re: [FFmpeg-devel] [PATCH 1/4] h261, h263 decoders: convert to RL_VLC.

2014-08-31 Thread Michael Niedermayer
On Sun, Aug 31, 2014 at 04:48:41PM +0200, Reimar Döffinger wrote:
 Some additional optimizations in following patch.
 
 Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de
 ---
  libavcodec/flv.h|  1 -
  libavcodec/flvdec.c | 12 --
  libavcodec/h261dec.c| 27 ++-
  libavcodec/ituh263dec.c | 58 
 -
  4 files changed, 60 insertions(+), 38 deletions(-)
 
 diff --git a/libavcodec/flv.h b/libavcodec/flv.h
 index 16bc88b..df50820 100644
 --- a/libavcodec/flv.h
 +++ b/libavcodec/flv.h
 @@ -28,6 +28,5 @@ void ff_flv_encode_picture_header(MpegEncContext * s, int 
 picture_number);
  void ff_flv2_encode_ac_esc(PutBitContext *pb, int slevel, int level, int 
 run, int last);
  
  int ff_flv_decode_picture_header(MpegEncContext *s);
 -void ff_flv2_decode_ac_esc(GetBitContext *gb, int *level, int *run, int 
 *last);
  
  #endif /* AVCODEC_FLV_H */
 diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c
 index 3b048f6..db413f2 100644
 --- a/libavcodec/flvdec.c
 +++ b/libavcodec/flvdec.c
 @@ -22,18 +22,6 @@
  #include flv.h
  #include libavutil/imgutils.h
  
 -void ff_flv2_decode_ac_esc(GetBitContext *gb, int *level, int *run, int 
 *last)
 -{
 -int is11 = get_bits1(gb);
 -*last = get_bits1(gb);
 -*run  = get_bits(gb, 6);
 -if (is11) {
 -*level = get_sbits(gb, 11);
 -} else {
 -*level = get_sbits(gb, 7);
 -}
 -}
 -
  int ff_flv_decode_picture_header(MpegEncContext *s)
  {
  int format, width, height;
 diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
 index 301ecc1..5f0eb59 100644
 --- a/libavcodec/h261dec.c
 +++ b/libavcodec/h261dec.c
 @@ -258,7 +258,7 @@ static int decode_mv_component(GetBitContext *gb, int v)
  static int h261_decode_block(H261Context *h, int16_t *block, int n, int 
 coded)
  {
  MpegEncContext *const s = h-s;
 -int code, level, i, j, run;
 +int level, i, j, run;
  RLTable *rl = ff_h261_rl_tcoeff;
  const uint8_t *scan_table;
  
 @@ -303,27 +303,32 @@ static int h261_decode_block(H261Context *h, int16_t 
 *block, int n, int coded)
  s-block_last_index[n] = i - 1;
  return 0;
  }
 +{
 +OPEN_READER(re, s-gb);
  for (;;) {
 -code = get_vlc2(s-gb, rl-vlc.table, TCOEFF_VLC_BITS, 2);
 -if (code  0) {
 +UPDATE_CACHE(re, s-gb);
 +GET_RL_VLC(level, run, re, s-gb, rl-rl_vlc[0], TCOEFF_VLC_BITS, 
 2, 0);
 +if (run == 66  level) {
  av_log(s-avctx, AV_LOG_ERROR, illegal ac vlc code at %dx%d\n,
 s-mb_x, s-mb_y);
  return -1;
  }
 -if (code == rl-n) {
 +if (run == 66) {

the if (run == 66  level) { could be put under run == 66, if thats
faster
though maybe better as a seperate patch

patch should be ok

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

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


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


[FFmpeg-devel] [PATCH] h261dec, ituh263dec: ensure CLOSE_READER is done on error paths, too.

2014-08-31 Thread Reimar Döffinger
Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de
---
 libavcodec/h261dec.c| 2 ++
 libavcodec/ituh263dec.c | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index c9470b1..9b95775 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -310,6 +310,7 @@ static int h261_decode_block(H261Context *h, int16_t 
*block, int n, int coded)
 UPDATE_CACHE(re, s-gb);
 GET_RL_VLC(level, run, re, s-gb, rl-rl_vlc[0], TCOEFF_VLC_BITS, 2, 
0);
 if (run == 66  level) {
+CLOSE_READER(re, s-gb);
 av_log(s-avctx, AV_LOG_ERROR, illegal ac vlc code at %dx%d\n,
s-mb_x, s-mb_y);
 return -1;
@@ -332,6 +333,7 @@ static int h261_decode_block(H261Context *h, int16_t 
*block, int n, int coded)
 }
 i += run;
 if (i = 64) {
+CLOSE_READER(re, s-gb);
 av_log(s-avctx, AV_LOG_ERROR, run overflow at %dx%d\n,
s-mb_x, s-mb_y);
 return -1;
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index bea4d5a..f9f13d3 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -486,6 +486,7 @@ retry:
 UPDATE_CACHE(re, s-gb);
 GET_RL_VLC(level, run, re, s-gb, rl-rl_vlc[0], TEX_VLC_BITS, 2, 0);
 if (run == 66  level){
+CLOSE_READER(re, s-gb);
 av_log(s-avctx, AV_LOG_ERROR, illegal ac vlc code at %dx%d\n, 
s-mb_x, s-mb_y);
 return -1;
 }
@@ -531,6 +532,7 @@ retry:
 }
 i += run;
 if (i = 64){
+CLOSE_READER(re, s-gb);
 // redo update without last flag, revert -1 offset
 i = i - run + ((run-1)63) + 1;
 if (i  64) {
@@ -539,7 +541,6 @@ retry:
 break;
 }
 if(s-alt_inter_vlc  rl == ff_h263_rl_inter  !s-mb_intra){
-CLOSE_READER(re, s-gb);
 //Looks like a hack but no, it's the way it is supposed to 
work ...
 rl = ff_rl_intra_aic;
 i = 0;
@@ -553,7 +554,6 @@ retry:
 j = scan_table[i];
 block[j] = level;
 }
-CLOSE_READER(re, s-gb);
 }
 not_coded:
 if (s-mb_intra  s-h263_aic) {
-- 
2.1.0

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


Re: [FFmpeg-devel] [PATCH] h261dec, ituh263dec: ensure CLOSE_READER is done on error paths, too.

2014-08-31 Thread Michael Niedermayer
On Sun, Aug 31, 2014 at 09:40:05PM +0200, Reimar Döffinger wrote:
 Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de
 ---
  libavcodec/h261dec.c| 2 ++
  libavcodec/ituh263dec.c | 4 ++--
  2 files changed, 4 insertions(+), 2 deletions(-)

LGTM
though in theory its probably also ok not to write back on errors

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

No great genius has ever existed without some touch of madness. -- Aristotle


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


[FFmpeg-devel] [PATCH] mpegaudiodec: share identical tables between float and fixed decoder.

2014-08-31 Thread Reimar Döffinger
ff_mpa_table_4_3_value alone saves over 128kB.

Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de
---
 libavcodec/Makefile|  24 +++---
 libavcodec/mpegaudio_tablegen.c|  13 +--
 libavcodec/mpegaudio_tablegen.h|  26 +++---
 libavcodec/mpegaudiodec_common.c   | 135 +++
 libavcodec/mpegaudiodec_common.h   |  54 +
 libavcodec/mpegaudiodec_template.c | 159 +++--
 libavcodec/mpegaudiodectab.h   |  14 ++--
 7 files changed, 256 insertions(+), 169 deletions(-)
 create mode 100644 libavcodec/mpegaudiodec_common.c
 create mode 100644 libavcodec/mpegaudiodec_common.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 28ae252..3936f03 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -304,20 +304,20 @@ OBJS-$(CONFIG_MMVIDEO_DECODER) += mmvideo.o
 OBJS-$(CONFIG_MOTIONPIXELS_DECODER)+= motionpixels.o
 OBJS-$(CONFIG_MOVTEXT_DECODER) += movtextdec.o ass.o
 OBJS-$(CONFIG_MOVTEXT_ENCODER) += movtextenc.o ass_split.o
-OBJS-$(CONFIG_MP1_DECODER) += mpegaudiodec_fixed.o
-OBJS-$(CONFIG_MP1FLOAT_DECODER)+= mpegaudiodec_float.o
-OBJS-$(CONFIG_MP2_DECODER) += mpegaudiodec_fixed.o
-OBJS-$(CONFIG_MP2_ENCODER) += mpegaudioenc_float.o mpegaudio.o \
+OBJS-$(CONFIG_MP1_DECODER) += mpegaudiodec_fixed.o 
mpegaudiodec_common.o
+OBJS-$(CONFIG_MP1FLOAT_DECODER)+= mpegaudiodec_float.o 
mpegaudiodec_common.o
+OBJS-$(CONFIG_MP2_DECODER) += mpegaudiodec_fixed.o 
mpegaudiodec_common.o
+OBJS-$(CONFIG_MP2_ENCODER) += mpegaudioenc_float.o 
mpegaudiodec_common.o mpegaudio.o \
   mpegaudiodata.o mpegaudiodsp_data.o
-OBJS-$(CONFIG_MP2FIXED_ENCODER)+= mpegaudioenc_fixed.o mpegaudio.o \
+OBJS-$(CONFIG_MP2FIXED_ENCODER)+= mpegaudioenc_fixed.o 
mpegaudiodec_common.o mpegaudio.o \
   mpegaudiodata.o mpegaudiodsp_data.o
-OBJS-$(CONFIG_MP2FLOAT_DECODER)+= mpegaudiodec_float.o
-OBJS-$(CONFIG_MP3_DECODER) += mpegaudiodec_fixed.o
-OBJS-$(CONFIG_MP3ADU_DECODER)  += mpegaudiodec_fixed.o
-OBJS-$(CONFIG_MP3ADUFLOAT_DECODER) += mpegaudiodec_float.o
-OBJS-$(CONFIG_MP3FLOAT_DECODER)+= mpegaudiodec_float.o
-OBJS-$(CONFIG_MP3ON4_DECODER)  += mpegaudiodec_fixed.o mpeg4audio.o
-OBJS-$(CONFIG_MP3ON4FLOAT_DECODER) += mpegaudiodec_float.o mpeg4audio.o
+OBJS-$(CONFIG_MP2FLOAT_DECODER)+= mpegaudiodec_float.o 
mpegaudiodec_common.o
+OBJS-$(CONFIG_MP3_DECODER) += mpegaudiodec_fixed.o 
mpegaudiodec_common.o
+OBJS-$(CONFIG_MP3ADU_DECODER)  += mpegaudiodec_fixed.o 
mpegaudiodec_common.o
+OBJS-$(CONFIG_MP3ADUFLOAT_DECODER) += mpegaudiodec_float.o 
mpegaudiodec_common.o
+OBJS-$(CONFIG_MP3FLOAT_DECODER)+= mpegaudiodec_float.o 
mpegaudiodec_common.o
+OBJS-$(CONFIG_MP3ON4_DECODER)  += mpegaudiodec_fixed.o 
mpegaudiodec_common.o mpeg4audio.o
+OBJS-$(CONFIG_MP3ON4FLOAT_DECODER) += mpegaudiodec_float.o 
mpegaudiodec_common.o mpeg4audio.o
 OBJS-$(CONFIG_MPC7_DECODER)+= mpc7.o mpc.o
 OBJS-$(CONFIG_MPC8_DECODER)+= mpc8.o mpc.o
 OBJS-$(CONFIG_MPEGVIDEO_DECODER)   += mpeg12dec.o mpeg12.o mpeg12data.o
diff --git a/libavcodec/mpegaudio_tablegen.c b/libavcodec/mpegaudio_tablegen.c
index 90c9de4..2f57600 100644
--- a/libavcodec/mpegaudio_tablegen.c
+++ b/libavcodec/mpegaudio_tablegen.c
@@ -22,6 +22,7 @@
 
 #include stdlib.h
 #define CONFIG_HARDCODED_TABLES 0
+#define VLC int
 #include mpegaudio_tablegen.h
 #include tableprint.h
 
@@ -31,12 +32,12 @@ int main(void)
 
 write_fileheader();
 
-WRITE_ARRAY(static const, int8_t, table_4_3_exp);
-WRITE_ARRAY(static const, uint32_t, table_4_3_value);
-WRITE_ARRAY(static const, uint32_t, exp_table_fixed);
-WRITE_ARRAY(static const, float, exp_table_float);
-WRITE_2D_ARRAY(static const, uint32_t, expval_table_fixed);
-WRITE_2D_ARRAY(static const, float, expval_table_float);
+WRITE_ARRAY(const, int8_t, ff_mpa_table_4_3_exp);
+WRITE_ARRAY(const, uint32_t, ff_mpa_table_4_3_value);
+WRITE_ARRAY(const, uint32_t, ff_mpa_exp_table_fixed);
+WRITE_ARRAY(const, float, ff_mpa_exp_table_float);
+WRITE_2D_ARRAY(const, uint32_t, ff_mpa_expval_table_fixed);
+WRITE_2D_ARRAY(const, float, ff_mpa_expval_table_float);
 
 return 0;
 }
diff --git a/libavcodec/mpegaudio_tablegen.h b/libavcodec/mpegaudio_tablegen.h
index 86b2cd3..7ad57c5 100644
--- a/libavcodec/mpegaudio_tablegen.h
+++ b/libavcodec/mpegaudio_tablegen.h
@@ -26,18 +26,18 @@
 #include stdint.h
 #include math.h
 #include libavutil/attributes.h
+#include mpegaudiodec_common.h
 
-#define TABLE_4_3_SIZE (8191 + 16)*4
 #if CONFIG_HARDCODED_TABLES
 #define mpegaudio_tableinit()
 #include libavcodec/mpegaudio_tables.h
 #else
-static int8_t   table_4_3_exp[TABLE_4_3_SIZE];
-static uint32_t 

Re: [FFmpeg-devel] [PATCH] h261dec, ituh263dec: ensure CLOSE_READER is done on error paths, too.

2014-08-31 Thread Reimar Döffinger
On Sun, Aug 31, 2014 at 09:56:03PM +0200, Michael Niedermayer wrote:
 On Sun, Aug 31, 2014 at 09:40:05PM +0200, Reimar Döffinger wrote:
  Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de
  ---
   libavcodec/h261dec.c| 2 ++
   libavcodec/ituh263dec.c | 4 ++--
   2 files changed, 4 insertions(+), 2 deletions(-)
 
 LGTM
 though in theory its probably also ok not to write back on errors

My concern was whether it might mess with error concealment,
so I thought it safer like this.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/4] h261, h263 decoders: convert to RL_VLC.

2014-08-31 Thread Reimar Döffinger
On Sun, Aug 31, 2014 at 09:32:45PM +0200, Michael Niedermayer wrote:
 On Sun, Aug 31, 2014 at 04:48:41PM +0200, Reimar Döffinger wrote:
  -code = get_vlc2(s-gb, rl-vlc.table, TCOEFF_VLC_BITS, 2);
  -if (code  0) {
  +UPDATE_CACHE(re, s-gb);
  +GET_RL_VLC(level, run, re, s-gb, rl-rl_vlc[0], TCOEFF_VLC_BITS, 
  2, 0);
  +if (run == 66  level) {
   av_log(s-avctx, AV_LOG_ERROR, illegal ac vlc code at 
  %dx%d\n,
  s-mb_x, s-mb_y);
   return -1;
   }
  -if (code == rl-n) {
  +if (run == 66) {
 
 the if (run == 66  level) { could be put under run == 66, if thats
 faster
 though maybe better as a seperate patch

I should probably test it, but I was thinking about it and then went
the compiler certainly will figure that out on its own!?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] h261dec, ituh263dec: Move condition.

2014-08-31 Thread Reimar Döffinger
Stops compiler from doing incredibly stupid things.
With vsynth1-flv inner loop goes from 3501 to 3275
decicycles.

Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de
---
 libavcodec/h261dec.c| 12 ++--
 libavcodec/ituh263dec.c | 10 +-
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 9b95775..a8aae6e 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -309,13 +309,13 @@ static int h261_decode_block(H261Context *h, int16_t 
*block, int n, int coded)
 for (;;) {
 UPDATE_CACHE(re, s-gb);
 GET_RL_VLC(level, run, re, s-gb, rl-rl_vlc[0], TCOEFF_VLC_BITS, 2, 
0);
-if (run == 66  level) {
-CLOSE_READER(re, s-gb);
-av_log(s-avctx, AV_LOG_ERROR, illegal ac vlc code at %dx%d\n,
-   s-mb_x, s-mb_y);
-return -1;
-}
 if (run == 66) {
+if (level) {
+CLOSE_READER(re, s-gb);
+av_log(s-avctx, AV_LOG_ERROR, illegal ac vlc code at 
%dx%d\n,
+   s-mb_x, s-mb_y);
+return -1;
+}
 /* escape */
 /* The remaining combinations of (run, level) are encoded with a
  * 20-bit word consisting of 6 bits escape, 6 bits run and 8 bits
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index f9f13d3..c71b1e9 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -485,12 +485,12 @@ retry:
 for(;;) {
 UPDATE_CACHE(re, s-gb);
 GET_RL_VLC(level, run, re, s-gb, rl-rl_vlc[0], TEX_VLC_BITS, 2, 0);
-if (run == 66  level){
-CLOSE_READER(re, s-gb);
-av_log(s-avctx, AV_LOG_ERROR, illegal ac vlc code at %dx%d\n, 
s-mb_x, s-mb_y);
-return -1;
-}
 if (run == 66) {
+if (level){
+CLOSE_READER(re, s-gb);
+av_log(s-avctx, AV_LOG_ERROR, illegal ac vlc code at 
%dx%d\n, s-mb_x, s-mb_y);
+return -1;
+}
 /* escape */
 if (CONFIG_FLV_DECODER  s-h263_flv  1) {
 int is11 = SHOW_UBITS(re, s-gb, 1);
-- 
2.1.0

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


[FFmpeg-devel] [PATCH] ac3dec: avoid duplicating symbols between fixed and float decoder.

2014-08-31 Thread Reimar Döffinger
Signed-off-by: Reimar Döffinger reimar.doeffin...@gmx.de
---
 libavcodec/ac3.h |   4 +-
 libavcodec/ac3dec.c  | 188 +++
 libavcodec/ac3dec_data.c | 138 ++
 libavcodec/ac3dec_data.h |  15 
 4 files changed, 182 insertions(+), 163 deletions(-)

diff --git a/libavcodec/ac3.h b/libavcodec/ac3.h
index 871640b..0d01014 100644
--- a/libavcodec/ac3.h
+++ b/libavcodec/ac3.h
@@ -86,8 +86,8 @@
 #define AC3_RENAME(x)   x
 #define AC3_NORM(norm)  (1.0f/(norm))
 #define AC3_MUL(a,b)((a) * (b))
-#define AC3_RANGE(x)(dynamic_range_tab[(x)])
-#define AC3_HEAVY_RANGE(x)  (heavy_dynamic_range_tab[(x)])
+#define AC3_RANGE(x)(ff_ac3_dynamic_range_tab[(x)])
+#define AC3_HEAVY_RANGE(x)  (ff_ac3_heavy_dynamic_range_tab[(x)])
 #define AC3_DYNAMIC_RANGE(x)(powf(x,  s-drc_scale))
 #define AC3_SPX_BLEND(x)(x)* (1.0f/32)
 #define AC3_DYNAMIC_RANGE1  1.0f
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 969e37f..4dbb784 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -42,140 +42,6 @@
 #include kbdwin.h
 
 /**
- * table for ungrouping 3 values in 7 bits.
- * used for exponents and bap=2 mantissas
- */
-static uint8_t ungroup_3_in_7_bits_tab[128][3];
-
-/** tables for ungrouping mantissas */
-static int b1_mantissas[32][3];
-static int b2_mantissas[128][3];
-static int b3_mantissas[8];
-static int b4_mantissas[128][2];
-static int b5_mantissas[16];
-
-/**
- * Quantization table: levels for symmetric. bits for asymmetric.
- * reference: Table 7.18 Mapping of bap to Quantizer
- */
-static const uint8_t quantization_tab[16] = {
-0, 3, 5, 7, 11, 15,
-5, 6, 7, 8, 9, 10, 11, 12, 14, 16
-};
-
-/** dynamic range table. converts codes to scale factors. */
-static float dynamic_range_tab[256];
-static float heavy_dynamic_range_tab[256];
-
-/** Adjustments in dB gain */
-static const float gain_levels[9] = {
-LEVEL_PLUS_3DB,
-LEVEL_PLUS_1POINT5DB,
-LEVEL_ONE,
-LEVEL_MINUS_1POINT5DB,
-LEVEL_MINUS_3DB,
-LEVEL_MINUS_4POINT5DB,
-LEVEL_MINUS_6DB,
-LEVEL_ZERO,
-LEVEL_MINUS_9DB
-};
-
-/** Adjustments in dB gain (LFE, +10 to -21 dB) */
-static const float gain_levels_lfe[32] = {
-3.162275, 2.818382, 2.511886, 2.238719, 1.995261, 1.778278, 1.584893,
-1.412536, 1.258924, 1.122018, 1.00, 0.891251, 0.794328, 0.707946,
-0.630957, 0.562341, 0.501187, 0.446683, 0.398107, 0.354813, 0.316227,
-0.281838, 0.251188, 0.223872, 0.199526, 0.177828, 0.158489, 0.141253,
-0.125892, 0.112201, 0.10, 0.089125
-};
-
-/**
- * Table for default stereo downmixing coefficients
- * reference: Section 7.8.2 Downmixing Into Two Channels
- */
-static const uint8_t ac3_default_coeffs[8][5][2] = {
-{ { 2, 7 }, { 7, 2 },   },
-{ { 4, 4 }, },
-{ { 2, 7 }, { 7, 2 },   },
-{ { 2, 7 }, { 5, 5 }, { 7, 2 }, },
-{ { 2, 7 }, { 7, 2 }, { 6, 6 }, },
-{ { 2, 7 }, { 5, 5 }, { 7, 2 }, { 8, 8 },   },
-{ { 2, 7 }, { 7, 2 }, { 6, 7 }, { 7, 6 },   },
-{ { 2, 7 }, { 5, 5 }, { 7, 2 }, { 6, 7 }, { 7, 6 }, },
-};
-
-/**
- * Symmetrical Dequantization
- * reference: Section 7.3.3 Expansion of Mantissas for Symmetrical Quantization
- *Tables 7.19 to 7.23
- */
-static inline int
-symmetric_dequant(int code, int levels)
-{
-return ((code - (levels  1))  24) / levels;
-}
-
-/*
- * Initialize tables at runtime.
- */
-static av_cold void ac3_tables_init(void)
-{
-int i;
-
-/* generate table for ungrouping 3 values in 7 bits
-   reference: Section 7.1.3 Exponent Decoding */
-for (i = 0; i  128; i++) {
-ungroup_3_in_7_bits_tab[i][0] =  i / 25;
-ungroup_3_in_7_bits_tab[i][1] = (i % 25) / 5;
-ungroup_3_in_7_bits_tab[i][2] = (i % 25) % 5;
-}
-
-/* generate grouped mantissa tables
-   reference: Section 7.3.5 Ungrouping of Mantissas */
-for (i = 0; i  32; i++) {
-/* bap=1 mantissas */
-b1_mantissas[i][0] = 
symmetric_dequant(ff_ac3_ungroup_3_in_5_bits_tab[i][0], 3);
-b1_mantissas[i][1] = 
symmetric_dequant(ff_ac3_ungroup_3_in_5_bits_tab[i][1], 3);
-b1_mantissas[i][2] = 
symmetric_dequant(ff_ac3_ungroup_3_in_5_bits_tab[i][2], 3);
-}
-for (i = 0; i  128; i++) {
-/* bap=2 mantissas */
-b2_mantissas[i][0] = symmetric_dequant(ungroup_3_in_7_bits_tab[i][0], 
5);
-b2_mantissas[i][1] = symmetric_dequant(ungroup_3_in_7_bits_tab[i][1], 
5);
-b2_mantissas[i][2] = symmetric_dequant(ungroup_3_in_7_bits_tab[i][2], 
5);
-
-/* bap=4 mantissas */
-b4_mantissas[i][0] = symmetric_dequant(i / 11, 11);
-b4_mantissas[i][1] = symmetric_dequant(i % 11, 11);
-}
-/* generate ungrouped mantissa tables
-   reference: Tables 7.21 

[FFmpeg-devel] [PATCH v4] Add SUP/PGS subtitle demuxer

2014-08-31 Thread wm4
---
Integrating Reimar's suggestions. No changes outside of the probe
function.
---
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/supdec.c | 107 +++
 3 files changed, 109 insertions(+)
 create mode 100644 libavformat/supdec.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 3d124fb..b4965fe 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -405,6 +405,7 @@ OBJS-$(CONFIG_SRT_MUXER) += srtenc.o
 OBJS-$(CONFIG_STR_DEMUXER)   += psxstr.o
 OBJS-$(CONFIG_SUBVIEWER1_DEMUXER)+= subviewer1dec.o subtitles.o
 OBJS-$(CONFIG_SUBVIEWER_DEMUXER) += subviewerdec.o subtitles.o
+OBJS-$(CONFIG_SUP_DEMUXER)   += supdec.o
 OBJS-$(CONFIG_SWF_DEMUXER)   += swfdec.o swf.o
 OBJS-$(CONFIG_SWF_MUXER) += swfenc.o swf.o
 OBJS-$(CONFIG_TAK_DEMUXER)   += takdec.o apetag.o img2.o rawdec.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 8f70c4b..e6c0e5f 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -280,6 +280,7 @@ void av_register_all(void)
 REGISTER_DEMUXER (STR,  str);
 REGISTER_DEMUXER (SUBVIEWER1,   subviewer1);
 REGISTER_DEMUXER (SUBVIEWER,subviewer);
+REGISTER_DEMUXER (SUP,  sup);
 REGISTER_MUXDEMUX(SWF,  swf);
 REGISTER_DEMUXER (TAK,  tak);
 REGISTER_MUXER   (TEE,  tee);
diff --git a/libavformat/supdec.c b/libavformat/supdec.c
new file mode 100644
index 000..4217460
--- /dev/null
+++ b/libavformat/supdec.c
@@ -0,0 +1,107 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include avformat.h
+#include internal.h
+#include libavutil/intreadwrite.h
+
+#define SUP_PGS_MAGIC 0x5047 /* PG, big endian */
+
+static int sup_read_header(AVFormatContext *s)
+{
+AVStream *st = avformat_new_stream(s, NULL);
+if (!st)
+return AVERROR(ENOMEM);
+st-codec-codec_type = AVMEDIA_TYPE_SUBTITLE;
+st-codec-codec_id = AV_CODEC_ID_HDMV_PGS_SUBTITLE;
+avpriv_set_pts_info(st, 32, 1, 9);
+
+return 0;
+}
+
+static int sup_read_packet(struct AVFormatContext *s, AVPacket *pkt)
+{
+int64_t pts, pos;
+int ret;
+
+pos = avio_tell(s-pb);
+
+if (avio_rb16(s-pb) != SUP_PGS_MAGIC)
+return avio_feof(s-pb) ? AVERROR_EOF : AVERROR_INVALIDDATA;
+
+pts = avio_rb32(s-pb);
+avio_rb32(s-pb); /* discard DTS (usually 0, and useless) */
+
+if ((ret = av_get_packet(s-pb, pkt, 3))  0)
+return ret;
+
+pkt-stream_index = 0;
+pkt-flags |= AV_PKT_FLAG_KEY;
+pkt-pos = pos;
+pkt-pts = pts;
+
+if (pkt-size = 3) {
+// The full packet size is stored as part of the packet.
+size_t len = AV_RB16(pkt-data + 1);
+
+if ((ret = av_append_packet(s-pb, pkt, len))  0)
+return ret;
+}
+
+return 0;
+}
+
+static int sup_probe(AVProbeData *p)
+{
+unsigned char *buf = p-buf;
+size_t buf_size = p-buf_size;
+int nb_packets;
+
+for (nb_packets = 0; nb_packets  10; nb_packets++) {
+size_t full_packet_size;
+if (buf_size  10 + 3)
+break;
+if (memcmp(buf, PG, 2))
+return 0;
+full_packet_size = AV_RB16(buf + 10 + 1) + 10 + 3;
+if (buf_size  full_packet_size)
+break;
+buf += full_packet_size;
+buf_size -= full_packet_size;
+}
+if (!nb_packets)
+return 0;
+if (nb_packets  2)
+return AVPROBE_SCORE_EXTENSION;
+if (nb_packets  4)
+return AVPROBE_SCORE_RETRY;
+if (nb_packets  10)
+return AVPROBE_SCORE_RETRY + 1;
+return AVPROBE_SCORE_MAX;
+}
+
+AVInputFormat ff_sup_demuxer = {
+.name   = sup,
+.long_name  = NULL_IF_CONFIG_SMALL(raw HDMV Presentation Graphic 
Stream subtitles),
+.extensions = sup,
+.mime_type  = application/x-pgs,
+.read_probe = sup_probe,
+.read_header= sup_read_header,
+.read_packet= sup_read_packet,
+.flags  = AVFMT_GENERIC_INDEX,
+};
-- 
2.1.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org

Re: [FFmpeg-devel] [PATCH v4] Add SUP/PGS subtitle demuxer

2014-08-31 Thread Reimar Döffinger
On Mon, Sep 01, 2014 at 12:05:23AM +0200, wm4 wrote:
 +for (nb_packets = 0; nb_packets  10; nb_packets++) {
 +size_t full_packet_size;
 +if (buf_size  10 + 3)
 +break;
 +if (memcmp(buf, PG, 2))
 +return 0;

AV_RB16(buf) != SUP_PGS_MAGIC
would maybe be more consistent?

 +if (!nb_packets)
 +return 0;
 +if (nb_packets  2)
 +return AVPROBE_SCORE_EXTENSION;
 +if (nb_packets  4)
 +return AVPROBE_SCORE_RETRY;
 +if (nb_packets  10)
 +return AVPROBE_SCORE_RETRY + 1;

I think you fell for the same mistake as I.
AVPROBE_SCORE_EXTENSION (50) is in fact much higher than AVPROBE_SCORE_RETRY 
(25),
so that does not really make sense.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCHv2] doc/demuxers: document gif demuxer

2014-08-31 Thread Lou Logan
From ecad89e3edb64da662ae06a9d37c1fa84b02fadb Mon Sep 17 00:00:00 2001
From: Lou Logan l...@lrcd.com
Date: Thu, 28 Aug 2014 16:26:11 -0800
Subject: [PATCH] doc/demuxers: document gif demuxer

Signed-off-by: Lou Logan l...@lrcd.com
---
New patch addressing comments from Timothy and Clément.

 doc/demuxers.texi | 40 
 1 file changed, 40 insertions(+)

diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index d51b9d0..2c9d142 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -174,6 +174,46 @@ See @url{http://quvi.sourceforge.net/} for more 
information.
 FFmpeg needs to be built with @code{--enable-libquvi} for this demuxer to be
 enabled.
 
+@section gif
+
+Animated GIF demuxer.
+
+It accepts the following options:
+
+@table @option
+@item min_delay
+Set the minimum valid delay between frames in hundredths of seconds.
+Range is 0 to 6000. Default value is 2.
+
+@item default_delay
+Set the default delay between frames in hundredths of seconds.
+Range is 0 to 6000. Default value is 10.
+
+@item ignore_loop
+GIF files can be set to loop infinitely or up to a certain number of
+times.
+
+If @option{ignore_loop} is set to 1, then the loop setting from the
+input will be ignored and looping will not occur.
+
+If set to 0, then looping will occur and will cycle the number of times
+the GIF dictates.
+
+This option prevents a GIF stream from looping forever.
+
+Default value is 1.
+@end table
+
+For example, with the overlay filter, place an infinitely looping GIF
+over another video:
+@example
+ffmpeg -i input.mp4 -ignore_loop 0 -i input.gif -filter_complex 
overlay=shortest=1 out.mkv
+@end example
+
+Note that in the above example the shortest option for overlay filter is
+used to end the output video at the length of the shortest input file,
+which in this case is @file{input.mp4} as the GIF loops infinitely.
+
 @section image2
 
 Image file demuxer.
-- 
2.0.4
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v5] Add SUP/PGS subtitle demuxer

2014-08-31 Thread wm4
---
Use AV_RB16 instead of memcpy.
Don't use AVPROBE_SCORE_EXTENSION.
---
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/supdec.c | 107 +++
 3 files changed, 109 insertions(+)
 create mode 100644 libavformat/supdec.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 3d124fb..b4965fe 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -405,6 +405,7 @@ OBJS-$(CONFIG_SRT_MUXER) += srtenc.o
 OBJS-$(CONFIG_STR_DEMUXER)   += psxstr.o
 OBJS-$(CONFIG_SUBVIEWER1_DEMUXER)+= subviewer1dec.o subtitles.o
 OBJS-$(CONFIG_SUBVIEWER_DEMUXER) += subviewerdec.o subtitles.o
+OBJS-$(CONFIG_SUP_DEMUXER)   += supdec.o
 OBJS-$(CONFIG_SWF_DEMUXER)   += swfdec.o swf.o
 OBJS-$(CONFIG_SWF_MUXER) += swfenc.o swf.o
 OBJS-$(CONFIG_TAK_DEMUXER)   += takdec.o apetag.o img2.o rawdec.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 8f70c4b..e6c0e5f 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -280,6 +280,7 @@ void av_register_all(void)
 REGISTER_DEMUXER (STR,  str);
 REGISTER_DEMUXER (SUBVIEWER1,   subviewer1);
 REGISTER_DEMUXER (SUBVIEWER,subviewer);
+REGISTER_DEMUXER (SUP,  sup);
 REGISTER_MUXDEMUX(SWF,  swf);
 REGISTER_DEMUXER (TAK,  tak);
 REGISTER_MUXER   (TEE,  tee);
diff --git a/libavformat/supdec.c b/libavformat/supdec.c
new file mode 100644
index 000..3726c97
--- /dev/null
+++ b/libavformat/supdec.c
@@ -0,0 +1,107 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include avformat.h
+#include internal.h
+#include libavutil/intreadwrite.h
+
+#define SUP_PGS_MAGIC 0x5047 /* PG, big endian */
+
+static int sup_read_header(AVFormatContext *s)
+{
+AVStream *st = avformat_new_stream(s, NULL);
+if (!st)
+return AVERROR(ENOMEM);
+st-codec-codec_type = AVMEDIA_TYPE_SUBTITLE;
+st-codec-codec_id = AV_CODEC_ID_HDMV_PGS_SUBTITLE;
+avpriv_set_pts_info(st, 32, 1, 9);
+
+return 0;
+}
+
+static int sup_read_packet(struct AVFormatContext *s, AVPacket *pkt)
+{
+int64_t pts, pos;
+int ret;
+
+pos = avio_tell(s-pb);
+
+if (avio_rb16(s-pb) != SUP_PGS_MAGIC)
+return avio_feof(s-pb) ? AVERROR_EOF : AVERROR_INVALIDDATA;
+
+pts = avio_rb32(s-pb);
+avio_rb32(s-pb); /* discard DTS (usually 0, and useless) */
+
+if ((ret = av_get_packet(s-pb, pkt, 3))  0)
+return ret;
+
+pkt-stream_index = 0;
+pkt-flags |= AV_PKT_FLAG_KEY;
+pkt-pos = pos;
+pkt-pts = pts;
+
+if (pkt-size = 3) {
+// The full packet size is stored as part of the packet.
+size_t len = AV_RB16(pkt-data + 1);
+
+if ((ret = av_append_packet(s-pb, pkt, len))  0)
+return ret;
+}
+
+return 0;
+}
+
+static int sup_probe(AVProbeData *p)
+{
+unsigned char *buf = p-buf;
+size_t buf_size = p-buf_size;
+int nb_packets;
+
+for (nb_packets = 0; nb_packets  10; nb_packets++) {
+size_t full_packet_size;
+if (buf_size  10 + 3)
+break;
+if (AV_RB16(buf) != SUP_PGS_MAGIC)
+return 0;
+full_packet_size = AV_RB16(buf + 10 + 1) + 10 + 3;
+if (buf_size  full_packet_size)
+break;
+buf += full_packet_size;
+buf_size -= full_packet_size;
+}
+if (!nb_packets)
+return 0;
+if (nb_packets  2)
+return AVPROBE_SCORE_RETRY / 2;
+if (nb_packets  4)
+return AVPROBE_SCORE_RETRY;
+if (nb_packets  10)
+return AVPROBE_SCORE_RETRY + 1;
+return AVPROBE_SCORE_MAX;
+}
+
+AVInputFormat ff_sup_demuxer = {
+.name   = sup,
+.long_name  = NULL_IF_CONFIG_SMALL(raw HDMV Presentation Graphic 
Stream subtitles),
+.extensions = sup,
+.mime_type  = application/x-pgs,
+.read_probe = sup_probe,
+.read_header= sup_read_header,
+.read_packet= sup_read_packet,
+.flags  = AVFMT_GENERIC_INDEX,
+};
-- 
2.1.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org

Re: [FFmpeg-devel] [PATCH] mpegaudiodec: share identical tables between float and fixed decoder.

2014-08-31 Thread Michael Niedermayer
On Sun, Aug 31, 2014 at 10:47:09PM +0200, Reimar Döffinger wrote:
 ff_mpa_table_4_3_value alone saves over 128kB.

i wonder if that table shouldnt be something different in the float
implementation.
Also i think anyone caring about file size would likely not build
the float and fixed point mp3 decoder

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

Old school: Use the lowest level language in which you can solve the problem
conveniently.
New school: Use the highest level language in which the latest supercomputer
can solve the problem without the user falling asleep waiting.


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


[FFmpeg-devel] [PATCH 1/2] avcodec/dvbsubdec: make compute_edt user settable

2014-08-31 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer michae...@gmx.at
---
 ffmpeg.c   |2 +-
 libavcodec/dvbsubdec.c |3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index ff7961f..8bca9e7 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2298,7 +2298,7 @@ static int init_input_stream(int ist_index, char *error, 
int error_len)
 
 av_opt_set_int(ist-dec_ctx, refcounted_frames, 1, 0);
 if(ist-dec_ctx-codec_id == AV_CODEC_ID_DVB_SUBTITLE)
-av_dict_set(ist-decoder_opts, compute_edt, 1, 0);
+av_dict_set(ist-decoder_opts, compute_edt, 1, 
AV_DICT_DONT_OVERWRITE);
 
 if (!av_dict_get(ist-decoder_opts, threads, NULL, 0))
 av_dict_set(ist-decoder_opts, threads, auto, 0);
diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index 4cf5b02..097597e 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -1585,8 +1585,9 @@ end:
 return p - buf;
 }
 
+#define DS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_SUBTITLE_PARAM
 static const AVOption options[] = {
-{compute_edt, compute end of time using pts or timeout, 
offsetof(DVBSubContext, compute_edt), FF_OPT_TYPE_INT, {.i64 = 0}, 0, 1, 0},
+{compute_edt, compute end of time using pts or timeout, 
offsetof(DVBSubContext, compute_edt), FF_OPT_TYPE_INT, {.i64 = 0}, 0, 1, DS},
 {NULL}
 };
 static const AVClass dvbsubdec_class = {
-- 
1.7.9.5

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


Re: [FFmpeg-devel] [PATCH] Use makeinfo to generate html doc for the new website

2014-08-31 Thread Timothy Gu
On Sat, Aug 23, 2014 at 4:16 PM, Michael Niedermayer michae...@gmx.at wrote:
 On Sun, Jul 20, 2014 at 02:23:07PM -0700, Timothy Gu wrote:
 texi2html is deprecated by upstream in favor of makeinfo/texi2any. See:

 - 
 https://www.gnu.org/software/texinfo/manual/texinfo/html_node/texi2html.html
 - https://wiki.debian.org/Texi2htmlTransition
 - https://lists.debian.org/debian-devel/2013/05/msg01516.html

 This is actually two separate changes. But as makeinfo and texi2html
 adopt 2 (very) different init file syntaxes, it is easier to do the two
 transitions at once.

 Based on a patch by Andreas Cadhalpun andreas.cadhal...@googlemail.com.

 Fixes Trac ticket #3232.

 Signed-off-by: Timothy Gu timothyg...@gmail.com

 breaks build on ubuntu 12.04

 makeinfo: unrecognized option '--init-file=./doc/t2h.pm'
 Try `makeinfo --help' for more information.
 makeinfo: unrecognized option '--init-file=./doc/t2h.pm'
 Try `makeinfo --help' for more information.
 make: *** [doc/ffmpeg-utils.html] Error 1
 make: *** Waiting for unfinished jobs
 make: *** [doc/ffplay.html] Error 1
 HTMLdoc/ffserver.html
 HTMLdoc/ffprobe-all.html

 also mac OSX 10.9.4 seems to only have makeinfo 4.8, or at least thats
 whats installed on the box i looked at

Should be fixed by the upcoming patch.

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


[FFmpeg-devel] [PATCH] general: Fix usage of @float

2014-08-31 Thread Timothy Gu
makeinfo chokes on that.

Signed-off-by: Timothy Gu timothyg...@gmail.com
---
 doc/general.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/general.texi b/doc/general.texi
index 9ce0b31..8d7555d 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -130,7 +130,7 @@ Go to @url{http://x265.org/developers.html} and follow the 
instructions
 for installing the library. Then pass @code{--enable-libx265} to configure
 to enable it.
 
-@float note
+@float NOTE
 x265 is under the GNU Public License Version 2 or later
 (see @url{http://www.gnu.org/licenses/old-licenses/gpl-2.0.html} for
 details), you must upgrade FFmpeg's license to GPL in order to use it.
-- 
1.9.1

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


[FFmpeg-devel] [PATCH] x86/hevc_res_add: add ff_hevc_transform_add32_8_avx2

2014-08-31 Thread James Almer
~20% faster than AVX.

Signed-off-by: James Almer jamr...@gmail.com
---
 libavcodec/x86/hevc_res_add.asm | 31 +++
 libavcodec/x86/hevcdsp.h|  2 ++
 libavcodec/x86/hevcdsp_init.c   |  2 ++
 3 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/libavcodec/x86/hevc_res_add.asm b/libavcodec/x86/hevc_res_add.asm
index 7238fb3..488c5b7 100644
--- a/libavcodec/x86/hevc_res_add.asm
+++ b/libavcodec/x86/hevc_res_add.asm
@@ -89,8 +89,12 @@ cglobal hevc_transform_add4_8, 3, 4, 6
 %endmacro
 
 %macro TR_ADD_SSE_16_32_8 3
-mova  m2, [r1+%1   ]
-mova  m6, [r1+%1+16]
+mova xm2, [r1+%1   ]
+mova xm6, [r1+%1+16]
+%if cpuflag(avx2)
+vinserti128   m2, m2, [r1+%1+32], 1
+vinserti128   m6, m6, [r1+%1+48], 1
+%endif
 %if cpuflag(avx)
 psubw m1, m0, m2
 psubw m5, m0, m6
@@ -103,8 +107,12 @@ cglobal hevc_transform_add4_8, 3, 4, 6
 packuswb  m2, m6
 packuswb  m1, m5
 
-mova  m4, [r1+%1+32]
-mova  m6, [r1+%1+48]
+mova xm4, [r1+%1+mmsize*2   ]
+mova xm6, [r1+%1+mmsize*2+16]
+%if cpuflag(avx2)
+vinserti128   m4, m4, [r1+%1+96 ], 1
+vinserti128   m6, m6, [r1+%1+112], 1
+%endif
 %if cpuflag(avx)
 psubw m3, m0, m4
 psubw m5, m0, m6
@@ -169,6 +177,21 @@ TRANSFORM_ADD_8
 INIT_XMM avx
 TRANSFORM_ADD_8
 
+INIT_YMM avx2
+; void ff_hevc_transform_add32_8_avx2(uint8_t *dst, int16_t *coeffs, ptrdiff_t 
stride)
+cglobal hevc_transform_add32_8, 3, 4, 7
+pxor  m0, m0
+lea   r3, [r2*3]
+TR_ADD_SSE_16_32_8   0, r0,  r0+r2
+TR_ADD_SSE_16_32_8 128, r0+r2*2, r0+r3
+%rep 7
+addr1, 256
+lear0, [r0+r2*4]
+TR_ADD_SSE_16_32_8   0, r0,  r0+r2
+TR_ADD_SSE_16_32_8 128, r0+r2*2, r0+r3
+%endrep
+RET
+
 ;-
 ; void ff_hevc_transform_add_10(pixel *dst, int16_t *block, int stride)
 ;-
diff --git a/libavcodec/x86/hevcdsp.h b/libavcodec/x86/hevcdsp.h
index 839e052..8dea142 100644
--- a/libavcodec/x86/hevcdsp.h
+++ b/libavcodec/x86/hevcdsp.h
@@ -143,6 +143,8 @@ void ff_hevc_transform_add8_8_avx(uint8_t *dst, int16_t 
*coeffs, ptrdiff_t strid
 void ff_hevc_transform_add16_8_avx(uint8_t *dst, int16_t *coeffs, ptrdiff_t 
stride);
 void ff_hevc_transform_add32_8_avx(uint8_t *dst, int16_t *coeffs, ptrdiff_t 
stride);
 
+void ff_hevc_transform_add32_8_avx2(uint8_t *dst, int16_t *coeffs, ptrdiff_t 
stride);
+
 void ff_hevc_transform_add4_10_mmxext(uint8_t *dst, int16_t *coeffs, ptrdiff_t 
stride);
 void ff_hevc_transform_add8_10_sse2(uint8_t *dst, int16_t *coeffs, ptrdiff_t 
stride);
 void ff_hevc_transform_add16_10_sse2(uint8_t *dst, int16_t *coeffs, ptrdiff_t 
stride);
diff --git a/libavcodec/x86/hevcdsp_init.c b/libavcodec/x86/hevcdsp_init.c
index 6bcced6..eaa97e1 100644
--- a/libavcodec/x86/hevcdsp_init.c
+++ b/libavcodec/x86/hevcdsp_init.c
@@ -555,6 +555,8 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int 
bit_depth)
 if (EXTERNAL_AVX2(cpu_flags)) {
 c-idct_dc[2] = ff_hevc_idct16x16_dc_8_avx2;
 c-idct_dc[3] = ff_hevc_idct32x32_dc_8_avx2;
+
+c-transform_add[3]= ff_hevc_transform_add32_8_avx2;
 }
 } else if (bit_depth == 10) {
 if (EXTERNAL_MMXEXT(cpu_flags)) {
-- 
1.8.5.5

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


[FFmpeg-devel] [PATCH 2/2] [WEB] Add generate-doc.sh to generate makeinfo-based ffmpeg docs

2014-08-31 Thread Timothy Gu
Signed-off-by: Timothy Gu timothyg...@gmail.com
---

Changes:

- src/template_doctitle is not deleted in this commit per Michael's request.

Michael, now this patch should be able to be applied before the server 
patch I will send to you in a moment.

 README  | 12 +---
 generate-doc.sh | 41 +
 2 files changed, 42 insertions(+), 11 deletions(-)
 create mode 100755 generate-doc.sh

diff --git a/README b/README
index 93854ee..7f15db2 100644
--- a/README
+++ b/README
@@ -15,17 +15,7 @@ GENERATE THE DOCUMENTATION
 
 /!\ None of the generated versions of the website contain the documentation.
 
-To generate the documentation pages:
-- Add the HTML wrappers to your environment:
-  $ export FFMPEG_HEADER1=$(cat src/template_head1 src/template_doctitle 
src/template_head_prod)
-  $ export FFMPEG_HEADER2=$(cat src/template_head2 src/template_doctitle 
src/template_head3)
-  $ export FFMPEG_FOOTER=$(cat src/template_footer1 src/template_footer_prod 
src/template_footer2)
-- Get the main ffmpeg repo:
-  $ git clone git://source.ffmpeg.org/ffmpeg.git
-- Compile the documentation using the ffmpeg main repo Makefile:
-  $ make doc
-- Copy the generated HTML files inside the website:
-  $ cp /path/to/ffmpeg/doc/*.html /path/to/ffmpeg-web/htdocs/
+To generate the documentation pages, just `./generate-doc.sh ffmpeg-src`.
 
 In case of a major CSS update, please also update the `style.min.css` file in
 the main FFmpeg repo:
diff --git a/generate-doc.sh b/generate-doc.sh
new file mode 100755
index 000..f953a9a
--- /dev/null
+++ b/generate-doc.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+#
+# Copyright (c) 2014 Tiancheng Timothy Gu.
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+die() {
+echo $1
+exit 1
+}
+
+if [ $# != 1 ]; then
+die Usage: $0 ffmpeg-source
+fi
+
+src=$1
+current_dir=$(pwd)
+
+export FFMPEG_HEADER1=$(cat src/template_head1)
+export FFMPEG_HEADER2=$(cat src/template_head_prod src/template_head2)
+export FFMPEG_HEADER3=$(cat src/template_head3)
+export FFMPEG_FOOTER=$(cat src/template_footer1 src/template_footer_prod 
src/template_footer2)
+
+rm -rf build-doc
+mkdir build-doc  cd build-doc
+$src/configure --enable-gpl --disable-yasm || die configure failed
+make doc || die doc not made
+cp doc/*.html ../htdocs/ || die copy failed
+
+cd ..
+rm -rf build-doc
\ No newline at end of file
-- 
1.9.1

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


[FFmpeg-devel] [PATCH 1/2] [WEB] style: add warning style similar to .info but has a red border

2014-08-31 Thread Timothy Gu
Signed-off-by: Timothy Gu timothyg...@gmail.com
---

No changes.

 src/less/style.less | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/less/style.less b/src/less/style.less
index 6a26684..0c9ea03 100644
--- a/src/less/style.less
+++ b/src/less/style.less
@@ -15,6 +15,7 @@
 @Cseconddarkdark: darken(@Cseconddark, 10%);
 @Csecondlight: lighten(@Csecond, 15%);
 @Csecondlightlight: lighten(@Csecondlight, 20%);
+@Cwarning: #ae4c4c;
 
 // * //
 // SIZES
@@ -180,17 +181,24 @@ a.well {
 }
 }
 
-.info {
+.info, .warning {
 margin: 10px;
 padding: 10px;
 background-color: @Cmainlight;
-border-left: 10px @Csecond solid;
 color: @Cinvert;
 code {
background-color: @Cmain;
 }
 }
 
+.info {
+border-left: 10px @Csecond solid;
+}
+
+.warning {
+border-left: 10px @Cwarning solid;
+}
+
 .with-icon {
 padding: 30px;
 .pull-left {
-- 
1.9.1

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