[libav-devel] [PATCH] fate: add Alias PIX tests

2014-03-20 Thread Vittorio Giovara
---
Test OCDing.
Vittorio

 tests/fate/image.mak | 6 ++
 tests/ref/fate/aliaspix-bgr  | 2 ++
 tests/ref/fate/aliaspix-gray | 2 ++
 3 files changed, 10 insertions(+)
 create mode 100644 tests/ref/fate/aliaspix-bgr
 create mode 100644 tests/ref/fate/aliaspix-gray

diff --git a/tests/fate/image.mak b/tests/fate/image.mak
index 1357cbd..00351e8 100644
--- a/tests/fate/image.mak
+++ b/tests/fate/image.mak
@@ -1,3 +1,9 @@
+FATE_SAMPLES_AVCONV-$(call DEMDEC, IMAGE2, ALIAS_PIX) += fate-aliaspix-bgr
+fate-aliaspix-bgr: CMD = framecrc -i $(TARGET_SAMPLES)/aliaspix/first.pix 
-pix_fmt bgr24
+
+FATE_SAMPLES_AVCONV-$(call DEMDEC, IMAGE2, ALIAS_PIX) += fate-aliaspix-gray
+fate-aliaspix-gray: CMD = framecrc -i $(TARGET_SAMPLES)/aliaspix/firstgray.pix 
-pix_fmt gray
+
 FATE_SAMPLES_AVCONV-$(call DEMDEC, IMAGE2, DPX) += fate-dpx
 fate-dpx: CMD = framecrc -i $(TARGET_SAMPLES)/dpx/lighthouse_rgb48.dpx
 
diff --git a/tests/ref/fate/aliaspix-bgr b/tests/ref/fate/aliaspix-bgr
new file mode 100644
index 000..235a5ac
--- /dev/null
+++ b/tests/ref/fate/aliaspix-bgr
@@ -0,0 +1,2 @@
+#tb 0: 1/25
+0,  0,  0,1,36000, 0x9ff1ba55
diff --git a/tests/ref/fate/aliaspix-gray b/tests/ref/fate/aliaspix-gray
new file mode 100644
index 000..74cf6a2
--- /dev/null
+++ b/tests/ref/fate/aliaspix-gray
@@ -0,0 +1,2 @@
+#tb 0: 1/25
+0,  0,  0,1,12000, 0x29f8832c
-- 
1.8.3.4 (Apple Git-47)

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


[libav-devel] [PATCH] Alias PIX image encoder and decoder

2014-03-20 Thread Vittorio Giovara
---
Now with a working gray encoder.
Vittorio

 Changelog|   1 +
 doc/general.texi |   2 +
 libavcodec/Makefile  |   2 +
 libavcodec/aliaspixdec.c | 114 
 libavcodec/aliaspixenc.c | 134 +++
 libavcodec/allcodecs.c   |   1 +
 libavcodec/avcodec.h |   1 +
 libavcodec/codec_desc.c  |   7 +++
 libavcodec/version.h |   4 +-
 libavformat/img2.c   |   1 +
 libavformat/img2enc.c|   2 +-
 11 files changed, 266 insertions(+), 3 deletions(-)
 create mode 100644 libavcodec/aliaspixdec.c
 create mode 100644 libavcodec/aliaspixenc.c

diff --git a/Changelog b/Changelog
index 279c0d8..0f1007d 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
 version :
 - compand audio filter
 - shuffleplanes filter
+- Alias PIX image encoder and decoder
 
 
 version 10:
diff --git a/doc/general.texi b/doc/general.texi
index 8c0cb1b..dce4c0a 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -424,6 +424,8 @@ following image formats are supported:
 @item Name @tab Encoding @tab Decoding @tab Comments
 @item .Y.U.V   @tab X @tab X
 @tab one raw file per component
+@item Alias PIX@tab X @tab X
+@tab Alias/Wavefront PIX image format
 @item animated GIF @tab X @tab X
 @tab Only uncompressed GIFs are generated.
 @item BMP  @tab X @tab X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index c04b3f1..8f531fc 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -88,6 +88,8 @@ OBJS-$(CONFIG_AC3_FIXED_ENCODER)   += ac3enc_fixed.o 
ac3enc.o ac3tab.o ac3.o
 OBJS-$(CONFIG_AIC_DECODER) += aic.o
 OBJS-$(CONFIG_ALAC_DECODER)+= alac.o alac_data.o
 OBJS-$(CONFIG_ALAC_ENCODER)+= alacenc.o alac_data.o
+OBJS-$(CONFIG_ALIAS_PIX_DECODER)   += aliaspixdec.o
+OBJS-$(CONFIG_ALIAS_PIX_ENCODER)   += aliaspixenc.o
 OBJS-$(CONFIG_ALS_DECODER) += alsdec.o bgmc.o mpeg4audio.o
 OBJS-$(CONFIG_AMRNB_DECODER)   += amrnbdec.o celp_filters.o   \
   celp_math.o acelp_filters.o \
