[FFmpeg-cvslog] utvideodec: Prevent possible signed overflow

2017-10-27 Thread Ganesh Ajjanagadde
ffmpeg | branch: master | Ganesh Ajjanagadde  | Mon Feb 22 
23:21:58 2016 -0500| [1fe858136b315796dd5349f3b4448a29d1bd6fa1] | committer: 
Luca Barbato

utvideodec: Prevent possible signed overflow

Doing slice_end - slice_start is unsafe and can lead to undefined behavior
until slice_end has been properly sanitized.

Reviewed-by: Ronald S. Bultje 
Signed-off-by: Ganesh Ajjanagadde 
Signed-off-by: Luca Barbato 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1fe858136b315796dd5349f3b4448a29d1bd6fa1
---

 libavcodec/utvideodec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/utvideodec.c b/libavcodec/utvideodec.c
index 808e3be067..2aaf861e62 100644
--- a/libavcodec/utvideodec.c
+++ b/libavcodec/utvideodec.c
@@ -361,12 +361,12 @@ static int decode_frame(AVCodecContext *avctx, void 
*data, int *got_frame,
 slice_end   = 0;
 for (j = 0; j < c->slices; j++) {
 slice_end   = bytestream2_get_le32u();
-slice_size  = slice_end - slice_start;
-if (slice_end < 0 || slice_size < 0 ||
+if (slice_end < 0 || slice_end < slice_start ||
 bytestream2_get_bytes_left() < slice_end) {
 av_log(avctx, AV_LOG_ERROR, "Incorrect slice size\n");
 return AVERROR_INVALIDDATA;
 }
+slice_size  = slice_end - slice_start;
 slice_start = slice_end;
 max_slice_size = FFMAX(max_slice_size, slice_size);
 }

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


[FFmpeg-cvslog] Merge commit '1fe858136b315796dd5349f3b4448a29d1bd6fa1'

2017-10-27 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Oct 27 22:21:13 
2017 -0300| [7f9de7b416c97b96aee2cf9025db382c71756806] | committer: James Almer

Merge commit '1fe858136b315796dd5349f3b4448a29d1bd6fa1'

* commit '1fe858136b315796dd5349f3b4448a29d1bd6fa1':
  utvideodec: Prevent possible signed overflow

This commit is a noop, see e86444b19d0b63c098298243fb20fd577f34cf34

Merged-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7f9de7b416c97b96aee2cf9025db382c71756806
---



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


[FFmpeg-cvslog] Add FM Screen Capture Codec decoder

2017-10-27 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Mon Feb  6 09:17:29 
2017 +0100| [95a8a03a191204c3ca5c8cf6b69ab166765d5ff3] | committer: Diego 
Biurrun

Add FM Screen Capture Codec decoder

Signed-off-by: Paul B Mahol 
Signed-off-by: Diego Biurrun 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=95a8a03a191204c3ca5c8cf6b69ab166765d5ff3
---

 Changelog   |   1 +
 doc/general.texi|   1 +
 libavcodec/Makefile |   1 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/avcodec.h|   1 +
 libavcodec/codec_desc.c |   7 +
 libavcodec/fmvc.c   | 636 
 libavcodec/version.h|   2 +-
 libavformat/riff.c  |   1 +
 9 files changed, 650 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index b3aed3cd7e..dccf173741 100644
--- a/Changelog
+++ b/Changelog
@@ -13,6 +13,7 @@ version :
   --x86asmexe=yasm to configure to restore the old behavior.
 - Cineform HD decoder
 - VP9 superframe split/merge bitstream filters
+- FM Screen Capture Codec decoder
 
 
 version 12:
diff --git a/doc/general.texi b/doc/general.texi
index b21195bde2..b1a42c50f8 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -667,6 +667,7 @@ following image formats are supported:
 @item Flash Screen Video v2  @tab @tab  X
 @item Flash Video (FLV)  @tab  X  @tab  X
 @tab Sorenson H.263 used in Flash
+@item FM Screen Capture Codec  @tab @tab  X
 @item Forward Uncompressed   @tab @tab  X
 @item Fraps  @tab @tab  X
 @item Go2Meeting @tab @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index a82210d89f..e835133842 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -235,6 +235,7 @@ OBJS-$(CONFIG_FLASHSV_DECODER) += flashsv.o
 OBJS-$(CONFIG_FLASHSV_ENCODER) += flashsvenc.o
 OBJS-$(CONFIG_FLASHSV2_DECODER)+= flashsv.o
 OBJS-$(CONFIG_FLIC_DECODER)+= flicvideo.o
+OBJS-$(CONFIG_FMVC_DECODER)+= fmvc.o
 OBJS-$(CONFIG_FOURXM_DECODER)  += 4xm.o
 OBJS-$(CONFIG_FRAPS_DECODER)   += fraps.o
 OBJS-$(CONFIG_FRWU_DECODER)+= frwu.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 36f839c852..20b3b35b90 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -161,6 +161,7 @@ void avcodec_register_all(void)
 REGISTER_DECODER(FLASHSV2,  flashsv2);
 REGISTER_DECODER(FLIC,  flic);
 REGISTER_ENCDEC (FLV,   flv);
+REGISTER_DECODER(FMVC,  fmvc);
 REGISTER_DECODER(FOURXM,fourxm);
 REGISTER_DECODER(FRAPS, fraps);
 REGISTER_DECODER(FRWU,  frwu);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 1c58fe2d68..4cf446faf9 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -408,6 +408,7 @@ enum AVCodecID {
 AV_CODEC_ID_AV1,
 AV_CODEC_ID_PIXLET,
 AV_CODEC_ID_CFHD,
+AV_CODEC_ID_FMVC,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
start of audio codecs
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 7103b5890a..ed97420d42 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1210,6 +1210,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("Apple Pixlet"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
 },
+{
+.id= AV_CODEC_ID_FMVC,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "fmvc",
+.long_name = NULL_IF_CONFIG_SMALL("FM Screen Capture Codec"),
+.props = AV_CODEC_PROP_LOSSLESS,
+},
 
 /* image codecs */
 {
diff --git a/libavcodec/fmvc.c b/libavcodec/fmvc.c
new file mode 100644
index 00..64136e392d
--- /dev/null
+++ b/libavcodec/fmvc.c
@@ -0,0 +1,636 @@
+/*
+ * FM Screen Capture Codec decoder
+ *
+ * Copyright (c) 2017 Paul B Mahol
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include 
+#include 
+
+#include "avcodec.h"
+#include "bytestream.h"
+#include "internal.h"
+
+#define BLOCK_HEIGHT 112u
+#define BLOCK_WIDTH  84u
+

[FFmpeg-cvslog] fmvc: Add FATE tests

2017-10-27 Thread Diego Biurrun
ffmpeg | branch: master | Diego Biurrun  | Tue Mar 21 
12:16:00 2017 +0100| [4d4d7cf9d539a053f531f662a972b23d335738eb] | committer: 
Diego Biurrun

fmvc: Add FATE tests

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4d4d7cf9d539a053f531f662a972b23d335738eb
---

 tests/fate/screen.mak |  9 +
 tests/ref/fate/fmvc-type1 |  7 +++
 tests/ref/fate/fmvc-type2 | 29 +
 3 files changed, 45 insertions(+)

diff --git a/tests/fate/screen.mak b/tests/fate/screen.mak
index 7d2f7909b7..575d217d5a 100644
--- a/tests/fate/screen.mak
+++ b/tests/fate/screen.mak
@@ -8,6 +8,15 @@ fate-dxtory: CMD = framecrc -i 
$(TARGET_SAMPLES)/dxtory/dxtory_mic.avi -an
 FATE_SAMPLES_AVCONV-$(call DEMDEC, AVI, FIC) += fate-fic-avi
 fate-fic-avi: CMD = framecrc -i $(TARGET_SAMPLES)/fic/fic-partial-2MB.avi -an
 
+FATE_FMVC += fate-fmvc-type1
+fate-fmvc-type1: CMD = framecrc -i 
$(TARGET_SAMPLES)/fmvc/6-methyl-5-hepten-2-one-CC-db_small.avi
+
+FATE_FMVC += fate-fmvc-type2
+fate-fmvc-type2: CMD = framecrc -i 
$(TARGET_SAMPLES)/fmvc/fmvcVirtualDub_small.avi
+
+FATE_SAMPLES_AVCONV-$(call DEMDEC, AVI, FMVC) += $(FATE_FMVC)
+fate-fmvc: $(FATE_FMVC)
+
 FATE_FRAPS += fate-fraps-v0
 fate-fraps-v0: CMD = framecrc -i 
$(TARGET_SAMPLES)/fraps/Griffin_Ragdoll01-partial.avi
 
diff --git a/tests/ref/fate/fmvc-type1 b/tests/ref/fate/fmvc-type1
new file mode 100644
index 00..821866da7d
--- /dev/null
+++ b/tests/ref/fate/fmvc-type1
@@ -0,0 +1,7 @@
+#tb 0: 1/15
+0,  0,  0,1,   760944, 0x2feb1453
+0,  1,  1,1,   760944, 0x9677ebf8
+0,  2,  2,1,   760944, 0x83d2ed49
+0,  3,  3,1,   760944, 0x9ab6c63d
+0,  4,  4,1,   760944, 0x1820189c
+0,  5,  5,1,   760944, 0x4b94f521
diff --git a/tests/ref/fate/fmvc-type2 b/tests/ref/fate/fmvc-type2
new file mode 100644
index 00..32a307ea4f
--- /dev/null
+++ b/tests/ref/fate/fmvc-type2
@@ -0,0 +1,29 @@
+#tb 0: 1/10
+0,  0,  0,1,  1327104, 0xa73c232d
+0,  1,  1,1,  1327104, 0xa73c232d
+0,  2,  2,1,  1327104, 0xa73c232d
+0,  3,  3,1,  1327104, 0xf14e05be
+0,  4,  4,1,  1327104, 0xd8c03726
+0,  5,  5,1,  1327104, 0x16e8447a
+0,  6,  6,1,  1327104, 0x8dfd94d2
+0,  7,  7,1,  1327104, 0x3550833b
+0,  8,  8,1,  1327104, 0x74bd2959
+0,  9,  9,1,  1327104, 0xc2b4505c
+0, 10, 10,1,  1327104, 0x7c6999cd
+0, 11, 11,1,  1327104, 0xb6562711
+0, 12, 12,1,  1327104, 0x50993565
+0, 13, 13,1,  1327104, 0x579549d2
+0, 14, 14,1,  1327104, 0xb17170f6
+0, 15, 15,1,  1327104, 0xc7d87708
+0, 16, 16,1,  1327104, 0xdb3879da
+0, 17, 17,1,  1327104, 0xdb3879da
+0, 18, 18,1,  1327104, 0xdb3879da
+0, 19, 19,1,  1327104, 0x6f1c5c01
+0, 20, 20,1,  1327104, 0xd9d15c01
+0, 21, 21,1,  1327104, 0x826f0bab
+0, 22, 22,1,  1327104, 0xf25b041d
+0, 23, 23,1,  1327104, 0xc85a041d
+0, 24, 24,1,  1327104, 0xc85a041d
+0, 25, 25,1,  1327104, 0xc85a041d
+0, 26, 26,1,  1327104, 0xc85a041d
+0, 27, 27,1,  1327104, 0xc54cc6ae

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


[FFmpeg-cvslog] Merge commit '4d4d7cf9d539a053f531f662a972b23d335738eb'

2017-10-27 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Oct 27 21:16:18 
2017 -0300| [3c4c092774e3047826252c9ba35003d8ec7f0c5f] | committer: James Almer

Merge commit '4d4d7cf9d539a053f531f662a972b23d335738eb'

* commit '4d4d7cf9d539a053f531f662a972b23d335738eb':
  fmvc: Add FATE tests

Merged-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3c4c092774e3047826252c9ba35003d8ec7f0c5f
---

 tests/fate/screen.mak |  9 +
 tests/ref/fate/fmvc-type1 | 11 +++
 tests/ref/fate/fmvc-type2 | 33 +
 3 files changed, 53 insertions(+)

diff --git a/tests/fate/screen.mak b/tests/fate/screen.mak
index 66dfa6ba7f..68b4f6f979 100644
--- a/tests/fate/screen.mak
+++ b/tests/fate/screen.mak
@@ -8,6 +8,15 @@ fate-dxtory: CMD = framecrc -i 
$(TARGET_SAMPLES)/dxtory/dxtory_mic.avi -an
 FATE_SAMPLES_AVCONV-$(call DEMDEC, AVI, FIC) += fate-fic-avi
 fate-fic-avi: CMD = framecrc -i $(TARGET_SAMPLES)/fic/fic-partial-2MB.avi -an
 
+FATE_FMVC += fate-fmvc-type1
+fate-fmvc-type1: CMD = framecrc -i 
$(TARGET_SAMPLES)/fmvc/6-methyl-5-hepten-2-one-CC-db_small.avi
+
+FATE_FMVC += fate-fmvc-type2
+fate-fmvc-type2: CMD = framecrc -i 
$(TARGET_SAMPLES)/fmvc/fmvcVirtualDub_small.avi
+
+FATE_SAMPLES_AVCONV-$(call DEMDEC, AVI, FMVC) += $(FATE_FMVC)
+fate-fmvc: $(FATE_FMVC)
+
 FATE_FRAPS += fate-fraps-v0
 fate-fraps-v0: CMD = framecrc -i 
$(TARGET_SAMPLES)/fraps/Griffin_Ragdoll01-partial.avi
 
diff --git a/tests/ref/fate/fmvc-type1 b/tests/ref/fate/fmvc-type1
new file mode 100644
index 00..d59de047e7
--- /dev/null
+++ b/tests/ref/fate/fmvc-type1
@@ -0,0 +1,11 @@
+#tb 0: 1/15
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 664x382
+#sar 0: 0/1
+0,  0,  0,1,   760944, 0x2feb1453
+0,  1,  1,1,   760944, 0x9677ebf8
+0,  2,  2,1,   760944, 0x83d2ed49
+0,  3,  3,1,   760944, 0x9ab6c63d
+0,  4,  4,1,   760944, 0x1820189c
+0,  5,  5,1,   760944, 0x4b94f521
diff --git a/tests/ref/fate/fmvc-type2 b/tests/ref/fate/fmvc-type2
new file mode 100644
index 00..60c630803a
--- /dev/null
+++ b/tests/ref/fate/fmvc-type2
@@ -0,0 +1,33 @@
+#tb 0: 1/10
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 768x576
+#sar 0: 0/1
+0,  0,  0,1,  1327104, 0xa73c232d
+0,  1,  1,1,  1327104, 0xa73c232d
+0,  2,  2,1,  1327104, 0xa73c232d
+0,  3,  3,1,  1327104, 0xf14e05be
+0,  4,  4,1,  1327104, 0xd8c03726
+0,  5,  5,1,  1327104, 0x16e8447a
+0,  6,  6,1,  1327104, 0x8dfd94d2
+0,  7,  7,1,  1327104, 0x3550833b
+0,  8,  8,1,  1327104, 0x74bd2959
+0,  9,  9,1,  1327104, 0xc2b4505c
+0, 10, 10,1,  1327104, 0x7c6999cd
+0, 11, 11,1,  1327104, 0xb6562711
+0, 12, 12,1,  1327104, 0x50993565
+0, 13, 13,1,  1327104, 0x579549d2
+0, 14, 14,1,  1327104, 0xb17170f6
+0, 15, 15,1,  1327104, 0xc7d87708
+0, 16, 16,1,  1327104, 0xdb3879da
+0, 17, 17,1,  1327104, 0xdb3879da
+0, 18, 18,1,  1327104, 0xdb3879da
+0, 19, 19,1,  1327104, 0x6f1c5c01
+0, 20, 20,1,  1327104, 0xd9d15c01
+0, 21, 21,1,  1327104, 0x826f0bab
+0, 22, 22,1,  1327104, 0xf25b041d
+0, 23, 23,1,  1327104, 0xc85a041d
+0, 24, 24,1,  1327104, 0xc85a041d
+0, 25, 25,1,  1327104, 0xc85a041d
+0, 26, 26,1,  1327104, 0xc85a041d
+0, 27, 27,1,  1327104, 0xc54cc6ae


==

diff --cc tests/ref/fate/fmvc-type1
index 00,821866da7d..d59de047e7
mode 00,100644..100644
--- a/tests/ref/fate/fmvc-type1
+++ b/tests/ref/fate/fmvc-type1
@@@ -1,0 -1,7 +1,11 @@@
+ #tb 0: 1/15
++#media_type 0: video
++#codec_id 0: rawvideo
++#dimensions 0: 664x382
++#sar 0: 0/1
+ 0,  0,  0,1,   760944, 0x2feb1453
+ 0,  1,  1,1,   760944, 0x9677ebf8
+ 0,  2,  2,1,   760944, 0x83d2ed49
+ 0,  3,  3,1,   760944, 0x9ab6c63d
+ 0,  4,  4,1,   760944, 0x1820189c
+ 0,  5,  5,1,   760944, 0x4b94f521
diff --cc tests/ref/fate/fmvc-type2
index 00,32a307ea4f..60c630803a
mode 00,100644..100644
--- a/tests/ref/fate/fmvc-type2
+++ b/tests/ref/fate/fmvc-type2
@@@ -1,0 -1,29 +1,33 @@@
+ #tb 0: 1/10
++#media_type 0: video

[FFmpeg-cvslog] Merge commit '95a8a03a191204c3ca5c8cf6b69ab166765d5ff3'

2017-10-27 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Oct 27 21:15:34 
2017 -0300| [b94eda7194c2c4233d9b1c27f58098410f462fed] | committer: James Almer

Merge commit '95a8a03a191204c3ca5c8cf6b69ab166765d5ff3'

* commit '95a8a03a191204c3ca5c8cf6b69ab166765d5ff3':
  Add FM Screen Capture Codec decoder

Merged-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b94eda7194c2c4233d9b1c27f58098410f462fed
---

 libavcodec/fmvc.c | 76 ++-
 1 file changed, 41 insertions(+), 35 deletions(-)

diff --git a/libavcodec/fmvc.c b/libavcodec/fmvc.c
index 74e9bdd8a0..a06b90c6fe 100644
--- a/libavcodec/fmvc.c
+++ b/libavcodec/fmvc.c
@@ -44,11 +44,11 @@ typedef struct FMVCContext {
 size_t  buffer_size;
 uint8_t*pbuffer;
 size_t  pbuffer_size;
-int stride;
+ptrdiff_t   stride;
 int bpp;
 int yb, xb;
 InterBlock *blocks;
-int nb_blocks;
+unsignednb_blocks;
 } FMVCContext;
 
 static int decode_type2(GetByteContext *gb, PutByteContext *pb)
@@ -150,7 +150,7 @@ static int decode_type2(GetByteContext *gb, PutByteContext 
*pb)
 if (opcode >= 0x40) {
 bytestream2_skip(gb, 1);
 pos = - ((opcode >> 2) & 7) - 1 - 8 * bytestream2_get_byte(gb);
-len = (opcode >> 5) - 1;
+len =(opcode >> 5)  - 1;
 
 bytestream2_init(, pb->buffer_start, pb->buffer_end - 
pb->buffer_start);
 bytestream2_seek(, bytestream2_tell_p(pb) + pos, SEEK_SET);
@@ -305,7 +305,7 @@ static int decode_type1(GetByteContext *gb, PutByteContext 
*pb)
 break;
 opcode = bytestream2_get_byte(gb);
 if (opcode < 0xF8) {
-opcode = opcode + 32;
+opcode += 32;
 break;
 }
 i = opcode - 0xF8;
@@ -393,9 +393,8 @@ static int decode_type1(GetByteContext *gb, PutByteContext 
*pb)
 return 0;
 }
 
-static int decode_frame(AVCodecContext *avctx,
-void *data, int *got_frame,
-AVPacket *avpkt)
+static int decode_frame(AVCodecContext *avctx, void *data,
+int *got_frame, AVPacket *avpkt)
 {
 FMVCContext *s = avctx->priv_data;
 GetByteContext *gb = >gb;
@@ -414,7 +413,7 @@ static int decode_frame(AVCodecContext *avctx,
 
 if (frame->key_frame) {
 const uint8_t *src;
-int type, size;
+unsigned type, size;
 uint8_t *dst;
 
 type = bytestream2_get_le16(gb);
@@ -428,7 +427,7 @@ static int decode_frame(AVCodecContext *avctx,
 } else if (type == 2){
 decode_type2(gb, pb);
 } else {
-avpriv_report_missing_feature(avctx, "compression %d", type);
+avpriv_report_missing_feature(avctx, "Compression type %d", type);
 return AVERROR_PATCHWELCOME;
 }
 
@@ -440,7 +439,8 @@ static int decode_frame(AVCodecContext *avctx,
 src += s->stride * 4;
 }
 } else {
-int block, nb_blocks, type, k, l;
+unsigned block, nb_blocks;
+int type, k, l;
 uint8_t *ssrc, *ddst;
 const uint32_t *src;
 uint32_t *dst;
@@ -456,7 +456,8 @@ static int decode_frame(AVCodecContext *avctx,
 
 type = bytestream2_get_le16(gb);
 for (block = 0; block < nb_blocks; block++) {
-int size, offset, start = 0;
+unsigned size, offset;
+int start = 0;
 
 offset = bytestream2_get_le16(gb);
 if (offset >= s->nb_blocks)
@@ -472,7 +473,7 @@ static int decode_frame(AVCodecContext *avctx,
 } else if (type == 2){
 decode_type2(gb, pb);
 } else {
-avpriv_report_missing_feature(avctx, "compression %d", type);
+avpriv_report_missing_feature(avctx, "Compression type %d", 
type);
 return AVERROR_PATCHWELCOME;
 }
 
@@ -497,9 +498,8 @@ static int decode_frame(AVCodecContext *avctx,
 if (s->blocks[block].xor) {
 for (k = 0; k < block_h; k++) {
 uint32_t *column = dst;
-for (l = 0; l < block_w; l++) {
+for (l = 0; l < block_w; l++)
 *dst++ ^= *src++;
-}
 dst = [s->stride];
 }
 }
@@ -529,17 +529,24 @@ static av_cold int decode_init(AVCodecContext *avctx)
 int i, j, m, block = 0, h = BLOCK_HEIGHT, w = BLOCK_WIDTH;
 
 switch (avctx->bits_per_coded_sample) {
-case 16: avctx->pix_fmt = AV_PIX_FMT_RGB555; break;
-case 24: avctx->pix_fmt = AV_PIX_FMT_BGR24;  break;
-case 32: avctx->pix_fmt = AV_PIX_FMT_BGRA;   break;

[FFmpeg-cvslog] avcodec/audiotoolboxdec: fix ac3_parser header include

2017-10-27 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Oct 27 19:41:38 
2017 -0300| [2d11218877a5734ab1c5a97a650d0c74de0022ee] | committer: James Almer

avcodec/audiotoolboxdec: fix ac3_parser header include

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2d11218877a5734ab1c5a97a650d0c74de0022ee
---

 libavcodec/audiotoolboxdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c
index a149949aba..3711665bbd 100644
--- a/libavcodec/audiotoolboxdec.c
+++ b/libavcodec/audiotoolboxdec.c
@@ -24,7 +24,7 @@
 
 #include "config.h"
 #include "avcodec.h"
-#include "ac3_parser.h"
+#include "ac3_parser_internal.h"
 #include "bytestream.h"
 #include "internal.h"
 #include "mpegaudiodecheader.h"

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


[FFmpeg-cvslog] Merge commit '89d9869d2491d4209d707a8e7f29c58227ae5a4e'

2017-10-27 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Oct 27 18:22:39 
2017 -0300| [9840ca70e75d278c23580b6b7c116e58f2eb9c0f] | committer: James Almer

Merge commit '89d9869d2491d4209d707a8e7f29c58227ae5a4e'

* commit '89d9869d2491d4209d707a8e7f29c58227ae5a4e':
  hevc: Add NEON 16x16 IDCT

Merged-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9840ca70e75d278c23580b6b7c116e58f2eb9c0f
---

 libavcodec/arm/hevcdsp_idct_neon.S | 197 +
 libavcodec/arm/hevcdsp_init_neon.c |   4 +
 2 files changed, 201 insertions(+)

diff --git a/libavcodec/arm/hevcdsp_idct_neon.S 
b/libavcodec/arm/hevcdsp_idct_neon.S
index 627b9b4750..b59496ec25 100644
--- a/libavcodec/arm/hevcdsp_idct_neon.S
+++ b/libavcodec/arm/hevcdsp_idct_neon.S
@@ -429,7 +429,204 @@ function ff_hevc_idct_8x8_\bitdepth\()_neon, export=1
 endfunc
 .endm
 
+.macro butterfly e, o, tmp_p, tmp_m
+vadd.s32\tmp_p, \e, \o
+vsub.s32\tmp_m, \e, \o
+.endm
+
+.macro tr16_8x4 in0, in1, in2, in3, in4, in5, in6, in7
+tr_4x4_8\in0, \in2, \in4, \in6, q8, q9, q10, q11, q12, q13, 
q14, q15
+
+vmull.s16   q12, \in1, \in0[0]
+vmull.s16   q13, \in1, \in0[1]
+vmull.s16   q14, \in1, \in0[2]
+vmull.s16   q15, \in1, \in0[3]
+sum_sub q12, \in3, \in0[1], +
+sum_sub q13, \in3, \in0[3], -
+sum_sub q14, \in3, \in0[0], -
+sum_sub q15, \in3, \in0[2], -
+
+sum_sub q12, \in5, \in0[2], +
+sum_sub q13, \in5, \in0[0], -
+sum_sub q14, \in5, \in0[3], +
+sum_sub q15, \in5, \in0[1], +
+
+sum_sub q12, \in7, \in0[3], +
+sum_sub q13, \in7, \in0[2], -
+sum_sub q14, \in7, \in0[1], +
+sum_sub q15, \in7, \in0[0], -
+
+butterfly   q8,  q12, q0, q7
+butterfly   q9,  q13, q1, q6
+butterfly   q10, q14, q2, q5
+butterfly   q11, q15, q3, q4
+add r4,  sp,  #512
+vst1.s16{q0-q1}, [r4, :128]!
+vst1.s16{q2-q3}, [r4, :128]!
+vst1.s16{q4-q5}, [r4, :128]!
+vst1.s16{q6-q7}, [r4, :128]
+.endm
+
+.macro load16 in0, in1, in2, in3, in4, in5, in6, in7
+vld1.s16{\in0}, [r1, :64], r2
+vld1.s16{\in1}, [r3, :64], r2
+vld1.s16{\in2}, [r1, :64], r2
+vld1.s16{\in3}, [r3, :64], r2
+vld1.s16{\in4}, [r1, :64], r2
+vld1.s16{\in5}, [r3, :64], r2
+vld1.s16{\in6}, [r1, :64], r2
+vld1.s16{\in7}, [r3, :64], r2
+.endm
+
+.macro add_member in, t0, t1, t2, t3, t4, t5, t6, t7, op0, op1, op2, op3, op4, 
op5, op6, op7
+sum_sub q5, \in, \t0, \op0
+sum_sub q6, \in, \t1, \op1
+sum_sub q7, \in, \t2, \op2
+sum_sub q8, \in, \t3, \op3
+sum_sub q9, \in, \t4, \op4
+sum_sub q10,\in, \t5, \op5
+sum_sub q11,\in, \t6, \op6
+sum_sub q12,\in, \t7, \op7
+.endm
+
+.macro butterfly16 in0, in1, in2, in3, in4, in5, in6, in7
+vadd.s32q4, \in0, \in1
+vsub.s32\in0, \in0, \in1
+vadd.s32\in1, \in2, \in3
+vsub.s32\in2, \in2, \in3
+vadd.s32\in3, \in4, \in5
+vsub.s32\in4, \in4, \in5
+vadd.s32\in5, \in6, \in7
+vsub.s32\in6, \in6, \in7
+.endm
+
+.macro store16 in0, in1, in2, in3, in4, in5, in6, in7
+vst1.s16\in0, [r1, :64], r2
+vst1.s16\in1, [r3, :64], r4
+vst1.s16\in2, [r1, :64], r2
+vst1.s16\in3, [r3, :64], r4
+vst1.s16\in4, [r1, :64], r2
+vst1.s16\in5, [r3, :64], r4
+vst1.s16\in6, [r1, :64], r2
+vst1.s16\in7, [r3, :64], r4
+.endm
+
+.macro scale out0, out1, out2, out3, out4, out5, out6, out7, in0, in1, in2, 
in3, in4, in5, in6, in7, shift
+vqrshrn.s32 \out0, \in0, \shift
+vqrshrn.s32 \out1, \in1, \shift
+vqrshrn.s32 \out2, \in2, \shift
+vqrshrn.s32 \out3, \in3, \shift
+vqrshrn.s32 \out4, \in4, \shift
+vqrshrn.s32 \out5, \in5, \shift
+vqrshrn.s32 \out6, \in6, \shift
+vqrshrn.s32 \out7, \in7, \shift
+.endm
+
+.macro tr_16x4 name, shift
+function func_tr_16x4_\name
+mov r1,  r5
+add r3,  r5, #64
+mov r2,  #128
+load16  d0, d1, d2, d3, d4, d5, d6, d7
+movrel  r1, trans
+
+tr16_8x4d0, d1, d2, d3, d4, d5, d6, d7
+
+add r1,  r5, #32
+add r3,  r5, #(64 + 32)
+mov r2,  #128
+load16  d8, d9, d2, d3, d4, d5, d6, d7
+movrel  

[FFmpeg-cvslog] hevc: Add NEON 16x16 IDCT

2017-10-27 Thread Alexandra Hájková
ffmpeg | branch: master | Alexandra Hájková  | 
Wed Apr 12 09:29:44 2017 +0200| [89d9869d2491d4209d707a8e7f29c58227ae5a4e] | 
committer: Martin Storsjö

hevc: Add NEON 16x16 IDCT

The speedup vs C code is around 6-13x.

Signed-off-by: Martin Storsjö 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=89d9869d2491d4209d707a8e7f29c58227ae5a4e
---

 libavcodec/arm/hevc_idct.S| 197 ++
 libavcodec/arm/hevcdsp_init_arm.c |   4 +
 2 files changed, 201 insertions(+)

diff --git a/libavcodec/arm/hevc_idct.S b/libavcodec/arm/hevc_idct.S
index 4124fc8226..156d4765f0 100644
--- a/libavcodec/arm/hevc_idct.S
+++ b/libavcodec/arm/hevc_idct.S
@@ -222,7 +222,204 @@ function ff_hevc_idct_8x8_\bitdepth\()_neon, export=1
 endfunc
 .endm
 
+.macro butterfly e, o, tmp_p, tmp_m
+vadd.s32\tmp_p, \e, \o
+vsub.s32\tmp_m, \e, \o
+.endm
+
+.macro tr16_8x4 in0, in1, in2, in3, in4, in5, in6, in7
+tr_4x4_8\in0, \in2, \in4, \in6, q8, q9, q10, q11, q12, q13, 
q14, q15
+
+vmull.s16   q12, \in1, \in0[0]
+vmull.s16   q13, \in1, \in0[1]
+vmull.s16   q14, \in1, \in0[2]
+vmull.s16   q15, \in1, \in0[3]
+sum_sub q12, \in3, \in0[1], +
+sum_sub q13, \in3, \in0[3], -
+sum_sub q14, \in3, \in0[0], -
+sum_sub q15, \in3, \in0[2], -
+
+sum_sub q12, \in5, \in0[2], +
+sum_sub q13, \in5, \in0[0], -
+sum_sub q14, \in5, \in0[3], +
+sum_sub q15, \in5, \in0[1], +
+
+sum_sub q12, \in7, \in0[3], +
+sum_sub q13, \in7, \in0[2], -
+sum_sub q14, \in7, \in0[1], +
+sum_sub q15, \in7, \in0[0], -
+
+butterfly   q8,  q12, q0, q7
+butterfly   q9,  q13, q1, q6
+butterfly   q10, q14, q2, q5
+butterfly   q11, q15, q3, q4
+add r4,  sp,  #512
+vst1.s16{q0-q1}, [r4, :128]!
+vst1.s16{q2-q3}, [r4, :128]!
+vst1.s16{q4-q5}, [r4, :128]!
+vst1.s16{q6-q7}, [r4, :128]
+.endm
+
+.macro load16 in0, in1, in2, in3, in4, in5, in6, in7
+vld1.s16{\in0}, [r1, :64], r2
+vld1.s16{\in1}, [r3, :64], r2
+vld1.s16{\in2}, [r1, :64], r2
+vld1.s16{\in3}, [r3, :64], r2
+vld1.s16{\in4}, [r1, :64], r2
+vld1.s16{\in5}, [r3, :64], r2
+vld1.s16{\in6}, [r1, :64], r2
+vld1.s16{\in7}, [r3, :64], r2
+.endm
+
+.macro add_member in, t0, t1, t2, t3, t4, t5, t6, t7, op0, op1, op2, op3, op4, 
op5, op6, op7
+sum_sub q5, \in, \t0, \op0
+sum_sub q6, \in, \t1, \op1
+sum_sub q7, \in, \t2, \op2
+sum_sub q8, \in, \t3, \op3
+sum_sub q9, \in, \t4, \op4
+sum_sub q10,\in, \t5, \op5
+sum_sub q11,\in, \t6, \op6
+sum_sub q12,\in, \t7, \op7
+.endm
+
+.macro butterfly16 in0, in1, in2, in3, in4, in5, in6, in7
+vadd.s32q4, \in0, \in1
+vsub.s32\in0, \in0, \in1
+vadd.s32\in1, \in2, \in3
+vsub.s32\in2, \in2, \in3
+vadd.s32\in3, \in4, \in5
+vsub.s32\in4, \in4, \in5
+vadd.s32\in5, \in6, \in7
+vsub.s32\in6, \in6, \in7
+.endm
+
+.macro store16 in0, in1, in2, in3, in4, in5, in6, in7
+vst1.s16\in0, [r1, :64], r2
+vst1.s16\in1, [r3, :64], r4
+vst1.s16\in2, [r1, :64], r2
+vst1.s16\in3, [r3, :64], r4
+vst1.s16\in4, [r1, :64], r2
+vst1.s16\in5, [r3, :64], r4
+vst1.s16\in6, [r1, :64], r2
+vst1.s16\in7, [r3, :64], r4
+.endm
+
+.macro scale out0, out1, out2, out3, out4, out5, out6, out7, in0, in1, in2, 
in3, in4, in5, in6, in7, shift
+vqrshrn.s32 \out0, \in0, \shift
+vqrshrn.s32 \out1, \in1, \shift
+vqrshrn.s32 \out2, \in2, \shift
+vqrshrn.s32 \out3, \in3, \shift
+vqrshrn.s32 \out4, \in4, \shift
+vqrshrn.s32 \out5, \in5, \shift
+vqrshrn.s32 \out6, \in6, \shift
+vqrshrn.s32 \out7, \in7, \shift
+.endm
+
+.macro tr_16x4 name, shift
+function func_tr_16x4_\name
+mov r1,  r5
+add r3,  r5, #64
+mov r2,  #128
+load16  d0, d1, d2, d3, d4, d5, d6, d7
+movrel  r1, trans
+
+tr16_8x4d0, d1, d2, d3, d4, d5, d6, d7
+
+add r1,  r5, #32
+add r3,  r5, #(64 + 32)
+mov r2,  #128
+load16  d8, d9, d2, d3, d4, d5, d6, d7
+movrel  r1, trans + 16
+vld1.s16{q0}, [r1, :128]
+

[FFmpeg-cvslog] Merge commit '50a1c66cf6ab7eb683daaa9e2da3869fa3a54609'

2017-10-27 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Oct 27 13:52:19 
2017 -0300| [e0250cf3651e6417e0117486a7816b45fb2d34cd] | committer: James Almer

Merge commit '50a1c66cf6ab7eb683daaa9e2da3869fa3a54609'

* commit '50a1c66cf6ab7eb683daaa9e2da3869fa3a54609':
  ac3_parser: add a public function for parsing the data required by the demuxer

avpriv_ac3_parse_header() is left in place but without the
GetBitContext parameter, as the mov muxer requires a lot more fields
than just bitstream_id and frame_size from the AC3HeaderInfo struct.

Merged-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e0250cf3651e6417e0117486a7816b45fb2d34cd
---

 libavcodec/Makefile  |  9 ++---
 libavcodec/ac3_parser.c  | 72 ++--
 libavcodec/ac3_parser.h  | 18 --
 libavcodec/ac3_parser_internal.h | 42 +++
 libavcodec/ac3dec.c  |  6 ++--
 libavcodec/audiotoolboxdec.c |  4 +--
 libavcodec/eac3dec.c |  1 -
 libavformat/ac3dec.c | 34 +++
 libavformat/movenc.c | 17 +-
 9 files changed, 149 insertions(+), 54 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index bc4d7dab27..8c878c3699 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1,7 +1,8 @@
 NAME = avcodec
 DESC = FFmpeg codec library
 
-HEADERS = avcodec.h \
+HEADERS = ac3_parser.h  \
+  avcodec.h \
   avdct.h   \
   avfft.h   \
   d3d11va.h \
@@ -18,7 +19,8 @@ HEADERS = avcodec.h   
  \
   vorbis_parser.h   \
   xvmc.h\
 
-OBJS = allcodecs.o  \
+OBJS = ac3_parser.o \
+   allcodecs.o  \
avdct.o  \
avpacket.o   \
avpicture.o  \
@@ -955,8 +957,7 @@ OBJS-$(CONFIG_LIBZVBI_TELETEXT_DECODER)   += 
libzvbi-teletextdec.o ass.o
 OBJS-$(CONFIG_AAC_LATM_PARSER) += latm_parser.o
 OBJS-$(CONFIG_AAC_PARSER)  += aac_parser.o aac_ac3_parser.o \
   aacadtsdec.o mpeg4audio.o
-OBJS-$(CONFIG_AC3_PARSER)  += ac3_parser.o ac3tab.o \
-  aac_ac3_parser.o
+OBJS-$(CONFIG_AC3_PARSER)  += ac3tab.o aac_ac3_parser.o
 OBJS-$(CONFIG_ADX_PARSER)  += adx_parser.o adx.o
 OBJS-$(CONFIG_BMP_PARSER)  += bmp_parser.o
 OBJS-$(CONFIG_CAVSVIDEO_PARSER)+= cavs_parser.o
diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c
index 83dd90ff67..1015245a90 100644
--- a/libavcodec/ac3_parser.c
+++ b/libavcodec/ac3_parser.c
@@ -20,15 +20,19 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "config.h"
+
 #include "libavutil/channel_layout.h"
 #include "parser.h"
 #include "ac3_parser.h"
+#include "ac3_parser_internal.h"
 #include "aac_ac3_parser.h"
 #include "get_bits.h"
 
 
 #define AC3_HEADER_SIZE 7
 
+#if CONFIG_AC3_PARSER
 
 static const uint8_t eac3_blocks[4] = {
 1, 2, 3, 6
@@ -47,16 +51,9 @@ static const uint8_t center_levels[4] = { 4, 5, 6, 5 };
 static const uint8_t surround_levels[4] = { 4, 6, 7, 6 };
 
 
-int avpriv_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo **phdr)
+int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
 {
 int frame_size_code;
-AC3HeaderInfo *hdr;
-
-if (!*phdr)
-*phdr = av_mallocz(sizeof(AC3HeaderInfo));
-if (!*phdr)
-return AVERROR(ENOMEM);
-hdr = *phdr;
 
 memset(hdr, 0, sizeof(*hdr));
 
@@ -151,6 +148,46 @@ int avpriv_ac3_parse_header(GetBitContext *gbc, 
AC3HeaderInfo **phdr)
 return 0;
 }
 
+// TODO: Better way to pass AC3HeaderInfo fields to mov muxer.
+int avpriv_ac3_parse_header(AC3HeaderInfo **phdr, const uint8_t *buf,
+size_t size)
+{
+GetBitContext gb;
+AC3HeaderInfo *hdr;
+int err;
+
+if (!*phdr)
+*phdr = av_mallocz(sizeof(AC3HeaderInfo));
+if (!*phdr)
+return AVERROR(ENOMEM);
+hdr = *phdr;
+
+init_get_bits8(, buf, size);
+err = ff_ac3_parse_header(, hdr);
+if (err < 0)
+return AVERROR_INVALIDDATA;
+
+return get_bits_count();
+}
+
+int 

[FFmpeg-cvslog] ac3_parser: add a public function for parsing the data required by the demuxer

2017-10-27 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Thu Mar 30 
16:56:28 2017 +0200| [50a1c66cf6ab7eb683daaa9e2da3869fa3a54609] | committer: 
Diego Biurrun

ac3_parser: add a public function for parsing the data required by the demuxer

Make the current semi-public avpriv_ac3_parse_header() private to lavc.

Signed-off-by: Diego Biurrun 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=50a1c66cf6ab7eb683daaa9e2da3869fa3a54609
---

 libavcodec/Makefile  |  9 +
 libavcodec/ac3_parser.c  | 35 +--
 libavcodec/ac3_parser.h  | 17 ++---
 libavcodec/ac3_parser_internal.h | 39 +++
 libavcodec/ac3dec.c  |  4 ++--
 libavcodec/eac3dec.c |  1 -
 libavformat/ac3dec.c | 19 +++
 7 files changed, 96 insertions(+), 28 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index ec62f514a7..a82210d89f 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1,7 +1,8 @@
 NAME = avcodec
 DESC = Libav codec library
 
-HEADERS = avcodec.h \
+HEADERS = ac3_parser.h  \
+  avcodec.h \
   avfft.h   \
   d3d11va.h \
   dirac.h   \
@@ -14,7 +15,8 @@ HEADERS = avcodec.h   
  \
   version.h \
   vorbis_parser.h   \
 
-OBJS = allcodecs.o  \
+OBJS = ac3_parser.o \
+   allcodecs.o  \
avpacket.o   \
avpicture.o  \
bitstream.o  \
@@ -719,8 +721,7 @@ OBJS-$(CONFIG_LIBXVID_ENCODER)+= libxvid.o
 OBJS-$(CONFIG_AAC_LATM_PARSER) += latm_parser.o
 OBJS-$(CONFIG_AAC_PARSER)  += aac_parser.o aac_ac3_parser.o \
   aacadtsdec.o mpeg4audio.o
-OBJS-$(CONFIG_AC3_PARSER)  += ac3_parser.o ac3tab.o \
-  aac_ac3_parser.o
+OBJS-$(CONFIG_AC3_PARSER)  += ac3tab.o aac_ac3_parser.o
 OBJS-$(CONFIG_ADX_PARSER)  += adx_parser.o adx.o
 OBJS-$(CONFIG_BMP_PARSER)  += bmp_parser.o
 OBJS-$(CONFIG_CAVSVIDEO_PARSER)+= cavs_parser.o
diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c
index 970484810b..53189e0d4e 100644
--- a/libavcodec/ac3_parser.c
+++ b/libavcodec/ac3_parser.c
@@ -20,15 +20,19 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "config.h"
+
 #include "libavutil/channel_layout.h"
 #include "parser.h"
 #include "ac3_parser.h"
+#include "ac3_parser_internal.h"
 #include "aac_ac3_parser.h"
 #include "get_bits.h"
 
 
 #define AC3_HEADER_SIZE 7
 
+#if CONFIG_AC3_PARSER
 
 static const uint8_t eac3_blocks[4] = {
 1, 2, 3, 6
@@ -47,7 +51,7 @@ static const uint8_t center_levels[4] = { 4, 5, 6, 5 };
 static const uint8_t surround_levels[4] = { 4, 6, 7, 6 };
 
 
-int avpriv_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
+int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
 {
 int frame_size_code;
 
@@ -144,6 +148,24 @@ int avpriv_ac3_parse_header(GetBitContext *gbc, 
AC3HeaderInfo *hdr)
 return 0;
 }
 
+int av_ac3_parse_header(const uint8_t *buf, size_t size,
+uint8_t *bitstream_id, uint16_t *frame_size)
+{
+GetBitContext gb;
+AC3HeaderInfo hdr;
+int err;
+
+init_get_bits8(, buf, size);
+err = ff_ac3_parse_header(, );
+if (err < 0)
+return AVERROR_INVALIDDATA;
+
+*bitstream_id = hdr.bitstream_id;
+*frame_size   = hdr.frame_size;
+
+return 0;
+}
+
 static int ac3_sync(uint64_t state, AACAC3ParseContext *hdr_info,
 int *need_next_header, int *new_frame_start)
 {
@@ -156,7 +178,7 @@ static int ac3_sync(uint64_t state, AACAC3ParseContext 
*hdr_info,
 GetBitContext gbc;
 
 init_get_bits(, tmp.u8+8-AC3_HEADER_SIZE, 54);
-err = avpriv_ac3_parse_header(, );
+err = ff_ac3_parse_header(, );
 
 if(err < 0)
 return 0;
@@ -195,3 +217,12 @@ AVCodecParser ff_ac3_parser = {
 .parser_parse   = ff_aac_ac3_parse,
 .parser_close   = ff_parse_close,
 };
+
+#else
+
+int av_ac3_parse_header(const uint8_t *buf, size_t size,
+uint8_t *bitstream_id,