diff --git a/libavcodec/aliaspixdec.c b/libavcodec/aliaspixdec.c
new file mode 100644
index 000..0dd1c84
--- /dev/null
+++ b/libavcodec/aliaspixdec.c
@@ -0,0 +1,114 @@
+/*
+ * Alias PIX image decoder
+ * Copyright (C) 2014 Vittorio Giovara 
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/intreadwrite.h"
+
+#include "avcodec.h"
+#include "bytestream.h"
+#include "internal.h"
+
+#define ALIAS_HEADER_SIZE 10
+
+static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
+AVPacket *avpkt)
+{
+AVFrame *f = data;
+GetByteContext gb;
+int width, height, ret, bits_pixel, pixel;
+uint8_t *out_buf;
+uint8_t count;
+int y = 0;
+
+bytestream2_init(&gb, avpkt->data, avpkt->size);
+
+if (bytestream2_get_bytes_left(&gb) < ALIAS_HEADER_SIZE) {
+av_log(avctx, AV_LOG_ERROR, "Header too small %d.\n", avpkt->size);
+return AVERROR_INVALIDDATA;
+}
+
+width  = bytestream2_get_be16u(&gb);
+height = bytestream2_get_be16u(&gb);
+bytestream2_skipu(&gb, 4); // obsolete X, Y offset
+bits_pixel = bytestream2_get_be16u(&gb);
+
+if (bits_pixel == 24)
+avctx->pix_fmt = AV_PIX_FMT_BGR24;
+else if (bits_pixel == 8)
+avctx->pix_fmt = AV_PIX_FMT_GRAY8;
+else {
+av_log(avctx, AV_LOG_ERROR, "Invalid pixel format.\n");
+return AVERROR_INVALIDDATA;
+}
+
+ret = ff_set_dimensions(avctx, width, height);
+if (ret < 0)
+return ret;
+
+ret = ff_get_buffer(avctx, f, 0);
+if (ret < 0)
+return ret;
+
+f->pict_type = AV_PICTURE_TYPE_I;
+f->key_frame = 1;
+
+while (bytestream2_get_bytes_left(&gb) > 0) {
+int i;
+
+/* set buffer at the right position at every new line */
+if (width == avctx->width) {
+width = 0;
+out_buf = f->data[0] + f->linesize[0] * y++;
+}
+
+/* read packet and copy data */
+count = bytestream2_get_byteu(&gb);
+if (!count || width + count > avctx->width) {
+av_log(avctx, AV_LOG_E

[libav-devel] [PATCH] Alias PIX image encoder and decoder

2014-03-20 Thread Vittorio Giovara
---
 Changelog|   1 +
 doc/general.texi |   2 +
 libavcodec/Makefile  |   2 +
 libavcodec/aliaspixdec.c | 114 
 libavcodec/aliaspixenc.c | 132 +++
 libavcodec/allcodecs.c   |   1 +
 libavcodec/avcodec.h |   1 +
 libavcodec/codec_desc.c  |   7 +++
 libavcodec/version.h |   4 +-
 libavformat/img2.c   |   1 +
 libavformat/img2enc.c|   2 +-
 11 files changed, 264 insertions(+), 3 deletions(-)
 create mode 100644 libavcodec/aliaspixdec.c
 create mode 100644 libavcodec/aliaspixenc.c

diff --git a/Changelog b/Changelog
index 279c0d8..0f1007d 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
 version :
 - compand audio filter
 - shuffleplanes filter
+- Alias PIX image encoder and decoder
 
 
 version 10:
diff --git a/doc/general.texi b/doc/general.texi
index 8c0cb1b..dce4c0a 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -424,6 +424,8 @@ following image formats are supported:
 @item Name @tab Encoding @tab Decoding @tab Comments
 @item .Y.U.V   @tab X @tab X
 @tab one raw file per component
+@item Alias PIX@tab X @tab X
+@tab Alias/Wavefront PIX image format
 @item animated GIF @tab X @tab X
 @tab Only uncompressed GIFs are generated.
 @item BMP  @tab X @tab X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index c04b3f1..8f531fc 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -88,6 +88,8 @@ OBJS-$(CONFIG_AC3_FIXED_ENCODER)   += ac3enc_fixed.o 
ac3enc.o ac3tab.o ac3.o
 OBJS-$(CONFIG_AIC_DECODER) += aic.o
 OBJS-$(CONFIG_ALAC_DECODER)+= alac.o alac_data.o
 OBJS-$(CONFIG_ALAC_ENCODER)+= alacenc.o alac_data.o
+OBJS-$(CONFIG_ALIAS_PIX_DECODER)   += aliaspixdec.o
+OBJS-$(CONFIG_ALIAS_PIX_ENCODER)   += aliaspixenc.o
 OBJS-$(CONFIG_ALS_DECODER) += alsdec.o bgmc.o mpeg4audio.o
 OBJS-$(CONFIG_AMRNB_DECODER)   += amrnbdec.o celp_filters.o   \
   celp_math.o acelp_filters.o \
diff --git a/libavcodec/aliaspixdec.c b/libavcodec/aliaspixdec.c
new file mode 100644
index 000..0dd1c84
--- /dev/null
+++ b/libavcodec/aliaspixdec.c
@@ -0,0 +1,114 @@
+/*
+ * Alias PIX image decoder
+ * Copyright (C) 2014 Vittorio Giovara 
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/intreadwrite.h"
+
+#include "avcodec.h"
+#include "bytestream.h"
+#include "internal.h"
+
+#define ALIAS_HEADER_SIZE 10
+
+static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
+AVPacket *avpkt)
+{
+AVFrame *f = data;
+GetByteContext gb;
+int width, height, ret, bits_pixel, pixel;
+uint8_t *out_buf;
+uint8_t count;
+int y = 0;
+
+bytestream2_init(&gb, avpkt->data, avpkt->size);
+
+if (bytestream2_get_bytes_left(&gb) < ALIAS_HEADER_SIZE) {
+av_log(avctx, AV_LOG_ERROR, "Header too small %d.\n", avpkt->size);
+return AVERROR_INVALIDDATA;
+}
+
+width  = bytestream2_get_be16u(&gb);
+height = bytestream2_get_be16u(&gb);
+bytestream2_skipu(&gb, 4); // obsolete X, Y offset
+bits_pixel = bytestream2_get_be16u(&gb);
+
+if (bits_pixel == 24)
+avctx->pix_fmt = AV_PIX_FMT_BGR24;
+else if (bits_pixel == 8)
+avctx->pix_fmt = AV_PIX_FMT_GRAY8;
+else {
+av_log(avctx, AV_LOG_ERROR, "Invalid pixel format.\n");
+return AVERROR_INVALIDDATA;
+}
+
+ret = ff_set_dimensions(avctx, width, height);
+if (ret < 0)
+return ret;
+
+ret = ff_get_buffer(avctx, f, 0);
+if (ret < 0)
+return ret;
+
+f->pict_type = AV_PICTURE_TYPE_I;
+f->key_frame = 1;
+
+while (bytestream2_get_bytes_left(&gb) > 0) {
+int i;
+
+/* set buffer at the right position at every new line */
+if (width == avctx->width) {
+width = 0;
+out_buf = f->data[0] + f->linesize[0] * y++;
+}
+
+/* read packet and copy data */
+count = bytestream2_get_byteu(&gb);
+if (!count || width + count > avctx->width) {
+av_log(avctx, AV_LOG_ERROR, "Invalid run length %d.\n", count);
+

Re: [libav-devel] [PATCH] OpenEXR decoder

2014-03-20 Thread Vittorio Giovara
On Fri, Mar 21, 2014 at 2:59 AM, Justin Ruggles
 wrote:
> On 03/20/2014 09:01 PM, Vittorio Giovara wrote:
>> +// Process unknown variables
>> +for (i = 0; i < 2; i++) // value_name and value_type
>> +while (bytestream2_get_bytes_left(&s->gb) > 0)
>> +if (bytestream2_get_byte(&s->gb) == 0)
>> +break;
>
> If there are no bytes left, bytestream2_get_byte() returns 0, so you
> don't have to check the remaining byte count.

Amended locally

// Process unknown variables
for (i = 0; i < 2; i++) // value_name and value_type
while (bytestream2_get_byte(&s->gb) != 0);

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


Re: [libav-devel] [PATCH] Alias PIX image encoder and decoder

2014-03-20 Thread Justin Ruggles
On 03/20/2014 09:13 PM, Vittorio Giovara wrote:
> ---
> Amended as asked by Justin. I only kept the avctx->pix_fmt checks because 
> they look
> more readable to me.
> Cheers,
> Vittorio
> 
>  Changelog|   1 +
>  doc/general.texi |   2 +
>  libavcodec/Makefile  |   2 +
>  libavcodec/aliaspixdec.c | 114 
>  libavcodec/aliaspixenc.c | 132 
> +++
>  libavcodec/allcodecs.c   |   1 +
>  libavcodec/avcodec.h |   1 +
>  libavcodec/codec_desc.c  |   7 +++
>  libavcodec/version.h |   4 +-
>  libavformat/img2.c   |   1 +
>  libavformat/img2enc.c|   2 +-
>  11 files changed, 264 insertions(+), 3 deletions(-)
>  create mode 100644 libavcodec/aliaspixdec.c
>  create mode 100644 libavcodec/aliaspixenc.c
> 
[...]
> diff --git a/libavcodec/aliaspixenc.c b/libavcodec/aliaspixenc.c
> new file mode 100644
> index 000..22f6aac
> --- /dev/null
> +++ b/libavcodec/aliaspixenc.c
> @@ -0,0 +1,132 @@
> +/*
> + * Alias PIX image encoder
> + * Copyright (C) 2014 Vittorio Giovara 
> + *
> + * This file is part of Libav.
> + *
> + * Libav is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * Libav is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with Libav; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +#include "libavutil/intreadwrite.h"
> +
> +#include "avcodec.h"
> +#include "bytestream.h"
> +#include "internal.h"
> +
> +#define ALIAS_HEADER_SIZE 10
> +
> +static av_cold int encode_init(AVCodecContext *avctx)
> +{
> +avctx->coded_frame = av_frame_alloc();
> +if (!avctx->coded_frame)
> +return AVERROR(ENOMEM);
> +return 0;
> +}
> +
> +static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
> +const AVFrame *frame, int *got_packet)
> +{
> +int width, height, bits_pixel, i, j, length, ret;
> +uint8_t *in_buf, *buf;
> +
> +avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
> +avctx->coded_frame->key_frame = 1;
> +
> +width  = avctx->width;
> +height = avctx->height;
> +
> +if (width > 65535 || height > 65535 ||
> +width * height >= INT_MAX / 4 - 10LL) {
> +av_log(avctx, AV_LOG_ERROR, "Invalid image size %dx%d.\n", width, 
> height);
> +return AVERROR_INVALIDDATA;
> +}

That doesn't need to be 10LL. You can use ALIAS_HEADER_SIZE.

> +
> +switch (avctx->pix_fmt) {
> +case AV_PIX_FMT_GRAY8:
> +bits_pixel = 8;
> +break;
> +case AV_PIX_FMT_BGR24:
> +bits_pixel = 24;
> +break;
> +default:
> +return AVERROR_INVALIDDATA;

AVERROR(EINVAL)

although it won't ever get this far...

> +}
> +
> +length = ALIAS_HEADER_SIZE + 4 * width * height; // max possible
> +if ((ret = ff_alloc_packet(pkt, length)) < 0) {
> +av_log(avctx, AV_LOG_ERROR, "Error getting output packet of size 
> %d.\n", length);
> +return ret;
> +}
> +
> +buf = pkt->data;
> +
> +/* Encode header. */
> +bytestream_put_be16(&buf, width);
> +bytestream_put_be16(&buf, height);
> +bytestream_put_be32(&buf, 0L); /* X, Y offset */

You don't need the L

> +bytestream_put_be16(&buf, bits_pixel);
> +
> +for (j = 0; j < height; j++) {
> +in_buf = frame->data[0] + frame->linesize[0] * j;
> +for (i = 0; i < width; ) {
> +int count = 0;
> +int pixel;
> +
> +if (avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
> +pixel = *in_buf;
> +while (count < 255 && count + i < width && pixel == *in_buf) 
> {
> +count++;
> +in_buf++;
> +}
> +} else { /* AV_PIX_FMT_BGR24 */
> +pixel = AV_RB24(in_buf);
> +while (count < 255 && count + i < width &&
> +   pixel == AV_RB24(in_buf)) {
> +count++;
> +in_buf += 3;
> +}
> +}
> +i += count;
> +bytestream_put_byte(&buf, count);
> +bytestream_put_be24(&buf, pixel);
> +}
> +}
> +
> +/* Total length */
> +av_shrink_packet(pkt, buf - pkt->data);
> +pkt->flags |= AV_PKT_FLAG_KEY;
> +*got_packet = 1;
> +
> +return 0;
> +}
> +
> +static av_cold int encode_close(AVCodecContext *avctx)
> +{
> +av_frame_free(&avctx->cod

Re: [libav-devel] [PATCH] OpenEXR decoder

2014-03-20 Thread Justin Ruggles
On 03/20/2014 09:01 PM, Vittorio Giovara wrote:
> +// Process unknown variables
> +for (i = 0; i < 2; i++) // value_name and value_type
> +while (bytestream2_get_bytes_left(&s->gb) > 0)
> +if (bytestream2_get_byte(&s->gb) == 0)
> +break;

If there are no bytes left, bytestream2_get_byte() returns 0, so you
don't have to check the remaining byte count.

-Justin


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


Re: [libav-devel] THE GRAND DSPUTIL REFACTORING (act VII)

2014-03-20 Thread Vittorio Giovara
On Thu, Mar 20, 2014 at 3:03 PM, Diego Biurrun  wrote:
> On Thu, Mar 20, 2014 at 02:33:52PM +0100, Luca Barbato wrote:
>> On 19/03/14 19:12, Diego Biurrun wrote:
>> > Finally, I start to put dsputil on a diet, like the doctor ordered.
>> >
>> > There are still preparatory patches that pave the way for later changes,
>> > but some big chunks are broken out of dsputil and off into separate
>> > structures.
>>
>> We aren't using any high bit version anywhere? I'm surprised, Vittorio
>> might need them for something soon.
>
> I'm not sure what this comment refers to ...

I think Luca was referring to the fact that it'd be interesting to
pick and review h264 at 12/14 bits, which is all templarized.
However it's quite a tedious (and theoretical) idea, so for now it can
be put off after the refactoring.
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] changelog: move libx265 to version

2014-03-20 Thread Luca Barbato
On 21/03/14 02:15, Vittorio Giovara wrote:
> ---
> It was agreed to remove libx265 from release/10, so update the Changelog 
> accordingly.
> Vittorio
> 

Ok.

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


[libav-devel] [PATCH 1/4] lavu: Move all color-related enums to AVPixFmtModel

2014-03-20 Thread Vittorio Giovara
This struct unambiguously describes how the bits of a pixel should be
interpreted and elaborated.
---
 doc/APIchanges   |   4 ++
 libavcodec/avcodec.h |  68 +--
 libavutil/Makefile   |   1 +
 libavutil/pixdesc.h  |   1 +
 libavutil/pixmodel.h | 129 +++
 libavutil/version.h  |   2 +-
 6 files changed, 137 insertions(+), 68 deletions(-)
 create mode 100644 libavutil/pixmodel.h

diff --git a/doc/APIchanges b/doc/APIchanges
index 38d18bc..0fce83f 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,10 @@ libavutil: 2013-12-xx
 
 API changes, most recent first:
 
+2014-xx-xx - xxx - lavu 53.07.0 - pixmodel.h
+  Move all color-related enums (AVColorPrimaries, AVColorSpace, AVColorRange,
+  and AVChromaLocation) inside lavu, and introduce a new type containing them.
+
 2014-xx-xx - xxx - lavu 53.06.0 - pixfmt.h
   Add RGBA64 pixel format and variants.
 
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 7beb277..eee975e 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -37,6 +37,7 @@
 #include "libavutil/frame.h"
 #include "libavutil/log.h"
 #include "libavutil/pixfmt.h"
+#include "libavutil/pixmodel.h"
 #include "libavutil/rational.h"
 
 #include "version.h"
@@ -546,73 +547,6 @@ enum AVDiscard{
 AVDISCARD_ALL = 48, ///< discard all
 };
 
-enum AVColorPrimaries{
-AVCOL_PRI_BT709   = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE 
RP177 Annex B
-AVCOL_PRI_UNSPECIFIED = 2,
-AVCOL_PRI_BT470M  = 4,
-AVCOL_PRI_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 
/ ITU-R BT1700 625 PAL & SECAM
-AVCOL_PRI_SMPTE170M   = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 
/ ITU-R BT1700 NTSC
-AVCOL_PRI_SMPTE240M   = 7, ///< functionally identical to above
-AVCOL_PRI_FILM= 8,
-AVCOL_PRI_BT2020  = 9, ///< ITU-R BT2020
-AVCOL_PRI_NB , ///< Not part of ABI
-};
-
-enum AVColorTransferCharacteristic{
-AVCOL_TRC_BT709=  1, ///< also ITU-R BT1361
-AVCOL_TRC_UNSPECIFIED  =  2,
-AVCOL_TRC_GAMMA22  =  4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL 
& SECAM
-AVCOL_TRC_GAMMA28  =  5, ///< also ITU-R BT470BG
-AVCOL_TRC_SMPTE170M=  6, ///< also ITU-R BT601-6 525 or 625 / ITU-R 
BT1358 525 or 625 / ITU-R BT1700 NTSC
-AVCOL_TRC_SMPTE240M=  7,
-AVCOL_TRC_LINEAR   =  8, ///< "Linear transfer characteristics"
-AVCOL_TRC_LOG  =  9, ///< "Logarithmic transfer characteristic 
(100:1 range)"
-AVCOL_TRC_LOG_SQRT = 10, ///< "Logarithmic transfer characteristic 
(100 * Sqrt( 10 ) : 1 range)"
-AVCOL_TRC_IEC61966_2_4 = 11, ///< IEC 61966-2-4
-AVCOL_TRC_BT1361_ECG   = 12, ///< ITU-R BT1361 Extended Colour Gamut
-AVCOL_TRC_IEC61966_2_1 = 13, ///< IEC 61966-2-1 (sRGB or sYCC)
-AVCOL_TRC_BT2020_10= 14, ///< ITU-R BT2020 for 10 bit system
-AVCOL_TRC_BT2020_12= 15, ///< ITU-R BT2020 for 12 bit system
-AVCOL_TRC_NB   , ///< Not part of ABI
-};
-
-enum AVColorSpace{
-AVCOL_SPC_RGB =  0,
-AVCOL_SPC_BT709   =  1, ///< also ITU-R BT1361 / IEC 61966-2-4 
xvYCC709 / SMPTE RP177 Annex B
-AVCOL_SPC_UNSPECIFIED =  2,
-AVCOL_SPC_FCC =  4,
-AVCOL_SPC_BT470BG =  5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 
/ ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
-AVCOL_SPC_SMPTE170M   =  6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 
/ ITU-R BT1700 NTSC / functionally identical to above
-AVCOL_SPC_SMPTE240M   =  7,
-AVCOL_SPC_YCOCG   =  8, ///< Used by Dirac / VC-2 and H.264 FRext, see 
ITU-T SG16
-AVCOL_SPC_BT2020_NCL  =  9, ///< ITU-R BT2020 non-constant luminance system
-AVCOL_SPC_BT2020_CL   = 10, ///< ITU-R BT2020 constant luminance system
-AVCOL_SPC_NB  , ///< Not part of ABI
-};
-
-enum AVColorRange{
-AVCOL_RANGE_UNSPECIFIED = 0,
-AVCOL_RANGE_MPEG= 1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges
-AVCOL_RANGE_JPEG= 2, ///< the normal 2^n-1   "JPEG" YUV ranges
-AVCOL_RANGE_NB , ///< Not part of ABI
-};
-
-/**
- *  X   X  3 4 X  X are luma samples,
- * 1 21-6 are possible chroma positions
- *  X   X  5 6 X  0 is undefined/unknown position
- */
-enum AVChromaLocation{
-AVCHROMA_LOC_UNSPECIFIED = 0,
-AVCHROMA_LOC_LEFT= 1, ///< mpeg2/4, h264 default
-AVCHROMA_LOC_CENTER  = 2, ///< mpeg1, jpeg, h263
-AVCHROMA_LOC_TOPLEFT = 3, ///< DV
-AVCHROMA_LOC_TOP = 4,
-AVCHROMA_LOC_BOTTOMLEFT  = 5,
-AVCHROMA_LOC_BOTTOM  = 6,
-AVCHROMA_LOC_NB , ///< Not part of ABI
-};
-
 enum AVAudioServiceType {
 AV_AUDIO_SERVICE_TYPE_MAIN  = 0,
 AV_AUDIO_SERVICE_TYPE_EFFECTS   = 1,
diff --git a/libavutil/Makefile b/libavutil/Makefile
index 5869e67..be42520 100644
--- a/libavutil/Makefile
+++ b/

[libav-devel] [PATCH 2/4] avframe: add COLOR side data

2014-03-20 Thread Vittorio Giovara
---
 doc/APIchanges   |  4 
 libavutil/Makefile   |  1 +
 libavutil/frame.h|  5 +
 libavutil/pixmodel.c | 38 ++
 libavutil/pixmodel.h | 17 +
 libavutil/version.h  |  2 +-
 6 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 libavutil/pixmodel.c

diff --git a/doc/APIchanges b/doc/APIchanges
index 0fce83f..1d8dbbc 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,10 @@ libavutil: 2013-12-xx
 
 API changes, most recent first:
 
+2014-xx-xx - xxx - lavu 53.08.0 - frame.h
+  Add AV_FRAME_DATA_COLOR value to the AVFrameSideDataType enum and pixmodel.h
+  API, that unquely convey colors representation for the frame pixel format.
+
 2014-xx-xx - xxx - lavu 53.07.0 - pixmodel.h
   Move all color-related enums (AVColorPrimaries, AVColorSpace, AVColorRange,
   and AVChromaLocation) inside lavu, and introduce a new type containing them.
diff --git a/libavutil/Makefile b/libavutil/Makefile
index be42520..fed1d41 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -91,6 +91,7 @@ OBJS = adler32.o  
  \
opt.o\
parseutils.o \
pixdesc.o\
+   pixmodel.o   \
random_seed.o\
rational.o   \
rc4.o\
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 6b168e2..560767d 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -69,6 +69,11 @@ enum AVFrameSideDataType {
  * The data is the AVDownmixInfo struct defined in 
libavutil/downmix_info.h.
  */
 AV_FRAME_DATA_DOWNMIX_INFO,
+/**
+ * Interpretation of the current frame pixel format.
+ * The data is the AVPixFmtModel struct defined in libavutil/pixmodel.h.
+ */
+AV_FRAME_DATA_COLOR,
 };
 
 typedef struct AVFrameSideData {
diff --git a/libavutil/pixmodel.c b/libavutil/pixmodel.c
new file mode 100644
index 000..d9b6c0c
--- /dev/null
+++ b/libavutil/pixmodel.c
@@ -0,0 +1,38 @@
+/*
+ * 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 "mem.h"
+#include "pixmodel.h"
+
+AVPixFmtModel *av_pixfmtmodel_alloc(void)
+{
+return av_mallocz(sizeof(AVPixFmtModel));
+}
+
+AVPixFmtModel *av_pixfmtmodel_create_side_data(AVFrame *frame)
+{
+AVFrameSideData *side_data = av_frame_new_side_data(frame,
+AV_FRAME_DATA_COLOR,
+sizeof(AVPixFmtModel));
+if (!side_data)
+return NULL;
+
+return (AVPixFmtModel *)side_data->data;
+}
diff --git a/libavutil/pixmodel.h b/libavutil/pixmodel.h
index be9202c..7e1426a 100644
--- a/libavutil/pixmodel.h
+++ b/libavutil/pixmodel.h
@@ -126,4 +126,21 @@ typedef struct AVPixFmtModel {
 enum AVChromaLocation chroma_location;
 } AVPixFmtModel;
 
+/**
+ * Allocate an AVPixFmtModel structure and set its fields to default values.
+ * The resulting struct can be freed using av_freep().
+ *
+ * @return An AVPixFmtModel filled with default values or NULL on failure.
+ */
+AVPixFmtModel *av_pixfmtmodel_alloc(void);
+
+/**
+ * Allocate a complete AVFrameSideData and add it to the frame.
+ *
+ * @param frame The frame which side data is added to.
+ *
+ * @return The AVPixFmtModel structure to be filled by caller.
+ */
+AVPixFmtModel *av_pixfmtmodel_create_side_data(AVFrame *frame);
+
 #endif /* AVUTIL_PIXMODEL_H */
diff --git a/libavutil/version.h b/libavutil/version.h
index d680979..7f439d7 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -54,7 +54,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR 53
-#define LIBAVUTIL_VERSION_MINOR  7
+#define LIBAVUTIL_VERSION_MINOR  8
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
1.8.3.4 (Apple Git-47)

___
libav-devel mailing

[libav-devel] [PATCH 3/4] WIP: add .pix_fmts_full for the list of full range colors

2014-03-20 Thread Vittorio Giovara
---
 libavcodec/avcodec.h  | 1 +
 libavcodec/ljpegenc.c | 4 
 libavcodec/mjpegenc.c | 3 +++
 libavcodec/svq3.c | 3 +++
 libavcodec/version.h  | 4 ++--
 5 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index eee975e..9358882 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2720,6 +2720,7 @@ typedef struct AVCodec {
 #endif
 const AVClass *priv_class;  ///< AVClass for the private 
context
 const AVProfile *profiles;  ///< array of recognized profiles, 
or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
+const enum AVPixelFormat *pix_fmts_full; ///< array of supported pixel 
formats to be interpreted as full range, or NULL if unknown, array is 
terminated by -1
 
 /*
  * No fields below this line are part of the public API. They
diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index e111c8c..6f01962 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -332,4 +332,8 @@ AVCodec ff_ljpeg_encoder = {
 AV_PIX_FMT_YUV422P,
 AV_PIX_FMT_YUV444P,
 AV_PIX_FMT_NONE },
+.pix_fmts_full  = (const enum AVPixelFormat[]) {
+AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, 
AV_PIX_FMT_NONE,
+}
+
 };
diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 30433c3..cabdc1f 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -449,4 +449,7 @@ AVCodec ff_mjpeg_encoder = {
 .pix_fmts   = (const enum AVPixelFormat[]){
 AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_NONE
 },
+.pix_fmts_full  = (const enum AVPixelFormat[]) {
+AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE
+},
 };
diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index ce42fcf..18e6924 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -1327,4 +1327,7 @@ AVCodec ff_svq3_decoder = {
   CODEC_CAP_DELAY,
 .pix_fmts   = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P,
  AV_PIX_FMT_NONE},
+.pix_fmts_full  = (const enum AVPixelFormat[]) {
+AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE
+},
 };
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 5ab49d5..d2f80ad 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,8 +29,8 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR 55
-#define LIBAVCODEC_VERSION_MINOR 34
-#define LIBAVCODEC_VERSION_MICRO  1
+#define LIBAVCODEC_VERSION_MINOR 35
+#define LIBAVCODEC_VERSION_MICRO  0
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
-- 
1.8.3.4 (Apple Git-47)

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


[libav-devel] [PATCH 0/4] [RFC] [libav12] pixel format overhaul

2014-03-20 Thread Vittorio Giovara
This is a second or alternative way that would allow us to deprecate J formats
without breaking AVCodec API. Instead of creating a monster struct with any 
possible
color combination, I propose to supply a list of formats which have to be 
interpreted
as full range, by adding a .pix_fmts_full to AVCodec. The old pix_fmts can 
remain and
is compatible with current behaviour.

In this set there is also an additional structure that will allow to seamlessly 
move
all color-related information from avcodeccontext to frame and then to avscale.

Note that the API for handling the second list is not yet implemented as I 
wanted to
get some feedback for it.
Cheers,
Vittorio

Vittorio Giovara (4):
  lavu: Move all color-related enums to AVPixFmtModel
  avframe: add COLOR side data
  WIP: add .pix_fmts_full for the list of full range colors
  lavu: add deprecation guards to full scale formats

 doc/APIchanges  |   8 +++
 libavcodec/avcodec.h|  69 +
 libavcodec/dirac.c  |  10 +++
 libavcodec/fraps.c  |   4 ++
 libavcodec/h264.c   |  12 
 libavcodec/hevc_ps.c|   2 +
 libavcodec/imgconvert.c |   8 ++-
 libavcodec/libx264.c|   8 +++
 libavcodec/ljpegenc.c   |  16 -
 libavcodec/mdec.c   |   4 ++
 libavcodec/mjpegdec.c   |  16 +
 libavcodec/mjpegenc.c   |  10 ++-
 libavcodec/mpegvideo_enc.c  |   9 ++-
 libavcodec/raw.c|   9 ++-
 libavcodec/svq3.c   |   9 +++
 libavcodec/utils.c  |   2 +
 libavcodec/version.h|   4 +-
 libavfilter/vf_boxblur.c|   2 +
 libavfilter/vf_crop.c   |   2 +
 libavfilter/vf_cropdetect.c |  11 ++--
 libavfilter/vf_drawbox.c|   6 +-
 libavfilter/vf_fade.c   |   6 +-
 libavfilter/vf_framepack.c  |   7 ++-
 libavfilter/vf_hflip.c  |   2 +
 libavfilter/vf_hqdn3d.c |   2 +
 libavfilter/vf_interlace.c  |   8 ++-
 libavfilter/vf_lut.c|   7 +++
 libavfilter/vf_pad.c|   2 +
 libavfilter/vf_transpose.c  |   6 +-
 libavfilter/vf_unsharp.c|   8 ++-
 libavfilter/vf_yadif.c  |   4 +-
 libavfilter/vsrc_color.c|   2 +
 libavformat/rtpenc_jpeg.c   |  13 +++-
 libavutil/Makefile  |   2 +
 libavutil/frame.h   |   5 ++
 libavutil/pixdesc.c |   4 ++
 libavutil/pixdesc.h |   1 +
 libavutil/pixfmt.h  |   4 ++
 libavutil/pixmodel.c|  38 
 libavutil/pixmodel.h| 146 
 libavutil/version.h |   5 +-
 libswscale/utils.c  |   6 ++
 42 files changed, 405 insertions(+), 94 deletions(-)
 create mode 100644 libavutil/pixmodel.c
 create mode 100644 libavutil/pixmodel.h

-- 
1.8.3.4 (Apple Git-47)

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


[libav-devel] [PATCH 4/4] lavu: add deprecation guards to full scale formats

2014-03-20 Thread Vittorio Giovara
---
 libavcodec/dirac.c  | 10 ++
 libavcodec/fraps.c  |  4 
 libavcodec/h264.c   | 12 
 libavcodec/hevc_ps.c|  2 ++
 libavcodec/imgconvert.c |  8 +++-
 libavcodec/libx264.c|  8 
 libavcodec/ljpegenc.c   | 12 +++-
 libavcodec/mdec.c   |  4 
 libavcodec/mjpegdec.c   | 16 
 libavcodec/mjpegenc.c   |  7 ++-
 libavcodec/mpegvideo_enc.c  |  9 -
 libavcodec/raw.c|  9 +++--
 libavcodec/svq3.c   |  6 ++
 libavcodec/utils.c  |  2 ++
 libavfilter/vf_boxblur.c|  2 ++
 libavfilter/vf_crop.c   |  2 ++
 libavfilter/vf_cropdetect.c | 11 +++
 libavfilter/vf_drawbox.c|  6 --
 libavfilter/vf_fade.c   |  6 --
 libavfilter/vf_framepack.c  |  7 +--
 libavfilter/vf_hflip.c  |  2 ++
 libavfilter/vf_hqdn3d.c |  2 ++
 libavfilter/vf_interlace.c  |  8 ++--
 libavfilter/vf_lut.c|  7 +++
 libavfilter/vf_pad.c|  2 ++
 libavfilter/vf_transpose.c  |  6 --
 libavfilter/vf_unsharp.c|  8 ++--
 libavfilter/vf_yadif.c  |  4 +++-
 libavfilter/vsrc_color.c|  2 ++
 libavformat/rtpenc_jpeg.c   | 13 -
 libavutil/pixdesc.c |  4 
 libavutil/pixfmt.h  |  4 
 libavutil/version.h |  3 +++
 libswscale/utils.c  |  6 ++
 34 files changed, 190 insertions(+), 24 deletions(-)

diff --git a/libavcodec/dirac.c b/libavcodec/dirac.c
index f0fb85d..2a94023 100644
--- a/libavcodec/dirac.c
+++ b/libavcodec/dirac.c
@@ -108,10 +108,16 @@ static const struct {
 };
 
 /* [DIRAC_STD] Table 10.2 Supported chroma sampling formats + luma Offset */
+#if FF_API_FULLSCALE_PIXFMT
 static const enum AVPixelFormat dirac_pix_fmt[2][3] = {
 { AV_PIX_FMT_YUV444P,  AV_PIX_FMT_YUV422P,  AV_PIX_FMT_YUV420P  },
 { AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ420P },
 };
+#else
+static const enum AVPixelFormat dirac_pix_fmt[3] = {
+{ AV_PIX_FMT_YUV444P,  AV_PIX_FMT_YUV422P,  AV_PIX_FMT_YUV420P  },
+};
+#endif /* FF_API_FULLSCALE_PIXFMT */
 
 /* [DIRAC_STD] 10.3 Parse Source Parameters.
  * source_parameters(base_video_format) */
@@ -236,7 +242,11 @@ static int parse_source_parameters(AVCodecContext *avctx, 
GetBitContext *gb,
 if (luma_depth > 8)
 av_log(avctx, AV_LOG_WARNING, "Bitdepth greater than 8");
 
+#if FF_API_FULLSCALE_PIXFMT
 avctx->pix_fmt = dirac_pix_fmt[!luma_offset][source->chroma_format];
+#else
+avctx->pix_fmt = dirac_pix_fmt[source->chroma_format];
+#endif /* FF_API_FULLSCALE_PIXFMT */
 
 /* [DIRAC_STD] 10.3.9 Colour specification. colour_spec(video_params) */
 if (get_bits1(gb)) { /* [DIRAC_STD] custom_colour_spec_flag */
diff --git a/libavcodec/fraps.c b/libavcodec/fraps.c
index 1005a56..cb61ebe 100644
--- a/libavcodec/fraps.c
+++ b/libavcodec/fraps.c
@@ -170,7 +170,11 @@ static int decode_frame(AVCodecContext *avctx,
 if (header_size == 8)
 buf += 4;
 
+#if FF_API_FULLSCALE_PIXFMT
 pix_fmt = version & 1 ? AV_PIX_FMT_BGR24 : AV_PIX_FMT_YUVJ420P;
+#else
+pix_fmt = version & 1 ? AV_PIX_FMT_BGR24 : AV_PIX_FMT_YUV420P;
+#endif /* FF_API_FULLSCALE_PIXFMT */
 if (avctx->pix_fmt != pix_fmt && f->data[0]) {
 av_frame_unref(f);
 }
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 9a84b11..b89207c 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -166,6 +166,7 @@ static const enum AVPixelFormat 
h264_hwaccel_pixfmt_list_420[] = {
 AV_PIX_FMT_NONE
 };
 
+#if FF_API_FULLSCALE_PIXFMT
 static const enum AVPixelFormat h264_hwaccel_pixfmt_list_jpeg_420[] = {
 #if CONFIG_H264_DXVA2_HWACCEL
 AV_PIX_FMT_DXVA2_VLD,
@@ -182,6 +183,7 @@ static const enum AVPixelFormat 
h264_hwaccel_pixfmt_list_jpeg_420[] = {
 AV_PIX_FMT_YUVJ420P,
 AV_PIX_FMT_NONE
 };
+#endif /* FF_API_FULLSCALE_PIXFMT */
 
 static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
   int (*mv)[2][4][2],
@@ -3127,16 +3129,26 @@ static enum AVPixelFormat get_pixel_format(H264Context 
*h)
 if (h->avctx->colorspace == AVCOL_SPC_RGB) {
 return AV_PIX_FMT_GBRP;
 } else
+#if FF_API_FULLSCALE_PIXFMT
 return h->avctx->color_range == AVCOL_RANGE_JPEG ? 
AV_PIX_FMT_YUVJ444P
  : 
AV_PIX_FMT_YUV444P;
+#else
+return AV_PIX_FMT_YUV444P;
+#endif /* FF_API_FULLSCALE_PIXFMT */
 } else if (CHROMA422(h)) {
+#if FF_API_FULLSCALE_PIXFMT
 return h->avctx->color_range == AVCOL_RANGE_JPEG ? 
AV_PIX_FMT_YUVJ422P
  : 
AV_PIX_FMT_YUV422P;
+#else
+return AV_PIX_FMT_YUV422P;
+#endif /* FF_API_FULLSCALE_PIXFMT */
 } else {
 return h->avctx->get_format(h->avctx, h->avctx->codec->pix_fmts ?
 h->

[libav-devel] [PATCH] changelog: move libx265 to version

2014-03-20 Thread Vittorio Giovara
---
It was agreed to remove libx265 from release/10, so update the Changelog 
accordingly.
Vittorio

 Changelog | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index 279c0d8..d0939a2 100644
--- a/Changelog
+++ b/Changelog
@@ -2,6 +2,7 @@ Entries are sorted chronologically from oldest to youngest 
within each release,
 releases are sorted from youngest to oldest.
 
 version :
+- libx265 encoder
 - compand audio filter
 - shuffleplanes filter
 
@@ -62,7 +63,6 @@ version 10:
 - framepack filter
 - Mirillis FIC video decoder
 - Support DNx444
-- libx265 encoder
 
 
 version 9:
-- 
1.8.3.4 (Apple Git-47)

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


[libav-devel] [PATCH] Alias PIX image encoder and decoder

2014-03-20 Thread Vittorio Giovara
---
Amended as asked by Justin. I only kept the avctx->pix_fmt checks because they 
look
more readable to me.
Cheers,
Vittorio

 Changelog|   1 +
 doc/general.texi |   2 +
 libavcodec/Makefile  |   2 +
 libavcodec/aliaspixdec.c | 114 
 libavcodec/aliaspixenc.c | 132 +++
 libavcodec/allcodecs.c   |   1 +
 libavcodec/avcodec.h |   1 +
 libavcodec/codec_desc.c  |   7 +++
 libavcodec/version.h |   4 +-
 libavformat/img2.c   |   1 +
 libavformat/img2enc.c|   2 +-
 11 files changed, 264 insertions(+), 3 deletions(-)
 create mode 100644 libavcodec/aliaspixdec.c
 create mode 100644 libavcodec/aliaspixenc.c

diff --git a/Changelog b/Changelog
index 279c0d8..0f1007d 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
 version :
 - compand audio filter
 - shuffleplanes filter
+- Alias PIX image encoder and decoder
 
 
 version 10:
diff --git a/doc/general.texi b/doc/general.texi
index 8c0cb1b..dce4c0a 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -424,6 +424,8 @@ following image formats are supported:
 @item Name @tab Encoding @tab Decoding @tab Comments
 @item .Y.U.V   @tab X @tab X
 @tab one raw file per component
+@item Alias PIX@tab X @tab X
+@tab Alias/Wavefront PIX image format
 @item animated GIF @tab X @tab X
 @tab Only uncompressed GIFs are generated.
 @item BMP  @tab X @tab X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index c04b3f1..8f531fc 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -88,6 +88,8 @@ OBJS-$(CONFIG_AC3_FIXED_ENCODER)   += ac3enc_fixed.o 
ac3enc.o ac3tab.o ac3.o
 OBJS-$(CONFIG_AIC_DECODER) += aic.o
 OBJS-$(CONFIG_ALAC_DECODER)+= alac.o alac_data.o
 OBJS-$(CONFIG_ALAC_ENCODER)+= alacenc.o alac_data.o
+OBJS-$(CONFIG_ALIAS_PIX_DECODER)   += aliaspixdec.o
+OBJS-$(CONFIG_ALIAS_PIX_ENCODER)   += aliaspixenc.o
 OBJS-$(CONFIG_ALS_DECODER) += alsdec.o bgmc.o mpeg4audio.o
 OBJS-$(CONFIG_AMRNB_DECODER)   += amrnbdec.o celp_filters.o   \
   celp_math.o acelp_filters.o \
diff --git a/libavcodec/aliaspixdec.c b/libavcodec/aliaspixdec.c
new file mode 100644
index 000..0dd1c84
--- /dev/null
+++ b/libavcodec/aliaspixdec.c
@@ -0,0 +1,114 @@
+/*
+ * Alias PIX image decoder
+ * Copyright (C) 2014 Vittorio Giovara 
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/intreadwrite.h"
+
+#include "avcodec.h"
+#include "bytestream.h"
+#include "internal.h"
+
+#define ALIAS_HEADER_SIZE 10
+
+static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
+AVPacket *avpkt)
+{
+AVFrame *f = data;
+GetByteContext gb;
+int width, height, ret, bits_pixel, pixel;
+uint8_t *out_buf;
+uint8_t count;
+int y = 0;
+
+bytestream2_init(&gb, avpkt->data, avpkt->size);
+
+if (bytestream2_get_bytes_left(&gb) < ALIAS_HEADER_SIZE) {
+av_log(avctx, AV_LOG_ERROR, "Header too small %d.\n", avpkt->size);
+return AVERROR_INVALIDDATA;
+}
+
+width  = bytestream2_get_be16u(&gb);
+height = bytestream2_get_be16u(&gb);
+bytestream2_skipu(&gb, 4); // obsolete X, Y offset
+bits_pixel = bytestream2_get_be16u(&gb);
+
+if (bits_pixel == 24)
+avctx->pix_fmt = AV_PIX_FMT_BGR24;
+else if (bits_pixel == 8)
+avctx->pix_fmt = AV_PIX_FMT_GRAY8;
+else {
+av_log(avctx, AV_LOG_ERROR, "Invalid pixel format.\n");
+return AVERROR_INVALIDDATA;
+}
+
+ret = ff_set_dimensions(avctx, width, height);
+if (ret < 0)
+return ret;
+
+ret = ff_get_buffer(avctx, f, 0);
+if (ret < 0)
+return ret;
+
+f->pict_type = AV_PICTURE_TYPE_I;
+f->key_frame = 1;
+
+while (bytestream2_get_bytes_left(&gb) > 0) {
+int i;
+
+/* set buffer at the right position at every new line */
+if (width == avctx->width) {
+width = 0;
+out_buf = f->data[0] + f->linesize[0] * y++;
+}
+
+/* read packet and copy data */
+count = bytestream2_get_byteu(&gb);
+

[libav-devel] [PATCH] OpenEXR decoder

2014-03-20 Thread Vittorio Giovara
From: Jimmy Christensen 

Additional fixes and enhancements by Vittorio Giovara, Gonzalo Garramuno,
Nicolas George, Paul B Mahol and Michael Niedermayer.

Signed-off-by: Vittorio Giovara 
---
I ported the header parsing to some sane bytestream2 and moved it to its own
function, as asked by Anton.

Anything else or is it good to go?
Cheers,
Vittorio

 Changelog   |1 +
 configure   |1 +
 doc/general.texi|2 +
 libavcodec/Makefile |1 +
 libavcodec/allcodecs.c  |1 +
 libavcodec/avcodec.h|1 +
 libavcodec/codec_desc.c |8 +
 libavcodec/exr.c| 1353 +++
 libavcodec/version.h|4 +-
 libavformat/img2.c  |1 +
 libavformat/isom.c  |1 +
 11 files changed, 1372 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/exr.c

diff --git a/Changelog b/Changelog
index 279c0d8..0f52fd0 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
 version :
 - compand audio filter
 - shuffleplanes filter
+- OpenEXR image decoder
 
 
 version 10:
diff --git a/configure b/configure
index fced12f..c45a967 100755
--- a/configure
+++ b/configure
@@ -1725,6 +1725,7 @@ eac3_encoder_select="ac3_encoder"
 eamad_decoder_select="aandcttables dsputil mpegvideo"
 eatgq_decoder_select="aandcttables dsputil"
 eatqi_decoder_select="aandcttables dsputil error_resilience mpegvideo"
+exr_decoder_deps="zlib"
 ffv1_decoder_select="golomb rangecoder"
 ffv1_encoder_select="rangecoder"
 ffvhuff_decoder_select="huffyuv_decoder"
diff --git a/doc/general.texi b/doc/general.texi
index 8c0cb1b..e2480d6 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -430,6 +430,8 @@ following image formats are supported:
 @tab Microsoft BMP image
 @item DPX  @tab X @tab X
 @tab Digital Picture Exchange
+@item EXR  @tab   @tab X
+@tab OpenEXR
 @item JPEG @tab X @tab X
 @tab Progressive JPEG is not supported.
 @item JPEG 2000@tab E @tab X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index c04b3f1..8e603a1 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -167,6 +167,7 @@ OBJS-$(CONFIG_EIGHTSVX_EXP_DECODER)+= 8svx.o
 OBJS-$(CONFIG_EIGHTSVX_FIB_DECODER)+= 8svx.o
 OBJS-$(CONFIG_ESCAPE124_DECODER)   += escape124.o
 OBJS-$(CONFIG_ESCAPE130_DECODER)   += escape130.o
+OBJS-$(CONFIG_EXR_DECODER) += exr.o
 OBJS-$(CONFIG_FFV1_DECODER)+= ffv1dec.o ffv1.o
 OBJS-$(CONFIG_FFV1_ENCODER)+= ffv1enc.o ffv1.o
 OBJS-$(CONFIG_FIC_DECODER) += fic.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index ed6d7ff..4d0fc7c 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -138,6 +138,7 @@ void avcodec_register_all(void)
 REGISTER_DECODER(EIGHTSVX_FIB,  eightsvx_fib);
 REGISTER_DECODER(ESCAPE124, escape124);
 REGISTER_DECODER(ESCAPE130, escape130);
+REGISTER_DECODER(EXR,   exr);
 REGISTER_ENCDEC (FFV1,  ffv1);
 REGISTER_ENCDEC (FFVHUFF,   ffvhuff);
 REGISTER_DECODER(FIC,   fic);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 7beb277..fe372e0 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -284,6 +284,7 @@ enum AVCodecID {
 AV_CODEC_ID_HNM4_VIDEO,
 AV_CODEC_ID_HEVC,
 AV_CODEC_ID_FIC,
+AV_CODEC_ID_EXR,
 
 /* 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 2ad5326..579109c 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1109,6 +1109,14 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
 },
 {
+.id= AV_CODEC_ID_EXR,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "exr",
+.long_name = NULL_IF_CONFIG_SMALL("OpenEXR image"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY |
+ AV_CODEC_PROP_LOSSLESS,
+},
+{
 .id= AV_CODEC_ID_GIF,
 .type  = AVMEDIA_TYPE_VIDEO,
 .name  = "gif",
diff --git a/libavcodec/exr.c b/libavcodec/exr.c
new file mode 100644
index 000..0aa02c1
--- /dev/null
+++ b/libavcodec/exr.c
@@ -0,0 +1,1353 @@
+/*
+ * OpenEXR (.exr) image decoder
+ * Copyright (c) 2009 Jimmy Christensen
+ *
+ * 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 F

Re: [libav-devel] [PATCH 1/6] truehd: add hand-scheduled ARM asm version of mlp_filter_channel.

2014-03-20 Thread Martin Storsjö

On Thu, 20 Mar 2014, Ben Avison wrote:


On Thu, 20 Mar 2014 07:33:10 -, Martin Storsjö  wrote:

Just to be clear, the tricks that don't work in thumb mode are non-
constant shifts, and jump tables with "ldr pc, [pc, ...]", right?


Yes, it looks like it. I admit, Thumb was something of an afterthought;
shortly before I released it I had a try at assembling it as Thumb and
saw multiple issues; switching to using ARM was the quick and easy
solution. Or so I thought...


Forcing arm mode like this isn't ok in all configurations - e.g. when
building for WinRT/Windows Phone 8, you really have to build all of it
in thumb mode; the linker doesn't handle everything needed for mixing
the modes there.


I would consider that a tools bug, myself. There's no architectural
reason why interworking wouldn't work on anything except a Cortex-M CPU
(which isn't the sort of thing you'd run libav on, especially a TrueHD
decoder - far too low power). My assembly functions are called through
function pointers, not BL statements, and ever since ARMv5 all loads to
the PC (which is how you use a function pointer) are treated as
interworking branches. Before ARMv5, the Thumb instruction set wouldn't
have been rich enough to assemble the sources anyway.


Yeah, architecturally there shouldn't be any issue, but they've more or 
less speced their environment to be thumb-only and that's all the tools 
care about. I'm not familiar enough with all the intricacies with 
interworking to figure out in which cases it works and what's missing in 
practice - I've only tested it lightly and got the general picture of 
"some things might work, but not everything".



However, I doubt I'll have much luck persuading Microsoft of the error of
their ways, so I have made the following changes:
* added IT statements where necessary
* replaced the branch tables with TBH branch tables when targeting Thumb
* where possible, replaced the ALU-op-with-register-shifted-register
instructions with Thumb-compatible sequences when targeting Thumb

It wasn't possible to convert one family of functions, though - the 18
ff_mlp_pack_output_outoforder_*ch_*shift_armv6 functions. There were no
spare registers which could be used as temporaries there, so supporting
Thumb would mean a major change to register allocation, which I haven't
attempted. Instead, I have switched out those functions when CONFIG_THUMB
is defined. (Yes, I saw the discussion about adding an interworking
switch - I'm not sure it's warranted now that most of the optimisations
work in Thumb mode.)


This sounds like a quite sensible thing to do.

Now it remains for me to fix up gas-preprocessor to the point that this 
assembles correctly via that tool as well. As far as I've seen now with 
the previous iterations, there's one issue about in which order the nested 
ifs/macros are evaluated that need to be tweaked.


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


Re: [libav-devel] [PATCH 3/9] Add replaygain side data type and code for parsing replaygain tags.

2014-03-20 Thread Anton Khirnov

On Tue, 18 Mar 2014 19:19:16 +0100, Alessandro Ghedini  
wrote:
> On mar, mar 18, 2014 at 06:26:42 +0100, Anton Khirnov wrote:
> > +int ff_replaygain_export(AVStream *st, AVDictionary *metadata)
> > +{
> > +const AVDictionaryEntry *tg, *tp, *ag, *ap;
> > +
> > +tg = av_dict_get(metadata, "REPLAYGAIN_TRACK_GAIN", NULL, 0);
> > +tp = av_dict_get(metadata, "REPLAYGAIN_TRACK_PEAK", NULL, 0);
> > +ag = av_dict_get(metadata, "REPLAYGAIN_ALBUM_GAIN", NULL, 0);
> > +ap = av_dict_get(metadata, "REPLAYGAIN_ALBUM_PEAK", NULL, 0);
> > +
> > +return replaygain_export(st,
> > + tg ? tg->value : NULL,
> > + tp ? tp->value : NULL,
> > + ag ? ag->value : NULL,
> > + ap ? ap->value : NULL);
> 
> I was wondering if it'd be possible to make this support LAME's XING/Info
> header as well, or better, make this so that it'd be possible to add support
> for the XING thing later if one wanted to do so.
> 
> With the proposed interface the information from the LAME header would need to
> be added directly to the stream metadata (from mp3dec.c I'd imagine) as
> REPLAYGAIN_* tags (e.g. if they are not present already), but I'm not sure if
> that would be acceptable.

No need to go through metadata I think, we could adapt the internal API directly
for this. Shouldn't be very hard to do.

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


Re: [libav-devel] [PATCH 5/6] truehd: break out part of output_data into platform-specific callback.

2014-03-20 Thread Ben Avison

On Thu, 20 Mar 2014 11:38:28 -, Diego Biurrun  wrote:

On Wed, Mar 19, 2014 at 07:43:49PM -, Ben Avison wrote:

>>--- a/libavcodec/mlpdsp.c
>>+++ b/libavcodec/mlpdsp.c
>>@@ -89,10 +89,46 @@ void ff_mlp_rematrix_channel(int32_t *samples,
>>+int32_t *data_32 = (int32_t *)data;
>>+int16_t *data_16 = (int16_t *)data;
>pointless void* casts

Fair enough, those were cut-and-pastes from their original location.


Which location?  I'll change them ..


Those (and the lines a bit further down the same function where you
objected to the formatting) were moved from rematrix_channels() in
mlpdec.c. My patch series already deletes the offenders from their
original position. :)

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


[libav-devel] [PATCH 1/6] truehd: add hand-scheduled ARM asm version of mlp_filter_channel.

2014-03-20 Thread Ben Avison
Profiling results for overall audio decode and the mlp_filter_channel(_arm)
function in particular are as follows:

  Before  After
  Mean   StdDev   Mean   StdDev  Confidence  Change
6:2 total 380.4  22.0 370.8  17.087.4%   +2.6%  (insignificant)
6:2 function  60.7   7.2  36.6   8.1 100.0%  +65.8%
8:2 total 357.0  17.5 343.2  19.097.8%   +4.0%  (insignificant)
8:2 function  60.3   8.8  37.3   3.8 100.0%  +61.8%
6:6 total 717.2  23.2 658.4  15.7100.0%  +8.9%
6:6 function  140.4  12.9 81.5   9.2 100.0%  +72.4%
8:8 total 981.9  16.2 896.2  24.5100.0%  +9.6%
8:8 function  193.4  15.0 103.3  11.5100.0%  +87.2%

Experiments with adding preload instructions to this function yielded no
useful benefit, so these have not been included.

The assembly version has also been tested with a fuzz tester to ensure that
any combinations of inputs not exercised by my available test streams still
generate mathematically identical results to the C version.
---
 libavcodec/arm/Makefile  |2 +
 libavcodec/arm/mlpdsp_arm.S  |  433 ++
 libavcodec/arm/mlpdsp_init_arm.c |   36 +++
 libavcodec/mlpdsp.c  |2 +
 libavcodec/mlpdsp.h  |1 +
 5 files changed, 474 insertions(+), 0 deletions(-)
 create mode 100644 libavcodec/arm/mlpdsp_arm.S
 create mode 100644 libavcodec/arm/mlpdsp_init_arm.c

diff --git a/libavcodec/arm/Makefile b/libavcodec/arm/Makefile
index 8bdccbd..c6cc96e 100644
--- a/libavcodec/arm/Makefile
+++ b/libavcodec/arm/Makefile
@@ -21,6 +21,8 @@ OBJS-$(CONFIG_H264PRED)+= 
arm/h264pred_init_arm.o
 OBJS-$(CONFIG_H264QPEL)+= arm/h264qpel_init_arm.o
 OBJS-$(CONFIG_HPELDSP) += arm/hpeldsp_init_arm.o\
   arm/hpeldsp_arm.o
+OBJS-$(CONFIG_MLP_DECODER) += arm/mlpdsp_init_arm.o \
+  arm/mlpdsp_arm.o
 OBJS-$(CONFIG_MPEGAUDIODSP)+= arm/mpegaudiodsp_init_arm.o
 OBJS-$(CONFIG_MPEGVIDEO)   += arm/mpegvideo_arm.o
 OBJS-$(CONFIG_NEON_CLOBBER_TEST)   += arm/neontest.o
diff --git a/libavcodec/arm/mlpdsp_arm.S b/libavcodec/arm/mlpdsp_arm.S
new file mode 100644
index 000..f36ba54
--- /dev/null
+++ b/libavcodec/arm/mlpdsp_arm.S
@@ -0,0 +1,433 @@
+/*
+ * Copyright (c) 2014 RISC OS Open Ltd
+ * Author: Ben Avison 
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/arm/asm.S"
+
+#define MAX_CHANNELS8
+#define MAX_FIR_ORDER   8
+#define MAX_IIR_ORDER   4
+#define MAX_RATEFACTOR  4
+#define MAX_BLOCKSIZE   (40 * MAX_RATEFACTOR)
+
+PST .reqa1
+PCO .reqa2
+AC0 .reqa3
+AC1 .reqa4
+CO0 .reqv1
+CO1 .reqv2
+CO2 .reqv3
+CO3 .reqv4
+ST0 .reqv5
+ST1 .reqv6
+ST2 .reqsl
+ST3 .reqfp
+I   .reqip
+PSAMP   .reqlr
+
+
+// Some macros that do loads/multiplies where the register number is determined
+// from an assembly-time expression. Boy is GNU assembler's syntax ugly...
+
+.macro load  group, index, base, offset
+   .altmacro
+   load_ \group, %(\index), \base, \offset
+   .noaltmacro
+.endm
+
+.macro load_ group, index, base, offset
+ldr \group\index, [\base, #\offset]
+.endm
+
+.macro loadd  group, index, base, offset
+   .altmacro
+   loadd_ \group, %(\index), %(\index+1), \base, \offset
+   .noaltmacro
+.endm
+
+.macro loadd_ group, index0, index1, base, offset
+A .if offset >= 256
+A   ldr \group\index0, [\base, #\offset]
+A   ldr \group\index1, [\base, #(\offset) + 4]
+A .else
+ldrd\group\index0, \group\index1, [\base, #\offset]
+A .endif
+.endm
+
+.macro multiply  index, accumulate, long
+.altmacro
+multiply_ %(\index), \accumulate, \long
+.noaltmacro
+.endm
+
+.macro multiply_  index, accumulate, long
+ .if \long
+  .if \accumulate
+smlal   AC0, AC1, CO\index, ST\index
+  .else
+smull   AC0, AC1, CO\index, ST\index
+  .endif
+ .else
+  .if \accumulate
+mla AC0, CO\index, ST\

[libav-devel] [PATCH 3/6] truehd: add hand-scheduled ARM asm version of ff_mlp_rematrix_channel.

2014-03-20 Thread Ben Avison
Profiling results for overall audio decode and the rematrix_channels function
in particular are as follows:

  Before  After
  Mean   StdDev   Mean   StdDev  Confidence  Change
6:2 total 370.8  17.0 348.8  20.199.9%   +6.3%
6:2 function  46.4   8.4  45.8   6.6 18.0%   +1.2%  (insignificant)
8:2 total 343.2  19.0 339.1  15.454.7%   +1.2%  (insignificant)
8:2 function  38.9   3.9  40.2   6.9 52.4%   -3.2%  (insignificant)
6:6 total 658.4  15.7 604.6  20.8100.0%  +8.9%
6:6 function  109.0  8.7  59.5   5.4 100.0%  +83.3%
8:8 total 896.2  24.5 766.4  17.6100.0%  +16.9%
8:8 function  223.4  12.8 93.8   5.0 100.0%  +138.3%

The assembly version has also been tested with a fuzz tester to ensure that
any combinations of inputs not exercised by my available test streams still
generate mathematically identical results to the C version.
---
 libavcodec/arm/mlpdsp_arm.S  |  222 ++
 libavcodec/arm/mlpdsp_init_arm.c |   12 ++
 2 files changed, 234 insertions(+), 0 deletions(-)

diff --git a/libavcodec/arm/mlpdsp_arm.S b/libavcodec/arm/mlpdsp_arm.S
index f36ba54..08cc2d0 100644
--- a/libavcodec/arm/mlpdsp_arm.S
+++ b/libavcodec/arm/mlpdsp_arm.S
@@ -431,3 +431,225 @@ endfunc
 .unreq  ST3
 .unreq  I
 .unreq  PSAMP
+
+//
+
+PSA .reqa1 // samples
+PCO .reqa2 // coeffs
+PBL .reqa3 // bypassed_lsbs
+INDEX   .reqa4
+CO0 .reqv1
+CO1 .reqv2
+CO2 .reqv3
+CO3 .reqv4
+SA0 .reqv5
+SA1 .reqv6
+SA2 .reqsl
+SA3 .reqfp
+AC0 .reqip
+AC1 .reqlr
+NOISE   .reqSA0
+LSB .reqSA1
+DCH .reqSA2 // dest_ch
+MASK.reqSA3
+
+// INDEX is used as follows:
+// bits 0..6   index2 (values up to 17, but wider so that we can
+//   add to index field without needing to mask)
+// bits 7..14  i (values up to 160)
+// bit 15  underflow detect for i
+// bits 25..31 (if access_unit_size_pow2 == 128)  \ index
+// bits 26..31 (if access_unit_size_pow2 == 64)   /
+
+.macro implement_rematrix  shift, index_mask, mask_minus1, maxchan
+.if \maxchan == 1
+// We can just leave the coefficients in registers in this case
+ldrdCO0, CO1, [PCO]
+.endif
+1:
+.if \maxchan == 1
+ldrdSA0, SA1, [PSA]
+smull   AC0, AC1, CO0, SA0
+.elseif \maxchan == 5
+ldr CO0, [PCO, #0]
+ldr SA0, [PSA, #0]
+ldr CO1, [PCO, #4]
+ldr SA1, [PSA, #4]
+ldrdCO2, CO3, [PCO, #8]
+smull   AC0, AC1, CO0, SA0
+ldrdSA2, SA3, [PSA, #8]
+smlal   AC0, AC1, CO1, SA1
+ldrdCO0, CO1, [PCO, #16]
+smlal   AC0, AC1, CO2, SA2
+ldrdSA0, SA1, [PSA, #16]
+smlal   AC0, AC1, CO3, SA3
+smlal   AC0, AC1, CO0, SA0
+.else // \maxchan == 7
+ldr CO2, [PCO, #0]
+ldr SA2, [PSA, #0]
+ldr CO3, [PCO, #4]
+ldr SA3, [PSA, #4]
+ldrdCO0, CO1, [PCO, #8]
+smull   AC0, AC1, CO2, SA2
+ldrdSA0, SA1, [PSA, #8]
+smlal   AC0, AC1, CO3, SA3
+ldrdCO2, CO3, [PCO, #16]
+smlal   AC0, AC1, CO0, SA0
+ldrdSA2, SA3, [PSA, #16]
+smlal   AC0, AC1, CO1, SA1
+ldrdCO0, CO1, [PCO, #24]
+smlal   AC0, AC1, CO2, SA2
+ldrdSA0, SA1, [PSA, #24]
+smlal   AC0, AC1, CO3, SA3
+smlal   AC0, AC1, CO0, SA0
+.endif
+ldm sp, {NOISE, DCH, MASK}
+smlal   AC0, AC1, CO1, SA1
+.if \shift != 0
+  .if \index_mask == 63
+add NOISE, NOISE, INDEX, lsr #32-6
+ldrbLSB, [PBL], #MAX_CHANNELS
+ldrsb   NOISE, [NOISE]
+add INDEX, INDEX, INDEX, lsl #32-6
+  .else // \index_mask == 127
+add NOISE, NOISE, INDEX, lsr #32-7
+ldrbLSB, [PBL], #MAX_CHANNELS
+ldrsb   NOISE, [NOISE]
+add INDEX, INDEX, INDEX, lsl #32-7
+  .endif
+sub INDEX, INDEX, #1<<7
+addsAC0, AC0, NOISE, lsl #\shift + 7
+adc AC1, AC1, NOISE, asr #31
+.else
+ldrbLSB, [PBL], #MAX_CHANNELS
+sub INDEX, INDEX, #1<<7
+.endif
+add PSA, PSA, #MAX_CHANNELS*4
+mov AC0, AC0, lsr #14
+orr AC0, AC0, AC1, lsl #18
+.if !\mask_minus1
+and AC0, AC0, MASK
+.endif
+add AC0, AC0, LSB
+tst INDEX, #1<<15
+str AC0, [PSA, DCH, lsl #2]  // DCH is precompensated for the 
early increment of PSA
+beq 1b
+b   98f
+.endm
+
+.macro switch_on_maxchan  shift, index_mask, mask_minus1
+cmp v4, #5
+blo 51f
+beq 50f
+  

[libav-devel] [PATCH 4/6] truehd: tune VLC decoding for ARM.

2014-03-20 Thread Ben Avison
Profiling on a Raspberry Pi revealed the best performance to correspond
with VLC_BITS = 5. Results for overall audio decode and the get_vlc2 function
in particular are as follows:

  Before  After
  Mean   StdDev   Mean   StdDev  Confidence  Change
6:2 total 348.8  20.1 339.6  15.188.8%   +2.7%  (insignificant)
6:2 function  38.1   8.1  26.4   4.1 100.0%  +44.5%
8:2 total 339.1  15.4 324.5  15.599.4%   +4.5%
8:2 function  33.8   7.0  27.3   5.6 99.7%   +23.6%
6:6 total 604.6  20.8 572.8  20.6100.0%  +5.6%
6:6 function  95.8   8.4  68.9   8.2 100.0%  +39.1%
8:8 total 766.4  17.6 741.5  21.2100.0%  +3.4%
8:8 function  106.0  11.4 86.1   9.9 100.0%  +23.1%
---
 libavcodec/mlpdec.c |   13 ++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index c0f2d6a..b9d1704 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -37,9 +37,16 @@
 #include "mlp_parser.h"
 #include "mlpdsp.h"
 #include "mlp.h"
+#include "config.h"
 
 /** number of bits used for VLC lookup - longest Huffman code is 9 */
+#if ARCH_ARM == 1
+#define VLC_BITS5
+#define VLC_STATIC_SIZE 64
+#else
 #define VLC_BITS9
+#define VLC_STATIC_SIZE 512
+#endif
 
 typedef struct SubStream {
 /// Set if a valid restart header has been read. Otherwise the substream 
cannot be decoded.
@@ -190,13 +197,13 @@ static av_cold void init_static(void)
 if (!huff_vlc[0].bits) {
 INIT_VLC_STATIC(&huff_vlc[0], VLC_BITS, 18,
 &ff_mlp_huffman_tables[0][0][1], 2, 1,
-&ff_mlp_huffman_tables[0][0][0], 2, 1, 512);
+&ff_mlp_huffman_tables[0][0][0], 2, 1, VLC_STATIC_SIZE);
 INIT_VLC_STATIC(&huff_vlc[1], VLC_BITS, 16,
 &ff_mlp_huffman_tables[1][0][1], 2, 1,
-&ff_mlp_huffman_tables[1][0][0], 2, 1, 512);
+&ff_mlp_huffman_tables[1][0][0], 2, 1, VLC_STATIC_SIZE);
 INIT_VLC_STATIC(&huff_vlc[2], VLC_BITS, 15,
 &ff_mlp_huffman_tables[2][0][1], 2, 1,
-&ff_mlp_huffman_tables[2][0][0], 2, 1, 512);
+&ff_mlp_huffman_tables[2][0][0], 2, 1, VLC_STATIC_SIZE);
 }
 
 ff_mlp_init_crc();
-- 
1.7.5.4

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


[libav-devel] [PATCH 5/6] truehd: break out part of output_data into platform-specific callback.

2014-03-20 Thread Ben Avison
Verified with profiling that this doesn't have a measurable effect upon
overall performance.
---
 libavcodec/mlpdec.c |   40 +++-
 libavcodec/mlpdsp.c |   38 ++
 libavcodec/mlpdsp.h |   22 ++
 3 files changed, 83 insertions(+), 17 deletions(-)

diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index b9d1704..49353d9 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -360,6 +360,10 @@ static int read_major_sync(MLPDecodeContext *m, 
GetBitContext *gb)
 m->avctx->sample_fmt = AV_SAMPLE_FMT_S32;
 else
 m->avctx->sample_fmt = AV_SAMPLE_FMT_S16;
+m->dsp.mlp_pack_output = 
m->dsp.mlp_select_pack_output(m->substream[m->max_decoded_substream].ch_assign,
+   
m->substream[m->max_decoded_substream].output_shift,
+   
m->substream[m->max_decoded_substream].max_matrix_channel,
+   
m->avctx->sample_fmt == AV_SAMPLE_FMT_S32);
 
 m->params_valid = 1;
 for (substr = 0; substr < MAX_SUBSTREAMS; substr++)
@@ -588,6 +592,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if (substr == m->max_decoded_substream) {
 m->avctx->channels   = s->max_matrix_channel + 1;
 m->avctx->channel_layout = s->ch_layout;
+m->dsp.mlp_pack_output = m->dsp.mlp_select_pack_output(s->ch_assign,
+   s->output_shift,
+   
s->max_matrix_channel,
+   
m->avctx->sample_fmt == AV_SAMPLE_FMT_S32);
 }
 
 return 0;
@@ -818,9 +826,15 @@ static int read_decoding_params(MLPDecodeContext *m, 
GetBitContext *gbp,
 return ret;
 
 if (s->param_presence_flags & PARAM_OUTSHIFT)
-if (get_bits1(gbp))
+if (get_bits1(gbp)) {
 for (ch = 0; ch <= s->max_matrix_channel; ch++)
 s->output_shift[ch] = get_sbits(gbp, 4);
+if (substr == m->max_decoded_substream)
+m->dsp.mlp_pack_output = 
m->dsp.mlp_select_pack_output(s->ch_assign,
+   
s->output_shift,
+   
s->max_matrix_channel,
+   
m->avctx->sample_fmt == AV_SAMPLE_FMT_S32);
+}
 
 if (s->param_presence_flags & PARAM_QUANTSTEP)
 if (get_bits1(gbp))
@@ -1019,9 +1033,6 @@ static int output_data(MLPDecodeContext *m, unsigned int 
substr,
 {
 AVCodecContext *avctx = m->avctx;
 SubStream *s = &m->substream[substr];
-unsigned int i, out_ch = 0;
-int32_t *data_32;
-int16_t *data_16;
 int ret;
 int is32 = (m->avctx->sample_fmt == AV_SAMPLE_FMT_S32);
 
@@ -1041,19 +1052,14 @@ static int output_data(MLPDecodeContext *m, unsigned 
int substr,
 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
 return ret;
 }
-data_32 = (int32_t *)frame->data[0];
-data_16 = (int16_t *)frame->data[0];
-
-for (i = 0; i < s->blockpos; i++) {
-for (out_ch = 0; out_ch <= s->max_matrix_channel; out_ch++) {
-int mat_ch = s->ch_assign[out_ch];
-int32_t sample = m->sample_buffer[i][mat_ch]
-  << s->output_shift[mat_ch];
-s->lossless_check_data ^= (sample & 0xff) << mat_ch;
-if (is32) *data_32++ = sample << 8;
-else  *data_16++ = sample >> 8;
-}
-}
+s->lossless_check_data = m->dsp.mlp_pack_output(s->lossless_check_data,
+s->blockpos,
+m->sample_buffer,
+frame->data[0],
+s->ch_assign,
+s->output_shift,
+s->max_matrix_channel,
+is32);
 
 /* Update matrix encoding side data */
 if ((ret = ff_side_data_update_matrix_encoding(frame, s->matrix_encoding)) 
< 0)
diff --git a/libavcodec/mlpdsp.c b/libavcodec/mlpdsp.c
index dfa13af..aded554 100644
--- a/libavcodec/mlpdsp.c
+++ b/libavcodec/mlpdsp.c
@@ -89,10 +89,48 @@ void ff_mlp_rematrix_channel(int32_t *samples,
 }
 }
 
+static int32_t (*mlp_select_pack_output(uint8_t *ch_assign,
+int8_t *output_shift,
+uint8_t max_matrix_channel,
+int is32))(int32_t, uint16_t, int32_t 
(*)[], void *, uint8_t*, int8_t *, uint8_t, int)
+{
+return ff_mlp_p

[libav-devel] [PATCH 6/6] truehd: add hand-scheduled ARM asm version of ff_mlp_pack_output.

2014-03-20 Thread Ben Avison
Profiling results for overall decode and the output_data function in
particular are as follows:

  Before  After
  Mean   StdDev   Mean   StdDev  Confidence  Change
6:2 total 339.6  15.1 329.3  16.095.8%   +3.1%  (insignificant)
6:2 function  24.6   6.0  9.93.1 100.0%  +148.5%
8:2 total 324.5  15.5 323.6  14.315.2%   +0.3%  (insignificant)
8:2 function  20.4   3.9  9.93.4 100.0%  +104.7%
6:6 total 572.8  20.6 539.9  24.2100.0%  +6.1%
6:6 function  54.5   5.6  16.0   3.8 100.0%  +240.9%
8:8 total 741.5  21.2 702.5  18.5100.0%  +5.6%
8:8 function  63.9   7.6  18.4   4.8 100.0%  +247.3%

The assembly version has also been tested with a fuzz tester to ensure that
any combinations of inputs not exercised by my available test streams still
generate mathematically identical results to the C version.
---
 libavcodec/arm/Makefile  |1 +
 libavcodec/arm/mlpdsp_armv6.S|  530 ++
 libavcodec/arm/mlpdsp_init_arm.c |   96 +++
 3 files changed, 627 insertions(+), 0 deletions(-)
 create mode 100644 libavcodec/arm/mlpdsp_armv6.S

diff --git a/libavcodec/arm/Makefile b/libavcodec/arm/Makefile
index c6cc96e..8d7e25a 100644
--- a/libavcodec/arm/Makefile
+++ b/libavcodec/arm/Makefile
@@ -51,6 +51,7 @@ ARMV6-OBJS-$(CONFIG_AC3DSP)+= arm/ac3dsp_armv6.o
 ARMV6-OBJS-$(CONFIG_H264DSP)   += arm/h264dsp_armv6.o
 ARMV6-OBJS-$(CONFIG_HPELDSP)   += arm/hpeldsp_init_armv6.o  \
   arm/hpeldsp_armv6.o
+ARMV6-OBJS-$(CONFIG_MLP_DECODER)   += arm/mlpdsp_armv6.o
 ARMV6-OBJS-$(CONFIG_MPEGAUDIODSP)  += arm/mpegaudiodsp_fixed_armv6.o
 ARMV6-OBJS-$(CONFIG_VP8_DECODER)   += arm/vp8_armv6.o   \
   arm/vp8dsp_init_armv6.o   \
diff --git a/libavcodec/arm/mlpdsp_armv6.S b/libavcodec/arm/mlpdsp_armv6.S
new file mode 100644
index 000..7f41a15
--- /dev/null
+++ b/libavcodec/arm/mlpdsp_armv6.S
@@ -0,0 +1,530 @@
+/*
+ * Copyright (c) 2014 RISC OS Open Ltd
+ * Author: Ben Avison 
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/arm/asm.S"
+
+.macro loadregoffsh2  group, index, base, offgroup, offindex
+   .altmacro
+   loadregoffsh2_ \group, %(\index), \base, \offgroup, %(\offindex)
+   .noaltmacro
+.endm
+
+.macro loadregoffsh2_ group, index, base, offgroup, offindex
+ldr \group\index, [\base, \offgroup\offindex, lsl #2]
+.endm
+
+.macro eorlslreg  check, data, group, index
+.altmacro
+eorlslreg_ \check, \data, \group, %(\index)
+.noaltmacro
+.endm
+
+.macro eorlslreg_ check, data, group, index
+eor \check, \check, \data, lsl \group\index
+.endm
+
+.macro decr_modulo var, by, modulus
+ .set \var, \var - \by
+ .if \var == 0
+  .set \var, \modulus
+ .endif
+.endm
+
+ .macro load_group1  size, channels, r0, r1, r2, r3, pointer_dead=0
+  .if \size == 2
+ldrd\r0, \r1, [IN], #(\size + 8 - \channels) * 4
+  .else // size == 4
+   .if IDX1 > 4 || \channels==8
+ldm IN!, {\r0, \r1, \r2, \r3}
+   .else
+ldm IN, {\r0, \r1, \r2, \r3}
+.if !\pointer_dead
+add IN, IN, #(4 + 8 - \channels) * 4
+ .endif
+   .endif
+  .endif
+decr_modulo IDX1, \size, \channels
+ .endm
+
+ .macro load_group2  size, channels, r0, r1, r2, r3, pointer_dead=0
+  .if \size == 2
+   .if IDX1 > 2
+ldm IN!, {\r2, \r3}
+   .else
+//A   .ifc \r2, ip
+//A.if \pointer_dead
+//A   ldm IN, {\r2, \r3}
+//A.else
+//A   ldr \r2, [IN], #4
+//A   ldr \r3, [IN], #(\size - 1 + 8 - \channels) * 4
+//A.endif
+//A   .else
+ldrd\r2, \r3, [IN], #(\size + 8 - \channels) * 4
+//A   .endif
+   .endif
+  .endif
+decr_modulo IDX1, \size, \channels
+ .endm
+
+.macro implement_pack  inorder, channels, shift
+.if \inorder
+.ifc \shift, mixed
+
+CHECK   .reqa1
+COUNT   .reqa2
+IN  .reqa3
+OUT .reqa4
+DAT0.reqv1
+DAT1.reqv2
+DAT2.reqv3
+DAT3.reqv4
+SHIFT0  .reqv5
+SHIFT1  .reqv6
+SHIFT2  .reqsl

[libav-devel] [PATCH 2/6] truehd: break out part of rematrix_channels into platform-specific callback.

2014-03-20 Thread Ben Avison
Verified with profiling that this doesn't have a measurable effect upon
overall performance.
---
 libavcodec/mlpdec.c |   37 -
 libavcodec/mlpdsp.c |   33 +
 libavcodec/mlpdsp.h |   23 +++
 3 files changed, 68 insertions(+), 25 deletions(-)

diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index ed5a6ac..c0f2d6a 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -978,7 +978,7 @@ static void fill_noise_buffer(MLPDecodeContext *m, unsigned 
int substr)
 static void rematrix_channels(MLPDecodeContext *m, unsigned int substr)
 {
 SubStream *s = &m->substream[substr];
-unsigned int mat, src_ch, i;
+unsigned int mat;
 unsigned int maxchan;
 
 maxchan = s->max_matrix_channel;
@@ -990,31 +990,18 @@ static void rematrix_channels(MLPDecodeContext *m, 
unsigned int substr)
 }
 
 for (mat = 0; mat < s->num_primitive_matrices; mat++) {
-int matrix_noise_shift = s->matrix_noise_shift[mat];
 unsigned int dest_ch = s->matrix_out_ch[mat];
-int32_t mask = MSB_MASK(s->quant_step_size[dest_ch]);
-int32_t *coeffs = s->matrix_coeff[mat];
-int index  = s->num_primitive_matrices - mat;
-int index2 = 2 * index + 1;
-
-/* TODO: DSPContext? */
-
-for (i = 0; i < s->blockpos; i++) {
-int32_t bypassed_lsb = m->bypassed_lsbs[i][mat];
-int32_t *samples = m->sample_buffer[i];
-int64_t accum = 0;
-
-for (src_ch = 0; src_ch <= maxchan; src_ch++)
-accum += (int64_t) samples[src_ch] * coeffs[src_ch];
-
-if (matrix_noise_shift) {
-index &= m->access_unit_size_pow2 - 1;
-accum += m->noise_buffer[index] << (matrix_noise_shift + 7);
-index += index2;
-}
-
-samples[dest_ch] = ((accum >> 14) & mask) + bypassed_lsb;
-}
+m->dsp.mlp_rematrix_channel(&m->sample_buffer[0][0],
+s->matrix_coeff[mat],
+&m->bypassed_lsbs[0][mat],
+m->noise_buffer,
+s->num_primitive_matrices - mat,
+dest_ch,
+s->blockpos,
+maxchan,
+s->matrix_noise_shift[mat],
+m->access_unit_size_pow2,
+MSB_MASK(s->quant_step_size[dest_ch]));
 }
 }
 
diff --git a/libavcodec/mlpdsp.c b/libavcodec/mlpdsp.c
index 151cf83..dfa13af 100644
--- a/libavcodec/mlpdsp.c
+++ b/libavcodec/mlpdsp.c
@@ -57,9 +57,42 @@ static void mlp_filter_channel(int32_t *state, const int32_t 
*coeff,
 }
 }
 
+void ff_mlp_rematrix_channel(int32_t *samples,
+ const int32_t *coeffs,
+ const uint8_t *bypassed_lsbs,
+ const int8_t *noise_buffer,
+ int index,
+ unsigned int dest_ch,
+ uint16_t blockpos,
+ unsigned int maxchan,
+ int matrix_noise_shift,
+ int access_unit_size_pow2,
+ int32_t mask)
+{
+unsigned int src_ch, i;
+int index2 = 2 * index + 1;
+for (i = 0; i < blockpos; i++) {
+int64_t accum = 0;
+
+for (src_ch = 0; src_ch <= maxchan; src_ch++)
+accum += (int64_t) samples[src_ch] * coeffs[src_ch];
+
+if (matrix_noise_shift) {
+index &= access_unit_size_pow2 - 1;
+accum += noise_buffer[index] << (matrix_noise_shift + 7);
+index += index2;
+}
+
+samples[dest_ch] = ((accum >> 14) & mask) + *bypassed_lsbs;
+bypassed_lsbs += MAX_CHANNELS;
+samples += MAX_CHANNELS;
+}
+}
+
 av_cold void ff_mlpdsp_init(MLPDSPContext *c)
 {
 c->mlp_filter_channel = mlp_filter_channel;
+c->mlp_rematrix_channel = ff_mlp_rematrix_channel;
 if (ARCH_ARM)
 ff_mlpdsp_init_arm(c);
 if (ARCH_X86)
diff --git a/libavcodec/mlpdsp.h b/libavcodec/mlpdsp.h
index c985a17..bd864d9 100644
--- a/libavcodec/mlpdsp.h
+++ b/libavcodec/mlpdsp.h
@@ -24,11 +24,34 @@
 
 #include 
 
+void ff_mlp_rematrix_channel(int32_t *samples,
+ const int32_t *coeffs,
+ const uint8_t *bypassed_lsbs,
+ const int8_t *noise_buffer,
+ int index,
+ unsigned int dest_ch,
+ uint16_t blockpos,
+ unsigned int maxchan,
+ int matrix_noise_shift,
+ int access_unit_size_pow2,
+ int32_t 

[libav-devel] [PATCH 0/6] truehd: ARM optimisations

2014-03-20 Thread Ben Avison
An updated patch series. The main difference here is that for Thumb targets,
it's assumed that interworking is not supported, so individual functions are
either assembled as Thumb, or omitted if they cannot be supported without a
major refactoring.

Ben Avison (6):
  truehd: add hand-scheduled ARM asm version of mlp_filter_channel.
  truehd: break out part of rematrix_channels into platform-specific
callback.
  truehd: add hand-scheduled ARM asm version of
ff_mlp_rematrix_channel.
  truehd: tune VLC decoding for ARM.
  truehd: break out part of output_data into platform-specific
callback.
  truehd: add hand-scheduled ARM asm version of ff_mlp_pack_output.

 libavcodec/arm/Makefile  |3 +
 libavcodec/arm/mlpdsp_arm.S  |  655 ++
 libavcodec/arm/mlpdsp_armv6.S|  530 ++
 libavcodec/arm/mlpdsp_init_arm.c |  144 +
 libavcodec/mlpdec.c  |   90 +++---
 libavcodec/mlpdsp.c  |   73 +
 libavcodec/mlpdsp.h  |   46 +++
 7 files changed, 1496 insertions(+), 45 deletions(-)
 create mode 100644 libavcodec/arm/mlpdsp_arm.S
 create mode 100644 libavcodec/arm/mlpdsp_armv6.S
 create mode 100644 libavcodec/arm/mlpdsp_init_arm.c

-- 
1.7.5.4

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


Re: [libav-devel] [PATCH 1/6] truehd: add hand-scheduled ARM asm version of mlp_filter_channel.

2014-03-20 Thread Ben Avison

On Thu, 20 Mar 2014 07:33:10 -, Martin Storsjö  wrote:

Just to be clear, the tricks that don't work in thumb mode are non-
constant shifts, and jump tables with "ldr pc, [pc, ...]", right?


Yes, it looks like it. I admit, Thumb was something of an afterthought;
shortly before I released it I had a try at assembling it as Thumb and
saw multiple issues; switching to using ARM was the quick and easy
solution. Or so I thought...


Forcing arm mode like this isn't ok in all configurations - e.g. when
building for WinRT/Windows Phone 8, you really have to build all of it
in thumb mode; the linker doesn't handle everything needed for mixing
the modes there.


I would consider that a tools bug, myself. There's no architectural
reason why interworking wouldn't work on anything except a Cortex-M CPU
(which isn't the sort of thing you'd run libav on, especially a TrueHD
decoder - far too low power). My assembly functions are called through
function pointers, not BL statements, and ever since ARMv5 all loads to
the PC (which is how you use a function pointer) are treated as
interworking branches. Before ARMv5, the Thumb instruction set wouldn't
have been rich enough to assemble the sources anyway.

However, I doubt I'll have much luck persuading Microsoft of the error of
their ways, so I have made the following changes:
* added IT statements where necessary
* replaced the branch tables with TBH branch tables when targeting Thumb
* where possible, replaced the ALU-op-with-register-shifted-register
  instructions with Thumb-compatible sequences when targeting Thumb

It wasn't possible to convert one family of functions, though - the 18
ff_mlp_pack_output_outoforder_*ch_*shift_armv6 functions. There were no
spare registers which could be used as temporaries there, so supporting
Thumb would mean a major change to register allocation, which I haven't
attempted. Instead, I have switched out those functions when CONFIG_THUMB
is defined. (Yes, I saw the discussion about adding an interworking
switch - I'm not sure it's warranted now that most of the optimisations
work in Thumb mode.)

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


[libav-devel] [PATCH 0/3 v2] synth filter float ASM

2014-03-20 Thread James Almer
Here are some extra implementations that extend Christophe's work.

Differences with v1:

* AVX/FMA3: Removed the main loop and related bookkeepeing for x64 since said 
loop 
would be run only once anyway.
* FMA3: Replaced mulps+subps with FMA3 instructions, meaning two less 
instructions 
run per loop in that version.
* Removed some unnecessary preprocessor guards and added some missing ones.

Knowing that currently AMD has lackluster performance with ymm registers I 
could 
add an FMA4 version of this function using xmm registers, which would benefit 
said 
processors unlike the AVX/FMA3 ymm ones. Thoughts?

James Almer (3):
  x86/synth_filter: add synth_filter_sse
  x86/synth_filter: add synth_filter_avx
  x86/synth_filter: add synth_filter_fma3

 libavcodec/x86/dcadsp.asm| 138 ---
 libavcodec/x86/dcadsp_init.c |  55 +++--
 2 files changed, 143 insertions(+), 50 deletions(-)

-- 
1.8.3.2

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


[libav-devel] [PATCH 1/3 v2] x86/synth_filter: add synth_filter_sse

2014-03-20 Thread James Almer
Build only on x86_32 targets.

Signed-off-by: James Almer 
---
 libavcodec/x86/dcadsp.asm| 55 +---
 libavcodec/x86/dcadsp_init.c | 45 ++--
 2 files changed, 70 insertions(+), 30 deletions(-)

diff --git a/libavcodec/x86/dcadsp.asm b/libavcodec/x86/dcadsp.asm
index 56039ba..970ec3d 100644
--- a/libavcodec/x86/dcadsp.asm
+++ b/libavcodec/x86/dcadsp.asm
@@ -199,15 +199,31 @@ INIT_XMM sse
 DCA_LFE_FIR 0
 DCA_LFE_FIR 1
 
-INIT_XMM sse2
+%macro SETZERO 1
+%if cpuflag(sse2)
+pxor  %1, %1
+%else
+xorps %1, %1, %1
+%endif
+%endmacro
+
+%macro SHUF 2
+%if cpuflag(sse2)
+pshufd%1, %2, q0123
+%else
+mova  %1, %2
+shufps%1, %1, q0123
+%endif
+%endmacro
+
 %macro INNER_LOOP   1
 ; reading backwards:  ptr1 = synth_buf + j + i; ptr2 = synth_buf + j - i
 ;~ a += window[i + j]  * (-synth_buf[15 - i + j])
 ;~ b += window[i + j + 16] * (synth_buf[i + j])
-pshufdm5, [ptr2 + j + (15 - 3) * 4], q0123
+SHUF  m5, [ptr2 + j + (15 - 3) * 4]
 mova  m6, [ptr1 + j]
 %if ARCH_X86_64
-pshufd   m11, [ptr2 + j + (15 - 3) * 4 - mmsize], q0123
+SHUF m11, [ptr2 + j + (15 - 3) * 4 - mmsize]
 mova m12, [ptr1 + j + mmsize]
 %endif
 mulps m6, [win  + %1 + j + 16 * 4]
@@ -224,10 +240,10 @@ INIT_XMM sse2
 %endif
 ;~ c += window[i + j + 32] * (synth_buf[16 + i + j])
 ;~ d += window[i + j + 48] * (synth_buf[31 - i + j])
-pshufdm6, [ptr2 + j + (31 - 3) * 4], q0123
+SHUF  m6, [ptr2 + j + (31 - 3) * 4]
 mova  m5, [ptr1 + j + 16 * 4]
 %if ARCH_X86_64
-pshufd   m12, [ptr2 + j + (31 - 3) * 4 - mmsize], q0123
+SHUF m12, [ptr2 + j + (31 - 3) * 4 - mmsize]
 mova m11, [ptr1 + j + mmsize + 16 * 4]
 %endif
 mulps m5, [win  + %1 + j + 32 * 4]
@@ -245,20 +261,25 @@ INIT_XMM sse2
 subj, 64 * 4
 %endmacro
 
-; void ff_synth_filter_inner_sse2(float *synth_buf, float synth_buf2[32],
-; const float window[512], float out[32],
-; intptr_t offset, float scale)
+; void ff_synth_filter_inner_(float *synth_buf, float synth_buf2[32],
+;  const float window[512], float out[32],
+;  intptr_t offset, float scale)
+%macro SYNTH_FILTER 0
 cglobal synth_filter_inner, 0, 6 + 4 * ARCH_X86_64, 7 + 6 * ARCH_X86_64, \
   synth_buf, synth_buf2, window, out, off, scale
 %define scale m0
 %if ARCH_X86_32 || WIN64
+%if cpuflag(sse2)
 movd   scale, scalem
+%else
+movss  scale, scalem
+%endif
 ; Make sure offset is in a register and not on the stack
 %define OFFQ  r4q
 %else
 %define OFFQ  offq
 %endif
-pshufdm0, m0, 0
+SPLATDm0
 ; prepare inner counter limit 1
 mov  r5q, 480
 sub  r5q, offmp
@@ -274,8 +295,8 @@ cglobal synth_filter_inner, 0, 6 + 4 * ARCH_X86_64, 7 + 6 * 
ARCH_X86_64, \
 %endif
 .mainloop
 ; m1 = a  m2 = b  m3 = c  m4 = d
-pxor  m3, m3
-pxor  m4, m4
+SETZERO   m3
+SETZERO   m4
 mova  m1, [buf2 + i]
 mova  m2, [buf2 + i + 16 * 4]
 %if ARCH_X86_32
@@ -292,8 +313,8 @@ cglobal synth_filter_inner, 0, 6 + 4 * ARCH_X86_64, 7 + 6 * 
ARCH_X86_64, \
 %define ptr2 r7q ; must be loaded
 %define win  r8q
 %define jr9q
-pxor  m9, m9
-pxor m10, m10
+SETZERO   m9
+SETZERO  m10
 mova  m7, [buf2 + i + mmsize]
 mova  m8, [buf2 + i + mmsize + 16 * 4]
 lea  win, [windowq + i]
@@ -350,3 +371,11 @@ cglobal synth_filter_inner, 0, 6 + 4 * ARCH_X86_64, 7 + 6 
* ARCH_X86_64, \
 subi, (ARCH_X86_64 + 1) * mmsize
 jge.mainloop
 RET
+%endmacro
+
+%if ARCH_X86_32
+INIT_XMM sse
+SYNTH_FILTER
+%endif
+INIT_XMM sse2
+SYNTH_FILTER
diff --git a/libavcodec/x86/dcadsp_init.c b/libavcodec/x86/dcadsp_init.c
index 65e3db5..5b77985 100644
--- a/libavcodec/x86/dcadsp_init.c
+++ b/libavcodec/x86/dcadsp_init.c
@@ -56,25 +56,31 @@ av_cold void ff_dcadsp_init_x86(DCADSPContext *s)
 }
 }
 
-void ff_synth_filter_inner_sse2(float *synth_buf_ptr, float synth_buf2[32],
-const float window[512],
-float out[32], intptr_t offset, float scale);
 
-#if HAVE_YASM
-static void synth_filter_sse2(FFTContext *imdct,
-  float *synth_buf_ptr, int *synth_buf_offset,
-  float synth_buf2[32], const float window[512],
-  float out[32], const float in[32], float scale)
-{
-float *synth_buf= synth_buf_ptr + *synth_buf_offset;
-
-imdct->imdct_half(imdct, synth_buf, in);
+#define SYNTH_FILTER_FUNC(opt) 
\
+vo

[libav-devel] [PATCH 3/3 v2] x86/synth_filter: add synth_filter_fma3

2014-03-20 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/x86/dcadsp.asm| 22 ++
 libavcodec/x86/dcadsp_init.c |  6 ++
 2 files changed, 28 insertions(+)

diff --git a/libavcodec/x86/dcadsp.asm b/libavcodec/x86/dcadsp.asm
index 662cb96..59d96bf 100644
--- a/libavcodec/x86/dcadsp.asm
+++ b/libavcodec/x86/dcadsp.asm
@@ -230,6 +230,14 @@ DCA_LFE_FIR 1
 SHUF m11,  ptr2 + j + (15 - 3) * 4 - mmsize, m12
 mova m12, [ptr1 + j + mmsize]
 %endif
+%if cpuflag(fma3)
+fmaddps   m2, m6,  [win + %1 + j + 16 * 4], m2
+fnmaddps  m1, m5,  [win + %1 + j], m1
+%if ARCH_X86_64
+fmaddps   m8, m12, [win + %1 + j + mmsize + 16 * 4], m8
+fnmaddps  m7, m11, [win + %1 + j + mmsize], m7
+%endif
+%else ; non-FMA
 mulps m6, m6,  [win + %1 + j + 16 * 4]
 mulps m5, m5,  [win + %1 + j]
 %if ARCH_X86_64
@@ -242,6 +250,7 @@ DCA_LFE_FIR 1
 addps m8, m8, m12
 subps m7, m7, m11
 %endif
+%endif ; cpuflag(fma3)
 ;~ c += window[i + j + 32] * (synth_buf[16 + i + j])
 ;~ d += window[i + j + 48] * (synth_buf[31 - i + j])
 SHUF  m6,  ptr2 + j + (31 - 3) * 4, m5
@@ -250,6 +259,14 @@ DCA_LFE_FIR 1
 SHUF m12,  ptr2 + j + (31 - 3) * 4 - mmsize, m11
 mova m11, [ptr1 + j + mmsize + 16 * 4]
 %endif
+%if cpuflag(fma3)
+fmaddps   m3, m5,  [win + %1 + j + 32 * 4], m3
+fmaddps   m4, m6,  [win + %1 + j + 48 * 4], m4
+%if ARCH_X86_64
+fmaddps   m9, m11, [win + %1 + j + mmsize + 32 * 4], m9
+fmaddps  m10, m12, [win + %1 + j + mmsize + 48 * 4], m10
+%endif
+%else ; non-FMA
 mulps m5, m5,  [win + %1 + j + 32 * 4]
 mulps m6, m6,  [win + %1 + j + 48 * 4]
 %if ARCH_X86_64
@@ -262,6 +279,7 @@ DCA_LFE_FIR 1
 addps m9, m9, m11
 addpsm10, m10, m12
 %endif
+%endif ; cpuflag(fma3)
 subj, 64 * 4
 %endmacro
 
@@ -400,3 +418,7 @@ INIT_XMM sse2
 SYNTH_FILTER
 INIT_YMM avx
 SYNTH_FILTER
+%if HAVE_FMA3_EXTERNAL
+INIT_YMM fma3
+SYNTH_FILTER
+%endif
diff --git a/libavcodec/x86/dcadsp_init.c b/libavcodec/x86/dcadsp_init.c
index d7e0d65..beef288 100644
--- a/libavcodec/x86/dcadsp_init.c
+++ b/libavcodec/x86/dcadsp_init.c
@@ -82,6 +82,9 @@ SYNTH_FILTER_FUNC(sse)
 #endif
 SYNTH_FILTER_FUNC(sse2)
 SYNTH_FILTER_FUNC(avx)
+#if HAVE_FMA3_EXTERNAL
+SYNTH_FILTER_FUNC(fma3)
+#endif
 #endif /* HAVE_YASM */
 
 av_cold void ff_synth_filter_init_x86(SynthFilterContext *s)
@@ -100,5 +103,8 @@ av_cold void ff_synth_filter_init_x86(SynthFilterContext *s)
 if (EXTERNAL_AVX(cpu_flags)) {
 s->synth_filter_float = synth_filter_avx;
 }
+if (EXTERNAL_FMA3(cpu_flags)) {
+s->synth_filter_float = synth_filter_fma3;
+}
 #endif /* HAVE_YASM */
 }
-- 
1.8.3.2

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


[libav-devel] [PATCH 2/3 v2] x86/synth_filter: add synth_filter_avx

2014-03-20 Thread James Almer
Sandy Bridge Win64:
180 cycles in ff_synth_filter_inner_sse2
150 cycles in ff_synth_filter_inner_avx

Also switch some instructions to a three operand format to avoid
assembly errors with Yasm 1.1.0 or older.

Signed-off-by: James Almer 
---
 libavcodec/x86/dcadsp.asm| 85 +++-
 libavcodec/x86/dcadsp_init.c |  4 +++
 2 files changed, 57 insertions(+), 32 deletions(-)

diff --git a/libavcodec/x86/dcadsp.asm b/libavcodec/x86/dcadsp.asm
index 970ec3d..662cb96 100644
--- a/libavcodec/x86/dcadsp.asm
+++ b/libavcodec/x86/dcadsp.asm
@@ -200,18 +200,22 @@ DCA_LFE_FIR 0
 DCA_LFE_FIR 1
 
 %macro SETZERO 1
-%if cpuflag(sse2)
+%if cpuflag(sse2) && notcpuflag(avx)
 pxor  %1, %1
 %else
 xorps %1, %1, %1
 %endif
 %endmacro
 
-%macro SHUF 2
-%if cpuflag(sse2)
-pshufd%1, %2, q0123
+%macro SHUF 3
+%if cpuflag(avx)
+mova  %3, [%2 - 16]
+vperm2f128%1, %3, %3, 1
+vshufps   %1, %1, %1, q0123
+%elif cpuflag(sse2)
+pshufd%1, [%2], q0123
 %else
-mova  %1, %2
+mova  %1, [%2]
 shufps%1, %1, q0123
 %endif
 %endmacro
@@ -220,43 +224,43 @@ DCA_LFE_FIR 1
 ; reading backwards:  ptr1 = synth_buf + j + i; ptr2 = synth_buf + j - i
 ;~ a += window[i + j]  * (-synth_buf[15 - i + j])
 ;~ b += window[i + j + 16] * (synth_buf[i + j])
-SHUF  m5, [ptr2 + j + (15 - 3) * 4]
+SHUF  m5,  ptr2 + j + (15 - 3) * 4, m6
 mova  m6, [ptr1 + j]
 %if ARCH_X86_64
-SHUF m11, [ptr2 + j + (15 - 3) * 4 - mmsize]
+SHUF m11,  ptr2 + j + (15 - 3) * 4 - mmsize, m12
 mova m12, [ptr1 + j + mmsize]
 %endif
-mulps m6, [win  + %1 + j + 16 * 4]
-mulps m5, [win  + %1 + j]
+mulps m6, m6,  [win + %1 + j + 16 * 4]
+mulps m5, m5,  [win + %1 + j]
 %if ARCH_X86_64
-mulpsm12, [win  + %1 + j + mmsize + 16 * 4]
-mulpsm11, [win  + %1 + j + mmsize]
+mulpsm12, m12, [win + %1 + j + mmsize + 16 * 4]
+mulpsm11, m11, [win + %1 + j + mmsize]
 %endif
-addps m2, m6
-subps m1, m5
+addps m2, m2, m6
+subps m1, m1, m5
 %if ARCH_X86_64
-addps m8, m12
-subps m7, m11
+addps m8, m8, m12
+subps m7, m7, m11
 %endif
 ;~ c += window[i + j + 32] * (synth_buf[16 + i + j])
 ;~ d += window[i + j + 48] * (synth_buf[31 - i + j])
-SHUF  m6, [ptr2 + j + (31 - 3) * 4]
+SHUF  m6,  ptr2 + j + (31 - 3) * 4, m5
 mova  m5, [ptr1 + j + 16 * 4]
 %if ARCH_X86_64
-SHUF m12, [ptr2 + j + (31 - 3) * 4 - mmsize]
+SHUF m12,  ptr2 + j + (31 - 3) * 4 - mmsize, m11
 mova m11, [ptr1 + j + mmsize + 16 * 4]
 %endif
-mulps m5, [win  + %1 + j + 32 * 4]
-mulps m6, [win  + %1 + j + 48 * 4]
+mulps m5, m5,  [win + %1 + j + 32 * 4]
+mulps m6, m6,  [win + %1 + j + 48 * 4]
 %if ARCH_X86_64
-mulpsm11, [win  + %1 + j + mmsize + 32 * 4]
-mulpsm12, [win  + %1 + j + mmsize + 48 * 4]
+mulpsm11, m11, [win + %1 + j + mmsize + 32 * 4]
+mulpsm12, m12, [win + %1 + j + mmsize + 48 * 4]
 %endif
-addps m3, m5
-addps m4, m6
+addps m3, m3, m5
+addps m4, m4, m6
 %if ARCH_X86_64
-addps m9, m11
-addpsm10, m12
+addps m9, m9, m11
+addpsm10, m10, m12
 %endif
 subj, 64 * 4
 %endmacro
@@ -269,25 +273,34 @@ cglobal synth_filter_inner, 0, 6 + 4 * ARCH_X86_64, 7 + 6 
* ARCH_X86_64, \
   synth_buf, synth_buf2, window, out, off, scale
 %define scale m0
 %if ARCH_X86_32 || WIN64
-%if cpuflag(sse2)
+%if cpuflag(sse2) && notcpuflag(avx)
 movd   scale, scalem
+SPLATDm0
 %else
-movss  scale, scalem
+VBROADCASTSS  m0, scalem
 %endif
 ; Make sure offset is in a register and not on the stack
 %define OFFQ  r4q
 %else
+SPLATD  xmm0
+%if cpuflag(avx)
+vinsertf128   m0, m0, xmm0, 1
+%endif
 %define OFFQ  offq
 %endif
-SPLATDm0
 ; prepare inner counter limit 1
 mov  r5q, 480
 sub  r5q, offmp
 and  r5q, -64
 shl  r5q, 2
+%if ARCH_X86_32 || notcpuflag(avx)
 mov OFFQ, r5q
 %define ir5q
 movi, 16 * 4 - (ARCH_X86_64 + 1) * mmsize  ; main loop counter
+%else
+%define i 0
+%define OFFQ  r5q
+%endif
 
 %define buf2 synth_buf2q
 %if ARCH_X86_32
@@ -306,8 +319,10 @@ cglobal synth_filter_inner, 0, 6 + 4 * ARCH_X86_64, 7 + 6 
* ARCH_X86_64, \
 %define jr3q
 mov  win, windowm
 mov ptr1, synth_bufm
+%if ARCH_X86_32 || notcpuflag(avx)
 add  win, i
 add ptr1, i
+%endif
 %else ; ARCH_X86_64
 %define ptr1 r6q
 %define ptr2 r7q ; must be loaded
@@ -323,7 +33

Re: [libav-devel] [PATCH] Alias PIX image encoder and decoder

2014-03-20 Thread Justin Ruggles
On 03/20/2014 11:57 AM, Vittorio Giovara wrote:
> ---
> Some more tweaks Justin asked me.
> Vittorio
> 
>  Changelog|   1 +
>  doc/general.texi |   2 +
>  libavcodec/Makefile  |   2 +
>  libavcodec/aliaspixdec.c | 114 
>  libavcodec/aliaspixenc.c | 132 
> +++
>  libavcodec/allcodecs.c   |   1 +
>  libavcodec/avcodec.h |   1 +
>  libavcodec/codec_desc.c  |   7 +++
>  libavcodec/version.h |   4 +-
>  libavformat/img2.c   |   1 +
>  libavformat/img2enc.c|   2 +-
>  11 files changed, 264 insertions(+), 3 deletions(-)
>  create mode 100644 libavcodec/aliaspixdec.c
>  create mode 100644 libavcodec/aliaspixenc.c
[...]
> +bytestream2_init(&gb, avpkt->data, avpkt->size);
> +
> +if (bytestream2_get_bytes_left(&gb) < ALIAS_HEADER_SIZE) {
> +av_log(avctx, AV_LOG_ERROR, "Header too small %d.\n", avpkt->size);
> +return AVERROR_INVALIDDATA;
> +}
> +
> +width  = bytestream2_get_be16(&gb);
> +height = bytestream2_get_be16(&gb);
> +bytestream2_skip(&gb, 4); // obsolete X, Y offset
> +format = bytestream2_get_be16(&gb);

since you check the size first, you should use the unchecked bytestream2
functions (i.e. add 'u' to the end of all 4)

also, why not call it 'depth' instead of 'format' to match your encoder?

> +
> +if (format == 24)
> +avctx->pix_fmt = AV_PIX_FMT_BGR24;
> +else if (format == 8)
> +avctx->pix_fmt = AV_PIX_FMT_GRAY8;
> +else {
> +av_log(avctx, AV_LOG_ERROR, "Invalid pixel format.\n");
> +return AVERROR_INVALIDDATA;
> +}
> +
> +ret = ff_set_dimensions(avctx, width, height);
> +if (ret < 0)
> +return ret;
> +
> +ret = ff_get_buffer(avctx, f, 0);
> +if (ret < 0)
> +return ret;
> +
> +f->pict_type = AV_PICTURE_TYPE_I;
> +f->key_frame = 1;
> +
> +while (bytestream2_get_bytes_left(&gb) > 0) {
> +int i;
> +
> +/* set buffer at the right position at every new line */
> +if (width == avctx->width) {
> +width = 0;
> +out_buf = f->data[0] + f->linesize[0] * y++;
> +}
> +
> +/* read packet and copy data */
> +count = bytestream2_get_byte(&gb);

same here bytestream2_get_byteu(&gb)

> +if (!count || width + count > avctx->width) {
> +av_log(avctx, AV_LOG_ERROR, "Invalid run length %d.\n", count);
> +return AVERROR_INVALIDDATA;
> +}
> +
> +if (avctx->pix_fmt == AV_PIX_FMT_BGR24) {

you could check 'format' instead of avctx->pix_fmt.

[...]
> +static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
> +const AVFrame *frame, int *got_packet)
> +{
> +int width, height, depth, i, j, length, ret;
> +uint8_t *in_buf, *buf;
> +
> +avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
> +avctx->coded_frame->key_frame = 1;
> +
> +width  = avctx->width;
> +height = avctx->height;
> +
> +if (width > 65535 || height > 65536 ||

Looks like a typo for height.

> +width * height >= INT_MAX / 4 - 10LL) {
> +av_log(avctx, AV_LOG_ERROR, "Invalid image size %dx%d.\n", width, 
> height);
> +return AVERROR_INVALIDDATA;
> +}
> +
> +switch (avctx->pix_fmt) {
> +case AV_PIX_FMT_GRAY8:
> +depth = 8;
> +break;
> +case AV_PIX_FMT_BGR24:
> +depth = 24;
> +break;
> +default:
> +return AVERROR_INVALIDDATA;
> +}
> +
> +length = ALIAS_HEADER_SIZE + 4 * width * height; // max possible
> +if ((ret = ff_alloc_packet(pkt, length)) < 0) {
> +av_log(avctx, AV_LOG_ERROR, "Error getting output packet of size 
> %d.\n", length);
> +return ret;
> +}
> +
> +buf = pkt->data;
> +
> +/* Encode header. */
> +bytestream_put_be16(&buf, width);
> +bytestream_put_be16(&buf, height);
> +bytestream_put_be32(&buf, 0L); /* X, Y offset */
> +bytestream_put_be16(&buf, depth);
> +
> +for (j = 0; j < height; j++) {
> +in_buf = frame->data[0] + frame->linesize[0] * j;
> +for (i = 0; i < width; ) {
> +int count = 0;
> +int pixel;
> +
> +if (avctx->pix_fmt == AV_PIX_FMT_GRAY8) {

you could check 'depth' instead of avctx->pix_fmt.

> +pixel = *in_buf;
> +while (count < 255 && count + i < width && pixel == *in_buf) 
> {
> +count++;
> +in_buf++;
> +}
> +} else { /* AV_PIX_FMT_BGR24 */
> +pixel = AV_RB24(in_buf);
> +while (count < 255 && count + i < width &&
> +   pixel == AV_RB24(in_buf)) {
> +count++;
> +in_buf += 3;
> +}
> +}
> +i += count;
> +bytestream_put_byte(&buf, count);
> +bytestream_put_be24(&buf, pixe

Re: [libav-devel] [PATCH] vdpau: add av_vdpau_get_level()

2014-03-20 Thread Rémi Denis-Courmont
Le jeudi 20 mars 2014, 18:31:19 wm4 a écrit :
> On Thu, 20 Mar 2014 19:10:23 +0200
> 
> Rémi Denis-Courmont  wrote:
> > Le jeudi 20 mars 2014, 19:03:29 Rémi Denis-Courmont a écrit :
> > > This was the last bit of codec-specific handling in VLC.
> > 
> > Well, almost last. (Still special H.264 case for reference frames count.)
> 
> av_vdpau_get_nb_reference_frames()?

I think creating (and destroying) the VdpDecoder from within lavc would make 
more sense. At least VLC does not use the reference frames count for any other 
purpose than calling VdpDecoderCreate().

Of course, the level check could also be moved to lavc as well, in which case 
this patch would be superseded.

-- 
Rémi Denis-Courmont
http://www.remlab.net/

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

Re: [libav-devel] [PATCH] vdpau: add av_vdpau_get_level()

2014-03-20 Thread wm4
On Thu, 20 Mar 2014 19:10:23 +0200
Rémi Denis-Courmont  wrote:

> Le jeudi 20 mars 2014, 19:03:29 Rémi Denis-Courmont a écrit :
> > This was the last bit of codec-specific handling in VLC.
> 
> Well, almost last. (Still special H.264 case for reference frames count.)

av_vdpau_get_nb_reference_frames()?
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] vdpau: add av_vdpau_get_level()

2014-03-20 Thread Rémi Denis-Courmont
Le jeudi 20 mars 2014, 19:03:29 Rémi Denis-Courmont a écrit :
> This was the last bit of codec-specific handling in VLC.

Well, almost last. (Still special H.264 case for reference frames count.)
-- 
Rémi Denis-Courmont
http://www.remlab.net/

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

[libav-devel] [PATCH] vdpau: add av_vdpau_get_level()

2014-03-20 Thread Rémi Denis-Courmont
This was the last bit of codec-specific handling in VLC.
---
 doc/APIchanges   |  3 +++
 libavcodec/vdpau.c   | 28 
 libavcodec/vdpau.h   | 14 ++
 libavcodec/version.h |  4 ++--
 4 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 38d18bc..cb19cf8 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil: 2013-12-xx
 
 API changes, most recent first:
 
+2014-xx-xx - xxx - lavc 55.35.0 - vdpau.h
+  Add av_vdpau_get_level().
+
 2014-xx-xx - xxx - lavu 53.06.0 - pixfmt.h
   Add RGBA64 pixel format and variants.
 
diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c
index 5ad5d06..e650009 100644
--- a/libavcodec/vdpau.c
+++ b/libavcodec/vdpau.c
@@ -131,6 +131,34 @@ do {\
 return AVERROR(EINVAL);
 }
 
+int av_vdpau_get_level(AVCodecContext *avctx, unsigned *levelp)
+{
+unsigned level = avctx->level;
+
+if (level == FF_LEVEL_UNKNOWN)
+return AVERROR(EINVAL);
+
+switch (avctx->codec_id)
+{
+case AV_CODEC_ID_MPEG1VIDEO:
+level = VDP_DECODER_LEVEL_MPEG1_NA;
+break;
+case AV_CODEC_ID_MPEG2VIDEO:
+level = VDP_DECODER_LEVEL_MPEG2_HL;
+break;
+case AV_CODEC_ID_H263:
+level = VDP_DECODER_LEVEL_MPEG4_PART2_ASP_L5;
+break;
+case AV_CODEC_ID_H264:
+if ((avctx->profile & FF_PROFILE_H264_INTRA) && level == 11)
+level = VDP_DECODER_LEVEL_H264_1b;
+break;
+}
+
+*levelp = level;
+return 0;
+}
+
 AVVDPAUContext *av_vdpau_alloc_context(void)
 {
 return av_mallocz(sizeof(AVVDPAUContext));
diff --git a/libavcodec/vdpau.h b/libavcodec/vdpau.h
index 75cb1bf..ec8686f 100644
--- a/libavcodec/vdpau.h
+++ b/libavcodec/vdpau.h
@@ -150,6 +150,20 @@ AVVDPAUContext *av_vdpau_alloc_context(void);
  */
 int av_vdpau_get_profile(AVCodecContext *avctx, VdpDecoderProfile *profile);
 
+/**
+ * Get a decoder level to match with the capabilities of a VDPAU decoder
+ * (from VdpDecoderQueryCapabilities()).
+ * Should be called from the AVCodecContext.get_format() callback.
+ *
+ * @param avctx the codec context being used for decoding the stream
+ * @param level a pointer into which the result will be written on success.
+ *The value is undefined if this function returns an error.
+ *
+ * @return 0 on success (non-negative), a negative AVERROR on failure.
+ */
+int av_vdpau_get_level(AVCodecContext *avctx, unsigned *profile);
+
+
 #if FF_API_CAP_VDPAU
 /** @brief The videoSurface is used for rendering. */
 #define FF_VDPAU_STATE_USED_FOR_RENDER 1
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 5ab49d5..d2f80ad 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,8 +29,8 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR 55
-#define LIBAVCODEC_VERSION_MINOR 34
-#define LIBAVCODEC_VERSION_MICRO  1
+#define LIBAVCODEC_VERSION_MINOR 35
+#define LIBAVCODEC_VERSION_MICRO  0
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
-- 
1.9.1

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


Re: [libav-devel] [PATCH 3/3] vaapi: switch ff_vaapi_get_surface_id from Picture to AVFrame

2014-03-20 Thread Anton Khirnov

The set looks fine to me, and appears to work pushing.
Thanks

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


[libav-devel] [PATCH] Alias PIX image encoder and decoder

2014-03-20 Thread Vittorio Giovara
---
Some more tweaks Justin asked me.
Vittorio

 Changelog|   1 +
 doc/general.texi |   2 +
 libavcodec/Makefile  |   2 +
 libavcodec/aliaspixdec.c | 114 
 libavcodec/aliaspixenc.c | 132 +++
 libavcodec/allcodecs.c   |   1 +
 libavcodec/avcodec.h |   1 +
 libavcodec/codec_desc.c  |   7 +++
 libavcodec/version.h |   4 +-
 libavformat/img2.c   |   1 +
 libavformat/img2enc.c|   2 +-
 11 files changed, 264 insertions(+), 3 deletions(-)
 create mode 100644 libavcodec/aliaspixdec.c
 create mode 100644 libavcodec/aliaspixenc.c

diff --git a/Changelog b/Changelog
index 279c0d8..0f1007d 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
 version :
 - compand audio filter
 - shuffleplanes filter
+- Alias PIX image encoder and decoder
 
 
 version 10:
diff --git a/doc/general.texi b/doc/general.texi
index 8c0cb1b..dce4c0a 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -424,6 +424,8 @@ following image formats are supported:
 @item Name @tab Encoding @tab Decoding @tab Comments
 @item .Y.U.V   @tab X @tab X
 @tab one raw file per component
+@item Alias PIX@tab X @tab X
+@tab Alias/Wavefront PIX image format
 @item animated GIF @tab X @tab X
 @tab Only uncompressed GIFs are generated.
 @item BMP  @tab X @tab X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index c04b3f1..8f531fc 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -88,6 +88,8 @@ OBJS-$(CONFIG_AC3_FIXED_ENCODER)   += ac3enc_fixed.o 
ac3enc.o ac3tab.o ac3.o
 OBJS-$(CONFIG_AIC_DECODER) += aic.o
 OBJS-$(CONFIG_ALAC_DECODER)+= alac.o alac_data.o
 OBJS-$(CONFIG_ALAC_ENCODER)+= alacenc.o alac_data.o
+OBJS-$(CONFIG_ALIAS_PIX_DECODER)   += aliaspixdec.o
+OBJS-$(CONFIG_ALIAS_PIX_ENCODER)   += aliaspixenc.o
 OBJS-$(CONFIG_ALS_DECODER) += alsdec.o bgmc.o mpeg4audio.o
 OBJS-$(CONFIG_AMRNB_DECODER)   += amrnbdec.o celp_filters.o   \
   celp_math.o acelp_filters.o \
diff --git a/libavcodec/aliaspixdec.c b/libavcodec/aliaspixdec.c
new file mode 100644
index 000..47cd5e2
--- /dev/null
+++ b/libavcodec/aliaspixdec.c
@@ -0,0 +1,114 @@
+/*
+ * Alias PIX image decoder
+ * Copyright (C) 2014 Vittorio Giovara 
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/intreadwrite.h"
+
+#include "avcodec.h"
+#include "bytestream.h"
+#include "internal.h"
+
+#define ALIAS_HEADER_SIZE 10
+
+static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
+AVPacket *avpkt)
+{
+AVFrame *f = data;
+GetByteContext gb;
+int width, height, ret, format, pixel;
+uint8_t *out_buf;
+uint8_t count;
+int y = 0;
+
+bytestream2_init(&gb, avpkt->data, avpkt->size);
+
+if (bytestream2_get_bytes_left(&gb) < ALIAS_HEADER_SIZE) {
+av_log(avctx, AV_LOG_ERROR, "Header too small %d.\n", avpkt->size);
+return AVERROR_INVALIDDATA;
+}
+
+width  = bytestream2_get_be16(&gb);
+height = bytestream2_get_be16(&gb);
+bytestream2_skip(&gb, 4); // obsolete X, Y offset
+format = bytestream2_get_be16(&gb);
+
+if (format == 24)
+avctx->pix_fmt = AV_PIX_FMT_BGR24;
+else if (format == 8)
+avctx->pix_fmt = AV_PIX_FMT_GRAY8;
+else {
+av_log(avctx, AV_LOG_ERROR, "Invalid pixel format.\n");
+return AVERROR_INVALIDDATA;
+}
+
+ret = ff_set_dimensions(avctx, width, height);
+if (ret < 0)
+return ret;
+
+ret = ff_get_buffer(avctx, f, 0);
+if (ret < 0)
+return ret;
+
+f->pict_type = AV_PICTURE_TYPE_I;
+f->key_frame = 1;
+
+while (bytestream2_get_bytes_left(&gb) > 0) {
+int i;
+
+/* set buffer at the right position at every new line */
+if (width == avctx->width) {
+width = 0;
+out_buf = f->data[0] + f->linesize[0] * y++;
+}
+
+/* read packet and copy data */
+count = bytestream2_get_byte(&gb);
+if (!count || width + count > avctx->width) {
+av_log(avctx, AV_LOG_ERROR, "Invalid run l

[libav-devel] [PATCH] Alias PIX image encoder and decoder

2014-03-20 Thread Vittorio Giovara
---
 Changelog|   1 +
 doc/general.texi |   2 +
 libavcodec/Makefile  |   2 +
 libavcodec/aliaspixdec.c | 115 +
 libavcodec/aliaspixenc.c | 131 +++
 libavcodec/allcodecs.c   |   1 +
 libavcodec/avcodec.h |   1 +
 libavcodec/codec_desc.c  |   7 +++
 libavcodec/version.h |   4 +-
 libavformat/img2.c   |   1 +
 libavformat/img2enc.c|   2 +-
 11 files changed, 264 insertions(+), 3 deletions(-)
 create mode 100644 libavcodec/aliaspixdec.c
 create mode 100644 libavcodec/aliaspixenc.c

diff --git a/Changelog b/Changelog
index 279c0d8..0f1007d 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
 version :
 - compand audio filter
 - shuffleplanes filter
+- Alias PIX image encoder and decoder
 
 
 version 10:
diff --git a/doc/general.texi b/doc/general.texi
index 8c0cb1b..dce4c0a 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -424,6 +424,8 @@ following image formats are supported:
 @item Name @tab Encoding @tab Decoding @tab Comments
 @item .Y.U.V   @tab X @tab X
 @tab one raw file per component
+@item Alias PIX@tab X @tab X
+@tab Alias/Wavefront PIX image format
 @item animated GIF @tab X @tab X
 @tab Only uncompressed GIFs are generated.
 @item BMP  @tab X @tab X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index c04b3f1..8f531fc 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -88,6 +88,8 @@ OBJS-$(CONFIG_AC3_FIXED_ENCODER)   += ac3enc_fixed.o 
ac3enc.o ac3tab.o ac3.o
 OBJS-$(CONFIG_AIC_DECODER) += aic.o
 OBJS-$(CONFIG_ALAC_DECODER)+= alac.o alac_data.o
 OBJS-$(CONFIG_ALAC_ENCODER)+= alacenc.o alac_data.o
+OBJS-$(CONFIG_ALIAS_PIX_DECODER)   += aliaspixdec.o
+OBJS-$(CONFIG_ALIAS_PIX_ENCODER)   += aliaspixenc.o
 OBJS-$(CONFIG_ALS_DECODER) += alsdec.o bgmc.o mpeg4audio.o
 OBJS-$(CONFIG_AMRNB_DECODER)   += amrnbdec.o celp_filters.o   \
   celp_math.o acelp_filters.o \
diff --git a/libavcodec/aliaspixdec.c b/libavcodec/aliaspixdec.c
new file mode 100644
index 000..6b55614
--- /dev/null
+++ b/libavcodec/aliaspixdec.c
@@ -0,0 +1,115 @@
+/*
+ * Alias PIX image decoder
+ * Copyright (C) 2014 Vittorio Giovara 
+ *
+ * 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 "avcodec.h"
+#include "bytestream.h"
+#include "internal.h"
+
+#define ALIAS_HEADER_SIZE 10
+
+static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
+AVPacket *avpkt)
+{
+AVFrame *f = data;
+GetByteContext gb;
+int width, height, ret, format;
+uint8_t *out_buf;
+uint8_t count, r, g, b;
+int y = 0;
+
+bytestream2_init(&gb, avpkt->data, avpkt->size);
+
+if (bytestream2_get_bytes_left(&gb) < ALIAS_HEADER_SIZE) {
+av_log(avctx, AV_LOG_ERROR, "Header too small %d.\n", avpkt->size);
+return AVERROR_INVALIDDATA;
+}
+
+width  = bytestream2_get_be16(&gb);
+height = bytestream2_get_be16(&gb);
+bytestream2_skip(&gb, 4); // obsolete X, Y offset
+format = bytestream2_get_be16(&gb);
+
+if (format == 24)
+avctx->pix_fmt = AV_PIX_FMT_BGR24;
+else if (format == 8)
+avctx->pix_fmt = AV_PIX_FMT_GRAY8;
+else {
+av_log(avctx, AV_LOG_ERROR, "Invalid pixel format.\n");
+return AVERROR_INVALIDDATA;
+}
+
+ret = ff_set_dimensions(avctx, width, height);
+if (ret < 0)
+return ret;
+
+ret = ff_get_buffer(avctx, f, 0);
+if (ret < 0)
+return ret;
+
+f->pict_type = AV_PICTURE_TYPE_I;
+f->key_frame = 1;
+
+while (bytestream2_get_bytes_left(&gb) > 0) {
+int i;
+
+/* set buffer at the right position at every new line */
+if (width == avctx->width) {
+width = 0;
+out_buf = f->data[0] + f->linesize[0] * y++;
+}
+
+/* read packet and copy data */
+count = bytestream2_get_byte(&gb);
+if (!count || width + count > avctx->width) {
+av_log(avctx, AV_LOG_ERROR, "Invalid run length %d.\n", count);
+return AVERROR_INVALIDDATA;
+}
+
+   

Re: [libav-devel] THE GRAND DSPUTIL REFACTORING (act VII)

2014-03-20 Thread Diego Biurrun
On Thu, Mar 20, 2014 at 02:33:52PM +0100, Luca Barbato wrote:
> On 19/03/14 19:12, Diego Biurrun wrote:
> > Finally, I start to put dsputil on a diet, like the doctor ordered.
> > 
> > There are still preparatory patches that pave the way for later changes,
> > but some big chunks are broken out of dsputil and off into separate
> > structures.
> 
> We aren't using any high bit version anywhere? I'm surprised, Vittorio
> might need them for something soon.

I'm not sure what this comment refers to ...

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


Re: [libav-devel] THE GRAND DSPUTIL REFACTORING (act VII)

2014-03-20 Thread Luca Barbato
On 19/03/14 19:12, Diego Biurrun wrote:
> Finally, I start to put dsputil on a diet, like the doctor ordered.
> 
> There are still preparatory patches that pave the way for later changes,
> but some big chunks are broken out of dsputil and off into separate
> structures.
> 

We aren't using any high bit version anywhere? I'm surprised, Vittorio
might need them for something soon.

lu

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


Re: [libav-devel] [PATCH 083/132] x86: hpeldsp: Keep all rnd_template instantiations in hpeldsp_init

2014-03-20 Thread Luca Barbato
On 19/03/14 19:13, Diego Biurrun wrote:
> There is no point in having a separate file just for the instantiation
> that provides the public functions.
> ---
>  libavcodec/x86/Makefile   |  4 +---
>  libavcodec/x86/hpeldsp_init.c |  9 +
>  libavcodec/x86/rnd_mmx.c  | 37 -
>  3 files changed, 10 insertions(+), 40 deletions(-)
>  delete mode 100644 libavcodec/x86/rnd_mmx.c
> 

Probably ok.

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


Re: [libav-devel] [PATCH 079/132] dsputil: Move RV40-specific bits into rv40dsp

2014-03-20 Thread Luca Barbato
On 19/03/14 19:13, Diego Biurrun wrote:
> ---
>  libavcodec/dsputil.c  | 22 ---
>  libavcodec/dsputil.h  |  6 ---
>  libavcodec/dsputil_template.c | 52 -
>  libavcodec/rv40dsp.c  | 90 
> ---
>  4 files changed, 85 insertions(+), 85 deletions(-)
> 

Makes sense.

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


Re: [libav-devel] [PATCH 075/132] dsputil_template: Move bits that are used templatized into separate file

2014-03-20 Thread Luca Barbato
On 19/03/14 19:13, Diego Biurrun wrote:
> This allows detemplatizing the bits that are not instantiated twice.
> ---
>  libavcodec/dsputil.c |  3 ++-
>  libavcodec/dsputil_template.c| 27 -
>  libavcodec/dsputilenc_template.c | 51 
> 
>  3 files changed, 53 insertions(+), 28 deletions(-)
>  create mode 100644 libavcodec/dsputilenc_template.c
> 

since it is mostly draw_edges and clear_block, maybe you could fold some
of those patches and move those two out directly.

(the end result is ok, the intermediate steps are a bit hard to follow)

lu

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


Re: [libav-devel] [PATCH 080/132] dsputil: Move draw_edges and clear_block* out of dsputil_template

2014-03-20 Thread Luca Barbato
On 19/03/14 19:13, Diego Biurrun wrote:
> The functions are not used templatized.
> ---
>  libavcodec/dsputil.c  | 38 ++
>  libavcodec/dsputil_template.c | 40 
>  2 files changed, 38 insertions(+), 40 deletions(-)
> 

Ok.

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


Re: [libav-devel] [PATCH 073/132] dsputil: Move thirdpel-related bits into their own context

2014-03-20 Thread Luca Barbato
On 19/03/14 19:13, Diego Biurrun wrote:
> ---
>  configure  |   3 +-
>  doc/optimization.txt   |   3 -
>  libavcodec/Makefile|   1 +
>  libavcodec/dsputil.c   | 299 +---
>  libavcodec/dsputil.h   |  16 --
>  libavcodec/h264qpel_template.c |   1 +
>  libavcodec/hpel_template.c |  45 --
>  libavcodec/hpeldsp_template.c  |   1 +
>  libavcodec/svq3.c  |  18 ++-
>  libavcodec/tpel_template.c |  80 ++
>  libavcodec/tpeldsp.c   | 333 
> +
>  libavcodec/tpeldsp.h   |  59 
>  12 files changed, 489 insertions(+), 370 deletions(-)
>  create mode 100644 libavcodec/tpel_template.c
>  create mode 100644 libavcodec/tpeldsp.c
>  create mode 100644 libavcodec/tpeldsp.h
> 

Ok.

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


Re: [libav-devel] [PATCH] float_dsp: Replace arch optimization ifdefs by if cascade

2014-03-20 Thread Luca Barbato
On 20/03/14 14:16, Diego Biurrun wrote:
> Arch-specific optimizations are handled this way everywhere else.
> ---
>  libavutil/float_dsp.c | 17 -
>  1 file changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/libavutil/float_dsp.c b/libavutil/float_dsp.c
> index 6ff7e2f..aabc800 100644
> --- a/libavutil/float_dsp.c
> +++ b/libavutil/float_dsp.c
> @@ -124,15 +124,14 @@ av_cold void avpriv_float_dsp_init(AVFloatDSPContext 
> *fdsp, int bit_exact)
>  fdsp->butterflies_float = butterflies_float_c;
>  fdsp->scalarproduct_float = avpriv_scalarproduct_float_c;
>  
> -#if   ARCH_AARCH64
> -ff_float_dsp_init_aarch64(fdsp);
> -#elif ARCH_ARM
> -ff_float_dsp_init_arm(fdsp);
> -#elif ARCH_PPC
> -ff_float_dsp_init_ppc(fdsp, bit_exact);
> -#elif ARCH_X86
> -ff_float_dsp_init_x86(fdsp);
> -#endif
> +if (ARCH_AARCH64)
> +ff_float_dsp_init_aarch64(fdsp);
> +if (ARCH_ARM)
> +ff_float_dsp_init_arm(fdsp);
> +if (ARCH_PPC)
> +ff_float_dsp_init_ppc(fdsp, bit_exact);
> +if (ARCH_X86)
> +ff_float_dsp_init_x86(fdsp);
>  }
>  
>  #ifdef TEST
> 

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


[libav-devel] [PATCH] float_dsp: Replace arch optimization ifdefs by if cascade

2014-03-20 Thread Diego Biurrun
Arch-specific optimizations are handled this way everywhere else.
---
 libavutil/float_dsp.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/libavutil/float_dsp.c b/libavutil/float_dsp.c
index 6ff7e2f..aabc800 100644
--- a/libavutil/float_dsp.c
+++ b/libavutil/float_dsp.c
@@ -124,15 +124,14 @@ av_cold void avpriv_float_dsp_init(AVFloatDSPContext 
*fdsp, int bit_exact)
 fdsp->butterflies_float = butterflies_float_c;
 fdsp->scalarproduct_float = avpriv_scalarproduct_float_c;
 
-#if   ARCH_AARCH64
-ff_float_dsp_init_aarch64(fdsp);
-#elif ARCH_ARM
-ff_float_dsp_init_arm(fdsp);
-#elif ARCH_PPC
-ff_float_dsp_init_ppc(fdsp, bit_exact);
-#elif ARCH_X86
-ff_float_dsp_init_x86(fdsp);
-#endif
+if (ARCH_AARCH64)
+ff_float_dsp_init_aarch64(fdsp);
+if (ARCH_ARM)
+ff_float_dsp_init_arm(fdsp);
+if (ARCH_PPC)
+ff_float_dsp_init_ppc(fdsp, bit_exact);
+if (ARCH_X86)
+ff_float_dsp_init_x86(fdsp);
 }
 
 #ifdef TEST
-- 
1.8.3.2

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


Re: [libav-devel] [PATCH] fixed miscellaneous coding standard violation

2014-03-20 Thread Tim Walker
On 20 Mar 2014, at 08:03, Martin Storsjö  wrote:

> On Wed, 19 Mar 2014, Tanja Batchelor wrote:
> 
>> ---
>> libavformat/mpeg.c |  6 +++---
>> libavformat/srtp.c | 10 +-
>> 2 files changed, 8 insertions(+), 8 deletions(-)
> 
> This is part of the srtp test program and intentionally uses printf to write 
> the output to stdout instead of stderr - please don't change it to av_log.
> 
> // Martin

Nice catch… still, perhaps this would warrant a comment.

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


Re: [libav-devel] [PATCH 1/6] truehd: add hand-scheduled ARM asm version of mlp_filter_channel.

2014-03-20 Thread Martin Storsjö

On Thu, 20 Mar 2014, Janne Grunau wrote:


On 2014-03-20 09:33:10 +0200, Martin Storsjö wrote:

On Thu, 20 Mar 2014, Ben Avison wrote:


diff --git a/libavcodec/arm/mlpdsp_arm.S b/libavcodec/arm/mlpdsp_arm.S
new file mode 100644
index 000..9e0bf57
--- /dev/null
+++ b/libavcodec/arm/mlpdsp_arm.S
@@ -0,0 +1,435 @@
+/*
+
+#include "libavutil/arm/asm.S"
+
+// This code uses too many ARM-only tricks to easily assemble as Thumb
+.arm


Just to be clear, the tricks that don't work in thumb mode are
non-constant shifts, and jump tables with "ldr pc, [pc, ...]",
right?

Forcing arm mode like this isn't ok in all configurations - e.g.
when building for WinRT/Windows Phone 8, you really have to build
all of it in thumb mode; the linker doesn't handle everything needed
for mixing the modes there.

Would it be acceptable to build and run this code only if
CONFIG_THUMB is disabled? That's the case for most raspberry pi
builds at least, although I guess it would lead to not using this
code at all on other e.g. armv7 builds on linux where it still could
have been beneficial?


We could add CONFIG_THUMB_INTERWORKING and disable that for
WinRT/Windows Phone 8.


Sure, that could also work.

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


Re: [libav-devel] [PATCH] Alias PIX image encoder and decoder

2014-03-20 Thread Kostya Shishkov
On Thu, Mar 20, 2014 at 01:10:06PM +0100, Vittorio Giovara wrote:
> ---
> Amended as requested.
> Thanks for the reviews.
> Vittorio
> 
>  Changelog|   1 +
>  doc/general.texi |   2 +
>  libavcodec/Makefile  |   2 +
>  libavcodec/aliaspixdec.c | 115 +
>  libavcodec/aliaspixenc.c | 130 
> +++
>  libavcodec/allcodecs.c   |   1 +
>  libavcodec/avcodec.h |   1 +
>  libavcodec/codec_desc.c  |   7 +++
>  libavcodec/version.h |   4 +-
>  libavformat/img2.c   |   1 +
>  libavformat/img2enc.c|   2 +-
>  11 files changed, 263 insertions(+), 3 deletions(-)
>  create mode 100644 libavcodec/aliaspixdec.c
>  create mode 100644 libavcodec/aliaspixenc.c
> 
> diff --git a/Changelog b/Changelog
> index 279c0d8..0f1007d 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
>  version :
>  - compand audio filter
>  - shuffleplanes filter
> +- Alias PIX image encoder and decoder
>  
>  
>  version 10:
> diff --git a/doc/general.texi b/doc/general.texi
> index 8c0cb1b..dce4c0a 100644
> --- a/doc/general.texi
> +++ b/doc/general.texi
> @@ -424,6 +424,8 @@ following image formats are supported:
>  @item Name @tab Encoding @tab Decoding @tab Comments
>  @item .Y.U.V   @tab X @tab X
>  @tab one raw file per component
> +@item Alias PIX@tab X @tab X
> +@tab Alias/Wavefront PIX image format
>  @item animated GIF @tab X @tab X
>  @tab Only uncompressed GIFs are generated.
>  @item BMP  @tab X @tab X
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index c04b3f1..8f531fc 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -88,6 +88,8 @@ OBJS-$(CONFIG_AC3_FIXED_ENCODER)   += ac3enc_fixed.o 
> ac3enc.o ac3tab.o ac3.o
>  OBJS-$(CONFIG_AIC_DECODER) += aic.o
>  OBJS-$(CONFIG_ALAC_DECODER)+= alac.o alac_data.o
>  OBJS-$(CONFIG_ALAC_ENCODER)+= alacenc.o alac_data.o
> +OBJS-$(CONFIG_ALIAS_PIX_DECODER)   += aliaspixdec.o
> +OBJS-$(CONFIG_ALIAS_PIX_ENCODER)   += aliaspixenc.o
>  OBJS-$(CONFIG_ALS_DECODER) += alsdec.o bgmc.o mpeg4audio.o
>  OBJS-$(CONFIG_AMRNB_DECODER)   += amrnbdec.o celp_filters.o   \
>celp_math.o acelp_filters.o \
> diff --git a/libavcodec/aliaspixdec.c b/libavcodec/aliaspixdec.c
> new file mode 100644
> index 000..aeaa748
> --- /dev/null
> +++ b/libavcodec/aliaspixdec.c
> @@ -0,0 +1,115 @@
> +/*
> + * Alias PIX image

Alias PIX image decoder

> + * Copyright (C) 2014 Vittorio Giovara 
> + *
> + * 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 "avcodec.h"
> +#include "bytestream.h"
> +#include "internal.h"
> +
> +#define ALIAS_HEADER_SIZE 10
> +
> +static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
> +AVPacket *avpkt)
> +{
> +AVFrame *f = data;
> +GetByteContext gb;
> +int width, height, ret, format;
> +uint8_t *out_buf;
> +uint8_t count, r, g, b;
> +int y = 0;
> +
> +bytestream2_init(&gb, avpkt->data, avpkt->size);
> +
> +if (bytestream2_get_bytes_left(&gb) < ALIAS_HEADER_SIZE) {
> +av_log(avctx, AV_LOG_ERROR, "buf_size too small (%d)\n", 
> avpkt->size);
> +return AVERROR_INVALIDDATA;
> +}
> +
> +width  = bytestream2_get_be16(&gb);
> +height = bytestream2_get_be16(&gb);
> +bytestream2_skip(&gb, 4); // obsolete X, Y offset
> +format = bytestream2_get_be16(&gb);
> +
> +if (format == 24)
> +avctx->pix_fmt = AV_PIX_FMT_BGR24;
> +else if (format == 8)
> +avctx->pix_fmt = AV_PIX_FMT_GRAY8;
> +else {
> +av_log(avctx, AV_LOG_ERROR, "invalid format\n");
> +return AVERROR_INVALIDDATA;
> +}
> +
> +ret = ff_set_dimensions(avctx, width, height);
> +if (ret < 0)
> +return ret;
> +
> +ret = ff_get_buffer(avctx, f, 0);
> +if (ret < 0)
> +return ret;
> +
> +f->pict_type = AV_PICTURE_TYPE_I;
> +f->key_frame = 1;
> +
> +while (bytestream2_get_bytes_left(&gb) > 0) {
> +int i;
> +
> +/* set buffer at the right position at every

[libav-devel] [PATCH] Alias PIX image encoder and decoder

2014-03-20 Thread Vittorio Giovara
---
Amended as requested.
Thanks for the reviews.
Vittorio

 Changelog|   1 +
 doc/general.texi |   2 +
 libavcodec/Makefile  |   2 +
 libavcodec/aliaspixdec.c | 115 +
 libavcodec/aliaspixenc.c | 130 +++
 libavcodec/allcodecs.c   |   1 +
 libavcodec/avcodec.h |   1 +
 libavcodec/codec_desc.c  |   7 +++
 libavcodec/version.h |   4 +-
 libavformat/img2.c   |   1 +
 libavformat/img2enc.c|   2 +-
 11 files changed, 263 insertions(+), 3 deletions(-)
 create mode 100644 libavcodec/aliaspixdec.c
 create mode 100644 libavcodec/aliaspixenc.c

diff --git a/Changelog b/Changelog
index 279c0d8..0f1007d 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
 version :
 - compand audio filter
 - shuffleplanes filter
+- Alias PIX image encoder and decoder
 
 
 version 10:
diff --git a/doc/general.texi b/doc/general.texi
index 8c0cb1b..dce4c0a 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -424,6 +424,8 @@ following image formats are supported:
 @item Name @tab Encoding @tab Decoding @tab Comments
 @item .Y.U.V   @tab X @tab X
 @tab one raw file per component
+@item Alias PIX@tab X @tab X
+@tab Alias/Wavefront PIX image format
 @item animated GIF @tab X @tab X
 @tab Only uncompressed GIFs are generated.
 @item BMP  @tab X @tab X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index c04b3f1..8f531fc 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -88,6 +88,8 @@ OBJS-$(CONFIG_AC3_FIXED_ENCODER)   += ac3enc_fixed.o 
ac3enc.o ac3tab.o ac3.o
 OBJS-$(CONFIG_AIC_DECODER) += aic.o
 OBJS-$(CONFIG_ALAC_DECODER)+= alac.o alac_data.o
 OBJS-$(CONFIG_ALAC_ENCODER)+= alacenc.o alac_data.o
+OBJS-$(CONFIG_ALIAS_PIX_DECODER)   += aliaspixdec.o
+OBJS-$(CONFIG_ALIAS_PIX_ENCODER)   += aliaspixenc.o
 OBJS-$(CONFIG_ALS_DECODER) += alsdec.o bgmc.o mpeg4audio.o
 OBJS-$(CONFIG_AMRNB_DECODER)   += amrnbdec.o celp_filters.o   \
   celp_math.o acelp_filters.o \
diff --git a/libavcodec/aliaspixdec.c b/libavcodec/aliaspixdec.c
new file mode 100644
index 000..aeaa748
--- /dev/null
+++ b/libavcodec/aliaspixdec.c
@@ -0,0 +1,115 @@
+/*
+ * Alias PIX image
+ * Copyright (C) 2014 Vittorio Giovara 
+ *
+ * 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 "avcodec.h"
+#include "bytestream.h"
+#include "internal.h"
+
+#define ALIAS_HEADER_SIZE 10
+
+static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
+AVPacket *avpkt)
+{
+AVFrame *f = data;
+GetByteContext gb;
+int width, height, ret, format;
+uint8_t *out_buf;
+uint8_t count, r, g, b;
+int y = 0;
+
+bytestream2_init(&gb, avpkt->data, avpkt->size);
+
+if (bytestream2_get_bytes_left(&gb) < ALIAS_HEADER_SIZE) {
+av_log(avctx, AV_LOG_ERROR, "buf_size too small (%d)\n", avpkt->size);
+return AVERROR_INVALIDDATA;
+}
+
+width  = bytestream2_get_be16(&gb);
+height = bytestream2_get_be16(&gb);
+bytestream2_skip(&gb, 4); // obsolete X, Y offset
+format = bytestream2_get_be16(&gb);
+
+if (format == 24)
+avctx->pix_fmt = AV_PIX_FMT_BGR24;
+else if (format == 8)
+avctx->pix_fmt = AV_PIX_FMT_GRAY8;
+else {
+av_log(avctx, AV_LOG_ERROR, "invalid format\n");
+return AVERROR_INVALIDDATA;
+}
+
+ret = ff_set_dimensions(avctx, width, height);
+if (ret < 0)
+return ret;
+
+ret = ff_get_buffer(avctx, f, 0);
+if (ret < 0)
+return ret;
+
+f->pict_type = AV_PICTURE_TYPE_I;
+f->key_frame = 1;
+
+while (bytestream2_get_bytes_left(&gb) > 0) {
+int i;
+
+/* set buffer at the right position at every new line */
+if (width == avctx->width) {
+width = 0;
+out_buf = f->data[0] + f->linesize[0] * y++;
+}
+
+/* read packet and copy data */
+count = bytestream2_get_byte(&gb);
+if (width + count > avctx->width) {
+av_log(avctx, AV_LOG_ERROR, "buffer overrun\n");
+return AVERROR_INVALIDDATA

Re: [libav-devel] [PATCH 1/2] Alias PIX image encoder and decoder

2014-03-20 Thread Kostya Shishkov
On Thu, Mar 20, 2014 at 12:45:36PM +0100, Diego Biurrun wrote:
> On Thu, Mar 20, 2014 at 03:14:55AM +0100, Vittorio Giovara wrote:
> > ---
> > My first encoder/decoder \o/
> 
> \o/
> 
> > --- a/libavcodec/Makefile
> > +++ b/libavcodec/Makefile
> > @@ -88,6 +88,8 @@ OBJS-$(CONFIG_AC3_FIXED_ENCODER)   += ac3enc_fixed.o 
> > ac3enc.o ac3tab.o ac3.o
> >  OBJS-$(CONFIG_AIC_DECODER) += aic.o
> >  OBJS-$(CONFIG_ALAC_DECODER)+= alac.o alac_data.o
> >  OBJS-$(CONFIG_ALAC_ENCODER)+= alacenc.o alac_data.o
> > +OBJS-$(CONFIG_ALIAS_PIX_ENCODER)   += alias.o
> > +OBJS-$(CONFIG_ALIAS_PIX_DECODER)   += alias.o
> 
> order
> 
> > --- /dev/null
> > +++ b/libavcodec/alias.c
> 
> Maybe it should be called aliaspix, as the test?

Nah, it's more confusing this way.
 
> > +bytestream2_skip(&g, 4); // obsolete offset
> 
> How is the offset obsolete?

By being X,Y coordinates of the image that were used back in the past but not
anymore.

> > +#if CONFIG_ALIAS_PIX_DECODER
> > +AVCodec ff_alias_pix_decoder = {
> > +.name = "alias_pix",
> > +.long_name= NULL_IF_CONFIG_SMALL("Alias/Wavefront PIX image"),
> > +.type = AVMEDIA_TYPE_VIDEO,
> > +.id   = AV_CODEC_ID_ALIAS_PIX,
> > +.decode   = decode_frame,
> > +.capabilities = CODEC_CAP_DR1,
> > +};
> > +#endif
> > +
> > +#if CONFIG_ALIAS_PIX_ENCODER
> > +AVCodec ff_alias_pix_encoder = {
> > +.name  = "alias_pix",
> > +.long_name = NULL_IF_CONFIG_SMALL("Alias/Wavefront PIX image"),
> > +.type  = AVMEDIA_TYPE_VIDEO,
> > +.id= AV_CODEC_ID_ALIAS_PIX,
> > +.init  = encode_init,
> > +.encode2   = encode_frame,
> > +.close = encode_close,
> > +.pix_fmts  = (const enum AVPixelFormat[]) {
> > +AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA, AV_PIX_FMT_GRAY8, 
> > AV_PIX_FMT_NONE
> > +},
> > +};
> > +#endif
> 
> It seems this can be split easily, then it should be in two separate files.

then the filenames won't be so confusing as now
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 3/4] avformat/mov: fill in subtitle dimensions after parsing tkhd

2014-03-20 Thread Diego Biurrun
On Thu, Mar 20, 2014 at 09:05:36AM +0100, wm4 wrote:
> From: Michael Niedermayer 
> 
> Sample: NeroRecodeSample.mp4
> Signed-off-by: Michael Niedermayer 
> 
> Conflicts:
>   libavformat/mov.c

Please drop such conflict markers in the future.
For now, it can be removed on push.

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


Re: [libav-devel] [PATCH 1/2] Alias PIX image encoder and decoder

2014-03-20 Thread Diego Biurrun
On Thu, Mar 20, 2014 at 03:14:55AM +0100, Vittorio Giovara wrote:
> ---
> My first encoder/decoder \o/

\o/

> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -88,6 +88,8 @@ OBJS-$(CONFIG_AC3_FIXED_ENCODER)   += ac3enc_fixed.o 
> ac3enc.o ac3tab.o ac3.o
>  OBJS-$(CONFIG_AIC_DECODER) += aic.o
>  OBJS-$(CONFIG_ALAC_DECODER)+= alac.o alac_data.o
>  OBJS-$(CONFIG_ALAC_ENCODER)+= alacenc.o alac_data.o
> +OBJS-$(CONFIG_ALIAS_PIX_ENCODER)   += alias.o
> +OBJS-$(CONFIG_ALIAS_PIX_DECODER)   += alias.o

order

> --- /dev/null
> +++ b/libavcodec/alias.c

Maybe it should be called aliaspix, as the test?

> +bytestream2_skip(&g, 4); // obsolete offset

How is the offset obsolete?

> +#if CONFIG_ALIAS_PIX_DECODER
> +AVCodec ff_alias_pix_decoder = {
> +.name = "alias_pix",
> +.long_name= NULL_IF_CONFIG_SMALL("Alias/Wavefront PIX image"),
> +.type = AVMEDIA_TYPE_VIDEO,
> +.id   = AV_CODEC_ID_ALIAS_PIX,
> +.decode   = decode_frame,
> +.capabilities = CODEC_CAP_DR1,
> +};
> +#endif
> +
> +#if CONFIG_ALIAS_PIX_ENCODER
> +AVCodec ff_alias_pix_encoder = {
> +.name  = "alias_pix",
> +.long_name = NULL_IF_CONFIG_SMALL("Alias/Wavefront PIX image"),
> +.type  = AVMEDIA_TYPE_VIDEO,
> +.id= AV_CODEC_ID_ALIAS_PIX,
> +.init  = encode_init,
> +.encode2   = encode_frame,
> +.close = encode_close,
> +.pix_fmts  = (const enum AVPixelFormat[]) {
> +AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA, AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE
> +},
> +};
> +#endif

It seems this can be split easily, then it should be in two separate files.

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


Re: [libav-devel] [PATCH 5/6] truehd: break out part of output_data into platform-specific callback.

2014-03-20 Thread Diego Biurrun
On Wed, Mar 19, 2014 at 07:43:49PM -, Ben Avison wrote:
> >>--- a/libavcodec/mlpdsp.c
> >>+++ b/libavcodec/mlpdsp.c
> >>@@ -89,10 +89,46 @@ void ff_mlp_rematrix_channel(int32_t *samples,
> >>+int32_t *data_32 = (int32_t *)data;
> >>+int16_t *data_16 = (int16_t *)data;
> >pointless void* casts
> 
> Fair enough, those were cut-and-pastes from their original location.

Which location?  I'll change them ..

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


Re: [libav-devel] [PATCH 1/6] truehd: add hand-scheduled ARM asm version of mlp_filter_channel.

2014-03-20 Thread Janne Grunau
On 2014-03-20 09:33:10 +0200, Martin Storsjö wrote:
> On Thu, 20 Mar 2014, Ben Avison wrote:
> 
> >diff --git a/libavcodec/arm/mlpdsp_arm.S b/libavcodec/arm/mlpdsp_arm.S
> >new file mode 100644
> >index 000..9e0bf57
> >--- /dev/null
> >+++ b/libavcodec/arm/mlpdsp_arm.S
> >@@ -0,0 +1,435 @@
> >+/*
> >+
> >+#include "libavutil/arm/asm.S"
> >+
> >+// This code uses too many ARM-only tricks to easily assemble as Thumb
> >+.arm
> 
> Just to be clear, the tricks that don't work in thumb mode are
> non-constant shifts, and jump tables with "ldr pc, [pc, ...]",
> right?
> 
> Forcing arm mode like this isn't ok in all configurations - e.g.
> when building for WinRT/Windows Phone 8, you really have to build
> all of it in thumb mode; the linker doesn't handle everything needed
> for mixing the modes there.
> 
> Would it be acceptable to build and run this code only if
> CONFIG_THUMB is disabled? That's the case for most raspberry pi
> builds at least, although I guess it would lead to not using this
> code at all on other e.g. armv7 builds on linux where it still could
> have been beneficial?

We could add CONFIG_THUMB_INTERWORKING and disable that for
WinRT/Windows Phone 8.

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


Re: [libav-devel] [PATCH 1/4] avformat/isom: Simplify mov_rewrite_dvd_sub_extradata()

2014-03-20 Thread Luca Barbato
On 20/03/14 09:05, wm4 wrote:
> From: Michael Niedermayer 
> 
> This avoids the 2nd buffer and fixes the palette truncated check
> 
> Signed-off-by: Michael Niedermayer 

I let others discuss the patch, just two items:

The "tag:" field will be parsed by plaid soon and should be a single
word w/out "/". It would be use for grouping. Please do not use "foo/bar:".
The directory is already parsed from the patch.

Sign-off: states that you edited the patch somehow. a "Sign-off:" equal
to "From:" is redundant.

Thanks for forwarding those fixes.

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


[libav-devel] [PATCH] Fixed miscellaneous coding standard violation.

2014-03-20 Thread Tanja Batchelor
---
 libavformat/mpeg.c | 82 +++---
 1 file changed, 41 insertions(+), 41 deletions(-)

diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 7430bb0..99112ac 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -38,15 +38,15 @@ static int check_pes(uint8_t *p, uint8_t *end){
 &&((p[4] & 0xC0) == 0x00 || (p[4]&0xC0)>>2 == (p[6]&0xF0));
 
 for(p+=3; pbuf_size; i++){
+for (i = 0; i < p->buf_size; i++) {
 code = (code<<8) + p->buf[i];
 if ((code & 0xff00) == 0x100) {
 int len= p->buf[i+1] << 8 | p->buf[i+2];
 int pes= check_pes(p->buf+i, p->buf+p->buf_size);
 int pack = check_pack_header(p->buf+i);
 
-if(code == SYSTEM_HEADER_START_CODE) sys++;
-else if(code == PACK_START_CODE && pack) pspack++;
-else if((code & 0xf0) == VIDEO_ID &&  pes) vid++;
+if (code == SYSTEM_HEADER_START_CODE) sys++;
+else if (code == PACK_START_CODE && pack) pspack++;
+else if ((code & 0xf0) == VIDEO_ID &&  pes) vid++;
 // skip pes payload to avoid start code emulation for private
 // and audio streams
-else if((code & 0xe0) == AUDIO_ID &&  pes) {audio++; i+=len;}
-else if(code == PRIVATE_STREAM_1  &&  pes) {priv1++; i+=len;}
+else if ((code & 0xe0) == AUDIO_ID &&  pes) {audio++; i+=len;}
+else if (code == PRIVATE_STREAM_1  &&  pes) {priv1++; i+=len;}
 
-else if((code & 0xf0) == VIDEO_ID && !pes) invalid++;
-else if((code & 0xe0) == AUDIO_ID && !pes) invalid++;
-else if(code == PRIVATE_STREAM_1  && !pes) invalid++;
+else if ((code & 0xf0) == VIDEO_ID && !pes) invalid++;
+else if ((code & 0xe0) == AUDIO_ID && !pes) invalid++;
+else if (code == PRIVATE_STREAM_1  && !pes) invalid++;
 }
 }
 
-if(vid+audio > invalid) /* invalid VDR files nd short PES streams */
+if (vid+audio > invalid) /* invalid VDR files nd short PES streams */
 score = AVPROBE_SCORE_EXTENSION / 2;
 
-if(sys>invalid && sys*9 <= pspack*10)
+if (sys > invalid && sys*9 <= pspack*10)
 return pspack > 2 ? AVPROBE_SCORE_EXTENSION + 2 : 
AVPROBE_SCORE_EXTENSION / 2; // 1 more than .mpg
-if(pspack > invalid && (priv1+vid+audio)*10 >= pspack*9)
+if (pspack > invalid && (priv1+vid+audio) * 10 >= pspack * 9)
 return pspack > 2 ? AVPROBE_SCORE_EXTENSION + 2 : 
AVPROBE_SCORE_EXTENSION / 2; // 1 more than .mpg
-if((!!vid ^ !!audio) && (audio > 4 || vid > 1) && !sys && !pspack && 
p->buf_size>2048 && vid + audio > invalid) /* PES stream */
+if ((!!vid ^ !!audio) && (audio > 4 || vid > 1) && !sys && !pspack && 
p->buf_size > 2048 && vid + audio > invalid) /* PES stream */
 return (audio > 12 || vid > 3) ? AVPROBE_SCORE_EXTENSION + 2 : 
AVPROBE_SCORE_EXTENSION / 2;
 
 //02-Penguin.flac has sys:0 priv1:0 pspack:0 vid:0 audio:1
@@ -218,7 +218,7 @@ static int mpegps_read_pes_header(AVFormatContext *s,
 startcode = find_next_start_code(s->pb, &size, &m->header_state);
 last_sync = avio_tell(s->pb);
 if (startcode < 0){
-if(s->pb->eof_reached)
+if (s->pb->eof_reached)
 return AVERROR_EOF;
 //FIXME we should remember header_state
 return AVERROR(EAGAIN);
@@ -332,11 +332,11 @@ static int mpegps_read_pes_header(AVFormatContext *s,
 }
 }
 }
-if(header_len < 0)
+if (header_len < 0)
 goto error_redo;
 avio_skip(s->pb, header_len);
 }
-else if( c!= 0xf )
+else if (c!= 0xf)
 goto redo;
 
 if (startcode == PRIVATE_STREAM_1 && !m->psm_es_type[startcode & 0xff]) {
@@ -355,12 +355,12 @@ static int mpegps_read_pes_header(AVFormatContext *s,
 }
 }
 }
-if(len<0)
+if (len < 0)
 goto error_redo;
-if(dts != AV_NOPTS_VALUE && ppos){
+if (dts != AV_NOPTS_VALUE && ppos){
 int i;
-for(i=0; inb_streams; i++){
-if(startcode == s->streams[i]->id &&
+for (i = 0; i < s->nb_streams; i++){ 
+if (startcode == s->streams[i]->id &&
s->pb->seekable /* index useless on streams anyway */) {
 ff_reduce_index(s, i);
 av_add_index_entry(s->streams[i], *ppos, dts, 0, 0, 
AVINDEX_KEYFRAME /* FIXME keyframe? */);
@@ -390,41 +390,41 @@ static int mpegps_read_packet(AVFormatContext *s,
 if (len < 0)
 return len;
 
-if(startcode == 0x1bd) {
+if (startcode == 0x1bd) {
 dvdaudio_substream_type = avio_r8(s->pb);
 avio_skip(s->pb, 3);
 len -= 4;
 }
 
 /* now find stream */
-for(i=0;inb_streams;i++) {
+for (i = 0; i < s->nb_streams;i++) {
 st = s->streams[i];
 if (st->id == startcode)
 goto found;
 }
 
 es_type 

[libav-devel] [PATCH 4/4] avformat/mov: call mov_rewrite_dvd_sub_extradata() after parsing dimensions from tkhd

2014-03-20 Thread wm4
From: Michael Niedermayer 

This also moves mov_rewrite_dvd_sub_extradata() to mov.c

Fixes: NeroRecodeSample.mp4
Signed-off-by: Michael Niedermayer 
---
This is a real problem. I wasn't sure whether this can happen, but
apparently it can and does happen.
---
 libavformat/isom.c | 56 --
 libavformat/mov.c  | 55 +
 2 files changed, 55 insertions(+), 56 deletions(-)

diff --git a/libavformat/isom.c b/libavformat/isom.c
index cade775..efe97b6 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -421,60 +421,8 @@ static const AVCodecTag mp4_audio_types[] = {
 { AV_CODEC_ID_NONE,   AOT_NULL },
 };
 
-static uint32_t yuv_to_rgba(uint32_t ycbcr)
-{
-uint8_t r, g, b;
-int y, cb, cr;
-
-y  = (ycbcr >> 16) & 0xFF;
-cr = (ycbcr >> 8)  & 0xFF;
-cb =  ycbcr& 0xFF;
-
-b = av_clip_uint8(1.164 * (y - 16)  + 2.018 * (cb - 
128));
-g = av_clip_uint8(1.164 * (y - 16) - 0.813 * (cr - 128) - 0.391 * (cb - 
128));
-r = av_clip_uint8(1.164 * (y - 16) + 1.596 * (cr - 128));
-
-return (r << 16) | (g << 8) | b;
-}
-
-static int mov_rewrite_dvd_sub_extradata(AVStream *st)
-{
-char buf[256] = {0};
-uint8_t *src = st->codec->extradata;
-int i;
-
-if (st->codec->extradata_size != 64)
-return 0;
-
-if (st->codec->width > 0 &&  st->codec->height > 0)
-snprintf(buf, sizeof(buf), "size: %dx%d\n",
- st->codec->width, st->codec->height);
-av_strlcat(buf, "palette: ", sizeof(buf));
-
-for (i = 0; i < 16; i++) {
-uint32_t yuv = AV_RB32(src + i * 4);
-uint32_t rgba = yuv_to_rgba(yuv);
-
-av_strlcatf(buf, sizeof(buf), "%06x%s", rgba, i != 15 ? ", " : "");
-}
-
-if (av_strlcat(buf, "\n", sizeof(buf)) >= sizeof(buf))
-return 0;
-
-av_freep(&st->codec->extradata);
-st->codec->extradata_size = 0;
-st->codec->extradata = av_mallocz(strlen(buf) + 
FF_INPUT_BUFFER_PADDING_SIZE);
-if (!st->codec->extradata)
-return AVERROR(ENOMEM);
-st->codec->extradata_size = strlen(buf);
-memcpy(st->codec->extradata, buf, st->codec->extradata_size);
-
-return 0;
-}
-
 int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, 
AVIOContext *pb)
 {
-int err;
 int len, tag;
 int object_type_id = avio_r8(pb);
 avio_r8(pb); /* stream type */
@@ -514,10 +462,6 @@ int ff_mp4_read_dec_config_descr(AVFormatContext *fc, 
AVStream *st, AVIOContext
 cfg.object_type)))
 st->codec->codec_id = AV_CODEC_ID_AAC;
 }
-if (st->codec->codec_id == AV_CODEC_ID_DVD_SUBTITLE) {
-if ((err = mov_rewrite_dvd_sub_extradata(st)) < 0)
-return err;
-}
 }
 return 0;
 }
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 8fc096f..5d0719c 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1309,6 +1309,57 @@ static void mov_parse_stsd_subtitle(MOVContext *c, 
AVIOContext *pb,
 st->codec->height = sc->height;
 }
 
+static uint32_t yuv_to_rgba(uint32_t ycbcr)
+{
+uint8_t r, g, b;
+int y, cb, cr;
+
+y  = (ycbcr >> 16) & 0xFF;
+cr = (ycbcr >> 8)  & 0xFF;
+cb =  ycbcr& 0xFF;
+
+b = av_clip_uint8(1.164 * (y - 16)  + 2.018 * (cb - 
128));
+g = av_clip_uint8(1.164 * (y - 16) - 0.813 * (cr - 128) - 0.391 * (cb - 
128));
+r = av_clip_uint8(1.164 * (y - 16) + 1.596 * (cr - 128));
+
+return (r << 16) | (g << 8) | b;
+}
+
+static int mov_rewrite_dvd_sub_extradata(AVStream *st)
+{
+char buf[256] = {0};
+uint8_t *src = st->codec->extradata;
+int i;
+
+if (st->codec->extradata_size != 64)
+return 0;
+
+if (st->codec->width > 0 &&  st->codec->height > 0)
+snprintf(buf, sizeof(buf), "size: %dx%d\n",
+ st->codec->width, st->codec->height);
+av_strlcat(buf, "palette: ", sizeof(buf));
+
+for (i = 0; i < 16; i++) {
+uint32_t yuv = AV_RB32(src + i * 4);
+uint32_t rgba = yuv_to_rgba(yuv);
+
+av_strlcatf(buf, sizeof(buf), "%06x%s", rgba, i != 15 ? ", " : "");
+}
+
+if (av_strlcat(buf, "\n", sizeof(buf)) >= sizeof(buf))
+return 0;
+
+av_freep(&st->codec->extradata);
+st->codec->extradata_size = 0;
+st->codec->extradata = av_mallocz(strlen(buf) + 
FF_INPUT_BUFFER_PADDING_SIZE);
+if (!st->codec->extradata)
+return AVERROR(ENOMEM);
+st->codec->extradata_size = strlen(buf);
+memcpy(st->codec->extradata, buf, st->codec->extradata_size);
+
+return 0;
+}
+
 static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb,
 AVStream *st, MOVStreamContext *sc,
 int size)
@@ -2891,6 +2942,10 @@ static int mov_read_header(AVFormatContext *s)
 st->codec->width  = sc->width;
   

[libav-devel] [PATCH 3/4] avformat/mov: fill in subtitle dimensions after parsing tkhd

2014-03-20 Thread wm4
From: Michael Niedermayer 

Sample: NeroRecodeSample.mp4
Signed-off-by: Michael Niedermayer 

Conflicts:
libavformat/mov.c
---
 libavformat/mov.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 6375847..8fc096f 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2857,6 +2857,7 @@ static int mov_read_header(AVFormatContext *s)
 AVIOContext *pb = s->pb;
 int err;
 MOVAtom atom = { AV_RL32("root") };
+int i;
 
 mov->fc = s;
 /* .mov and .mp4 aren't streamable anyway (only progressive download if 
moov is before mdat) */
@@ -2881,8 +2882,19 @@ static int mov_read_header(AVFormatContext *s)
 if (pb->seekable && mov->chapter_track > 0)
 mov_read_chapters(s);
 
+for (i = 0; i < s->nb_streams; i++) {
+AVStream *st = s->streams[i];
+MOVStreamContext *sc = st->priv_data;
+
+if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+if (st->codec->width <= 0 && st->codec->width <= 0) {
+st->codec->width  = sc->width;
+st->codec->height = sc->height;
+}
+}
+}
+
 if (mov->trex_data) {
-int i;
 for (i = 0; i < s->nb_streams; i++) {
 AVStream *st = s->streams[i];
 MOVStreamContext *sc = st->priv_data;
-- 
1.9.0

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


[libav-devel] [PATCH 1/4] avformat/isom: Simplify mov_rewrite_dvd_sub_extradata()

2014-03-20 Thread wm4
From: Michael Niedermayer 

This avoids the 2nd buffer and fixes the palette truncated check

Signed-off-by: Michael Niedermayer 
---
I guess the length check is off by 1, so this defensive measure was
ineffective, even if it wasn't a real bug.
---
 libavformat/isom.c | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/libavformat/isom.c b/libavformat/isom.c
index e15875e..3f420e7 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -26,6 +26,7 @@
 #include "isom.h"
 #include "libavcodec/mpeg4audio.h"
 #include "libavcodec/mpegaudiodata.h"
+#include "libavutil/avstring.h"
 #include "libavutil/intreadwrite.h"
 
 /* http://www.mp4ra.org */
@@ -438,28 +439,25 @@ static uint32_t yuv_to_rgba(uint32_t ycbcr)
 
 static int mov_rewrite_dvd_sub_extradata(AVStream *st)
 {
-char pal_s[256];
-char buf[256];
-int pal_s_pos = 0;
+char buf[256] = {0};
 uint8_t *src = st->codec->extradata;
 int i;
 
 if (st->codec->extradata_size != 64)
 return 0;
 
+snprintf(buf, sizeof(buf), "size: %dx%d\npalette: ",
+ st->codec->width, st->codec->height);
+
 for (i = 0; i < 16; i++) {
 uint32_t yuv = AV_RB32(src + i * 4);
 uint32_t rgba = yuv_to_rgba(yuv);
 
-snprintf(pal_s + pal_s_pos, sizeof(pal_s) - pal_s_pos, "%06x%s", rgba,
- i != 15 ? ", " : "");
-pal_s_pos = strlen(pal_s);
-if (pal_s_pos >= sizeof(pal_s))
-return 0;
+av_strlcatf(buf, sizeof(buf), "%06x%s", rgba, i != 15 ? ", " : "");
 }
 
-snprintf(buf, sizeof(buf), "size: %dx%d\npalette: %s\n",
- st->codec->width, st->codec->height, pal_s);
+if (av_strlcat(buf, "\n", sizeof(buf)) >= sizeof(buf))
+return 0;
 
 av_freep(&st->codec->extradata);
 st->codec->extradata_size = 0;
-- 
1.9.0

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


[libav-devel] [PATCH 2/4] avformat/isom: only write the size if its non zero in mov_rewrite_dvd_sub_extradata()

2014-03-20 Thread wm4
From: Michael Niedermayer 

Fixes regression with NeroRecodeSample.mp4

Signed-off-by: Michael Niedermayer 
---
 libavformat/isom.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/isom.c b/libavformat/isom.c
index 3f420e7..cade775 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -446,8 +446,10 @@ static int mov_rewrite_dvd_sub_extradata(AVStream *st)
 if (st->codec->extradata_size != 64)
 return 0;
 
-snprintf(buf, sizeof(buf), "size: %dx%d\npalette: ",
- st->codec->width, st->codec->height);
+if (st->codec->width > 0 &&  st->codec->height > 0)
+snprintf(buf, sizeof(buf), "size: %dx%d\n",
+ st->codec->width, st->codec->height);
+av_strlcat(buf, "palette: ", sizeof(buf));
 
 for (i = 0; i < 16; i++) {
 uint32_t yuv = AV_RB32(src + i * 4);
-- 
1.9.0

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


[libav-devel] [PATCH 2/3] vdpau: switch ff_vdpau_get_surface_id from Picture to AVFrame

2014-03-20 Thread wm4
This gets rid of aliasing completely unrelated structs to Picture.

Fixes the remaining compilation warnings in the vdpau code.
---
 libavcodec/vdpau.c  | 2 +-
 libavcodec/vdpau_h264.c | 6 +++---
 libavcodec/vdpau_internal.h | 6 +++---
 libavcodec/vdpau_mpeg12.c   | 4 ++--
 libavcodec/vdpau_mpeg4.c| 4 ++--
 libavcodec/vdpau_vc1.c  | 4 ++--
 6 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c
index 5d83b44..5ad5d06 100644
--- a/libavcodec/vdpau.c
+++ b/libavcodec/vdpau.c
@@ -57,7 +57,7 @@ int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx)
 MpegEncContext *s = avctx->priv_data;
 Picture *pic = s->current_picture_ptr;
 struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
-VdpVideoSurface surf = ff_vdpau_get_surface_id(pic);
+VdpVideoSurface surf = ff_vdpau_get_surface_id(&pic->f);
 
 hwctx->render(hwctx->decoder, surf, (void *)&pic_ctx->info,
   pic_ctx->bitstream_buffers_used, pic_ctx->bitstream_buffers);
diff --git a/libavcodec/vdpau_h264.c b/libavcodec/vdpau_h264.c
index c71d6b8..7aa17ef 100644
--- a/libavcodec/vdpau_h264.c
+++ b/libavcodec/vdpau_h264.c
@@ -50,7 +50,7 @@ static void vdpau_h264_clear_rf(VdpReferenceFrameH264 *rf)
 static void vdpau_h264_set_rf(VdpReferenceFrameH264 *rf, H264Picture *pic,
   int pic_structure)
 {
-VdpVideoSurface surface = ff_vdpau_get_surface_id(pic);
+VdpVideoSurface surface = ff_vdpau_get_surface_id(&pic->f);
 
 if (pic_structure == 0)
 pic_structure = pic->reference;
@@ -87,7 +87,7 @@ static void vdpau_h264_set_reference_frames(AVCodecContext 
*avctx)
 if (!pic || !pic->reference)
 continue;
 pic_frame_idx = pic->long_ref ? pic->pic_id : pic->frame_num;
-surface_ref = ff_vdpau_get_surface_id(pic);
+surface_ref = ff_vdpau_get_surface_id(&pic->f);
 
 rf2 = &info->referenceFrames[0];
 while (rf2 != rf) {
@@ -193,7 +193,7 @@ static int vdpau_h264_end_frame(AVCodecContext *avctx)
 H264Context *h = avctx->priv_data;
 H264Picture *pic = h->cur_pic_ptr;
 struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
-VdpVideoSurface surf = ff_vdpau_get_surface_id(pic);
+VdpVideoSurface surf = ff_vdpau_get_surface_id(&pic->f);
 
 hwctx->render(hwctx->decoder, surf, (void *)&pic_ctx->info,
   pic_ctx->bitstream_buffers_used, pic_ctx->bitstream_buffers);
diff --git a/libavcodec/vdpau_internal.h b/libavcodec/vdpau_internal.h
index 94c81ff..2443e0a 100644
--- a/libavcodec/vdpau_internal.h
+++ b/libavcodec/vdpau_internal.h
@@ -31,10 +31,10 @@
 #include "mpegvideo.h"
 #include "version.h"
 
-/** Extract VdpVideoSurface from a Picture */
-static inline uintptr_t ff_vdpau_get_surface_id(Picture *pic)
+/** Extract VdpVideoSurface from an AVFrame */
+static inline uintptr_t ff_vdpau_get_surface_id(AVFrame *pic)
 {
-return (uintptr_t)pic->f.data[3];
+return (uintptr_t)pic->data[3];
 }
 
 #if !FF_API_BUFS_VDPAU
diff --git a/libavcodec/vdpau_mpeg12.c b/libavcodec/vdpau_mpeg12.c
index e62901a..0f92cef 100644
--- a/libavcodec/vdpau_mpeg12.c
+++ b/libavcodec/vdpau_mpeg12.c
@@ -43,12 +43,12 @@ static int vdpau_mpeg_start_frame(AVCodecContext *avctx,
 
 switch (s->pict_type) {
 case AV_PICTURE_TYPE_B:
-ref = ff_vdpau_get_surface_id(&s->next_picture);
+ref = ff_vdpau_get_surface_id(&s->next_picture.f);
 assert(ref != VDP_INVALID_HANDLE);
 info->backward_reference = ref;
 /* fall through to forward prediction */
 case AV_PICTURE_TYPE_P:
-ref = ff_vdpau_get_surface_id(&s->last_picture);
+ref = ff_vdpau_get_surface_id(&s->last_picture.f);
 info->forward_reference  = ref;
 }
 
diff --git a/libavcodec/vdpau_mpeg4.c b/libavcodec/vdpau_mpeg4.c
index f328e48..3c6c8b3 100644
--- a/libavcodec/vdpau_mpeg4.c
+++ b/libavcodec/vdpau_mpeg4.c
@@ -46,13 +46,13 @@ static int vdpau_mpeg4_start_frame(AVCodecContext *avctx,
 
 switch (s->pict_type) {
 case AV_PICTURE_TYPE_B:
-ref = ff_vdpau_get_surface_id(&s->next_picture);
+ref = ff_vdpau_get_surface_id(&s->next_picture.f);
 assert(ref != VDP_INVALID_HANDLE);
 info->backward_reference = ref;
 info->vop_coding_type= 2;
 /* fall-through */
 case AV_PICTURE_TYPE_P:
-ref = ff_vdpau_get_surface_id(&s->last_picture);
+ref = ff_vdpau_get_surface_id(&s->last_picture.f);
 assert(ref != VDP_INVALID_HANDLE);
 info->forward_reference  = ref;
 }
diff --git a/libavcodec/vdpau_vc1.c b/libavcodec/vdpau_vc1.c
index 01ad0ae..392c511 100644
--- a/libavcodec/vdpau_vc1.c
+++ b/libavcodec/vdpau_vc1.c
@@ -44,12 +44,12 @@ static int vdpau_vc1_start_frame(AVCodecContext *avctx,
 
 switch (s->pict_type) {
 case AV_PICTURE_TYPE_B:
-ref = ff_vdpau_get_surface_id(&s->next_picture);
+  

[libav-devel] [PATCH 1/3] vdpau: don't assume Picture and H264Picture are the same

2014-03-20 Thread wm4
The code passed H264Picture* and Picture*, and assumed the
hwaccel_picture_private field was in the same place in both
structs. Somehow this happened to work in Libav, but broke in
FFmpeg (and probably subtly breaks in Libav too).
---
 libavcodec/vdpau.c  | 8 +++-
 libavcodec/vdpau_h264.c | 6 +++---
 libavcodec/vdpau_internal.h | 5 +++--
 libavcodec/vdpau_mpeg12.c   | 4 ++--
 libavcodec/vdpau_mpeg4.c| 4 ++--
 libavcodec/vdpau_vc1.c  | 4 ++--
 6 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c
index 50a57d0..5d83b44 100644
--- a/libavcodec/vdpau.c
+++ b/libavcodec/vdpau.c
@@ -38,12 +38,10 @@
  * @{
  */
 
-int ff_vdpau_common_start_frame(Picture *pic,
+int ff_vdpau_common_start_frame(struct vdpau_picture_context *pic_ctx,
 av_unused const uint8_t *buffer,
 av_unused uint32_t size)
 {
-struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
-
 pic_ctx->bitstream_buffers_allocated = 0;
 pic_ctx->bitstream_buffers_used  = 0;
 pic_ctx->bitstream_buffers   = NULL;
@@ -71,9 +69,9 @@ int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx)
 }
 #endif
 
-int ff_vdpau_add_buffer(Picture *pic, const uint8_t *buf, uint32_t size)
+int ff_vdpau_add_buffer(struct vdpau_picture_context *pic_ctx,
+const uint8_t *buf, uint32_t size)
 {
-struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
 VdpBitstreamBuffer *buffers = pic_ctx->bitstream_buffers;
 
 buffers = av_fast_realloc(buffers, &pic_ctx->bitstream_buffers_allocated,
diff --git a/libavcodec/vdpau_h264.c b/libavcodec/vdpau_h264.c
index fd1c6e8..c71d6b8 100644
--- a/libavcodec/vdpau_h264.c
+++ b/libavcodec/vdpau_h264.c
@@ -162,7 +162,7 @@ static int vdpau_h264_start_frame(AVCodecContext *avctx,
 
 vdpau_h264_set_reference_frames(avctx);
 
-return ff_vdpau_common_start_frame(pic, buffer, size);
+return ff_vdpau_common_start_frame(pic_ctx, buffer, size);
 }
 
 static const uint8_t start_code_prefix[3] = { 0x00, 0x00, 0x01 };
@@ -175,11 +175,11 @@ static int vdpau_h264_decode_slice(AVCodecContext *avctx,
 struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
 int val;
 
-val = ff_vdpau_add_buffer(pic, start_code_prefix, 3);
+val = ff_vdpau_add_buffer(pic_ctx, start_code_prefix, 3);
 if (val)
 return val;
 
-val = ff_vdpau_add_buffer(pic, buffer, size);
+val = ff_vdpau_add_buffer(pic_ctx, buffer, size);
 if (val)
 return val;
 
diff --git a/libavcodec/vdpau_internal.h b/libavcodec/vdpau_internal.h
index 50c4f5e..94c81ff 100644
--- a/libavcodec/vdpau_internal.h
+++ b/libavcodec/vdpau_internal.h
@@ -70,9 +70,10 @@ struct vdpau_picture_context {
 VdpBitstreamBuffer *bitstream_buffers;
 };
 
-int ff_vdpau_common_start_frame(Picture *pic,
+int ff_vdpau_common_start_frame(struct vdpau_picture_context *pic,
 const uint8_t *buffer, uint32_t size);
 int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx);
-int ff_vdpau_add_buffer(Picture *pic, const uint8_t *buf, uint32_t buf_size);
+int ff_vdpau_add_buffer(struct vdpau_picture_context *pic, const uint8_t *buf,
+uint32_t buf_size);
 
 #endif /* AVCODEC_VDPAU_INTERNAL_H */
diff --git a/libavcodec/vdpau_mpeg12.c b/libavcodec/vdpau_mpeg12.c
index 426d580..e62901a 100644
--- a/libavcodec/vdpau_mpeg12.c
+++ b/libavcodec/vdpau_mpeg12.c
@@ -75,7 +75,7 @@ static int vdpau_mpeg_start_frame(AVCodecContext *avctx,
 info->non_intra_quantizer_matrix[i] = s->inter_matrix[i];
 }
 
-return ff_vdpau_common_start_frame(pic, buffer, size);
+return ff_vdpau_common_start_frame(pic_ctx, buffer, size);
 }
 
 static int vdpau_mpeg_decode_slice(AVCodecContext *avctx,
@@ -86,7 +86,7 @@ static int vdpau_mpeg_decode_slice(AVCodecContext *avctx,
 struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
 int val;
 
-val = ff_vdpau_add_buffer(pic, buffer, size);
+val = ff_vdpau_add_buffer(pic_ctx, buffer, size);
 if (val < 0)
 return val;
 
diff --git a/libavcodec/vdpau_mpeg4.c b/libavcodec/vdpau_mpeg4.c
index 17205fe..f328e48 100644
--- a/libavcodec/vdpau_mpeg4.c
+++ b/libavcodec/vdpau_mpeg4.c
@@ -77,8 +77,8 @@ static int vdpau_mpeg4_start_frame(AVCodecContext *avctx,
 info->non_intra_quantizer_matrix[i] = s->inter_matrix[i];
 }
 
-ff_vdpau_common_start_frame(pic, buffer, size);
-return ff_vdpau_add_buffer(pic, buffer, size);
+ff_vdpau_common_start_frame(pic_ctx, buffer, size);
+return ff_vdpau_add_buffer(pic_ctx, buffer, size);
 }
 
 static int vdpau_mpeg4_decode_slice(av_unused AVCodecContext *avctx,
diff --git a/libavcodec/vdpau_vc1.c b/libavcodec/vdpau_vc1.c
index b401352..01ad0ae 100644
--- a/libavcodec/vdpau_vc1.c
+++ b/libavcodec/vdpau_vc1.c
@@ -89,7 +89,7 @@ static int vdpau_vc1_start_frame(AVCodecContext *avctx,

[libav-devel] [PATCH 3/3] vaapi: switch ff_vaapi_get_surface_id from Picture to AVFrame

2014-03-20 Thread wm4
---
 libavcodec/vaapi.c  | 2 +-
 libavcodec/vaapi_h264.c | 6 +++---
 libavcodec/vaapi_internal.h | 6 +++---
 libavcodec/vaapi_mpeg2.c| 4 ++--
 libavcodec/vaapi_mpeg4.c| 4 ++--
 libavcodec/vaapi_vc1.c  | 4 ++--
 6 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/libavcodec/vaapi.c b/libavcodec/vaapi.c
index 0532daf..6183d0b 100644
--- a/libavcodec/vaapi.c
+++ b/libavcodec/vaapi.c
@@ -205,7 +205,7 @@ int ff_vaapi_mpeg_end_frame(AVCodecContext *avctx)
 goto finish;
 
 ret = ff_vaapi_render_picture(vactx,
-  
ff_vaapi_get_surface_id(s->current_picture_ptr));
+  
ff_vaapi_get_surface_id(&s->current_picture_ptr->f));
 if (ret < 0)
 goto finish;
 
diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
index a1a0e07..f2a912c 100644
--- a/libavcodec/vaapi_h264.c
+++ b/libavcodec/vaapi_h264.c
@@ -59,7 +59,7 @@ static void fill_vaapi_pic(VAPictureH264 *va_pic,
 pic_structure = pic->reference;
 pic_structure &= PICT_FRAME; /* PICT_TOP_FIELD|PICT_BOTTOM_FIELD */
 
-va_pic->picture_id = ff_vaapi_get_surface_id(pic);
+va_pic->picture_id = ff_vaapi_get_surface_id(&pic->f);
 va_pic->frame_idx  = pic->long_ref ? pic->pic_id : pic->frame_num;
 
 va_pic->flags  = 0;
@@ -99,7 +99,7 @@ static int dpb_add(DPB *dpb, H264Picture *pic)
 
 for (i = 0; i < dpb->size; i++) {
 VAPictureH264 * const va_pic = &dpb->va_pics[i];
-if (va_pic->picture_id == ff_vaapi_get_surface_id(pic)) {
+if (va_pic->picture_id == ff_vaapi_get_surface_id(&pic->f)) {
 VAPictureH264 temp_va_pic;
 fill_vaapi_pic(&temp_va_pic, pic, 0);
 
@@ -298,7 +298,7 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
 if (ret < 0)
 goto finish;
 
-ret = ff_vaapi_render_picture(vactx, 
ff_vaapi_get_surface_id(h->cur_pic_ptr));
+ret = ff_vaapi_render_picture(vactx, 
ff_vaapi_get_surface_id(&h->cur_pic_ptr->f));
 if (ret < 0)
 goto finish;
 
diff --git a/libavcodec/vaapi_internal.h b/libavcodec/vaapi_internal.h
index 0292654..d0fa7ae 100644
--- a/libavcodec/vaapi_internal.h
+++ b/libavcodec/vaapi_internal.h
@@ -35,10 +35,10 @@
  * @{
  */
 
-/** Extract VASurfaceID from a Picture */
-static inline VASurfaceID ff_vaapi_get_surface_id(Picture *pic)
+/** Extract VASurfaceID from an AVFrame */
+static inline VASurfaceID ff_vaapi_get_surface_id(AVFrame *pic)
 {
-return (uintptr_t)pic->f.data[3];
+return (uintptr_t)pic->data[3];
 }
 
 /** Common AVHWAccel.end_frame() implementation */
diff --git a/libavcodec/vaapi_mpeg2.c b/libavcodec/vaapi_mpeg2.c
index d873cd0..e0f9193 100644
--- a/libavcodec/vaapi_mpeg2.c
+++ b/libavcodec/vaapi_mpeg2.c
@@ -73,10 +73,10 @@ static int vaapi_mpeg2_start_frame(AVCodecContext *avctx, 
av_unused const uint8_
 
 switch (s->pict_type) {
 case AV_PICTURE_TYPE_B:
-pic_param->backward_reference_picture = 
ff_vaapi_get_surface_id(&s->next_picture);
+pic_param->backward_reference_picture = 
ff_vaapi_get_surface_id(&s->next_picture.f);
 // fall-through
 case AV_PICTURE_TYPE_P:
-pic_param->forward_reference_picture = 
ff_vaapi_get_surface_id(&s->last_picture);
+pic_param->forward_reference_picture = 
ff_vaapi_get_surface_id(&s->last_picture.f);
 break;
 }
 
diff --git a/libavcodec/vaapi_mpeg4.c b/libavcodec/vaapi_mpeg4.c
index b771482..098b37a 100644
--- a/libavcodec/vaapi_mpeg4.c
+++ b/libavcodec/vaapi_mpeg4.c
@@ -95,9 +95,9 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, 
av_unused const uint8_
 pic_param->TRD  = s->pp_time;
 
 if (s->pict_type == AV_PICTURE_TYPE_B)
-pic_param->backward_reference_picture = 
ff_vaapi_get_surface_id(&s->next_picture);
+pic_param->backward_reference_picture = 
ff_vaapi_get_surface_id(&s->next_picture.f);
 if (s->pict_type != AV_PICTURE_TYPE_I)
-pic_param->forward_reference_picture  = 
ff_vaapi_get_surface_id(&s->last_picture);
+pic_param->forward_reference_picture  = 
ff_vaapi_get_surface_id(&s->last_picture.f);
 
 /* Fill in VAIQMatrixBufferMPEG4 */
 /* Only the first inverse quantisation method uses the weighting matrices 
*/
diff --git a/libavcodec/vaapi_vc1.c b/libavcodec/vaapi_vc1.c
index 50cba16..f50c5cf 100644
--- a/libavcodec/vaapi_vc1.c
+++ b/libavcodec/vaapi_vc1.c
@@ -258,10 +258,10 @@ static int vaapi_vc1_start_frame(AVCodecContext *avctx, 
av_unused const uint8_t
 
 switch (s->pict_type) {
 case AV_PICTURE_TYPE_B:
-pic_param->backward_reference_picture = 
ff_vaapi_get_surface_id(&s->next_picture);
+pic_param->backward_reference_picture = 
ff_vaapi_get_surface_id(&s->next_picture.f);
 // fall-through
 case AV_PICTURE_TYPE_P:
-pic_param->forward_reference_picture = 
ff_vaapi_get_surface_id(&s->last_picture);
+pic_param->forward_reference_picture 

Re: [libav-devel] [PATCH 1/6] truehd: add hand-scheduled ARM asm version of mlp_filter_channel.

2014-03-20 Thread Martin Storsjö

On Thu, 20 Mar 2014, Ben Avison wrote:


Profiling results for overall audio decode and the mlp_filter_channel(_arm)
function in particular are as follows:

 Before  After
 Mean   StdDev   Mean   StdDev  Confidence  Change
6:2 total 380.4  22.0 370.8  17.087.4%   +2.6%  (insignificant)
6:2 function  60.7   7.2  36.6   8.1 100.0%  +65.8%
8:2 total 357.0  17.5 343.2  19.097.8%   +4.0%  (insignificant)
8:2 function  60.3   8.8  37.3   3.8 100.0%  +61.8%
6:6 total 717.2  23.2 658.4  15.7100.0%  +8.9%
6:6 function  140.4  12.9 81.5   9.2 100.0%  +72.4%
8:8 total 981.9  16.2 896.2  24.5100.0%  +9.6%
8:8 function  193.4  15.0 103.3  11.5100.0%  +87.2%

Experiments with adding preload instructions to this function yielded no
useful benefit, so these have not been included.

The assembly version has also been tested with a fuzz tester to ensure that
any combinations of inputs not exercised by my available test streams still
generate mathematically identical results to the C version.
---
libavcodec/arm/Makefile  |2 +
libavcodec/arm/mlpdsp_arm.S  |  435 ++
libavcodec/arm/mlpdsp_init_arm.c |   36 +++
libavcodec/mlpdsp.c  |2 +
libavcodec/mlpdsp.h  |1 +
5 files changed, 476 insertions(+), 0 deletions(-)
create mode 100644 libavcodec/arm/mlpdsp_arm.S
create mode 100644 libavcodec/arm/mlpdsp_init_arm.c

diff --git a/libavcodec/arm/Makefile b/libavcodec/arm/Makefile
index 8bdccbd..c6cc96e 100644
--- a/libavcodec/arm/Makefile
+++ b/libavcodec/arm/Makefile
@@ -21,6 +21,8 @@ OBJS-$(CONFIG_H264PRED)+= 
arm/h264pred_init_arm.o
OBJS-$(CONFIG_H264QPEL)+= arm/h264qpel_init_arm.o
OBJS-$(CONFIG_HPELDSP) += arm/hpeldsp_init_arm.o\
  arm/hpeldsp_arm.o
+OBJS-$(CONFIG_MLP_DECODER) += arm/mlpdsp_init_arm.o \
+  arm/mlpdsp_arm.o
OBJS-$(CONFIG_MPEGAUDIODSP)+= arm/mpegaudiodsp_init_arm.o
OBJS-$(CONFIG_MPEGVIDEO)   += arm/mpegvideo_arm.o
OBJS-$(CONFIG_NEON_CLOBBER_TEST)   += arm/neontest.o
diff --git a/libavcodec/arm/mlpdsp_arm.S b/libavcodec/arm/mlpdsp_arm.S
new file mode 100644
index 000..9e0bf57
--- /dev/null
+++ b/libavcodec/arm/mlpdsp_arm.S
@@ -0,0 +1,435 @@
+/*
+ * Copyright (c) 2014 RISC OS Open Ltd
+ * Author: Ben Avison 
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/arm/asm.S"
+
+// This code uses too many ARM-only tricks to easily assemble as Thumb
+.arm


Just to be clear, the tricks that don't work in thumb mode are 
non-constant shifts, and jump tables with "ldr pc, [pc, ...]", right?


Forcing arm mode like this isn't ok in all configurations - e.g. when 
building for WinRT/Windows Phone 8, you really have to build all of it in 
thumb mode; the linker doesn't handle everything needed for mixing the 
modes there.


Would it be acceptable to build and run this code only if CONFIG_THUMB is 
disabled? That's the case for most raspberry pi builds at least, although 
I guess it would lead to not using this code at all on other e.g. armv7 
builds on linux where it still could have been beneficial?


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


Re: [libav-devel] [PATCH] fixed miscellaneous coding standard violation

2014-03-20 Thread Martin Storsjö

On Wed, 19 Mar 2014, Tanja Batchelor wrote:


---
libavformat/mpeg.c |  6 +++---
libavformat/srtp.c | 10 +-
2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavformat/srtp.c b/libavformat/srtp.c
index 6659bfc..7ccba47 100644
--- a/libavformat/srtp.c
+++ b/libavformat/srtp.c
@@ -400,8 +400,8 @@ static void print_data(const uint8_t *buf, int len)
{
int i;
for (i = 0; i < len; i++)
-printf("%02x", buf[i]);
-printf("\n");
+av_log("%02x", buf[i]);
+av_log("\n");
}

static int test_decrypt(struct SRTPContext *srtp, const uint8_t *in, int len,
@@ -426,11 +426,11 @@ static void test_encrypt(const uint8_t *data, int in_len, 
const char *suite,
len = ff_srtp_encrypt(&enc, data, in_len, buf, sizeof(buf));
if (!ff_srtp_decrypt(&dec, buf, &len)) {
if (len == in_len && !memcmp(buf, data, len))
-printf("Decrypted content matches input\n");
+av_log("Decrypted content matches input\n");
else
-printf("Decrypted content doesn't match input\n");
+av_log("Decrypted content doesn't match input\n");
} else {
-printf("Decryption failed\n");
+av_log("Decryption failed\n");
}
ff_srtp_free(&enc);
ff_srtp_free(&dec);
--
1.9.0


This is part of the srtp test program and intentionally uses printf to 
write the output to stdout instead of stderr - please don't change it to 
av_log.


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