Re: [libav-devel] [PATCH] cook: Use the correct table for 6-bit stereo coupling

2018-10-14 Thread Vittorio Giovara
On Sun, Oct 14, 2018 at 3:32 PM Luca Barbato  wrote:

> Thanks to Kostya for digging it out and telling me.
> ---
>
 libavcodec/cookdata.h | 13 +++--
>  1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/libavcodec/cookdata.h b/libavcodec/cookdata.h
> index 714ba1e76d..83fd7c71fb 100644
> --- a/libavcodec/cookdata.h
> +++ b/libavcodec/cookdata.h
> @@ -453,12 +453,13 @@ static const uint16_t ccpl_huffcodes5[31] = {
>  };
>
>  static const uint16_t ccpl_huffcodes6[63] = {
> -
> 0x0004,0x0005,0x0005,0x0006,0x0006,0x0007,0x0007,0x0007,0x0007,0x0008,0x0008,0x0008,
> -
> 0x0008,0x0009,0x0009,0x0009,0x0009,0x000a,0x000a,0x000a,0x000a,0x000a,0x000b,0x000b,
> -
> 0x000b,0x000b,0x000c,0x000d,0x000e,0x000e,0x0010,0x,0x000a,0x0018,0x0019,0x0036,
> -
> 0x0037,0x0074,0x0075,0x0076,0x0077,0x00f4,0x00f5,0x00f6,0x00f7,0x01f5,0x01f6,0x01f7,
> -
> 0x01f8,0x03f6,0x03f7,0x03f8,0x03f9,0x03fa,0x07fa,0x07fb,0x07fc,0x07fd,0x0ffd,0x1ffd,
> -0x3ffd,0x3ffe,0x,
> +0Xfffe, 0X7ffe, 0X3ffc, 0X1ffc, 0X0ffc, 0X07f6, 0X07f7, 0X07f8,
> 0X07f9,
> +0X03f2, 0X03f3, 0X03f4, 0X03f5, 0X01f0, 0X01f1, 0X01f2, 0X01f3,
> 0X01f4,
> +0X00f0, 0X00f1, 0X00f2, 0X00f3, 0X0070, 0X0071, 0X0072, 0X0073,
> 0X0034,
> +0X0035, 0X0016, 0X0017, 0X0004, 0X, 0X000a, 0X0018, 0X0019,
> 0X0036,
> +0X0037, 0X0074, 0X0075, 0X0076, 0X0077, 0X00f4, 0X00f5, 0X00f6,
> 0X00f7,
> +0X01f5, 0X01f6, 0X01f7, 0X01f8, 0X03f6, 0X03f7, 0X03f8, 0X03f9,
> 0X03fa,
> +0X07fa, 0X07fb, 0X07fc, 0X07fd, 0X0ffd, 0X1ffd, 0X3ffd, 0X3ffe, 0X
>  };
>
>  static const uint8_t ccpl_huffbits2[3] = {
> --
>

ok but please use the 0x notation instead of 0X
does this fix any particular sample?
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 16/20] tests: Move do_lavf() to fate-run.sh

2018-09-21 Thread Vittorio Giovara
On Fri, Sep 21, 2018 at 7:06 PM, Diego Biurrun  wrote:

> On Fri, Sep 21, 2018 at 05:28:01PM +0200, Vittorio Giovara wrote:
> > On Fri, Sep 21, 2018 at 2:56 PM, Diego Biurrun  wrote:
> > > On Thu, Sep 20, 2018 at 01:39:20PM +0200, Vittorio Giovara wrote:
> > > > On Thu, Sep 20, 2018 at 10:47 AM, Diego Biurrun 
> > > wrote:
> > > > > --- a/tests/fate-run.sh
> > > > > +++ b/tests/fate-run.sh
> > > > > -FATE_LAVF-$(call ENCDEC2, MPEG4,  MP2,   NUT)
> > > += nut
> > > > >  FATE_LAVF-$(call ENCMUX,  RV10 AC3_FIXED,RM)
> > >  += rm
> > > > > -FATE_LAVF-$(call ENCDEC,  FLV,   SWF)
> > > += swf
> > > > > -FATE_LAVF-$(call ENCDEC2, MPEG2VIDEO, MP2,   MPEGTS)
> > >  += ts
> > > > >  FATE_LAVF-$(CONFIG_YUV4MPEGPIPE_MUXER)
> > >  += y4m
> > > > >
> > > > > +
> > > > > +FATE_LAVF_LAVF-$(call ENCDEC2, MSMPEG4V3,  MP2,   ASF)
> > > > > += asf
> > > >
> > > > LAVF_LAVF? :-/
> > > > isn't there a way to prevent this duplication?
> > >
> > > Admittedly, this is not pretty. I'd have to rename the testing
> function as
> > > well, the Make variables match the testing function names. Suggestions?
> >
> > IMO renaming as you propose is fine
>
> I did not propose anything, I am waiting for suggestions ;-)
>
>

> I'd have to rename the testing function as
> well, the Make variables match the testing function names.
>

That sounded like a proposal :-p
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 16/20] tests: Move do_lavf() to fate-run.sh

2018-09-21 Thread Vittorio Giovara
On Fri, Sep 21, 2018 at 2:56 PM, Diego Biurrun  wrote:

> On Thu, Sep 20, 2018 at 01:39:20PM +0200, Vittorio Giovara wrote:
> > On Thu, Sep 20, 2018 at 10:47 AM, Diego Biurrun 
> wrote:
> > > --- a/tests/fate-run.sh
> > > +++ b/tests/fate-run.sh
> > > -FATE_LAVF-$(call ENCDEC2, MPEG4,  MP2,   NUT)
> += nut
> > >  FATE_LAVF-$(call ENCMUX,  RV10 AC3_FIXED,RM)
>  += rm
> > > -FATE_LAVF-$(call ENCDEC,  FLV,   SWF)
> += swf
> > > -FATE_LAVF-$(call ENCDEC2, MPEG2VIDEO, MP2,   MPEGTS)
>  += ts
> > >  FATE_LAVF-$(CONFIG_YUV4MPEGPIPE_MUXER)
>  += y4m
> > >
> > > +
> > > +FATE_LAVF_LAVF-$(call ENCDEC2, MSMPEG4V3,  MP2,   ASF)
> > > += asf
> >
> > LAVF_LAVF? :-/
> > isn't there a way to prevent this duplication?
>
> Admittedly, this is not pretty. I'd have to rename the testing function as
> well, the Make variables match the testing function names. Suggestions?
>

IMO renaming as you propose is fine


> > > --- a/tests/ref/lavf/asf
> > > +++ b/tests/ref/lavf/asf
> > > @@ -1,3 +1,3 @@
> > > -33e857a06b2b5dedce0bf76c9973944c *./tests/data/fate/lavf.asf
> > > -79 ./tests/data/fate/lavf.asf
> > > -./tests/data/fate/lavf.asf CRC=0xf6340a10
> > > +33e857a06b2b5dedce0bf76c9973944c *tests/data/fate/lavf.asf
> > > +79 tests/data/fate/lavf.asf
> > > +tests/data/fate/lavf.asf CRC=0xf6340a10
> >
> > is there a way to avoid having to modify these test files?
>
> Not really; the "./" is a remnant of the legacy test infrastructure.
> All the other reference files do not have it, so I think the change
> is actually an improvement.
>

ok thanks for clarifying
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 16/20] tests: Move do_lavf() to fate-run.sh

2018-09-20 Thread Vittorio Giovara
On Thu, Sep 20, 2018 at 10:47 AM, Diego Biurrun  wrote:

> ---
>  tests/fate-run.sh|  7 ++
>  tests/fate/avformat.mak  | 53 +++
>  tests/lavf-regression.sh | 59 --
> --
>  tests/ref/lavf/asf   |  6 ++---
>  tests/ref/lavf/avi   |  6 ++---
>  tests/ref/lavf/dv|  6 ++---
>  tests/ref/lavf/flv   |  6 ++---
>  tests/ref/lavf/gxf   |  6 ++---
>  tests/ref/lavf/mkv   |  6 ++---
>  tests/ref/lavf/mov   |  6 ++---
>  tests/ref/lavf/mpg   |  6 ++---
>  tests/ref/lavf/mxf   |  6 ++---
>  tests/ref/lavf/mxf_d10   |  6 ++---
>  tests/ref/lavf/nut   |  6 ++---
>  tests/ref/lavf/swf   |  6 ++---
>  tests/ref/lavf/ts|  6 ++---
>  16 files changed, 84 insertions(+), 113 deletions(-)
>
> diff --git a/tests/fate-run.sh b/tests/fate-run.sh
> index f8c3444e29..d6eb556dae 100755
> --- a/tests/fate-run.sh
> +++ b/tests/fate-run.sh
> -FATE_LAVF-$(call ENCDEC2, MPEG4,  MP2,   NUT)+=
> nut
>  FATE_LAVF-$(call ENCMUX,  RV10 AC3_FIXED,RM) += rm
> -FATE_LAVF-$(call ENCDEC,  FLV,   SWF)+=
> swf
> -FATE_LAVF-$(call ENCDEC2, MPEG2VIDEO, MP2,   MPEGTS) += ts
>  FATE_LAVF-$(CONFIG_YUV4MPEGPIPE_MUXER)   +=
> y4m
>
> +
> +FATE_LAVF_LAVF-$(call ENCDEC2, MSMPEG4V3,  MP2,   ASF)
> += asf
>

LAVF_LAVF? :-/
isn't there a way to prevent this duplication?

diff --git a/tests/ref/lavf/asf b/tests/ref/lavf/asf
> index 9a808d4e9a..ece5beb833 100644
> --- a/tests/ref/lavf/asf
> +++ b/tests/ref/lavf/asf
> @@ -1,3 +1,3 @@
> -33e857a06b2b5dedce0bf76c9973944c *./tests/data/fate/lavf.asf
> -79 ./tests/data/fate/lavf.asf
> -./tests/data/fate/lavf.asf CRC=0xf6340a10
> +33e857a06b2b5dedce0bf76c9973944c *tests/data/fate/lavf.asf
> +79 tests/data/fate/lavf.asf
> +tests/data/fate/lavf.asf CRC=0xf6340a10
>

is there a way to avoid having to modify these test files?
or does changing the path (dropping "./") actually matter?

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

Re: [libav-devel] [PATCH 02/20] tests: Enable CRC test for yuv4mpeg

2018-09-20 Thread Vittorio Giovara
On Thu, Sep 20, 2018 at 10:47 AM, Diego Biurrun  wrote:

> ---
>  tests/lavf-regression.sh | 2 +-
>  tests/ref/lavf/y4m   | 1 +
>  2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tests/lavf-regression.sh b/tests/lavf-regression.sh
> index 18f000bbea..fc9869cb9d 100755
> --- a/tests/lavf-regression.sh
> +++ b/tests/lavf-regression.sh
> @@ -130,7 +130,7 @@ fi
>  if [ -n "$do_y4m" ] ; then
>  file=${outfile}lavf.$test
>  do_avconv $file $DEC_OPTS -f image2 -c:v pgmyuv -i $raw_src $ENC_OPTS -t
> 1 -qscale 10
> -#do_avconv_crc $file -i $target_path/$file
> +do_avconv_crc $file -i $target_path/$file
>  fi
>
>  # image formats
> diff --git a/tests/ref/lavf/y4m b/tests/ref/lavf/y4m
> index 8c1566ea0d..367b37621d 100644
> --- a/tests/ref/lavf/y4m
> +++ b/tests/ref/lavf/y4m
> @@ -1,2 +1,3 @@
>  ec8178cb152f9cdbfd9cb724d977db2e *./tests/data/lavf/lavf.y4m
>  3801808 ./tests/data/lavf/lavf.y4m
> +./tests/data/lavf/lavf.y4m CRC=0x0a941f26
> --


OK. Do you know why it was disabled?
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] libopenh264dec: Export the decoded profile and level in AVCodecContext

2018-08-31 Thread Vittorio Giovara
On Fri, Aug 31, 2018 at 11:25 AM, Martin Storsjö  wrote:

> ---
>  libavcodec/libopenh264dec.c | 5 +
>  1 file changed, 5 insertions(+)
>
> diff --git a/libavcodec/libopenh264dec.c b/libavcodec/libopenh264dec.c
> index 5990a72ff9..7e9e66743a 100644
> --- a/libavcodec/libopenh264dec.c
> +++ b/libavcodec/libopenh264dec.c
> @@ -95,6 +95,7 @@ static int svc_decode_frame(AVCodecContext *avctx, void
> *data,
>  int linesize[3];
>  AVFrame *avframe = data;
>  DECODING_STATE state;
> +int opt;
>
>  if (!avpkt->data) {
>  #if OPENH264_VER_AT_LEAST(1, 9)
> @@ -136,6 +137,10 @@ FF_DISABLE_DEPRECATION_WARNINGS
>  avframe->pkt_pts = avpkt->pts;
>  FF_ENABLE_DEPRECATION_WARNINGS
>  #endif
> +(*s->decoder)->GetOption(s->decoder, DECODER_OPTION_PROFILE, );
> +avctx->profile = opt;
> +(*s->decoder)->GetOption(s->decoder, DECODER_OPTION_LEVEL, );
> +avctx->level = opt;
>
>  *got_frame = 1;
>  return avpkt->size;
> --
>

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

[libav-devel] [PATCH] aac: Rework extradata parsing code

2018-04-12 Thread Vittorio Giovara
- enable the parsing code
- use the new buffer instead of replacing the context one
- do not push/pop configuration, just discard the exiting one
- propagate errors correctly
---
 libavcodec/aacdec.c | 22 --
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index cf97181092..0c899285dd 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -324,20 +324,14 @@ static int aac_decode_frame(AVCodecContext *avctx, void 
*data,
AV_PKT_DATA_JP_DUALMONO,
_dualmono_size);
 
-if (new_extradata && 0) {
-av_free(avctx->extradata);
-avctx->extradata = av_mallocz(new_extradata_size +
-  AV_INPUT_BUFFER_PADDING_SIZE);
-if (!avctx->extradata)
-return AVERROR(ENOMEM);
-avctx->extradata_size = new_extradata_size;
-memcpy(avctx->extradata, new_extradata, new_extradata_size);
-push_output_configuration(ac);
-if (decode_audio_specific_config(ac, ac->avctx, >oc[1].m4ac,
- avctx->extradata,
- avctx->extradata_size*8LL, 1) < 0) {
-pop_output_configuration(ac);
-return AVERROR_INVALIDDATA;
+if (new_extradata) {
+/* discard previous configuration */
+ac->oc[1].status = OC_NONE;
+err = decode_audio_specific_config(ac, ac->avctx, >oc[1].m4ac,
+   new_extradata,
+   new_extradata_size * 8LL, 1);
+if (err < 0) {
+return err;
 }
 }
 
-- 
2.17.0

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

[libav-devel] [PATCH 1/6] avprobe: Support printing strings with empty keys

2018-04-04 Thread Vittorio Giovara
---
 avtools/avprobe.c | 38 ++
 1 file changed, 26 insertions(+), 12 deletions(-)

diff --git a/avtools/avprobe.c b/avtools/avprobe.c
index a9ca1934ca..d6809042f7 100644
--- a/avtools/avprobe.c
+++ b/avtools/avprobe.c
@@ -235,10 +235,14 @@ static void ini_print_integer(const char *key, int64_t 
value)
 
 static void ini_print_string(const char *key, const char *value)
 {
-ini_escape_print(key);
-avio_printf(probe_out, "=");
-ini_escape_print(value);
-avio_w8(probe_out, '\n');
+if (key) {
+ini_escape_print(key);
+avio_printf(probe_out, "=%s\n", value);
+} else {
+if (octx.prefix[octx.level -1].nb_elems)
+avio_printf(probe_out, ",");
+avio_printf(probe_out, "%s", value);
+}
 }
 
 /*
@@ -329,14 +333,24 @@ static void json_escape_print(const char *s)
 
 static void json_print_string(const char *key, const char *value)
 {
-if (octx.prefix[octx.level -1].nb_elems)
-avio_printf(probe_out, ",\n");
-AVP_INDENT();
-avio_w8(probe_out, '\"');
-json_escape_print(key);
-avio_printf(probe_out, "\" : \"");
-json_escape_print(value);
-avio_w8(probe_out, '\"');
+if (key) {
+if (octx.prefix[octx.level -1].nb_elems)
+avio_printf(probe_out, ",\n");
+AVP_INDENT();
+avio_w8(probe_out, '\"');
+json_escape_print(key);
+avio_printf(probe_out, "\" : \"");
+json_escape_print(value);
+avio_w8(probe_out, '\"');
+} else {
+if (octx.prefix[octx.level -1].nb_elems)
+avio_printf(probe_out, ", ");
+else
+AVP_INDENT();
+avio_w8(probe_out, '\"');
+json_escape_print(value);
+avio_w8(probe_out, '\"');
+}
 }
 
 /*
-- 
2.16.2

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

[libav-devel] [PATCH 3/6] display: Add AVDisplayOrientation API

2018-04-04 Thread Vittorio Giovara
The transformation operations that can be described by a display matrix
are not limited to pure rotation, but include horizontal and vertical
flip, as well as transpose and antitranspose. Unfortunately the current
API can only return a rotation angle in degrees, and is not designed to
detect flip operations or a combination of rotation and flip.

So implement an additional API to analyze the display matrix and return
the most common rotation operations (multiples of 90º) as well flips or
a combination thereof. This function returns a bitfield mask composed of
AVDisplayOrientation elements that describe which rendering operations
should be performed on the frame. The existing API is still available
and useful in case of custom rotations.

Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
Note: the new operations describe a clockwise rotation, while the
old API provided a counterclockwise rotation. I always felt this was
a mistake as it's counterintuitive and suprising to new users, so I
didn't want to cargo-cult it to a new API. What do people think about it?

See also https://github.com/FFMS/ffms2/issues/317 for flipped samples, code,
and additional discussion.

Missing changelog entry and version bump.
Vittorio

 libavutil/display.c | 92 +
 libavutil/display.h | 53 ++
 2 files changed, 145 insertions(+)

diff --git a/libavutil/display.c b/libavutil/display.c
index f7500948ff..839961ec20 100644
--- a/libavutil/display.c
+++ b/libavutil/display.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 
+#include "avstring.h"
 #include "display.h"
 #include "mathematics.h"
 
@@ -73,3 +74,94 @@ void av_display_matrix_flip(int32_t matrix[9], int hflip, 
int vflip)
 for (i = 0; i < 9; i++)
 matrix[i] *= flip[i % 3];
 }
+
+uint32_t av_display_orientation_get(int32_t matrix_src[9])
+{
+int32_t matrix[9];
+uint32_t orientation = 0;
+int64_t det = (int64_t)matrix_src[0] * matrix_src[4] - 
(int64_t)matrix_src[1] * matrix_src[3];
+
+/* Duplicate matrix so that the input one is not modified in case of flip. 
*/
+memcpy(matrix, matrix_src, sizeof(*matrix_src) * 9);
+
+if (det < 0) {
+/* Always assume an horizontal flip for simplicity, it can be
+ * changed later if rotation is 180º. */
+orientation = AV_FLIP_HORIZONTAL;
+av_display_matrix_flip(matrix, 1, 0);
+}
+
+if (matrix[1] == (1 << 16) && matrix[3] == -(1 << 16)) {
+orientation |= AV_ROTATION_90;
+} else if (matrix[0] == -(1 << 16) && matrix[4] == -(1 << 16)) {
+if (det < 0)
+orientation = AV_FLIP_VERTICAL;
+else
+orientation |= AV_ROTATION_180;
+} else if (matrix[1] == -(1 << 16) && matrix[3] == (1 << 16)) {
+orientation |= AV_ROTATION_270;
+} else if (matrix[0] == (1 << 16) && matrix[4] == (1 << 16)) {
+orientation |= AV_IDENTITY;
+} else {
+orientation |= AV_ROTATION_CUSTOM;
+}
+
+return orientation;
+}
+
+void av_display_orientation_set(int32_t matrix[9], uint32_t orientation, 
double angle)
+{
+int hflip = !!(orientation & AV_FLIP_HORIZONTAL);
+int vflip = !!(orientation & AV_FLIP_VERTICAL);
+
+memset(matrix, 0, sizeof(*matrix) * 9);
+matrix[8] = 1 << 30;
+
+if (orientation & AV_IDENTITY) {
+matrix[0] = 1 << 16;
+matrix[4] = 1 << 16;
+} else if (orientation & AV_ROTATION_90) {
+matrix[1] = 1 << 16;
+matrix[3] = -(1 << 16);
+} else if (orientation & AV_ROTATION_180) {
+matrix[0] = -(1 << 16);
+matrix[4] = -(1 << 16);
+} else if (orientation & AV_ROTATION_270) {
+matrix[1] = -(1 << 16);
+matrix[3] = 1 << 16;
+} else if (orientation & AV_ROTATION_CUSTOM) {
+av_display_rotation_set(matrix, angle);
+}
+
+av_display_matrix_flip(matrix, hflip, vflip);
+}
+
+void av_display_orientation_name(uint32_t orientation, char *buf, size_t 
buf_size)
+{
+if (orientation == 0) {
+av_strlcpy(buf, "identity", buf_size);
+return;
+}
+
+if (orientation & AV_ROTATION_90)
+av_strlcpy(buf, "rotation_90", buf_size);
+else if (orientation & AV_ROTATION_180)
+av_strlcpy(buf, "rotation_180", buf_size);
+else if (orientation & AV_ROTATION_270)
+av_strlcpy(buf, "rotation_270", buf_size);
+else if (orientation & AV_ROTATION_CUSTOM)
+av_strlcpy(buf, "rotation_custom", buf_size);
+else
+buf[0] = '\0';
+
+if (orientation & AV_FLIP_HORIZONTAL) {
+if (buf[0] != '\0')
+av_strlcat(buf, "+", buf_size);
+av_strlcat(buf, &q

[libav-devel] [PATCH 6/6] avconv: Support automatic horizontal and vertical flip

2018-04-04 Thread Vittorio Giovara
---
 avtools/avconv_filter.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/avtools/avconv_filter.c b/avtools/avconv_filter.c
index 858dc0409b..5a535a7ac1 100644
--- a/avtools/avconv_filter.c
+++ b/avtools/avconv_filter.c
@@ -551,6 +551,17 @@ static int configure_input_video_filter(FilterGraph *fg, 
InputFilter *ifilter,
 }
 if (ret < 0)
 return ret;
+
+if (orientation & AV_FLIP_HORIZONTAL) {
+ret = insert_filter(_filter, _idx, "hflip", NULL);
+if (ret < 0)
+return ret;
+}
+if (orientation & AV_FLIP_VERTICAL) {
+ret = insert_filter(_filter, _idx, "vflip", NULL);
+if (ret < 0)
+return ret;
+}
 }
 }
 
-- 
2.16.2

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

[libav-devel] [PATCH 2/6] avprobe: Print a user-friendly version of the display matrix

2018-04-04 Thread Vittorio Giovara
Shift fixed point numbers to be actual decimal numbers.
---
 avtools/avprobe.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/avtools/avprobe.c b/avtools/avprobe.c
index d6809042f7..0ea9ff46fd 100644
--- a/avtools/avprobe.c
+++ b/avtools/avprobe.c
@@ -131,6 +131,7 @@ typedef struct PrintContext {
 static AVIOContext *probe_out = NULL;
 static PrintContext octx;
 #define AVP_INDENT() avio_printf(probe_out, "%*c", octx.level * 2, ' ')
+#define CONV_FP(x,fp) ((double) (x)) / (1 << fp)
 
 /*
  * Default format, INI
@@ -816,6 +817,15 @@ static void show_stream(InputFile *ifile, InputStream *ist)
 for (j = 0; j < 9; j++)
 probe_int(NULL, ((int32_t *)sd->data)[j]);
 probe_array_footer("matrix", 1);
+probe_array_header("matrix_str", 1);
+for (j = 0; j < 9; j++) {
+char buf[32];
+int fp = (j == 2 || j == 5 || j == 8) ? 30 : 16;
+int32_t val = ((int32_t *)sd->data)[j];
+value_string(buf, sizeof(buf), CONV_FP(val, fp), "");
+probe_str(NULL, buf);
+}
+probe_array_footer("matrix_str", 1);
 probe_int("rotation",
   av_display_rotation_get((int32_t *)sd->data));
 probe_object_footer("displaymatrix");
-- 
2.16.2

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

[libav-devel] [PATCH 5/6] avconv: Port automatic rotation to the new orientation API

2018-04-04 Thread Vittorio Giovara
Needed to avoid conflicts with the upcoming automatic flip.
---
 avtools/avconv_filter.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/avtools/avconv_filter.c b/avtools/avconv_filter.c
index 884478da27..858dc0409b 100644
--- a/avtools/avconv_filter.c
+++ b/avtools/avconv_filter.c
@@ -538,15 +538,15 @@ static int configure_input_video_filter(FilterGraph *fg, 
InputFilter *ifilter,
 uint8_t* displaymatrix = av_stream_get_side_data(ist->st,
  
AV_PKT_DATA_DISPLAYMATRIX, NULL);
 if (displaymatrix) {
-double rot = av_display_rotation_get((int32_t*) displaymatrix);
-if (rot < -135 || rot > 135) {
+uint32_t orientation = av_display_orientation_get((int32_t*) 
displaymatrix);
+if (orientation & AV_ROTATION_180) {
 ret = insert_filter(_filter, _idx, "vflip", NULL);
 if (ret < 0)
 return ret;
 ret = insert_filter(_filter, _idx, "hflip", NULL);
-} else if (rot < -45) {
+} else if (orientation & AV_ROTATION_90) {
 ret = insert_filter(_filter, _idx, "transpose", 
"dir=clock");
-} else if (rot > 45) {
+} else if (orientation & AV_ROTATION_270) {
 ret = insert_filter(_filter, _idx, "transpose", 
"dir=cclock");
 }
 if (ret < 0)
-- 
2.16.2

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

[libav-devel] [PATCH 4/6] avprobe: Report the display orientation operations

2018-04-04 Thread Vittorio Giovara
---
 avtools/avprobe.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/avtools/avprobe.c b/avtools/avprobe.c
index 0ea9ff46fd..8ac8960014 100644
--- a/avtools/avprobe.c
+++ b/avtools/avprobe.c
@@ -809,6 +809,8 @@ static void show_stream(InputFile *ifile, InputStream *ist)
 const AVPacketSideData* sd = >side_data[i];
 AVStereo3D *stereo;
 AVSphericalMapping *spherical;
+uint32_t mask;
+char buf[64];
 
 switch (sd->type) {
 case AV_PKT_DATA_DISPLAYMATRIX:
@@ -828,6 +830,10 @@ static void show_stream(InputFile *ifile, InputStream *ist)
 probe_array_footer("matrix_str", 1);
 probe_int("rotation",
   av_display_rotation_get((int32_t *)sd->data));
+mask = av_display_orientation_get((int32_t *)sd->data);
+av_display_orientation_name(mask, [0], sizeof(buf));
+probe_str("orientation", buf);
+probe_int("orientation_mask", mask);
 probe_object_footer("displaymatrix");
 break;
 case AV_PKT_DATA_STEREO3D:
-- 
2.16.2

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

[libav-devel] [PATCH] libx265: Support tiny video sizes

2018-03-16 Thread Vittorio Giovara
Where tiny is less than the default CTU size.

Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 libavcodec/libx265.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index fd5452193b..8f1d60b4e5 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -122,6 +122,17 @@ static av_cold int libx265_encode_init(AVCodecContext 
*avctx)
 ctx->params->sourceHeight= avctx->height;
 ctx->params->bEnablePsnr = !!(avctx->flags & AV_CODEC_FLAG_PSNR);
 
+/* Tune the CTU size based on input resolution. */
+if (ctx->params->sourceWidth < 64 || ctx->params->sourceHeight < 64)
+ctx->params->maxCUSize = 32;
+if (ctx->params->sourceWidth < 32 || ctx->params->sourceHeight < 32)
+ctx->params->maxCUSize = 16;
+if (ctx->params->sourceWidth < 16 || ctx->params->sourceHeight < 16) {
+av_log(avctx, AV_LOG_ERROR, "Image size is too small (%dx%d).\n",
+   ctx->params->sourceWidth, ctx->params->sourceHeight);
+return AVERROR(EINVAL);
+}
+
 if ((avctx->color_primaries <= AVCOL_PRI_BT2020 &&
  avctx->color_primaries != AVCOL_PRI_UNSPECIFIED) ||
 (avctx->color_trc <= AVCOL_TRC_BT2020_12 &&
-- 
2.16.1

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

Re: [libav-devel] [PATCH] hls: Add a discontinuity marker on recover

2018-03-06 Thread Vittorio Giovara
On Tue, Mar 6, 2018 at 2:50 PM, Luca Barbato  wrote:

> On 19/02/2018 13:49, Luca Barbato wrote:
>
>> On 16/02/2018 16:09, Luca Barbato wrote:
>>
>>> It seems to improve the compatibility with the js demuxers.
>>> ---
>>>   libavformat/hlsenc.c | 25 -
>>>   1 file changed, 20 insertions(+), 5 deletions(-)
>>>
>>>
>> Ping.
>>
>>
> Ping2.
>

apparently ok (if tested)
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] Support AV1 encoding using libaom

2018-02-27 Thread Vittorio Giovara
On Tue, Feb 27, 2018 at 5:25 AM, Luca Barbato <lu_z...@gentoo.org> wrote:

> On 26/02/2018 18:21, Vittorio Giovara wrote:
>
>> On Mon, Feb 26, 2018 at 12:10 AM, Luca Barbato <lu_z...@gentoo.org>
>> wrote:
>>
>> ---
>>>
>>> +
>>> +if (avctx->qmin > 0)
>>> +enccfg.rc_min_quantizer = avctx->qmin;
>>> +if (avctx->qmax > 0)
>>> +enccfg.rc_max_quantizer = avctx->qmax;
>>> +
>>> +#if FF_API_PRIVATE_OPT
>>> +FF_DISABLE_DEPRECATION_WARNINGS
>>> +if (avctx->frame_skip_threshold)
>>> +ctx->drop_threshold = avctx->frame_skip_threshold;
>>> +FF_ENABLE_DEPRECATION_WARNINGS
>>> +#endif
>>> +enccfg.rc_dropframe_thresh = ctx->drop_threshold;
>>> +
>>>
>>>
>>
>> +static int storeframe(AVCodecContext *avctx, struct FrameListData
>>> *cx_frame,
>>> +  AVPacket *pkt)
>>> +{
>>> +int ret = ff_alloc_packet(pkt, cx_frame->sz);
>>> +if (ret >= 0) {
>>> +memcpy(pkt->data, cx_frame->buf, pkt->size);
>>> +pkt->pts = pkt->dts = cx_frame->pts;
>>> +#if FF_API_CODED_FRAME
>>> +FF_DISABLE_DEPRECATION_WARNINGS
>>> +avctx->coded_frame->pts   = cx_frame->pts;
>>> +avctx->coded_frame->key_frame = !!(cx_frame->flags &
>>> AOM_FRAME_IS_KEY);
>>> +FF_ENABLE_DEPRECATION_WARNINGS
>>> +#endif
>>> +
>>> +if (!!(cx_frame->flags & AOM_FRAME_IS_KEY)) {
>>> +#if FF_API_CODED_FRAME
>>> +FF_DISABLE_DEPRECATION_WARNINGS
>>> +avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
>>> +FF_ENABLE_DEPRECATION_WARNINGS
>>> +#endif
>>> +pkt->flags |= AV_PKT_FLAG_KEY;
>>> +} else {
>>> +#if FF_API_CODED_FRAME
>>> +FF_DISABLE_DEPRECATION_WARNINGS
>>> +avctx->coded_frame->pict_type = AV_PICTURE_TYPE_P;
>>> +FF_ENABLE_DEPRECATION_WARNINGS
>>> +#endif
>>> +}
>>> +} else {
>>>
>>>
>> I don't think we should add deprecated code.
>>
>>
> We have to if we want to keep compatibility.
>

No, compatibility is not needed for new APIs and new codecs.
If you want to implement this functionality, you should add the proper side
data, see 40cf1bbacc6220a0aa6bed5c331871d43f9ce370.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] Support AV1 encoding using libaom

2018-02-26 Thread Vittorio Giovara
On Mon, Feb 26, 2018 at 12:10 AM, Luca Barbato  wrote:

> ---
>
> +
> +if (avctx->qmin > 0)
> +enccfg.rc_min_quantizer = avctx->qmin;
> +if (avctx->qmax > 0)
> +enccfg.rc_max_quantizer = avctx->qmax;
> +
> +#if FF_API_PRIVATE_OPT
> +FF_DISABLE_DEPRECATION_WARNINGS
> +if (avctx->frame_skip_threshold)
> +ctx->drop_threshold = avctx->frame_skip_threshold;
> +FF_ENABLE_DEPRECATION_WARNINGS
> +#endif
> +enccfg.rc_dropframe_thresh = ctx->drop_threshold;
> +
>


> +static int storeframe(AVCodecContext *avctx, struct FrameListData
> *cx_frame,
> +  AVPacket *pkt)
> +{
> +int ret = ff_alloc_packet(pkt, cx_frame->sz);
> +if (ret >= 0) {
> +memcpy(pkt->data, cx_frame->buf, pkt->size);
> +pkt->pts = pkt->dts = cx_frame->pts;
> +#if FF_API_CODED_FRAME
> +FF_DISABLE_DEPRECATION_WARNINGS
> +avctx->coded_frame->pts   = cx_frame->pts;
> +avctx->coded_frame->key_frame = !!(cx_frame->flags &
> AOM_FRAME_IS_KEY);
> +FF_ENABLE_DEPRECATION_WARNINGS
> +#endif
> +
> +if (!!(cx_frame->flags & AOM_FRAME_IS_KEY)) {
> +#if FF_API_CODED_FRAME
> +FF_DISABLE_DEPRECATION_WARNINGS
> +avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
> +FF_ENABLE_DEPRECATION_WARNINGS
> +#endif
> +pkt->flags |= AV_PKT_FLAG_KEY;
> +} else {
> +#if FF_API_CODED_FRAME
> +FF_DISABLE_DEPRECATION_WARNINGS
> +avctx->coded_frame->pict_type = AV_PICTURE_TYPE_P;
> +FF_ENABLE_DEPRECATION_WARNINGS
> +#endif
> +}
> +} else {
>

I don't think we should add deprecated code.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 7/7] openh264: Use the framerate information

2018-02-16 Thread Vittorio Giovara
On Fri, Feb 16, 2018 at 12:02 PM, Luca Barbato  wrote:

> And not the often misleading timebase one.
> ---
>  libavcodec/libopenh264enc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
> index d075cb0854..f779c46196 100644
> --- a/libavcodec/libopenh264enc.c
> +++ b/libavcodec/libopenh264enc.c
> @@ -129,7 +129,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
>  FF_ENABLE_DEPRECATION_WARNINGS
>  #endif
>
> -param.fMaxFrameRate  = avctx->time_base.den /
> avctx->time_base.num;
> +param.fMaxFrameRate  = avctx->framerate.num /
> avctx->framerate.den;
>

why not av_q2d while at it?
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 4/7] x264: Use the framerate information instead of the timebase

2018-02-16 Thread Vittorio Giovara
On Fri, Feb 16, 2018 at 12:02 PM, Luca Barbato  wrote:

> Unbreaks the rate-control behaviour.
>

Same comment as for the x265 patch.
This seems to properly use x264 API.

---
>  libavcodec/libx264.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
> index 3dc53aaf38..b3f91a1f07 100644
> --- a/libavcodec/libx264.c
> +++ b/libavcodec/libx264.c
> @@ -573,8 +573,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  x4->params.i_height = avctx->height;
>  x4->params.vui.i_sar_width  = avctx->sample_aspect_ratio.num;
>  x4->params.vui.i_sar_height = avctx->sample_aspect_ratio.den;
> -x4->params.i_fps_num = x4->params.i_timebase_den =
> avctx->time_base.den;
> -x4->params.i_fps_den = x4->params.i_timebase_num =
> avctx->time_base.num;
> +
> +x4->params.i_fps_num = avctx->framerate.num;
> +x4->params.i_fps_den = avctx->framerate.den;
> +
> +x4->params.i_timebase_num = avctx->time_base.num;
> +x4->params.i_timebase_den = avctx->time_base.den;
>
>  x4->params.analyse.b_psnr = avctx->flags & AV_CODEC_FLAG_PSNR;
>
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 1/7] avcodec: Always fill the encoder target framerate

2018-02-16 Thread Vittorio Giovara
On Fri, Feb 16, 2018 at 12:02 PM, Luca Barbato  wrote:

> In preparation of using it in the encoders.
> ---
>  libavcodec/avcodec.h | 3 ++-
>  libavcodec/utils.c   | 5 +
>  2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 7eaa0c9277..f86ae0b8d6 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -2638,7 +2638,8 @@ typedef struct AVCodecContext {
>   * bitstream, the decoder may export it here. { 0, 1} when
>   * unknown.
>   * - encoding: May be used to signal the framerate of CFR content to
> an
> - * encoder.
> + * encoder or the target average framerate for
> rate-control
> + * tuning.
>   */
>  AVRational framerate;
>
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index ba3457664a..887c5618e2 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -539,6 +539,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  goto free_and_end;
>  }
>
> +if (avctx->framerate.num <= 0) {
> +avctx->framerate.num = avctx->time_base.den;
> +avctx->framerate.den = avctx->time_base.num;
> +}
>

Would be nice to have a comment that this is a fallback for when framerate
is not set.
Probably it would make sense to check for time_base.num too, in order to
avoid 0 as denominator.

+
>  if (avctx->codec->sample_fmts) {
>  for (i = 0; avctx->codec->sample_fmts[i] !=
> AV_SAMPLE_FMT_NONE; i++) {
>  if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
> --
>
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 3/7] x265: Use the framerate information instead of the timebase

2018-02-16 Thread Vittorio Giovara
On Fri, Feb 16, 2018 at 9:15 PM, Luca Barbato  wrote:

> On 17/02/2018 00:57, wm4 wrote:
>
>> On Fri, 16 Feb 2018 18:02:05 +0100
>> Luca Barbato  wrote:
>>
>> Unbreaks the rate-control behaviour.
>>>
>>
Would be nice that the commit message is expanded, explaining what is
currently broken and how this fixes it.


> ---
>>>   libavcodec/libx265.c | 4 ++--
>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
>>> index fd5452193b..73aff2caef 100644
>>> --- a/libavcodec/libx265.c
>>> +++ b/libavcodec/libx265.c
>>> @@ -116,8 +116,8 @@ static av_cold int libx265_encode_init(AVCodecContext
>>> *avctx)
>>>   }
>>> ctx->params->frameNumThreads = avctx->thread_count;
>>> -ctx->params->fpsNum  = avctx->time_base.den;
>>> -ctx->params->fpsDenom= avctx->time_base.num *
>>> avctx->ticks_per_frame;
>>> +ctx->params->fpsNum  = avctx->framerate.num;
>>> +ctx->params->fpsDenom= avctx->framerate.den *
>>> avctx->ticks_per_frame;
>>>   ctx->params->sourceWidth = avctx->width;
>>>   ctx->params->sourceHeight= avctx->height;
>>>   ctx->params->bEnablePsnr = !!(avctx->flags &
>>> AV_CODEC_FLAG_PSNR);
>>>
>>
>> Doesn't this use a potentially broken demuxer reported framerate?
>> (Not uncommon with mkv files at least.)
>>
> --
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 1/2] hls: Tell the actual segment being opened in verbose mode

2018-02-15 Thread Vittorio Giovara
On Thu, Feb 15, 2018 at 3:20 PM, Luca Barbato  wrote:

> ---
>  libavformat/hls.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index c9da4e30ec..5aa633269f 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -362,6 +362,7 @@ static int open_input(struct variant *var)
>  {
>  HLSContext *c = var->parent->priv_data;
>  struct segment *seg = var->segments[var->cur_seq_no -
> var->start_seq_no];
> +av_log(var->parent, AV_LOG_VERBOSE, "Opening %s\n", seg->url);
>  if (seg->key_type == KEY_NONE) {
>  return open_url(var->parent, >input, seg->url, c->avio_opts);
>  } else if (seg->key_type == KEY_AES_128) {
> --
>
>
seems fine
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 2/2] hls: Use the correct logging context

2018-02-15 Thread Vittorio Giovara
On Thu, Feb 15, 2018 at 3:20 PM, Luca Barbato  wrote:

> ---
>  libavformat/hls.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index 5aa633269f..6876b8411e 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -374,12 +374,12 @@ static int open_input(struct variant *var)
>  if (open_url(var->parent, , seg->key, c->avio_opts) == 0) {
>  ret = avio_read(pb, var->key, sizeof(var->key));
>  if (ret != sizeof(var->key)) {
> -av_log(NULL, AV_LOG_ERROR, "Unable to read key file
> %s\n",
> +av_log(var->parent, AV_LOG_ERROR, "Unable to read key
> file %s\n",
> seg->key);
>  }
>  ff_format_io_close(var->parent, );
>  } else {
> -av_log(NULL, AV_LOG_ERROR, "Unable to open key file %s\n",
> +av_log(var->parent, AV_LOG_ERROR, "Unable to open key
> file %s\n",
> seg->key);
>  }
>  av_strlcpy(var->key_url, seg->key, sizeof(var->key_url));
> @@ -428,7 +428,7 @@ reload:
>  reload_interval = v->target_duration / 2;
>  }
>  if (v->cur_seq_no < v->start_seq_no) {
> -av_log(NULL, AV_LOG_WARNING,
> +av_log(v->parent, AV_LOG_WARNING,
> "skipping %d segments ahead, expired from playlists\n",
> v->start_seq_no - v->cur_seq_no);
>  v->cur_seq_no = v->start_seq_no;
> @@ -521,7 +521,7 @@ static int hls_read_header(AVFormatContext *s)
>  goto fail;
>
>  if (c->n_variants == 0) {
> -av_log(NULL, AV_LOG_WARNING, "Empty playlist\n");
> +av_log(s, AV_LOG_WARNING, "Empty playlist\n");
>  ret = AVERROR_EOF;
>  goto fail;
>  }
> @@ -536,7 +536,7 @@ static int hls_read_header(AVFormatContext *s)
>  }
>
>  if (c->variants[0]->n_segments == 0) {
> -av_log(NULL, AV_LOG_WARNING, "Empty playlist\n");
> +av_log(s, AV_LOG_WARNING, "Empty playlist\n");
>  ret = AVERROR_EOF;
>  goto fail;
>  }
> --
>

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

Re: [libav-devel] [PATCH] Add AV1 video decoding support through libaom

2018-02-11 Thread Vittorio Giovara
On Sun, Feb 11, 2018 at 11:50 AM, Diego Biurrun  wrote:

> On Fri, Feb 09, 2018 at 10:51:36AM +0100, Luca Barbato wrote:
> >  libavcodec/version.h   |   2 +-
> >
> > --- a/libavcodec/version.h
> > +++ b/libavcodec/version.h
> > @@ -28,7 +28,7 @@
> >
> >  #define LIBAVCODEC_VERSION_MAJOR 58
> > -#define LIBAVCODEC_VERSION_MINOR  8
> > +#define LIBAVCODEC_VERSION_MINOR  9
> >  #define LIBAVCODEC_VERSION_MICRO  0
>
> I guess we should decide what to do about bumping version when there
> is no change to installed headers, e.g. when a decoder is added without
> adding an AV_CODEC_ID. Anton has been saying that minor should not be
> bumped in those cases and I think he is right.
>

IMO nothing wrong with bumping the minor version, but if not at least micro
should be changed.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 07/25] lavfi, buffersrc: switch to the new channel layout API

2018-01-19 Thread Vittorio Giovara
On Sat, Jul 22, 2017 at 12:02 PM, Anton Khirnov <an...@khirnov.net> wrote:

> Quoting Vittorio Giovara (2017-06-29 00:10:51)
> > Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
> > ---
> >  libavfilter/audio.c | 17 +--
> >  libavfilter/avfilter.c  |  9 
> >  libavfilter/avfilter.h  | 13 ++-
> >  libavfilter/avfiltergraph.c | 35 +++---
> >  libavfilter/buffersink.c|  2 +-
> >  libavfilter/buffersrc.c | 53 --
> ---
> >  libavfilter/buffersrc.h | 12 +-
> >  libavfilter/fifo.c  |  7 +++---
> >  8 files changed, 106 insertions(+), 42 deletions(-)
> >
> > diff --git a/libavfilter/audio.c b/libavfilter/audio.c
> > index 5fe9da95c3..afd8bdc169 100644
> > --- a/libavfilter/audio.c
> > +++ b/libavfilter/audio.c
> > @@ -31,7 +31,7 @@ AVFrame *ff_null_get_audio_buffer(AVFilterLink *link,
> int nb_samples)
> >  AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int
> nb_samples)
> >  {
> >  AVFrame *frame = av_frame_alloc();
> > -int channels = av_get_channel_layout_nb_
> channels(link->channel_layout);
> > +int channels = link->ch_layout.nb_channels;
> >  int ret;
> >
> >  if (!frame)
> > @@ -39,7 +39,20 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink
> *link, int nb_samples)
> >
> >  frame->nb_samples = nb_samples;
> >  frame->format = link->format;
> > -frame->channel_layout = link->channel_layout;
> > +
> > +ret = av_channel_layout_copy(>ch_layout, >ch_layout);
> > +if (ret < 0) {
> > +av_frame_free();
> > +return NULL;
> > +}
> > +#if FF_API_OLD_CHANNEL_LAYOUT
> > +FF_DISABLE_DEPRECATION_WARNINGS
> > +if (link->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ||
> > +link->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC)
> > +frame->channel_layout = link->channel_layout;
>
> This is incomplete, the channel layout should always be set, at least to
> (1<<count) - 1.
>

Right, I added this else as you suggested.

else
frame->channel_layout = (1 << channels) - 1;



> > +FF_ENABLE_DEPRECATION_WARNINGS
> > +#endif
> > +
> >  frame->sample_rate= link->sample_rate;
> >  ret = av_frame_get_buffer(frame, 0);
> >  if (ret < 0) {
> > diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
> > index 83c1a7c20d..f2adefff3d 100644
> > --- a/libavfilter/avfilter.c
> > +++ b/libavfilter/avfilter.c
> > @@ -247,16 +247,15 @@ void ff_dlog_link(void *ctx, AVFilterLink *link,
> int end)
> >  link->dst ? link->dst->filter->name : "",
> >  end ? "\n" : "");
> >  } else {
> > -char buf[128];
> > -av_get_channel_layout_string(buf, sizeof(buf), -1,
> link->channel_layout);
> > -
> > +char *chlstr = av_channel_layout_describe(>ch_layout);
> >  av_log(ctx, AV_LOG_TRACE,
> >  "link[%p r:%d cl:%s fmt:%-16s %-16s->%-16s]%s",
> > -link, link->sample_rate, buf,
> > +link, link->sample_rate, chlstr,
> >  av_get_sample_fmt_name(link->format),
> >  link->src ? link->src->filter->name : "",
> >  link->dst ? link->dst->filter->name : "",
> >  end ? "\n" : "");
> > +av_free(chlstr);
> >  }
> >  }
> >
> > @@ -683,7 +682,7 @@ int ff_filter_frame(AVFilterLink *link, AVFrame
> *frame)
> >  case AVMEDIA_TYPE_AUDIO:
> >  av_samples_copy(out->extended_data, frame->extended_data,
> >  0, 0, frame->nb_samples,
> > -av_get_channel_layout_nb_
> channels(frame->channel_layout),
> > +frame->ch_layout.nb_channels,
> >  frame->format);
> >  break;
> >  default:
> > diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
> > index 6df69dbbbf..5d5edf0ed3 100644
> > --- a/libavfilter/avfilter.h
> > +++ b/libavfilter/avfilter.h
> > @@ -36,6 +36,7 @@
> >  #include "libavutil/attributes.h"
> >  #include "libavutil/avutil.h"
> >  #include "libav

Re: [libav-devel] [PATCH 05/25] avtools: Use the new channel layout API in AVFrame

2018-01-19 Thread Vittorio Giovara
On Sat, Jul 22, 2017 at 10:15 AM, Anton Khirnov <an...@khirnov.net> wrote:

> Quoting Vittorio Giovara (2017-06-29 00:10:49)
> > ---
> >  avtools/avconv.c| 2 +-
> >  avtools/avconv_filter.c | 2 +-
> >  avtools/avplay.c| 4 ++--
> >  3 files changed, 4 insertions(+), 4 deletions(-)
> >
>
> Again, seems premature. The switch should be done at the end. If it
> needs to be done here, then your compatibility layer is broken.
>

ok I'll move tools-related changes to the end
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 04/25] avframe: switch to the new channel layout API

2018-01-19 Thread Vittorio Giovara
On Sat, Jul 22, 2017 at 10:13 AM, Anton Khirnov <an...@khirnov.net> wrote:

> Quoting Vittorio Giovara (2017-06-29 00:10:48)
> > From: Anton Khirnov <an...@khirnov.net>
> >
> > Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
> > ---
> >  libavcodec/decode.c | 67 
> >  libavcodec/encode.c |  9 ++
> >  libavutil/frame.c   | 88 ++
> +--
> >  libavutil/frame.h   | 12 +++-
> >  4 files changed, 146 insertions(+), 30 deletions(-)
> >
> > diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> > index a49cd77e51..b0d6b9fb33 100644
> > --- a/libavcodec/decode.c
> > +++ b/libavcodec/decode.c
> > @@ -132,7 +132,7 @@ static int unrefcount_frame(AVCodecInternal *avci,
> AVFrame *frame)
> >  memcpy(frame->data, avci->to_free->data,
>  sizeof(frame->data));
> >  memcpy(frame->linesize, avci->to_free->linesize,
> sizeof(frame->linesize));
> >  if (avci->to_free->extended_data != avci->to_free->data) {
> > -int planes = av_get_channel_layout_nb_channels(avci->to_free->
> channel_layout);
> > +int planes = avci->to_free->ch_layout.nb_channels;
> >  int size   = planes * sizeof(*frame->extended_data);
> >
> >  if (!size) {
> > @@ -153,9 +153,19 @@ static int unrefcount_frame(AVCodecInternal *avci,
> AVFrame *frame)
> >  frame->format = avci->to_free->format;
> >  frame->width  = avci->to_free->width;
> >  frame->height = avci->to_free->height;
> > +#if FF_API_OLD_CHANNEL_LAYOUT
> > +FF_DISABLE_DEPRECATION_WARNINGS
> >  frame->channel_layout = avci->to_free->channel_layout;
> > +FF_ENABLE_DEPRECATION_WARNINGS
> > +#endif
> >  frame->nb_samples = avci->to_free->nb_samples;
> >
> > +ret = av_channel_layout_copy(>ch_layout,
> >to_free->ch_layout);
> > +if (ret < 0) {
> > +av_frame_unref(frame);
> > +return ret;
> > +}
> > +
> >  return 0;
> >  }
> >
> > @@ -887,10 +897,20 @@ static int update_frame_pool(AVCodecContext
> *avctx, AVFrame *frame)
> >  break;
> >  }
> >  case AVMEDIA_TYPE_AUDIO: {
> > -int ch = av_get_channel_layout_nb_channels(frame->channel_
> layout);
> > +int ch = frame->ch_layout.nb_channels;
> >  int planar = av_sample_fmt_is_planar(frame->format);
> >  int planes = planar ? ch : 1;
> >
> > +#if FF_API_OLD_CHANNEL_LAYOUT
> > +FF_DISABLE_DEPRECATION_WARNINGS
> > +if (!ch && frame->channel_layout) {
> > +av_channel_layout_from_mask(>ch_layout,
> frame->channel_layout);
> > +ch = frame->ch_layout.nb_channels;
> > +planes = planar ? ch : 1;
> > +}
> > +FF_ENABLE_DEPRECATION_WARNINGS
> > +#endif
>
> What is this for? This code is the internal get_buffer2()
> implementation, so the new channel layout API should always be used.
>

Yes this chunk is unneeded I'll drop it.


> > +
> >  if (pool->format == frame->format && pool->planes == planes &&
> >  pool->channels == ch && frame->nb_samples == pool->samples)
> >  return 0;
> > @@ -,28 +1131,35 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame
> *frame, int flags)
> >  frame->sample_rate= avctx->sample_rate;
> >  if (frame->format < 0)
> >  frame->format = avctx->sample_fmt;
> > +if (!frame->ch_layout.nb_channels) {
> > +if (avctx->channel_layout)
> > +av_channel_layout_from_mask(>ch_layout,
> avctx->channel_layout);
> > +else
> > +av_channel_layout_default(>ch_layout,
> avctx->channels);
> > +}
>
> Same, why the deprecated API use.
>

This chunk is actually needed because some decoders don't set the channel
layout fully before ff_get_buffer.
Besides this use is going to be dropped in a later patch, as the
AVCodecContext is fully ported to the new API.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 04/25] avframe: switch to the new channel layout API

2018-01-19 Thread Vittorio Giovara
On Sat, Jul 22, 2017 at 10:02 AM, Anton Khirnov <an...@khirnov.net> wrote:

> Quoting Vittorio Giovara (2017-06-29 00:10:48)
> > From: Anton Khirnov <an...@khirnov.net>
> >
> > Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
> > ---
> >  libavcodec/decode.c | 67 
> >  libavcodec/encode.c |  9 ++
>
> Why are there lavc changes in this patch. Should they not come after
> lavc conversion? I'd expect this patch to break FATE.
>

I'll split this patch in two. No this does not break FATE in the current
incarnation.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 06/25] lavr: switch to the new channel layout API

2018-01-19 Thread Vittorio Giovara
On Sat, Jul 22, 2017 at 10:40 AM, Anton Khirnov <an...@khirnov.net> wrote:

> Quoting Vittorio Giovara (2017-06-29 00:10:50)
> > diff --git a/libavresample/utils.c b/libavresample/utils.c
> > index bab2153b4b..15c827efbe 100644
> > --- a/libavresample/utils.c
> > +++ b/libavresample/utils.c
> > @@ -18,6 +18,7 @@
> >   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA
> >   */
> >
> > +#include "libavutil/channel_layout.h"
> >  #include "libavutil/common.h"
> >  #include "libavutil/dict.h"
> >  #include "libavutil/error.h"
> > @@ -35,6 +36,7 @@
> >
> >  int avresample_open(AVAudioResampleContext *avr)
> >  {
> > +int in_ch, out_ch;
> >  int ret;
> >
> >  if (avresample_is_open(avr)) {
> > @@ -42,24 +44,67 @@ int avresample_open(AVAudioResampleContext *avr)
> >  return AVERROR(EINVAL);
> >  }
> >
> > +if ( avr->in_ch_layout.order == AV_CHANNEL_ORDER_CUSTOM ||
> > +avr->out_ch_layout.order == AV_CHANNEL_ORDER_CUSTOM) {
> > +av_log(avr, AV_LOG_ERROR,
> > +  "Resampling a custom channel layout order is not
> supported.\n");
> > +   return AVERROR(ENOSYS);
>
> Why? I don't remember if I tested it properly back then, but IIRC the
> matrix building code should work custom orders just fine.
>
> > +}
> > +
> > +if (avr->in_ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) {
> > +if (avr->in_ch_layout.nb_channels > 63) {
> > +   av_log(avr, AV_LOG_ERROR,
> > +  "Unspecified channel layout order is supported only
> for up "
> > +  "to 63 channels (got %d).\n",
> avr->in_ch_layout.nb_channels);
> > +   return AVERROR(ENOSYS);
> > +}
> > +av_channel_layout_default(>in_ch_layout,
> avr->in_ch_layout.nb_channels);
> > +}
> > +if (avr->out_ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) {
> > +if (avr->out_ch_layout.nb_channels > 63) {
> > +   av_log(avr, AV_LOG_ERROR,
> > +  "Unspecified channel layout order is supported only
> for up "
> > +  "to 63 channels (got %d).\n", avr->out_ch_layout.nb_
> channels);
> > +   return AVERROR(ENOSYS);
> > +}
> > +av_channel_layout_default(>out_ch_layout,
> avr->out_ch_layout.nb_channels);
> > +}
>
> Why are those needed? Seems they are redundant given the other checks
> right below.
>

You are right on both points, the code is fine (and simpler) without these
checks.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [RFC] [PATCH] Set video strides to a custom type in preparation of a change to ptrdiff_t

2018-01-05 Thread Vittorio Giovara
This patch introduces a new type, av_stride, which is set for any
representation of strides or linesize, including AVFrame and av_image_*
APIs. This is done in preparation of a future switch to ptrdiff_t, a
better suited type to represent this type of data, in a way that it is
atomically changed at the version bump.
---

This is a work in progress change that I was preparing and briefly discussed
on IRC today, based on suggestion by wm4. I wanted to share this early to
thread waters, as well as gather feedback on this approach. As a matter of
fact I haven't fully tested this yet, but if the idea is welcome, I will
extensively test it on Oracle.

The rationale of introducing this "temporary" type is to minimize impact on
downstream, allowing a long enough transition time to API users to change
their code. I say temporary because it is possible that in the very distant
future it would be nice to be able to just the standard type instead of a
custom one.

We considered other ideas, such as deprecating the current APIs and frame
fields and introducing setters and getters but they seemed less elegant and
more likely to induce annoying code breaks to our users.

Vittorio

 avtools/avconv_vda.c  |   2 +-
 avtools/avplay.c  |   2 +-
 libavcodec/avcodec.h  |   2 +-
 libavcodec/cinepakenc.c   |  42 +++---
 libavcodec/decode.c   |   6 +-
 libavcodec/error_resilience.c |   8 +--
 libavcodec/ffv1dec.c  |   2 +-
 libavcodec/ffv1enc.c  |   2 +-
 libavcodec/internal.h |   2 +-
 libavcodec/libvpxdec.c|   7 ++-
 libavcodec/mmaldec.c  |   2 +-
 libavcodec/mpegvideoencdsp.c  |  12 ++--
 libavcodec/mpegvideoencdsp.h  |   4 +-
 libavcodec/nuv.c  |   2 +-
 libavcodec/omx.c  |   4 +-
 libavcodec/roqvideoenc.c  |   8 +--
 libavcodec/utils.c|   2 +-
 libavfilter/drawutils.c   |   6 +-
 libavfilter/drawutils.h   |   7 ++-
 libavfilter/vf_framepack.c|   2 +-
 libavfilter/vf_interlace.c|   4 +-
 libavfilter/vf_showinfo.c |   2 +-
 libavutil/avutil.h|  13 -
 libavutil/frame.c |   4 +-
 libavutil/frame.h |   2 +-
 libavutil/hwcontext_d3d11va.c |   4 +-
 libavutil/imgutils.c  |  27 -
 libavutil/imgutils.h  |  22 +++
 libavutil/pixdesc.c   |   4 +-
 libavutil/pixdesc.h   |   5 +-
 libavutil/version.h   |   3 +
 libswscale/swscale.h  |   4 +-
 libswscale/swscale_internal.h |   4 +-
 libswscale/swscale_unscaled.c | 130 --
 libswscale/tests/swscale.c|   6 +-
 libswscale/yuv2rgb.c  |   4 +-
 36 files changed, 191 insertions(+), 171 deletions(-)

diff --git a/avtools/avconv_vda.c b/avtools/avconv_vda.c
index d86076e79e..3f3156dbbc 100644
--- a/avtools/avconv_vda.c
+++ b/avtools/avconv_vda.c
@@ -34,7 +34,7 @@ static int vda_retrieve_data(AVCodecContext *s, AVFrame 
*frame)
 OSType pixel_format = CVPixelBufferGetPixelFormatType(pixbuf);
 CVReturn err;
 uint8_t *data[4] = { 0 };
-int linesize[4] = { 0 };
+av_stride linesize[4] = { 0 };
 int planes, ret, i;
 
 av_frame_unref(vda->tmp_frame);
diff --git a/avtools/avplay.c b/avtools/avplay.c
index b6dbc52cf7..3392bd34c2 100644
--- a/avtools/avplay.c
+++ b/avtools/avplay.c
@@ -1312,7 +1312,7 @@ static int queue_picture(PlayerState *is, AVFrame 
*src_frame, double pts, int64_
 /* if the frame is not skipped, then display it */
 if (vp->bmp) {
 uint8_t *data[4];
-int linesize[4];
+av_stride linesize[4];
 
 /* get a pointer on the bitmap */
 SDL_LockYUVOverlay (vp->bmp);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 7eaa0c9277..c4f5168676 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3203,7 +3203,7 @@ typedef struct AVSubtitleRect {
  * Can be set for text/ass as well once they are rendered.
  */
 uint8_t *data[4];
-int linesize[4];
+av_stride linesize[4];
 
 enum AVSubtitleType type;
 
diff --git a/libavcodec/cinepakenc.c b/libavcodec/cinepakenc.c
index c323bde30f..f8d5f0cbe6 100644
--- a/libavcodec/cinepakenc.c
+++ b/libavcodec/cinepakenc.c
@@ -444,8 +444,8 @@ static int encode_codebook(CinepakEncContext *s, int 
*codebook, int size,
 
 // sets out to the sub picture starting at (x,y) in in
 static void get_sub_picture(CinepakEncContext *s, int x, int y,
-uint8_t * in_data[4], int  in_linesize[4],
-uint8_t *out_data[4], int out_linesize[4])
+uint8_t * in_data[4], av_stride  in_linesize[4],
+uint8_t *out_data[4], av_stride out_linesize[4])
 {
 out_data[0] = in_data[0] + x + y * in_linesize[0];
 out_linesize[0] = in_linesize[0];
@@ -461,7 +461,7 @@ static void get_sub_picture(CinepakEncContext *s, int x, 
int y,
 
 // decodes the V1 vector in mb into 

Re: [libav-devel] [PATCH] stereo3d: Support view type for frame sequence type

2017-11-27 Thread Vittorio Giovara
On Tue, Oct 3, 2017 at 9:41 AM, Vittorio Giovara <vittorio.giov...@gmail.com
> wrote:

>
>
> On Tue, Oct 3, 2017 at 9:29 AM, wm4 <nfx...@googlemail.com> wrote:
>
>> On Tue,  3 Oct 2017 09:26:39 -0400
>> Vittorio Giovara <vittorio.giov...@gmail.com> wrote:
>>
>> > Implement detection in h264 and hevc and insertion in framepack filter.
>> >
>> > Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
>> > ---
>> >  doc/APIchanges |  3 +++
>> >  libavcodec/h264_sei.c  |  7 ---
>> >  libavcodec/h264_sei.h  |  1 +
>> >  libavcodec/h264_slice.c|  7 +++
>> >  libavcodec/hevc_sei.c  |  9 +
>> >  libavcodec/hevc_sei.h  |  1 +
>> >  libavcodec/hevcdec.c   |  7 +++
>> >  libavfilter/vf_framepack.c |  2 ++
>> >  libavutil/stereo3d.h   | 24 
>> >  libavutil/version.h|  2 +-
>> >  10 files changed, 55 insertions(+), 8 deletions(-)
>> >
>> > diff --git a/doc/APIchanges b/doc/APIchanges
>> > index fa27007f44..b518b6307f 100644
>> > --- a/doc/APIchanges
>> > +++ b/doc/APIchanges
>> > @@ -13,6 +13,9 @@ libavutil: 2017-03-23
>> >
>> >  API changes, most recent first:
>> >
>> > +2017-xx-xx - xxx - lavu 56.7.0 - stereo3d.h
>> > +  Add view field to AVStereo3D structure and AVStereo3DView enum.
>> > +
>> >  2017-xx-xx - xxx - lavu 56.6.0 - pixdesc.h
>> >Add av_color_range_from_name(), av_color_primaries_from_name(),
>> >av_color_transfer_from_name(), av_color_space_from_name(), and
>> > diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
>> > index 03fca9017f..da5d33c36c 100644
>> > --- a/libavcodec/h264_sei.c
>> > +++ b/libavcodec/h264_sei.c
>> > @@ -314,10 +314,11 @@ static int 
>> > decode_frame_packing_arrangement(H264SEIFramePacking
>> *h,
>> >  h->quincunx_subsampling   = get_bits1(gb);
>> >  h->content_interpretation_type= get_bits(gb, 6);
>> >
>> > -// the following skips: spatial_flipping_flag,
>> frame0_flipped_flag,
>> > -// field_views_flag, current_frame_is_frame0_flag,
>> > +// spatial_flipping_flag, frame0_flipped_flag, field_views_flag
>> > +skip_bits(gb, 3);
>> > +h->current_frame_is_frame0_flag = get_bits1(gb);
>> >  // frame0_self_contained_flag, frame1_self_contained_flag
>> > -skip_bits(gb, 6);
>> > +skip_bits(gb, 2);
>> >
>> >  if (!h->quincunx_subsampling && h->arrangement_type != 5)
>> >  skip_bits(gb, 16);  // frame[01]_grid_position_[xy]
>> > diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h
>> > index f6ac6034da..c3a19dd831 100644
>> > --- a/libavcodec/h264_sei.h
>> > +++ b/libavcodec/h264_sei.h
>> > @@ -108,6 +108,7 @@ typedef struct H264SEIFramePacking {
>> >  int arrangement_type;
>> >  int content_interpretation_type;
>> >  int quincunx_subsampling;
>> > +int current_frame_is_frame0_flag;
>> >  } H264SEIFramePacking;
>> >
>> >  typedef struct H264SEIDisplayOrientation {
>> > diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
>> > index 5dd01d836e..1b968ebd50 100644
>> > --- a/libavcodec/h264_slice.c
>> > +++ b/libavcodec/h264_slice.c
>> > @@ -1112,6 +1112,13 @@ static int h264_export_frame_props(H264Context
>> *h)
>> >
>> >  if (fp->content_interpretation_type == 2)
>> >  stereo->flags = AV_STEREO3D_FLAG_INVERT;
>> > +
>> > +if (fp->arrangement_type == 5) {
>> > +if (fp->current_frame_is_frame0_flag)
>> > +stereo->view = AV_STEREO3D_VIEW_LEFT;
>> > +else
>> > +stereo->view = AV_STEREO3D_VIEW_RIGHT;
>> > +}
>> >  }
>> >
>> >  if (h->sei.display_orientation.present &&
>> > diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
>> > index 0a5d4440bf..2bf170601d 100644
>> > --- a/libavcodec/hevc_sei.c
>> > +++ b/libavcodec/hevc_sei.c
>> > @@ -57,10 +57,11 @@ static int 
>> > decode_nal_sei_frame_packing_arrangement(HEVCSEIFramePacking
>> *s, GetB
>> >  s->quincunx_subsampling   = get_bits1(gb);
>> > 

Re: [libav-devel] [PATCH 5/5] Drop some unnecessary config.h #includes

2017-11-12 Thread Vittorio Giovara
On Fri, Nov 3, 2017 at 12:43 PM, Diego Biurrun  wrote:

> ---
>
> Noticed while working on the previous patch, spun off into a separate
> commit.
>
>
Out of curiosity, how did you find these extra includes? Did you use some
tool or did you manually check every file?
Thanks
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] avutil: make AV_NOPTS_VALUE signed negative

2017-11-05 Thread Vittorio Giovara
On Sun, Nov 5, 2017 at 6:21 AM, Rémi Denis-Courmont  wrote:

> libav generally uses int64_t to represent timestamps, and thus
> AV_NOPTS_VALUE has to fit witin the range of int64_t.
>
> The current definition of AV_NOPTS_VALUE results in AV_NOPTS_VALUE
> having the same type as uint64_t, since its value is positive and
> cannot be represented by int64_t.
>
> See also ISO C11 §6.4.4.1 clause 5.
>
> This patch ensures that AV_NOPTS_VALUE is an int64_t, avoiding
> undefined overflowing conversion from uint64_t to int64_t.
> ---
>  libavutil/avutil.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavutil/avutil.h b/libavutil/avutil.h
> index 2339fe3c9c..6f90043952 100644
> --- a/libavutil/avutil.h
> +++ b/libavutil/avutil.h
> @@ -238,7 +238,7 @@ enum AVMediaType {
>   * either pts or dts.
>   */
>
> -#define AV_NOPTS_VALUE  INT64_C(0x8000)
> +#define AV_NOPTS_VALUE  INT64_MIN
>
>  /**
>   * Internal time base represented as integer
> --
>

is a version bump necessary for this change?
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 2/3] avformat/matroskadec: Call matroska_read_close() on header parsing error

2017-11-02 Thread Vittorio Giovara
On Wed, Nov 1, 2017 at 10:10 PM, Sean McGovern  wrote:

> From: Michael Niedermayer 
>
> Fixes memleak
>

nit full stop

Fixes Ticket5169
>

Please use the syntax "Bug-Id: ffmpeg/Ticket5169".


> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/matroskadec.c | 9 +++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index 3743d4d..9c523fb 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -592,6 +592,8 @@ static EbmlSyntax matroska_clusters_incremental[] = {
>
>  static const char *const matroska_doctypes[] = { "matroska", "webm" };
>
> +static int matroska_read_close(AVFormatContext *s);
> +
>

if possible there should be a separate patch that moves matroska_read_close
here, rather than introducing a forward statement.


>  static int matroska_resync(MatroskaDemuxContext *matroska, int64_t
> last_pos)
>  {
>  AVIOContext *pb = matroska->ctx->pb;
> @@ -2099,7 +2101,7 @@ static int matroska_read_header(AVFormatContext *s)
>  while (res != 1) {
>  res = matroska_resync(matroska, pos);
>  if (res < 0)
> -return res;
> +goto fail;
>  pos = avio_tell(matroska->ctx->pb);
>  res = ebml_parse(matroska, matroska_segment, matroska);
>  }
> @@ -2114,7 +2116,7 @@ static int matroska_read_header(AVFormatContext *s)
>
>  res = matroska_parse_tracks(s);
>  if (res < 0)
> -return res;
> +goto fail;
>
>  attachments = attachments_list->elem;
>  for (j = 0; j < attachments_list->nb_elem; j++) {
> @@ -2187,6 +2189,9 @@ static int matroska_read_header(AVFormatContext *s)
>  matroska_convert_tags(s);
>
>  return 0;
> +fail:
> +matroska_read_close(s);
> +return res;
>  }
>
> --
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [RFC][PATCH] Drop non-refcounted-frame code on the next version bump

2017-10-24 Thread Vittorio Giovara
On Tue, Oct 24, 2017 at 2:21 PM, Diego Biurrun  wrote:

> ---
>
> I'm quite suspicious of this. It passes tests w/ and w/o a lavc version
> bump,
>

doesn't that mean that the compat layer works as expected?
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] stereo3d: Support view type for frame sequence type

2017-10-03 Thread Vittorio Giovara
On Tue, Oct 3, 2017 at 9:29 AM, wm4 <nfx...@googlemail.com> wrote:

> On Tue,  3 Oct 2017 09:26:39 -0400
> Vittorio Giovara <vittorio.giov...@gmail.com> wrote:
>
> > Implement detection in h264 and hevc and insertion in framepack filter.
> >
> > Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
> > ---
> >  doc/APIchanges |  3 +++
> >  libavcodec/h264_sei.c  |  7 ---
> >  libavcodec/h264_sei.h  |  1 +
> >  libavcodec/h264_slice.c|  7 +++
> >  libavcodec/hevc_sei.c  |  9 +
> >  libavcodec/hevc_sei.h  |  1 +
> >  libavcodec/hevcdec.c   |  7 +++
> >  libavfilter/vf_framepack.c |  2 ++
> >  libavutil/stereo3d.h   | 24 
> >  libavutil/version.h|  2 +-
> >  10 files changed, 55 insertions(+), 8 deletions(-)
> >
> > diff --git a/doc/APIchanges b/doc/APIchanges
> > index fa27007f44..b518b6307f 100644
> > --- a/doc/APIchanges
> > +++ b/doc/APIchanges
> > @@ -13,6 +13,9 @@ libavutil: 2017-03-23
> >
> >  API changes, most recent first:
> >
> > +2017-xx-xx - xxx - lavu 56.7.0 - stereo3d.h
> > +  Add view field to AVStereo3D structure and AVStereo3DView enum.
> > +
> >  2017-xx-xx - xxx - lavu 56.6.0 - pixdesc.h
> >Add av_color_range_from_name(), av_color_primaries_from_name(),
> >av_color_transfer_from_name(), av_color_space_from_name(), and
> > diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
> > index 03fca9017f..da5d33c36c 100644
> > --- a/libavcodec/h264_sei.c
> > +++ b/libavcodec/h264_sei.c
> > @@ -314,10 +314,11 @@ static int 
> > decode_frame_packing_arrangement(H264SEIFramePacking
> *h,
> >  h->quincunx_subsampling   = get_bits1(gb);
> >  h->content_interpretation_type= get_bits(gb, 6);
> >
> > -// the following skips: spatial_flipping_flag,
> frame0_flipped_flag,
> > -// field_views_flag, current_frame_is_frame0_flag,
> > +// spatial_flipping_flag, frame0_flipped_flag, field_views_flag
> > +skip_bits(gb, 3);
> > +h->current_frame_is_frame0_flag = get_bits1(gb);
> >  // frame0_self_contained_flag, frame1_self_contained_flag
> > -skip_bits(gb, 6);
> > +skip_bits(gb, 2);
> >
> >  if (!h->quincunx_subsampling && h->arrangement_type != 5)
> >  skip_bits(gb, 16);  // frame[01]_grid_position_[xy]
> > diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h
> > index f6ac6034da..c3a19dd831 100644
> > --- a/libavcodec/h264_sei.h
> > +++ b/libavcodec/h264_sei.h
> > @@ -108,6 +108,7 @@ typedef struct H264SEIFramePacking {
> >  int arrangement_type;
> >  int content_interpretation_type;
> >  int quincunx_subsampling;
> > +int current_frame_is_frame0_flag;
> >  } H264SEIFramePacking;
> >
> >  typedef struct H264SEIDisplayOrientation {
> > diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
> > index 5dd01d836e..1b968ebd50 100644
> > --- a/libavcodec/h264_slice.c
> > +++ b/libavcodec/h264_slice.c
> > @@ -1112,6 +1112,13 @@ static int h264_export_frame_props(H264Context
> *h)
> >
> >  if (fp->content_interpretation_type == 2)
> >  stereo->flags = AV_STEREO3D_FLAG_INVERT;
> > +
> > +if (fp->arrangement_type == 5) {
> > +if (fp->current_frame_is_frame0_flag)
> > +stereo->view = AV_STEREO3D_VIEW_LEFT;
> > +else
> > +stereo->view = AV_STEREO3D_VIEW_RIGHT;
> > +}
> >  }
> >
> >  if (h->sei.display_orientation.present &&
> > diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
> > index 0a5d4440bf..2bf170601d 100644
> > --- a/libavcodec/hevc_sei.c
> > +++ b/libavcodec/hevc_sei.c
> > @@ -57,10 +57,11 @@ static int 
> > decode_nal_sei_frame_packing_arrangement(HEVCSEIFramePacking
> *s, GetB
> >  s->quincunx_subsampling   = get_bits1(gb);
> >  s->content_interpretation_type= get_bits(gb, 6);
> >
> > -// the following skips spatial_flipping_flag frame0_flipped_flag
> > -// field_views_flag current_frame_is_frame0_flag
> > -// frame0_self_contained_flag frame1_self_contained_flag
> > -skip_bits(gb, 6);
> > +// spatial_flipping_flag, frame0_flipped_flag, field_views_flag
> > +skip_bits(gb, 3);
> > + 

[libav-devel] [PATCH] stereo3d: Support view type for frame sequence type

2017-10-03 Thread Vittorio Giovara
Implement detection in h264 and hevc and insertion in framepack filter.

Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 doc/APIchanges |  3 +++
 libavcodec/h264_sei.c  |  7 ---
 libavcodec/h264_sei.h  |  1 +
 libavcodec/h264_slice.c|  7 +++
 libavcodec/hevc_sei.c  |  9 +
 libavcodec/hevc_sei.h  |  1 +
 libavcodec/hevcdec.c   |  7 +++
 libavfilter/vf_framepack.c |  2 ++
 libavutil/stereo3d.h   | 24 
 libavutil/version.h|  2 +-
 10 files changed, 55 insertions(+), 8 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index fa27007f44..b518b6307f 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil: 2017-03-23
 
 API changes, most recent first:
 
+2017-xx-xx - xxx - lavu 56.7.0 - stereo3d.h
+  Add view field to AVStereo3D structure and AVStereo3DView enum.
+
 2017-xx-xx - xxx - lavu 56.6.0 - pixdesc.h
   Add av_color_range_from_name(), av_color_primaries_from_name(),
   av_color_transfer_from_name(), av_color_space_from_name(), and
diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
index 03fca9017f..da5d33c36c 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -314,10 +314,11 @@ static int 
decode_frame_packing_arrangement(H264SEIFramePacking *h,
 h->quincunx_subsampling   = get_bits1(gb);
 h->content_interpretation_type= get_bits(gb, 6);
 
-// the following skips: spatial_flipping_flag, frame0_flipped_flag,
-// field_views_flag, current_frame_is_frame0_flag,
+// spatial_flipping_flag, frame0_flipped_flag, field_views_flag
+skip_bits(gb, 3);
+h->current_frame_is_frame0_flag = get_bits1(gb);
 // frame0_self_contained_flag, frame1_self_contained_flag
-skip_bits(gb, 6);
+skip_bits(gb, 2);
 
 if (!h->quincunx_subsampling && h->arrangement_type != 5)
 skip_bits(gb, 16);  // frame[01]_grid_position_[xy]
diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h
index f6ac6034da..c3a19dd831 100644
--- a/libavcodec/h264_sei.h
+++ b/libavcodec/h264_sei.h
@@ -108,6 +108,7 @@ typedef struct H264SEIFramePacking {
 int arrangement_type;
 int content_interpretation_type;
 int quincunx_subsampling;
+int current_frame_is_frame0_flag;
 } H264SEIFramePacking;
 
 typedef struct H264SEIDisplayOrientation {
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 5dd01d836e..1b968ebd50 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1112,6 +1112,13 @@ static int h264_export_frame_props(H264Context *h)
 
 if (fp->content_interpretation_type == 2)
 stereo->flags = AV_STEREO3D_FLAG_INVERT;
+
+if (fp->arrangement_type == 5) {
+if (fp->current_frame_is_frame0_flag)
+stereo->view = AV_STEREO3D_VIEW_LEFT;
+else
+stereo->view = AV_STEREO3D_VIEW_RIGHT;
+}
 }
 
 if (h->sei.display_orientation.present &&
diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index 0a5d4440bf..2bf170601d 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -57,10 +57,11 @@ static int 
decode_nal_sei_frame_packing_arrangement(HEVCSEIFramePacking *s, GetB
 s->quincunx_subsampling   = get_bits1(gb);
 s->content_interpretation_type= get_bits(gb, 6);
 
-// the following skips spatial_flipping_flag frame0_flipped_flag
-// field_views_flag current_frame_is_frame0_flag
-// frame0_self_contained_flag frame1_self_contained_flag
-skip_bits(gb, 6);
+// spatial_flipping_flag, frame0_flipped_flag, field_views_flag
+skip_bits(gb, 3);
+s->current_frame_is_frame0_flag = get_bits1(gb);
+// frame0_self_contained_flag, frame1_self_contained_flag
+skip_bits(gb, 2);
 
 if (!s->quincunx_subsampling && s->arrangement_type != 5)
 skip_bits(gb, 16);  // frame[01]_grid_position_[xy]
diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h
index e4aeac1fbe..8d4f5df69f 100644
--- a/libavcodec/hevc_sei.h
+++ b/libavcodec/hevc_sei.h
@@ -67,6 +67,7 @@ typedef struct HEVCSEIFramePacking {
 int arrangement_type;
 int content_interpretation_type;
 int quincunx_subsampling;
+int current_frame_is_frame0_flag;
 } HEVCSEIFramePacking;
 
 typedef struct HEVCSEIDisplayOrientation {
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index a1619cf4bd..f1d1c77497 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2397,6 +2397,13 @@ static int set_side_data(HEVCContext *s)
 
 if (s->sei.frame_packing.content_interpretation_type == 2)
 stereo->flags = AV_STEREO3D_FLAG_INVERT;
+
+if (s->sei.frame_packing.arrangement_type == 5) {
+if (s->sei.frame_packing.current_f

Re: [libav-devel] [PATCH] h264_sei: handle stereoscopy frame sequential flags

2017-10-03 Thread Vittorio Giovara
On Tue, Oct 3, 2017 at 9:19 AM, Steve Lhomme <rob...@gmail.com> wrote:

> On Thu, Sep 21, 2017 at 7:15 PM, Vittorio Giovara
> <vittorio.giov...@gmail.com> wrote:
> > On Thu, Sep 21, 2017 at 5:40 PM, Steve Lhomme <rob...@gmail.com> wrote:
> >
> >> On Thu, Sep 21, 2017 at 4:58 PM, Vittorio Giovara
> >> <vittorio.giov...@gmail.com> wrote:
> >> > On Thu, Sep 21, 2017 at 4:03 PM, Steve Lhomme <rob...@gmail.com>
> wrote:
> >> >
> >> >> From: "Mohammed (Shaan) Huzaifa Danish" <sha...@gmail.com>
> >> >>
> >> >> ---
> >> >> fix previous patch skipping the wrong amount of bits
> >> >> ---
> >> >>  libavcodec/h264_sei.c   | 6 --
> >> >>  libavcodec/h264_sei.h   | 1 +
> >> >>  libavcodec/h264_slice.c | 2 ++
> >> >>  libavutil/stereo3d.h| 4 
> >> >>  4 files changed, 11 insertions(+), 2 deletions(-)
> >> >>
> >> >> diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
> >> >> index 03fca9017f..96ac427931 100644
> >> >> --- a/libavcodec/h264_sei.c
> >> >> +++ b/libavcodec/h264_sei.c
> >> >> @@ -315,9 +315,11 @@ static int decode_frame_packing_arrangeme
> >> nt(H264SEIFramePacking
> >> >> *h,
> >> >>  h->content_interpretation_type= get_bits(gb, 6);
> >> >>
> >> >>  // the following skips: spatial_flipping_flag,
> >> >> frame0_flipped_flag,
> >> >> -// field_views_flag, current_frame_is_frame0_flag,
> >> >> +// field_views_flag
> >> >> +skip_bits(gb, 3);
> >> >> +h->current_frame_is_frame0_flag   = get_bits1(gb);
> >> >>  // frame0_self_contained_flag, frame1_self_contained_flag
> >> >> -skip_bits(gb, 6);
> >> >> +skip_bits(gb, 2);
> >> >>
> >> >>  if (!h->quincunx_subsampling && h->arrangement_type != 5)
> >> >>  skip_bits(gb, 16);  // frame[01]_grid_position_[xy]
> >> >> diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h
> >> >> index f6ac6034da..c3a19dd831 100644
> >> >> --- a/libavcodec/h264_sei.h
> >> >> +++ b/libavcodec/h264_sei.h
> >> >> @@ -108,6 +108,7 @@ typedef struct H264SEIFramePacking {
> >> >>  int arrangement_type;
> >> >>  int content_interpretation_type;
> >> >>  int quincunx_subsampling;
> >> >> +int current_frame_is_frame0_flag;
> >> >>  } H264SEIFramePacking;
> >> >>
> >> >>  typedef struct H264SEIDisplayOrientation {
> >> >> diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
> >> >> index 5dd01d836e..f5b78bfe29 100644
> >> >> --- a/libavcodec/h264_slice.c
> >> >> +++ b/libavcodec/h264_slice.c
> >> >> @@ -1112,6 +1112,8 @@ static int h264_export_frame_props(H264Context
> >> *h)
> >> >>
> >> >>  if (fp->content_interpretation_type == 2)
> >> >>  stereo->flags = AV_STEREO3D_FLAG_INVERT;
> >> >> +if (fp->current_frame_is_frame0_flag)
> >> >> +stereo->flags |= AV_STEREO3D_FLAG_FRAME0;
> >> >>  }
> >> >>
> >> >>  if (h->sei.display_orientation.present &&
> >> >> diff --git a/libavutil/stereo3d.h b/libavutil/stereo3d.h
> >> >> index 0fa9f63a2c..4c8ab5c40a 100644
> >> >> --- a/libavutil/stereo3d.h
> >> >> +++ b/libavutil/stereo3d.h
> >> >> @@ -146,6 +146,10 @@ enum AVStereo3DType {
> >> >>   * Inverted views, Right/Bottom represents the left view.
> >> >>   */
> >> >>  #define AV_STEREO3D_FLAG_INVERT (1 << 0)
> >> >> +/**
> >> >> + * This frame is frame0 (left view), otherwise it's the right view.
> >> >> + */
> >> >> +#define AV_STEREO3D_FLAG_FRAME0 (1 << 1)
> >> >>
> >> >
> >> > Hey Steve,
> >> > I would rather not expose a flag for something this specific (as it
> >> applies
> >> > to a single type only).
> >> > The name is also peculiar, and confusing, the left view has always
> >> priority
> >> > so that should be the default variant (ie no flag).
> >>
> >> If left is the default, how do you signal that it's the right eye ?
> >>
> >
> > You can keep track of the decoded frames, if frame_num%2 == 1 it means
> > you're on a right view.
> >
> >
> >> Given in all other cases where this SEI is not present you don't know
> >> if you can assume it's there or not ?
> >
> >
> > if you want, given that the left view has priority, you could do
> something
> > like
> > if packing_type == 5
> >   if flag0 == 0
> > flags |= invert
> >   else
> > flags = 0
> >
> >
> >> The flag signals that this frame is the left eye and the one coming
> >> next is the right eye.
> >>
> >
> > I'm not sure that's the best approach because this flag would be for a
> very
> > specific packing type only, and not generic (like the inverted one).
>
> What's the status on this ? Weren't you going to submit a patch to set
> a flag for that mode only ? Should I submit it ?


I forgot about it, I'll send it right away.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH] prores: Always assume limited range

2017-09-27 Thread Vittorio Giovara
As defined by the spcifications
---
 libavcodec/proresdec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/proresdec.c b/libavcodec/proresdec.c
index bc5bdb5a4d..c86d433f50 100644
--- a/libavcodec/proresdec.c
+++ b/libavcodec/proresdec.c
@@ -177,6 +177,7 @@ static int decode_frame_header(ProresContext *ctx, const 
uint8_t *buf,
 avctx->color_primaries = buf[14];
 avctx->color_trc   = buf[15];
 avctx->colorspace  = buf[16];
+avctx->color_range = AVCOL_RANGE_MPEG;
 
 ctx->qmat_changed = 0;
 ptr   = buf + 20;
-- 
2.14.2

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

Re: [libav-devel] [PATCH] configure: cosmetics: Wrap a configure error string to the paragraph length

2017-09-23 Thread Vittorio Giovara
On Sat, Sep 23, 2017 at 11:14 AM, Diego Biurrun <di...@biurrun.de> wrote:

> On Thu, Sep 21, 2017 at 07:08:00PM +0200, Vittorio Giovara wrote:
> > On Thu, Sep 21, 2017 at 6:34 PM, Diego Biurrun <di...@biurrun.de> wrote:
> > > On Thu, Sep 21, 2017 at 01:37:03PM +0200, Vittorio Giovara wrote:
> > > > --- a/configure
> > > > +++ b/configure
> > > > @@ -401,8 +401,8 @@ include the log this produces with your report.
> > > >  EOF
> > > >  else
> > > >  cat < > > > -Include the log file "$logfile" produced by configure as this will
> help
> > > > -solving the problem.
> > > > +Include the log file "$logfile" produced by configure as this
> > > > +will help solving the problem.
> > > >  EOF
> > >
> > > What paragraph length are you wrapping this to? It currently matches
> the
> > > length of the previous output lines quite well ...
> >
> > I'm talking about the output lines on a 80chars console
> > This is how I see it: https://www.dropbox.com/s/
> qfpgk7i9qs3htwk/Screenshot%
> > 202017-09-21%2019.05.15.png?dl=0
>
> OK, noted. I'll queue it up with more cosmetics that might be coming, OK?
>

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

Re: [libav-devel] [PATCH] h264_sei: handle stereoscopy frame sequential flags

2017-09-21 Thread Vittorio Giovara
On Thu, Sep 21, 2017 at 5:40 PM, Steve Lhomme <rob...@gmail.com> wrote:

> On Thu, Sep 21, 2017 at 4:58 PM, Vittorio Giovara
> <vittorio.giov...@gmail.com> wrote:
> > On Thu, Sep 21, 2017 at 4:03 PM, Steve Lhomme <rob...@gmail.com> wrote:
> >
> >> From: "Mohammed (Shaan) Huzaifa Danish" <sha...@gmail.com>
> >>
> >> ---
> >> fix previous patch skipping the wrong amount of bits
> >> ---
> >>  libavcodec/h264_sei.c   | 6 --
> >>  libavcodec/h264_sei.h   | 1 +
> >>  libavcodec/h264_slice.c | 2 ++
> >>  libavutil/stereo3d.h| 4 
> >>  4 files changed, 11 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
> >> index 03fca9017f..96ac427931 100644
> >> --- a/libavcodec/h264_sei.c
> >> +++ b/libavcodec/h264_sei.c
> >> @@ -315,9 +315,11 @@ static int decode_frame_packing_arrangeme
> nt(H264SEIFramePacking
> >> *h,
> >>  h->content_interpretation_type= get_bits(gb, 6);
> >>
> >>  // the following skips: spatial_flipping_flag,
> >> frame0_flipped_flag,
> >> -// field_views_flag, current_frame_is_frame0_flag,
> >> +// field_views_flag
> >> +skip_bits(gb, 3);
> >> +h->current_frame_is_frame0_flag   = get_bits1(gb);
> >>  // frame0_self_contained_flag, frame1_self_contained_flag
> >> -skip_bits(gb, 6);
> >> +skip_bits(gb, 2);
> >>
> >>  if (!h->quincunx_subsampling && h->arrangement_type != 5)
> >>  skip_bits(gb, 16);  // frame[01]_grid_position_[xy]
> >> diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h
> >> index f6ac6034da..c3a19dd831 100644
> >> --- a/libavcodec/h264_sei.h
> >> +++ b/libavcodec/h264_sei.h
> >> @@ -108,6 +108,7 @@ typedef struct H264SEIFramePacking {
> >>  int arrangement_type;
> >>  int content_interpretation_type;
> >>  int quincunx_subsampling;
> >> +int current_frame_is_frame0_flag;
> >>  } H264SEIFramePacking;
> >>
> >>  typedef struct H264SEIDisplayOrientation {
> >> diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
> >> index 5dd01d836e..f5b78bfe29 100644
> >> --- a/libavcodec/h264_slice.c
> >> +++ b/libavcodec/h264_slice.c
> >> @@ -1112,6 +1112,8 @@ static int h264_export_frame_props(H264Context
> *h)
> >>
> >>  if (fp->content_interpretation_type == 2)
> >>  stereo->flags = AV_STEREO3D_FLAG_INVERT;
> >> +if (fp->current_frame_is_frame0_flag)
> >> +stereo->flags |= AV_STEREO3D_FLAG_FRAME0;
> >>  }
> >>
> >>  if (h->sei.display_orientation.present &&
> >> diff --git a/libavutil/stereo3d.h b/libavutil/stereo3d.h
> >> index 0fa9f63a2c..4c8ab5c40a 100644
> >> --- a/libavutil/stereo3d.h
> >> +++ b/libavutil/stereo3d.h
> >> @@ -146,6 +146,10 @@ enum AVStereo3DType {
> >>   * Inverted views, Right/Bottom represents the left view.
> >>   */
> >>  #define AV_STEREO3D_FLAG_INVERT (1 << 0)
> >> +/**
> >> + * This frame is frame0 (left view), otherwise it's the right view.
> >> + */
> >> +#define AV_STEREO3D_FLAG_FRAME0 (1 << 1)
> >>
> >
> > Hey Steve,
> > I would rather not expose a flag for something this specific (as it
> applies
> > to a single type only).
> > The name is also peculiar, and confusing, the left view has always
> priority
> > so that should be the default variant (ie no flag).
>
> If left is the default, how do you signal that it's the right eye ?
>

You can keep track of the decoded frames, if frame_num%2 == 1 it means
you're on a right view.


> Given in all other cases where this SEI is not present you don't know
> if you can assume it's there or not ?


if you want, given that the left view has priority, you could do something
like
if packing_type == 5
  if flag0 == 0
flags |= invert
  else
flags = 0


> The flag signals that this frame is the left eye and the one coming
> next is the right eye.
>

I'm not sure that's the best approach because this flag would be for a very
specific packing type only, and not generic (like the inverted one).

Do you have a sample available?
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [RFC][PATCH] lavf: Wrap _DEFAULT_SOURCE symbols

2017-09-21 Thread Vittorio Giovara
On Thu, Sep 21, 2017 at 6:35 PM, Diego Biurrun <di...@biurrun.de> wrote:

> On Thu, Sep 21, 2017 at 01:44:44PM +0200, Vittorio Giovara wrote:
> > Silence warnings such as:
> >
> >  libavformat/udp.c:27:9: warning: '_DEFAULT_SOURCE'
> >macro redefined [-Wmacro-redefined]
> >  #define _DEFAULT_SOURCE
> >  ^
> >  :4:9: note: previous definition is here
> >  #define _DEFAULT_SOURCE 1
> >  ^
> > ---
> > I'm not sure this is the right approach, since configure explicitly adds
> > add_${pfx}cppflags -D_DEFAULT_SOURCE
> > in my compiler flag...
> > Any better ideas?
>
> And why would it do that? What is your libc?
>

It's the latest clang toolchain available on macOS

Apple LLVM version 9.0.0 (clang-900.0.37)
Target: x86_64-apple-darwin16.7.0
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] configure: cosmetics: Wrap a configure error string to the paragraph length

2017-09-21 Thread Vittorio Giovara
On Thu, Sep 21, 2017 at 6:34 PM, Diego Biurrun <di...@biurrun.de> wrote:

> On Thu, Sep 21, 2017 at 01:37:03PM +0200, Vittorio Giovara wrote:
> > --- a/configure
> > +++ b/configure
> > @@ -401,8 +401,8 @@ include the log this produces with your report.
> >  EOF
> >  else
> >  cat < > -Include the log file "$logfile" produced by configure as this will help
> > -solving the problem.
> > +Include the log file "$logfile" produced by configure as this
> > +will help solving the problem.
> >  EOF
>
> What paragraph length are you wrapping this to? It currently matches the
> length of the previous output lines quite well ...
>

I'm talking about the output lines on a 80chars console
This is how I see it: https://www.dropbox.com/s/qfpgk7i9qs3htwk/Screenshot%
202017-09-21%2019.05.15.png?dl=0
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] h264_sei: handle stereoscopy frame sequential flags

2017-09-21 Thread Vittorio Giovara
On Thu, Sep 21, 2017 at 4:03 PM, Steve Lhomme  wrote:

> From: "Mohammed (Shaan) Huzaifa Danish" 
>
> ---
> fix previous patch skipping the wrong amount of bits
> ---
>  libavcodec/h264_sei.c   | 6 --
>  libavcodec/h264_sei.h   | 1 +
>  libavcodec/h264_slice.c | 2 ++
>  libavutil/stereo3d.h| 4 
>  4 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
> index 03fca9017f..96ac427931 100644
> --- a/libavcodec/h264_sei.c
> +++ b/libavcodec/h264_sei.c
> @@ -315,9 +315,11 @@ static int 
> decode_frame_packing_arrangement(H264SEIFramePacking
> *h,
>  h->content_interpretation_type= get_bits(gb, 6);
>
>  // the following skips: spatial_flipping_flag,
> frame0_flipped_flag,
> -// field_views_flag, current_frame_is_frame0_flag,
> +// field_views_flag
> +skip_bits(gb, 3);
> +h->current_frame_is_frame0_flag   = get_bits1(gb);
>  // frame0_self_contained_flag, frame1_self_contained_flag
> -skip_bits(gb, 6);
> +skip_bits(gb, 2);
>
>  if (!h->quincunx_subsampling && h->arrangement_type != 5)
>  skip_bits(gb, 16);  // frame[01]_grid_position_[xy]
> diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h
> index f6ac6034da..c3a19dd831 100644
> --- a/libavcodec/h264_sei.h
> +++ b/libavcodec/h264_sei.h
> @@ -108,6 +108,7 @@ typedef struct H264SEIFramePacking {
>  int arrangement_type;
>  int content_interpretation_type;
>  int quincunx_subsampling;
> +int current_frame_is_frame0_flag;
>  } H264SEIFramePacking;
>
>  typedef struct H264SEIDisplayOrientation {
> diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
> index 5dd01d836e..f5b78bfe29 100644
> --- a/libavcodec/h264_slice.c
> +++ b/libavcodec/h264_slice.c
> @@ -1112,6 +1112,8 @@ static int h264_export_frame_props(H264Context *h)
>
>  if (fp->content_interpretation_type == 2)
>  stereo->flags = AV_STEREO3D_FLAG_INVERT;
> +if (fp->current_frame_is_frame0_flag)
> +stereo->flags |= AV_STEREO3D_FLAG_FRAME0;
>  }
>
>  if (h->sei.display_orientation.present &&
> diff --git a/libavutil/stereo3d.h b/libavutil/stereo3d.h
> index 0fa9f63a2c..4c8ab5c40a 100644
> --- a/libavutil/stereo3d.h
> +++ b/libavutil/stereo3d.h
> @@ -146,6 +146,10 @@ enum AVStereo3DType {
>   * Inverted views, Right/Bottom represents the left view.
>   */
>  #define AV_STEREO3D_FLAG_INVERT (1 << 0)
> +/**
> + * This frame is frame0 (left view), otherwise it's the right view.
> + */
> +#define AV_STEREO3D_FLAG_FRAME0 (1 << 1)
>

Hey Steve,
I would rather not expose a flag for something this specific (as it applies
to a single type only).
The name is also peculiar, and confusing, the left view has always priority
so that should be the default variant (ie no flag).
All in all, what problem is this trying to solve?
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH] cbs_h2645: Initialize a structure before use

2017-09-21 Thread Vittorio Giovara
---
This is to silence this warning (which, admittedly, could also be ignored)

cbs_h2645.c:1007:58: warning: variable 'sps_ext' is uninitialized when used 
here [-Wuninitialized]
err = cbs_h264_write_sps_extension(ctx, pbc, sps_ext);
^~~
cbs_h2645.c:1005:41: note: initialize the variable 'sps_ext' to silence this 
warning
H264RawSPSExtension *sps_ext;
^
= NULL

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

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 50a227da78..6fe138188a 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -1002,7 +1002,7 @@ static int cbs_h264_write_nal_unit(CodedBitstreamContext 
*ctx,
 
 case H264_NAL_SPS_EXT:
 {
-H264RawSPSExtension *sps_ext;
+H264RawSPSExtension *sps_ext = NULL;
 
 err = cbs_h264_write_sps_extension(ctx, pbc, sps_ext);
 if (err < 0)
-- 
2.14.1

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

[libav-devel] [RFC][PATCH] lavf: Wrap _DEFAULT_SOURCE symbols

2017-09-21 Thread Vittorio Giovara
Silence warnings such as:

 libavformat/udp.c:27:9: warning: '_DEFAULT_SOURCE'
   macro redefined [-Wmacro-redefined]
 #define _DEFAULT_SOURCE
 ^
 :4:9: note: previous definition is here
 #define _DEFAULT_SOURCE 1
 ^
---
I'm not sure this is the right approach, since configure explicitly adds
add_${pfx}cppflags -D_DEFAULT_SOURCE
in my compiler flag...
Any better ideas?
Vittorio

 libavformat/os_support.c | 2 ++
 libavformat/udp.c| 2 ++
 libswscale/utils.c   | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/libavformat/os_support.c b/libavformat/os_support.c
index c125dbe9ba..79be31dd82 100644
--- a/libavformat/os_support.c
+++ b/libavformat/os_support.c
@@ -21,7 +21,9 @@
  */
 
 /* needed by inet_aton() */
+#ifndef _DEFAULT_SOURCE
 #define _DEFAULT_SOURCE
+#endif
 #define _SVID_SOURCE
 
 #include "config.h"
diff --git a/libavformat/udp.c b/libavformat/udp.c
index a29eb1bd33..0994f4f198 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -24,7 +24,9 @@
  * UDP protocol
  */
 
+#ifndef _DEFAULT_SOURCE
 #define _DEFAULT_SOURCE
+#endif
 #define _BSD_SOURCE /* Needed for using struct ip_mreq with recent glibc */
 
 #include "avformat.h"
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 786774f241..07c336eef5 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -20,7 +20,9 @@
 
 #include "config.h"
 
+#ifndef _DEFAULT_SOURCE
 #define _DEFAULT_SOURCE
+#endif
 #define _SVID_SOURCE // needed for MAP_ANONYMOUS
 #include 
 #include 
-- 
2.14.1

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

[libav-devel] [PATCH] configure: cosmetics: Wrap a configure error string to the paragraph length

2017-09-21 Thread Vittorio Giovara
---
 configure | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index a3cfe37680..8e588ac104 100755
--- a/configure
+++ b/configure
@@ -401,8 +401,8 @@ include the log this produces with your report.
 EOF
 else
 cat 

Re: [libav-devel] [PATCH] pixdesc: Add API to map color property name to enum value

2017-09-21 Thread Vittorio Giovara
On Wed, Sep 20, 2017 at 8:15 PM, Vittorio Giovara <
vittorio.giov...@gmail.com> wrote:

>
>
> On Wed, Sep 20, 2017 at 8:10 PM, wm4 <nfx...@googlemail.com> wrote:
>
>> On Wed, 20 Sep 2017 13:33:13 +0200
>> Vittorio Giovara <vittorio.giov...@gmail.com> wrote:
>>
>> > Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
>> > ---
>> > TODO: version bump, APIdoc entry.
>> > Vittorio
>> >
>>
>> Suggestion: create a table with int/string pairs, and a shared lookup
>> function, so that you don't need to recreate the boilerplate over and
>> over?
>>
>
> I thought of that, but since these are tables that get updated relatively
> often, I didn't want to duplicate the amount of edits needed every time a
> new value is added.
> --
> Vittorio
>

As mentioned on IRC, there seems to be a preference for EINVAL instead of
ENOSYS.
Editing the patch, and queueing soon.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] pixdesc: Add API to map color property name to enum value

2017-09-20 Thread Vittorio Giovara
On Wed, Sep 20, 2017 at 8:10 PM, wm4 <nfx...@googlemail.com> wrote:

> On Wed, 20 Sep 2017 13:33:13 +0200
> Vittorio Giovara <vittorio.giov...@gmail.com> wrote:
>
> > Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
> > ---
> > TODO: version bump, APIdoc entry.
> > Vittorio
> >
>
> Suggestion: create a table with int/string pairs, and a shared lookup
> function, so that you don't need to recreate the boilerplate over and
> over?
>

I thought of that, but since these are tables that get updated relatively
often, I didn't want to duplicate the amount of edits needed every time a
new value is added.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] pixdesc: Add API to map color property name to enum value

2017-09-20 Thread Vittorio Giovara
On Wed, Sep 20, 2017 at 2:06 PM, Luca Barbato <lu_z...@gentoo.org> wrote:

> On 20/09/2017 13:33, Vittorio Giovara wrote:
>
>> Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
>> ---
>> TODO: version bump, APIdoc entry.
>> Vittorio
>>
>>   libavutil/pixdesc.c | 65 ++
>> +++
>>   libavutil/pixdesc.h | 25 +
>>   2 files changed, 90 insertions(+)
>>
>>
> Possibly fine, maybe mention negative instead of -1 in the documentation
> in case we want to change the return value to ENOSYS later.
>

Ok, I'll go ahead and just have them return AVERROR(ENOSYS) and update docs.
thanks
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH] pixdesc: Add API to map color property name to enum value

2017-09-20 Thread Vittorio Giovara
Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
TODO: version bump, APIdoc entry.
Vittorio

 libavutil/pixdesc.c | 65 +
 libavutil/pixdesc.h | 25 +
 2 files changed, 90 insertions(+)

diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 33aa2d705f..52340a459b 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -2749,26 +2749,91 @@ const char *av_color_range_name(enum AVColorRange range)
 color_range_names[range] : NULL;
 }
 
+int av_color_range_from_name(const char *name)
+{
+int i;
+
+for (i = 0; i < FF_ARRAY_ELEMS(color_range_names); i++) {
+size_t len = strlen(color_range_names[i]);
+if (!strncmp(color_range_names[i], name, len))
+return i;
+}
+
+return -1;
+}
+
 const char *av_color_primaries_name(enum AVColorPrimaries primaries)
 {
 return (unsigned) primaries < AVCOL_PRI_NB ?
 color_primaries_names[primaries] : NULL;
 }
 
+int av_color_primaries_from_name(const char *name)
+{
+int i;
+
+for (i = 0; i < FF_ARRAY_ELEMS(color_primaries_names); i++) {
+size_t len = strlen(color_primaries_names[i]);
+if (!strncmp(color_primaries_names[i], name, len))
+return i;
+}
+
+return -1;
+}
+
 const char *av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
 {
 return (unsigned) transfer < AVCOL_TRC_NB ?
 color_transfer_names[transfer] : NULL;
 }
 
+int av_color_transfer_from_name(const char *name)
+{
+int i;
+
+for (i = 0; i < FF_ARRAY_ELEMS(color_transfer_names); i++) {
+size_t len = strlen(color_transfer_names[i]);
+if (!strncmp(color_transfer_names[i], name, len))
+return i;
+}
+
+return -1;
+}
+
 const char *av_color_space_name(enum AVColorSpace space)
 {
 return (unsigned) space < AVCOL_SPC_NB ?
 color_space_names[space] : NULL;
 }
 
+int av_color_space_from_name(const char *name)
+{
+int i;
+
+for (i = 0; i < FF_ARRAY_ELEMS(color_space_names); i++) {
+size_t len = strlen(color_space_names[i]);
+if (!strncmp(color_space_names[i], name, len))
+return i;
+}
+
+return -1;
+}
+
 const char *av_chroma_location_name(enum AVChromaLocation location)
 {
 return (unsigned) location < AVCHROMA_LOC_NB ?
 chroma_location_names[location] : NULL;
 }
+
+int av_chroma_location_from_name(const char *name)
+{
+int i;
+
+for (i = 0; i < FF_ARRAY_ELEMS(chroma_location_names); i++) {
+size_t len = strlen(chroma_location_names[i]);
+if (!strncmp(chroma_location_names[i], name, len))
+return i;
+}
+
+return -1;
+}
diff --git a/libavutil/pixdesc.h b/libavutil/pixdesc.h
index b0ec81b81b..70e832405e 100644
--- a/libavutil/pixdesc.h
+++ b/libavutil/pixdesc.h
@@ -250,26 +250,51 @@ int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt);
  */
 const char *av_color_range_name(enum AVColorRange range);
 
+/**
+ * @return the AVColorRange value for name or -1 if not found.
+ */
+int av_color_range_from_name(const char *name);
+
 /**
  * @return the name for provided color primaries or NULL if unknown.
  */
 const char *av_color_primaries_name(enum AVColorPrimaries primaries);
 
+/**
+ * @return the AVColorPrimaries value for name or -1 if not found.
+ */
+int av_color_primaries_from_name(const char *name);
+
 /**
  * @return the name for provided color transfer or NULL if unknown.
  */
 const char *av_color_transfer_name(enum AVColorTransferCharacteristic 
transfer);
 
+/**
+ * @return the AVColorTransferCharacteristic value for name or -1 if not found.
+ */
+int av_color_transfer_from_name(const char *name);
+
 /**
  * @return the name for provided color space or NULL if unknown.
  */
 const char *av_color_space_name(enum AVColorSpace space);
 
+/**
+ * @return the AVColorSpace value for name or -1 if not found.
+ */
+int av_color_space_from_name(const char *name);
+
 /**
  * @return the name for provided chroma location or NULL if unknown.
  */
 const char *av_chroma_location_name(enum AVChromaLocation location);
 
+/**
+ * @return the AVChromaLocation value for name or -1 if not found.
+ */
+int av_chroma_location_from_name(const char *name);
+
 /**
  * Return the pixel format corresponding to name.
  *
-- 
2.14.1

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

[libav-devel] [PATCH] mp4: Support writing declarative SEis to hvcC

2017-08-17 Thread Vittorio Giovara
Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
Right now this patch lacks for a way to check for declarative SEIs,
so it appends all of them (creating out-of-spec files), and it
probably misses SEIs which are attach to other NALUs.
Any suggestions?
Vittorio

 libavcodec/extract_extradata_bsf.c |  1 +
 libavformat/hevc.c | 28 
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/libavcodec/extract_extradata_bsf.c 
b/libavcodec/extract_extradata_bsf.c
index 20840bd6af..990fc0e45c 100644
--- a/libavcodec/extract_extradata_bsf.c
+++ b/libavcodec/extract_extradata_bsf.c
@@ -54,6 +54,7 @@ static int extract_extradata_h2645(AVBSFContext *ctx, 
AVPacket *pkt,
 {
 static const int extradata_nal_types_hevc[] = {
 HEVC_NAL_VPS, HEVC_NAL_SPS, HEVC_NAL_PPS,
+HEVC_NAL_SEI_PREFIX, HEVC_NAL_SEI_SUFFIX,
 };
 static const int extradata_nal_types_h264[] = {
 H264_NAL_SPS, H264_NAL_PPS,
diff --git a/libavformat/hevc.c b/libavformat/hevc.c
index f8bfeebd31..70ebfd0a33 100644
--- a/libavformat/hevc.c
+++ b/libavformat/hevc.c
@@ -22,6 +22,7 @@
 #include "libavcodec/get_bits.h"
 #include "libavcodec/golomb_legacy.h"
 #include "libavcodec/hevc.h"
+#include "libavcodec/hevc_sei.h"
 #include "libavutil/intreadwrite.h"
 #include "avc.h"
 #include "avio.h"
@@ -751,17 +752,10 @@ static int hvcc_add_nal_unit(uint8_t *nal_buf, uint32_t 
nal_size,
 
 nal_unit_parse_header(, _type);
 
-/*
- * Note: only 'declarative' SEI messages are allowed in
- * hvcC. Perhaps the SEI playload type should be checked
- * and non-declarative SEI messages discarded?
- */
 switch (nal_type) {
 case HEVC_NAL_VPS:
 case HEVC_NAL_SPS:
 case HEVC_NAL_PPS:
-case HEVC_NAL_SEI_PREFIX:
-case HEVC_NAL_SEI_SUFFIX:
 ret = hvcc_array_add_nal_unit(nal_buf, nal_size, nal_type,
   ps_array_completeness, hvcc);
 if (ret < 0)
@@ -775,6 +769,15 @@ static int hvcc_add_nal_unit(uint8_t *nal_buf, uint32_t 
nal_size,
 if (ret < 0)
 goto end;
 break;
+case HEVC_NAL_SEI_PREFIX:
+case HEVC_NAL_SEI_SUFFIX:
+if (nal_size > 2 && *(nal_buf + 2) == 
HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO) {
+ret = hvcc_array_add_nal_unit(nal_buf, nal_size, nal_type,
+  ps_array_completeness, hvcc);
+if (ret < 0)
+goto end;
+}
+break;
 default:
 ret = AVERROR_INVALIDDATA;
 goto end;
@@ -823,6 +826,7 @@ static int hvcc_write(AVIOContext *pb, 
HEVCDecoderConfigurationRecord *hvcc)
 {
 uint8_t i;
 uint16_t j, vps_count = 0, sps_count = 0, pps_count = 0;
+int sei_prefix_count = 0, sei_suffix_count = 0;
 
 /*
  * We only support writing HEVCDecoderConfigurationRecord version 1.
@@ -913,12 +917,20 @@ static int hvcc_write(AVIOContext *pb, 
HEVCDecoderConfigurationRecord *hvcc)
 case HEVC_NAL_PPS:
 pps_count += hvcc->array[i].numNalus;
 break;
+case HEVC_NAL_SEI_PREFIX:
+sei_suffix_count += hvcc->array[i].numNalus;
+break;
+case HEVC_NAL_SEI_SUFFIX:
+sei_prefix_count += hvcc->array[i].numNalus;
+break;
 default:
 break;
 }
 if (!vps_count || vps_count > HEVC_MAX_VPS_COUNT ||
 !sps_count || sps_count > HEVC_MAX_SPS_COUNT ||
-!pps_count || pps_count > HEVC_MAX_PPS_COUNT)
+!pps_count || pps_count > HEVC_MAX_PPS_COUNT ||
+sei_prefix_count > UINT16_MAX ||
+sei_suffix_count > UINT16_MAX)
 return AVERROR_INVALIDDATA;
 
 /* unsigned int(8) configurationVersion = 1; */
-- 
2.13.2

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

[libav-devel] [PATCH] pixfmt: Support chroma-derived and ictcp color matrices

2017-08-08 Thread Vittorio Giovara
Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
Now without the typo in the name.
Vittorio

 libavutil/pixdesc.c | 4 
 libavutil/pixfmt.h  | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 7fa6dd7c0b..f1e35f2254 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -1806,6 +1806,10 @@ static const char * const color_space_names[] = {
 [AVCOL_SPC_BT2020_NCL] = "bt2020nc",
 [AVCOL_SPC_BT2020_CL] = "bt2020c",
 [AVCOL_SPC_SMPTE2085] = "smpte2085",
+[AVCOL_SPC_CHROMA_DERIVED_NCL] = "chroma-derived-nc",
+[AVCOL_SPC_CHROMA_DERIVED_CL] = "chroma-derived-c",
+[AVCOL_SPC_ICTCP] = "ictcp",
+
 };
 
 static const char * const chroma_location_names[] = {
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 2ba7ad1c88..2823a7ea36 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -384,6 +384,9 @@ enum AVColorSpace {
 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_SMPTE2085   = 11, ///< SMPTE 2085, Y'D'zD'x
+AVCOL_SPC_CHROMA_DERIVED_NCL = 12, ///< Chromaticity-derived non-constant 
luminance system
+AVCOL_SPC_CHROMA_DERIVED_CL = 13, ///< Chromaticity-derived constant 
luminance system
+AVCOL_SPC_ICTCP   = 14, ///< ITU-R BT.2100-0 ICTCP
 AVCOL_SPC_NB,   ///< Not part of ABI
 };
 
-- 
2.13.2

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

[libav-devel] [PATCH] pixfmt: Support chroma-derived and icpct color matrices

2017-08-08 Thread Vittorio Giovara
Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
Missing version bump.
Vittorio

 libavutil/pixdesc.c | 4 
 libavutil/pixfmt.h  | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 7fa6dd7c0b..a72ef3faf0 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -1806,6 +1806,10 @@ static const char * const color_space_names[] = {
 [AVCOL_SPC_BT2020_NCL] = "bt2020nc",
 [AVCOL_SPC_BT2020_CL] = "bt2020c",
 [AVCOL_SPC_SMPTE2085] = "smpte2085",
+[AVCOL_SPC_CHROMA_DERIVED_NCL] = "chroma-derived-nc",
+[AVCOL_SPC_CHROMA_DERIVED_CL] = "chroma-derived-c",
+[AVCOL_SPC_ICPCT] = "icpct",
+
 };
 
 static const char * const chroma_location_names[] = {
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 2ba7ad1c88..93fd95da58 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -384,6 +384,9 @@ enum AVColorSpace {
 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_SMPTE2085   = 11, ///< SMPTE 2085, Y'D'zD'x
+AVCOL_SPC_CHROMA_DERIVED_NCL = 12, ///< Chromaticity-derived non-constant 
luminance system
+AVCOL_SPC_CHROMA_DERIVED_CL = 13, ///< Chromaticity-derived constant 
luminance system
+AVCOL_SPC_ICPCT   = 14, ///< ITU-R BT.2100-0 ICTCP
 AVCOL_SPC_NB,   ///< Not part of ABI
 };
 
-- 
2.13.2

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

[libav-devel] [PATCH] h264: Add support for alternative transfer characterics SEI

2017-08-08 Thread Vittorio Giovara
The use of this SEI is for backward compatibility in HLG HDR systems:
older devices that cannot interpret the "arib-std-b67" transfer will
get the compatible transfer (usually bt709 or bt2020) from the VUI,
while newer devices that can interpret HDR will read the SEI and use
its value instead.

Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 libavcodec/h264_sei.c   | 11 +++
 libavcodec/h264_sei.h   |  7 +++
 libavcodec/h264_slice.c |  6 ++
 3 files changed, 24 insertions(+)

diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
index 3ca2b7a6cd..03fca9017f 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -346,6 +346,14 @@ static int 
decode_display_orientation(H264SEIDisplayOrientation *h,
 return 0;
 }
 
+static int decode_alternative_transfer(H264SEIAlternativeTransfer *h,
+   GetBitContext *gb)
+{
+h->present = 1;
+h->preferred_transfer_characteristics = get_bits(gb, 8);
+return 0;
+}
+
 int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb,
const H264ParamSets *ps, void *logctx)
 {
@@ -396,6 +404,9 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb,
 case H264_SEI_TYPE_DISPLAY_ORIENTATION:
 ret = decode_display_orientation(>display_orientation, gb);
 break;
+case H264_SEI_TYPE_ALTERNATIVE_TRANSFER:
+ret = decode_alternative_transfer(>alternative_transfer, gb);
+break;
 default:
 av_log(logctx, AV_LOG_DEBUG, "unknown SEI type %d\n", type);
 skip_bits(gb, 8 * size);
diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h
index ce9768ec3d..f6ac6034da 100644
--- a/libavcodec/h264_sei.h
+++ b/libavcodec/h264_sei.h
@@ -33,6 +33,7 @@ typedef enum {
 H264_SEI_TYPE_RECOVERY_POINT = 6,   ///< recovery point (frame # 
to decoder sync)
 H264_SEI_TYPE_FRAME_PACKING  = 45,  ///< frame packing arrangement
 H264_SEI_TYPE_DISPLAY_ORIENTATION= 47,  ///< display orientation
+H264_SEI_TYPE_ALTERNATIVE_TRANSFER   = 147, ///< alternative transfer
 } H264_SEI_Type;
 
 /**
@@ -115,6 +116,11 @@ typedef struct H264SEIDisplayOrientation {
 int hflip, vflip;
 } H264SEIDisplayOrientation;
 
+typedef struct H264SEIAlternativeTransfer {
+int present;
+int preferred_transfer_characteristics;
+} H264SEIAlternativeTransfer;
+
 typedef struct H264SEIContext {
 H264SEIPictureTiming picture_timing;
 H264SEIAFD afd;
@@ -124,6 +130,7 @@ typedef struct H264SEIContext {
 H264SEIBufferingPeriod buffering_period;
 H264SEIFramePacking frame_packing;
 H264SEIDisplayOrientation display_orientation;
+H264SEIAlternativeTransfer alternative_transfer;
 } H264SEIContext;
 
 struct H264ParamSets;
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index c6309b298c..5dd01d836e 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1154,6 +1154,12 @@ static int h264_export_frame_props(H264Context *h)
 a53->a53_caption_size = 0;
 }
 
+if (h->sei.alternative_transfer.present &&
+
av_color_transfer_name(h->sei.alternative_transfer.preferred_transfer_characteristics)
 &&
+h->sei.alternative_transfer.preferred_transfer_characteristics != 
AVCOL_TRC_UNSPECIFIED) {
+h->avctx->color_trc = cur->f->color_trc = 
h->sei.alternative_transfer.preferred_transfer_characteristics;
+}
+
 return 0;
 }
 
-- 
2.13.2

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

[libav-devel] [PATCH] hevc: Make sure to update the current frame transfer characteristic

2017-07-20 Thread Vittorio Giovara
Otherwise the first decoded frame will still be tagged with the
original transfer instead of the alternative one.

Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 libavcodec/hevcdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index ac0b1a3c1d..f6bbb7051e 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2410,7 +2410,7 @@ static int set_side_data(HEVCContext *s)
 if (s->sei.alternative_transfer.present &&
 
av_color_transfer_name(s->sei.alternative_transfer.preferred_transfer_characteristics)
 &&
 s->sei.alternative_transfer.preferred_transfer_characteristics != 
AVCOL_TRC_UNSPECIFIED) {
-s->avctx->color_trc = 
s->sei.alternative_transfer.preferred_transfer_characteristics;
+s->avctx->color_trc = out->color_trc = 
s->sei.alternative_transfer.preferred_transfer_characteristics;
 }
 
 return 0;
-- 
2.13.2

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

Re: [libav-devel] [PATCH] [RFC] Add Cinepak encoder

2017-07-04 Thread Vittorio Giovara
On Tue, Jul 4, 2017 at 11:59 AM, Diego Biurrun  wrote:
> From: Tomas Härdin 
>
> Signed-off-by: Diego Biurrun 
> ---
>
> The whole set squashed together, to ease Luca's review.

IMO that's also how the set should be squashed and pushed, with a
clear commit message about who changed what.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 05/25] avtools: Use the new channel layout API in AVFrame

2017-07-04 Thread Vittorio Giovara
On Tue, Jul 4, 2017 at 6:50 AM, Luca Barbato <lu_z...@gentoo.org> wrote:
> On 6/29/17 12:10 AM, Vittorio Giovara wrote:
>> ---
>>  avtools/avconv.c| 2 +-
>>  avtools/avconv_filter.c | 2 +-
>>  avtools/avplay.c| 4 ++--
>>  3 files changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/avtools/avconv.c b/avtools/avconv.c
>> index 8dd11bb5fc..42cbfef592 100644
>> --- a/avtools/avconv.c
>> +++ b/avtools/avconv.c
>> @@ -1209,7 +1209,7 @@ static int ifilter_send_frame(InputFilter *ifilter, 
>> AVFrame *frame)
>>  switch (ifilter->ist->st->codecpar->codec_type) {
>>  case AVMEDIA_TYPE_AUDIO:
>>  need_reinit |= ifilter->sample_rate!= frame->sample_rate ||
>> -   ifilter->channel_layout != frame->channel_layout;
>> +   ifilter->channel_layout != frame->ch_layout.u.mask;
>>  break;
>>  case AVMEDIA_TYPE_VIDEO:
>>  need_reinit |= ifilter->width  != frame->width ||
>> diff --git a/avtools/avconv_filter.c b/avtools/avconv_filter.c
>> index 884478da27..e719c06658 100644
>> --- a/avtools/avconv_filter.c
>> +++ b/avtools/avconv_filter.c
>> @@ -798,7 +798,7 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, 
>> const AVFrame *frame)
>>  ifilter->sample_aspect_ratio = frame->sample_aspect_ratio;
>>
>>  ifilter->sample_rate = frame->sample_rate;
>> -ifilter->channel_layout  = frame->channel_layout;
>> +ifilter->channel_layout  = frame->ch_layout.u.mask;
>>
>>  if (frame->hw_frames_ctx) {
>>  ifilter->hw_frames_ctx = av_buffer_ref(frame->hw_frames_ctx);
>> diff --git a/avtools/avplay.c b/avtools/avplay.c
>> index b6dbc52cf7..6cc63258fc 100644
>> --- a/avtools/avplay.c
>> +++ b/avtools/avplay.c
>> @@ -1837,11 +1837,11 @@ static int audio_decode_frame(PlayerState *is, 
>> double *pts_ptr)
>> is->frame->format, 1);
>>
>>  audio_resample = is->frame->format != 
>> is->sdl_sample_fmt ||
>> - is->frame->channel_layout != 
>> is->sdl_channel_layout ||
>> + is->frame->ch_layout.u.mask != 
>> is->sdl_channel_layout ||
>>   is->frame->sample_rate!= 
>> is->sdl_sample_rate;
>>
>>  resample_changed = is->frame->format != 
>> is->resample_sample_fmt ||
>> -   is->frame->channel_layout != 
>> is->resample_channel_layout ||
>> +   is->frame->ch_layout.u.mask != 
>> is->resample_channel_layout ||
>> is->frame->sample_rate!= 
>> is->resample_sample_rate;
>>
>>  if ((!is->avr && audio_resample) || resample_changed) {
>>
>
> Doesn't hurt, but might be folded with patch 16.

patch 16 is for supplementary parts, such as examples or tests, I'd
rather keep the main tools patches separated
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] Add a new channel layout API

2017-06-30 Thread Vittorio Giovara
On Fri, Jun 30, 2017 at 4:38 AM, wm4 <nfx...@googlemail.com> wrote:
> On Thu, 29 Jun 2017 17:28:51 -0400
> Vittorio Giovara <vittorio.giov...@gmail.com> wrote:
>
>> From: Anton Khirnov <an...@khirnov.net>
>>
>> The new API is more extensible and allows for custom layouts.
>> More accurate information is exported, eg for decoders that do not
>> set a channel layout, lavc will not make one up for them.
>>
>> Deprecate the old API working with just uint64_t bitmasks.
>>
>> Expanded and completed by Vittorio Giovara <vittorio.giov...@gmail.com>.
>> Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
>> ---
>
>
>> +
>> +/**
>> + * Initialize a channel layout from a given string description.
>> + * The input string can be represented by:
>> + *  - the formal channel layout name (returned by 
>> av_channel_layout_describe())
>> + *  - single or multiple channel names (returned by av_channel_name()
>> + *or concatenated with "|")
>> + *  - a hexadecimal value of a channel layout (eg. "0x4")
>> + *  - the number of channels with default layout (eg. "5")
>> + *  - the number of unordered channels (eg. "4 channels")
>> + *
>> + * @note channel_layout should be properly allocated as described above.
>
> Above, where?

in the structure description, I'll add this locally

>> + *
>> + * @param channel_layout input channel layout
>> + * @param str string describing the channel layout
>> + * @return 0 channel layout was detected, AVERROR_INVALIDATATA otherwise
>> + */
>> +int av_channel_layout_from_string(AVChannelLayout *channel_layout,
>> +  const char *str);
>
> I still think you need to describe in what state channel_layout should
> be.
>
> Why is this so hard? It's always the same with Libav API docs. AVFrame
> sort of has the same problem.

ok if you insist ^^

>> +/**
>> + * Get the default channel layout for a given number of channels.
>> + *
>> + * @note channel_layout should be properly allocated as described above.
>> + *
>> + * @param channel_layout the layout structure to be initialized
>> + * @param nb_channels number of channels
>> + */
>> +void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels);
>> +
>> +/**
>> + * Free any allocated data in the channel layout and reset the channel
>> + * count to 0.
>> + *
>> + * @note this only used for structure initialization and for freeing the
>> + *   allocated memory for AV_CHANNEL_ORDER_CUSTOM order.
>> + *
>> + * @param channel_layout the layout structure to be uninitialized
>> + */
>> +void av_channel_layout_uninit(AVChannelLayout *channel_layout);
>> +
>> +/**
>> + * Make a copy of a channel layout. This differs from just assigning src to 
>> dst
>> + * in that it allocates and copies the map for AV_CHANNEL_ORDER_CUSTOM.
>> + *
>
>> + * @note the destination channel_layout will be always uninitialized before 
>> copy.
>
> What does this statement even mean? Does it call
>
>   av_channel_layout_uninit(dst);
>
> as first line?

Correct, is that unclear? How would you phrase it?

>> + *
>> + * @param dst destination channel layout
>> + * @param src source channel layout
>> + * @return 0 on success, a negative AVERROR on error.
>> + */
>> +int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout 
>> *src);
>> +
>
> Otherwise ok.

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

Re: [libav-devel] [PATCH] lavf: Remove codec_tag from dashend and smoothstreamingenc

2017-06-30 Thread Vittorio Giovara
nit: s/dashend/dashenc/ in the commit title

On Fri, Jun 30, 2017 at 5:52 AM, Martin Storsjö  wrote:
> Currently, the tags enforced and set on the segmenter muxer level
> mismatches what the mp4/ismv muxer uses (since 713efb2c0d013).
>
> Skip the codec_tag altogether here, to let the user (try to) set
> whichever codec/tag he wants; the individual chained muxer will
> reject invalid codecs anyway.
> ---
>  libavformat/dashenc.c| 1 -
>  libavformat/smoothstreamingenc.c | 1 -
>  2 files changed, 2 deletions(-)

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

[libav-devel] [PATCH] Add a new channel layout API

2017-06-29 Thread Vittorio Giovara
From: Anton Khirnov <an...@khirnov.net>

The new API is more extensible and allows for custom layouts.
More accurate information is exported, eg for decoders that do not
set a channel layout, lavc will not make one up for them.

Deprecate the old API working with just uint64_t bitmasks.

Expanded and completed by Vittorio Giovara <vittorio.giov...@gmail.com>.
Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
Changes to documentation as suggested by wm4, completed the doxygen
documentation for a couple of functions.
Vittorio

 libavutil/channel_layout.c | 387 +++---
 libavutil/channel_layout.h | 408 ++---
 libavutil/version.h|   3 +
 3 files changed, 708 insertions(+), 90 deletions(-)

diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c
index 41340ecdb6..285997446d 100644
--- a/libavutil/channel_layout.c
+++ b/libavutil/channel_layout.c
@@ -31,77 +31,90 @@
 #include "common.h"
 
 static const char * const channel_names[] = {
-[0]  = "FL",/* front left */
-[1]  = "FR",/* front right */
-[2]  = "FC",/* front center */
-[3]  = "LFE",   /* low frequency */
-[4]  = "BL",/* back left */
-[5]  = "BR",/* back right */
-[6]  = "FLC",   /* front left-of-center  */
-[7]  = "FRC",   /* front right-of-center */
-[8]  = "BC",/* back-center */
-[9]  = "SL",/* side left */
-[10] = "SR",/* side right */
-[11] = "TC",/* top center */
-[12] = "TFL",   /* top front left */
-[13] = "TFC",   /* top front center */
-[14] = "TFR",   /* top front right */
-[15] = "TBL",   /* top back left */
-[16] = "TBC",   /* top back center */
-[17] = "TBR",   /* top back right */
-[29] = "DL",/* downmix left */
-[30] = "DR",/* downmix right */
-[31] = "WL",/* wide left */
-[32] = "WR",/* wide right */
-[33] = "SDL",   /* surround direct left */
-[34] = "SDR",   /* surround direct right */
-[35] = "LFE2",  /* low frequency 2 */
+[AV_CHAN_FRONT_LEFT  ] = "FL",
+[AV_CHAN_FRONT_RIGHT ] = "FR",
+[AV_CHAN_FRONT_CENTER] = "FC",
+[AV_CHAN_LOW_FREQUENCY   ] = "LFE",
+[AV_CHAN_BACK_LEFT   ] = "BL",
+[AV_CHAN_BACK_RIGHT  ] = "BR",
+[AV_CHAN_FRONT_LEFT_OF_CENTER] = "FLC",
+[AV_CHAN_FRONT_RIGHT_OF_CENTER   ] = "FRC",
+[AV_CHAN_BACK_CENTER ] = "BC",
+[AV_CHAN_SIDE_LEFT   ] = "SL",
+[AV_CHAN_SIDE_RIGHT  ] = "SR",
+[AV_CHAN_TOP_CENTER  ] = "TC",
+[AV_CHAN_TOP_FRONT_LEFT  ] = "TFL",
+[AV_CHAN_TOP_FRONT_CENTER] = "TFC",
+[AV_CHAN_TOP_FRONT_RIGHT ] = "TFR",
+[AV_CHAN_TOP_BACK_LEFT   ] = "TBL",
+[AV_CHAN_TOP_BACK_CENTER ] = "TBC",
+[AV_CHAN_TOP_BACK_RIGHT  ] = "TBR",
+[AV_CHAN_STEREO_LEFT ] = "DL",
+[AV_CHAN_STEREO_RIGHT] = "DR",
+[AV_CHAN_WIDE_LEFT   ] = "WL",
+[AV_CHAN_WIDE_RIGHT  ] = "WR",
+[AV_CHAN_SURROUND_DIRECT_LEFT] = "SDL",
+[AV_CHAN_SURROUND_DIRECT_RIGHT   ] = "SDR",
+[AV_CHAN_LOW_FREQUENCY_2 ] = "LFE2",
+[AV_CHAN_SILENCE ] = "PAD",
 };
 
-static const char *get_channel_name(int channel_id)
+const char *av_channel_name(enum AVChannel channel_id)
 {
-if (channel_id < 0 || channel_id >= FF_ARRAY_ELEMS(channel_names))
-return NULL;
+if ((unsigned) channel_id >= FF_ARRAY_ELEMS(channel_names))
+return "?";
 return channel_names[channel_id];
 }
 
+int av_channel_from_string(const char *str)
+{
+int i;
+for (i = 0; i < FF_ARRAY_ELEMS(channel_names); i++) {
+if (channel_names[i] && !strcmp(str, channel_names[i])) {
+return i;
+}
+}
+return AVERROR(EINVAL);
+}
+
 static const struct {
 const char *name;
-int nb_channels;
-uint64_t layout;
+AVChannelLayout layout;
 } channel_layout_map[] = {
-{ "mono",1,  AV_CH_LAYOUT_MONO },
-{ "stereo",  2,  AV_CH_LAYOUT_STEREO },
-{ "stereo",  2,  AV_CH_LAYOUT_STEREO_DOWNMIX },
-{ "2.1",  

Re: [libav-devel] [PATCH 01/25] Add a new channel layout API

2017-06-29 Thread Vittorio Giovara
On Thu, Jun 29, 2017 at 5:14 AM, wm4 <nfx...@googlemail.com> wrote:
> On Wed, 28 Jun 2017 18:10:45 -0400
> Vittorio Giovara <vittorio.giov...@gmail.com> wrote:
>>  /**
>> + * An AVChannelLayout holds information about the channel layout of audio 
>> data.
>> + *
>> + * A channel layout here is defined as a set of channels ordered in a 
>> specific
>> + * way (unless the channel order is AV_CHANNEL_ORDER_UNSPEC, in which case 
>> an
>> + * AVChannelLayout carries only the channel count).
>> + *
>> + * Unlike most structures in Libav, sizeof(AVChannelLayout) is a part of the
>> + * public ABI and may be used by the caller. E.g. it may be allocated on 
>> stack.
>
> You should specify how it has to be handled. You can:
> - default initialize it with {0} or by setting all used fields correctly
> - using a predefined layout as initializer (AV_CHANNEL_LAYOUT_STEREO
>   etc.)
> - initialize it with a constructor function
> - must be uninitialized with av_channel_layout_uninit() (at least in
>   some situations, which is weird)
> - copy via assigning is forbidden (probably?), av_channel_layout_copy()
>   must be used instead

Ok i'll add a verbatim of this description

>> + * No new fields may be added to it without a major version bump.
>
> I think it's still intended that you can add new fields to the union?
> So you will add new fields. You just won't change the size, or add
> new fields which are mandatory for already defined layout types.

ok I took it for granted, but mentioning it won't harm

>> + * An AVChannelLayout can be constructed using the convenience function
>> + * av_channel_layout_from_mask() / av_channel_layout_from_string(), or it 
>> can be
>> + * built manually by the caller.
>> + */
>> +typedef struct AVChannelLayout {
>> +/**
>> + * Channel order used in this layout.
>> + */
>
> ("Mandatory field.")

It is but it defaults to NATIVE order. I'll mention it anyway.

>> +enum AVChannelOrder order;
>> +
>> +/**
>> + * Number of channels in this layout. Mandatory field.
>> + */
>> +int nb_channels;
>> +
>> +/**
>> + * Details about which channels are present in this layout.
>> + * For AV_CHANNEL_ORDER_UNSPEC, this field is undefined and must not be
>> + * used.
>> + */
>> +union {
>> +/**
>> + * This member must be used for AV_CHANNEL_ORDER_NATIVE.
>> + * It is a bitmask, where the position of each set bit means that 
>> the
>> + * AVChannel with the corresponding value is present.
>> + *
>> + * I.e. when (mask & (1 << AV_CHAN_FOO)) is non-zero, then 
>> AV_CHAN_FOO
>> + * is present in the layout. Otherwise it is not present.
>> + *
>> + * @note when a channel layout using a bitmask is constructed or
>> + * modified manually (i.e.  not using any of the av_channel_layout_*
>> + * functions), the code doing it must ensure that the number of set 
>> bits
>> + * is equal to nb_channels.
>> + */
>> +uint64_t mask;
>> +/**
>> + * This member must be used when the channel order is
>> + * AV_CHANNEL_ORDER_CUSTOM. It is a nb_channels-sized array, with 
>> each
>> + * element signalling the presend of the AVChannel with the
>> + * corresponding value.
>> + *
>> + * I.e. when map[i] is equal to AV_CHAN_FOO, then AV_CH_FOO is the 
>> i-th
>> + * channel in the audio data.
>> + */
>> +enum AVChannel *map;
>
> Even if the channel map identifier is AV_CHAN_SILENCE? What does the
> data contain then, actual silence or undefined contents?

I suppose so, it will simply mean that the channel at position `i`
will be SILENCE.
I documented that channel as "empty", which is a little vague, do have
any suggestion?

>> +/**
>> + * @return a string describing a given channel.
>> + */
>> +const char *av_channel_name(enum AVChannel channel);
>
> What does it return for invalid channels?

it returns "?", I'll mention it in the docs

>> +
>> +/**
>> + * @return a channel described by the given string.
>> + */
>> +int av_channel_from_string(const char *name);
>
> Return what exactly? I guess AVChannel or negative error code. Could
> also say it's the inverse of av_channel_name().

okay

>> +
>> +/**
>> + * Initialize a native channel layout from a bitmask indicating which 
>> chan

[libav-devel] [PATCH] lavr: switch to the new channel layout API

2017-06-29 Thread Vittorio Giovara
From: Anton Khirnov <an...@khirnov.net>

Set a whitelist of supported channel order.

Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 libavresample/audio_mix.c| 148 ++--
 libavresample/audio_mix_matrix.c | 477 ++-
 libavresample/avresample.h   |  42 +++-
 libavresample/internal.h |  10 +-
 libavresample/options.c  |   8 +
 libavresample/tests/avresample.c |  26 +--
 libavresample/utils.c| 130 +++
 7 files changed, 507 insertions(+), 334 deletions(-)

diff --git a/libavresample/audio_mix.c b/libavresample/audio_mix.c
index 89ecc6ba71..36dff2b979 100644
--- a/libavresample/audio_mix.c
+++ b/libavresample/audio_mix.c
@@ -20,6 +20,7 @@
 
 #include 
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
 #include "libavutil/libm.h"
 #include "libavutil/samplefmt.h"
@@ -34,10 +35,8 @@ struct AudioMix {
 AVAudioResampleContext *avr;
 enum AVSampleFormat fmt;
 enum AVMixCoeffType coeff_type;
-uint64_t in_layout;
-uint64_t out_layout;
-int in_channels;
-int out_channels;
+AVChannelLayout in_layout;
+AVChannelLayout out_layout;
 
 int ptr_align;
 int samples_align;
@@ -331,8 +330,8 @@ static av_cold int mix_function_init(AudioMix *am)
 if (!am->mix) {
 av_log(am->avr, AV_LOG_ERROR, "audio_mix: NO FUNCTION FOUND: [fmt=%s] "
"[c=%s] [%d to %d]\n", av_get_sample_fmt_name(am->fmt),
-   coeff_type_names[am->coeff_type], am->in_channels,
-   am->out_channels);
+   coeff_type_names[am->coeff_type], am->in_layout.nb_channels,
+   am->out_layout.nb_channels);
 return AVERROR_PATCHWELCOME;
 }
 return 0;
@@ -358,38 +357,42 @@ AudioMix *ff_audio_mix_alloc(AVAudioResampleContext *avr)
 
 am->fmt  = avr->internal_sample_fmt;
 am->coeff_type   = avr->mix_coeff_type;
-am->in_layout= avr->in_channel_layout;
-am->out_layout   = avr->out_channel_layout;
-am->in_channels  = avr->in_channels;
-am->out_channels = avr->out_channels;
+
+ret = av_channel_layout_copy(>in_layout, >in_ch_layout);
+if (ret < 0)
+goto error;
+ret = av_channel_layout_copy(>out_layout, >out_ch_layout);
+if (ret < 0)
+goto error;
 
 /* build matrix if the user did not already set one */
 if (avr->mix_matrix) {
-ret = ff_audio_mix_set_matrix(am, avr->mix_matrix, avr->in_channels);
+ret = ff_audio_mix_set_matrix(am, avr->mix_matrix, 
avr->in_ch_layout.nb_channels);
 if (ret < 0)
 goto error;
 av_freep(>mix_matrix);
 } else {
-double *matrix_dbl = av_mallocz(avr->out_channels * avr->in_channels *
+double *matrix_dbl = av_mallocz(avr->out_ch_layout.nb_channels *
+avr->in_ch_layout.nb_channels *
 sizeof(*matrix_dbl));
 if (!matrix_dbl)
 goto error;
 
-ret = avresample_build_matrix(avr->in_channel_layout,
-  avr->out_channel_layout,
-  avr->center_mix_level,
-  avr->surround_mix_level,
-  avr->lfe_mix_level,
-  avr->normalize_mix_level,
-  matrix_dbl,
-  avr->in_channels,
-  avr->matrix_encoding);
+ret = avresample_build_matrix2(>in_ch_layout,
+   >out_ch_layout,
+   avr->center_mix_level,
+   avr->surround_mix_level,
+   avr->lfe_mix_level,
+   avr->normalize_mix_level,
+   matrix_dbl,
+   avr->in_ch_layout.nb_channels,
+   avr->matrix_encoding);
 if (ret < 0) {
 av_free(matrix_dbl);
 goto error;
 }
 
-ret = ff_audio_mix_set_matrix(am, matrix_dbl, avr->in_channels);
+ret = ff_audio_mix_set_matrix(am, matrix_dbl, 
avr->in_ch_layout.nb_channels);
 if (ret < 0) {
 av_log(avr, AV_LOG_ERROR, "error setting mix matrix\n");
 av_free(matrix_dbl);
@@ -402,7 +405,7 @@ AudioMix *ff_audio_mix_alloc(AVAudioResampleContext *avr)
 return am;
 
 error:
-av_free(am);
+ff_audio_mix_free();
 return NULL;
 }
 
@@ -422,11 +425,16 @@ void ff_audio_mix_free(AudioMi

[libav-devel] [PATCH] lavr: Only allow pass-through of ambisonic channel layouts

2017-06-29 Thread Vittorio Giovara
Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 libavresample/utils.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/libavresample/utils.c b/libavresample/utils.c
index 5e4a9f3ac3..cadfd5474f 100644
--- a/libavresample/utils.c
+++ b/libavresample/utils.c
@@ -46,8 +46,10 @@ int avresample_open(AVAudioResampleContext *avr)
 
 /* whitelist allowed channel orders */
 if ( (avr->in_ch_layout.order != AV_CHANNEL_ORDER_NATIVE &&
+  avr->in_ch_layout.order != AV_CHANNEL_ORDER_AMBISONIC &&
   avr->in_ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) ||
 (avr->out_ch_layout.order != AV_CHANNEL_ORDER_NATIVE &&
+ avr->out_ch_layout.order != AV_CHANNEL_ORDER_AMBISONIC &&
  avr->out_ch_layout.order != AV_CHANNEL_ORDER_UNSPEC)) {
 av_log(avr, AV_LOG_ERROR,
   "Input or ouput channel order is not supported.\n");
@@ -73,6 +75,14 @@ int avresample_open(AVAudioResampleContext *avr)
 av_channel_layout_default(>out_ch_layout, 
avr->out_ch_layout.nb_channels);
 }
 
+if (( avr->in_ch_layout.order == AV_CHANNEL_ORDER_AMBISONIC ||
+ avr->out_ch_layout.order == AV_CHANNEL_ORDER_AMBISONIC) &&
+av_channel_layout_compare(>in_ch_layout, >out_ch_layout)) {
+av_log(avr, AV_LOG_ERROR,
+   "Resampling to/from ambisonic channel layouts is not 
supported.\n");
+return AVERROR(ENOSYS);
+}
+
 /* set channel mixing parameters */
 #if FF_API_OLD_CHANNEL_LAYOUT
 if (avr->in_channel_layout) {
-- 
2.13.1

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

Re: [libav-devel] [PATCH 18/25] lavr: Only let pass-through ambisonic channel layouts

2017-06-29 Thread Vittorio Giovara
On Thu, Jun 29, 2017 at 5:23 AM, wm4 <nfx...@googlemail.com> wrote:
> On Wed, 28 Jun 2017 18:11:02 -0400
> Vittorio Giovara <vittorio.giov...@gmail.com> wrote:
>
>> Resampling or conversion to/from ambisonic audio are currently
>> unsupported features.
>>
>> Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
>> ---
>>  libavresample/utils.c | 8 
>>  1 file changed, 8 insertions(+)
>>
>> diff --git a/libavresample/utils.c b/libavresample/utils.c
>> index 15c827efbe..af2b9dbf2d 100644
>> --- a/libavresample/utils.c
>> +++ b/libavresample/utils.c
>> @@ -70,6 +70,14 @@ int avresample_open(AVAudioResampleContext *avr)
>>  av_channel_layout_default(>out_ch_layout, 
>> avr->out_ch_layout.nb_channels);
>>  }
>>
>> +if (( avr->in_ch_layout.order == AV_CHANNEL_ORDER_AMBISONIC ||
>> + avr->out_ch_layout.order == AV_CHANNEL_ORDER_AMBISONIC) &&
>> +av_channel_layout_compare(>in_ch_layout, >out_ch_layout)) 
>> {
>> +av_log(avr, AV_LOG_ERROR,
>> +   "Resampling to/from ambisonic channel layouts is not 
>> supported.\n");
>> +return AVERROR(ENOSYS);
>> +}
>> +
>>  /* set channel mixing parameters */
>>  #if FF_API_OLD_CHANNEL_LAYOUT
>>  if (avr->in_channel_layout) {
>
> Did it error out in all cases before this patch? It shouldn't use a
> blacklist for unknown channel orders, but a whitelist for supported
> ones.

In the past it used to support up any layout up to 62 channels, but it
never errored out.
I will change it to use a whitelist for only NATIVE and UNSPEC orders,
in the first lavr patch, and modify this one to only allow
passthrough.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 18/25] lavr: Only let pass-through ambisonic channel layouts

2017-06-29 Thread Vittorio Giovara
On Thu, Jun 29, 2017 at 3:22 AM, Diego Biurrun <di...@biurrun.de> wrote:
> On Wed, Jun 28, 2017 at 06:11:02PM -0400, Vittorio Giovara wrote:
>> Resampling or conversion to/from ambisonic audio are currently
>> unsupported features.
>
> Maybe you mean something like
>
>   lavr: Only allow pass-through of ambisonic channel layouts
>
> ? Your current commit title does not parse...

Yeah that is good. I tried to convey the fact that as long as you
don't change channel order, you're fine with using an ambisonic
channel layout for input and output.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 12/25] lavc: switch to the new channel layout API

2017-06-29 Thread Vittorio Giovara
On Thu, Jun 29, 2017 at 5:18 AM, wm4 <nfx...@googlemail.com> wrote:
> On Wed, 28 Jun 2017 18:10:56 -0400
> Vittorio Giovara <vittorio.giov...@gmail.com> wrote:
>
>> Since the request_channel_layout is used only by a handful of codecs,
>> move the option to codec private contexts.
>
> Not sure if that is justified...

I believe it is always good to move options out of the global state,
and this seems to be a perfect opportunity: beside adding the new API,
we are modifying the concept that a channel layout is not represented
(simply) by a bitmask, but by a series of features, such as map,
channel order, and count. The request_channel_layout is the last
holdout of that concept, so I think it makes sense to change and allow
for future expansion, for example an in-codec downmix from ambisonic
to normal stereo.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 08/25] libavfilter changes for the new channel layout API

2017-06-29 Thread Vittorio Giovara
On Thu, Jun 29, 2017 at 3:59 AM, Diego Biurrun <di...@biurrun.de> wrote:
> On Wed, Jun 28, 2017 at 06:10:52PM -0400, Vittorio Giovara wrote:
>> --- a/libavfilter/af_aformat.c
>> +++ b/libavfilter/af_aformat.c
>> @@ -94,6 +94,13 @@ static int get_sample_rate(const char *samplerate)
>> +static int get_channel_layout(const char *channel_layout)
>> +{
>> +AVChannelLayout ch_layout = {0};
>> --- a/libavfilter/af_channelmap.c
>> +++ b/libavfilter/af_channelmap.c
>> @@ -219,50 +223,59 @@ static av_cold int channelmap_init(AVFilterContext 
>> *ctx)
>>  if (s->channel_layout_str) {
>> -uint64_t fmt;
>> -if ((fmt = av_get_channel_layout(s->channel_layout_str)) == 0) {
>> +int ret;
>> +AVChannelLayout fmt = {0};
>
>> --- a/libavfilter/af_join.c
>> +++ b/libavfilter/af_join.c
>> @@ -285,12 +273,14 @@ static void guess_map_any(AVFilterContext *ctx, 
>> ChannelMap *ch,
>> -if ((inputs[i] & link->channel_layout) != link->channel_layout) {
>> -uint64_t unused = link->channel_layout & ~inputs[i];
>> +if ((inputs[i] & link->ch_layout.u.mask) != link->ch_layout.u.mask) 
>> {
>> +uint64_t unused = link->ch_layout.u.mask & ~inputs[i];
>> +AVChannelLayout layout = {0};
>
> spaces inside {}
>

applied locally

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

Re: [libav-devel] [PATCH 20/25] lavf: Add non diegetic stream disposition flag

2017-06-29 Thread Vittorio Giovara
On Thu, Jun 29, 2017 at 4:02 AM, Diego Biurrun <di...@biurrun.de> wrote:
> On Wed, Jun 28, 2017 at 06:11:04PM -0400, Vittorio Giovara wrote:
>> Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
>> ---
>>  libavformat/avformat.h | 6 ++
>>  libavformat/dump.c | 2 ++
>>  2 files changed, 8 insertions(+)
>
> non-diegetic
>
>> --- a/libavformat/dump.c
>> +++ b/libavformat/dump.c
>> @@ -482,6 +482,8 @@ static void dump_stream_format(AVFormatContext *ic, int 
>> i,
>>  if (st->disposition & AV_DISPOSITION_CLEAN_EFFECTS)
>>  av_log(NULL, AV_LOG_INFO, " (clean effects)");
>> +if (st->disposition & AV_DISPOSITION_NON_DIEGETIC)
>> +av_log(NULL, AV_LOG_INFO, " (non diegetic)");
>
> same

applied locally

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

[libav-devel] [PATCH 24/25] fate: Add ambisonic tests

2017-06-28 Thread Vittorio Giovara
Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 tests/fate/mov.mak| 3 +++
 tests/fate/opus.mak   | 5 +
 tests/ref/fate/mov-ambisonic  | 1 +
 tests/ref/fate/opus-ambisonic | 1 +
 4 files changed, 10 insertions(+)
 create mode 100644 tests/ref/fate/mov-ambisonic
 create mode 100644 tests/ref/fate/opus-ambisonic

diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
index 9d64fd3a4a..00b447505b 100644
--- a/tests/fate/mov.mak
+++ b/tests/fate/mov.mak
@@ -1,3 +1,6 @@
+FATE_MOV += fate-mov-ambisonic
+fate-mov-ambisonic: CMD = probestream layout 
$(TARGET_SAMPLES)/mov/ambisonic.mp4
+
 FATE_MOV += fate-mov-dar
 fate-mov-dar: CMD = probestream display_aspect_ratio 
$(TARGET_SAMPLES)/mov/displaymatrix.mov
 
diff --git a/tests/fate/opus.mak b/tests/fate/opus.mak
index 161a94f472..2c80de8308 100644
--- a/tests/fate/opus.mak
+++ b/tests/fate/opus.mak
@@ -32,6 +32,11 @@ $(FATE_OPUS): FUZZ = 3
 $(FATE_OPUS_CELT): CMP = oneoff
 $(FATE_OPUS_CELT): FUZZ = 6
 
+# ambisonic does not change coding, only introduces a new map type
+# so a simple probe test should be enough
+FATE_OPUS += fate-opus-ambisonic
+fate-opus-ambisonic: CMD = probestream layout 
$(TARGET_SAMPLES)/opus/11ch-different-talkers.mka
+
 FATE_SAMPLES_AVCONV-$(call DEMDEC, MATROSKA, OPUS) += $(FATE_OPUS)
 fate-opus-celt: $(FATE_OPUS_CELT)
 fate-opus-hybrid: $(FATE_OPUS_HYBRID)
diff --git a/tests/ref/fate/mov-ambisonic b/tests/ref/fate/mov-ambisonic
new file mode 100644
index 00..3ee612c13a
--- /dev/null
+++ b/tests/ref/fate/mov-ambisonic
@@ -0,0 +1 @@
+ambisonic channels 4 order 1
diff --git a/tests/ref/fate/opus-ambisonic b/tests/ref/fate/opus-ambisonic
new file mode 100644
index 00..14f69e13e1
--- /dev/null
+++ b/tests/ref/fate/opus-ambisonic
@@ -0,0 +1 @@
+ambisonic channels 9 order 2|stereo
-- 
2.13.1

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

[libav-devel] [PATCH 21/25] mov: Implement spatial audio support

2017-06-28 Thread Vittorio Giovara
As defined by Google's Spatial Audio RFC.

Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 libavformat/mov.c | 98 +++
 1 file changed, 98 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index c90b5fa108..48fd865411 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3459,6 +3459,102 @@ static int mov_read_uuid(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 return 0;
 }
 
+static int mov_read_SA3D(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+{
+AVStream *st;
+MOVStreamContext *sc;
+int i, version, type;
+int ambisonic_order, channel_order, normalization, channel_count;
+
+if (c->fc->nb_streams < 1)
+return 0;
+
+st = c->fc->streams[c->fc->nb_streams - 1];
+sc = st->priv_data;
+
+if (atom.size < 16) {
+av_log(c->fc, AV_LOG_ERROR, "SA3D audio box too small\n");
+return AVERROR_INVALIDDATA;
+}
+
+version = avio_r8(pb);
+if (version) {
+av_log(c->fc, AV_LOG_WARNING, "Unsupported SA3D box version %d\n", 
version);
+return 0;
+}
+
+type = avio_r8(pb);
+if (type) {
+av_log(c->fc, AV_LOG_WARNING,
+   "Unsupported ambisonic type %d\n", type);
+return 0;
+}
+
+ambisonic_order = avio_rb32(pb);
+
+channel_order = avio_r8(pb);
+if (channel_order) {
+av_log(c->fc, AV_LOG_WARNING,
+   "Unsupported channel_order %d\n", channel_order);
+return 0;
+}
+
+normalization = avio_r8(pb);
+if (normalization) {
+av_log(c->fc, AV_LOG_WARNING,
+   "Unsupported normalization %d\n", normalization);
+return 0;
+}
+
+channel_count = avio_rb32(pb);
+if (ambisonic_order != sqrt(channel_count) - 1) {
+av_log(c->fc, AV_LOG_ERROR,
+   "Invalid number of channels (%d / %d)\n",
+   channel_count, ambisonic_order);
+return 0;
+}
+
+for (i = 0; i < channel_count; i++) {
+if (i != avio_rb32(pb)) {
+av_log(c->fc, AV_LOG_WARNING,
+   "Ambisonic channel reordering is not supported\n");
+return 0;
+}
+}
+
+av_channel_layout_uninit(>codecpar->ch_layout);
+st->codecpar->ch_layout.order = AV_CHANNEL_ORDER_AMBISONIC;
+st->codecpar->ch_layout.nb_channels = channel_count;
+
+return 0;
+}
+
+static int mov_read_SAND(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+{
+AVStream *st;
+int version;
+
+if (c->fc->nb_streams < 1)
+return 0;
+
+st = c->fc->streams[c->fc->nb_streams - 1];
+
+if (atom.size < 5) {
+av_log(c->fc, AV_LOG_ERROR, "Empty SAND audio box\n");
+return AVERROR_INVALIDDATA;
+}
+
+version = avio_r8(pb);
+if (version) {
+av_log(c->fc, AV_LOG_WARNING, "Unsupported SAND box version %d\n", 
version);
+return 0;
+}
+
+st->disposition |= AV_DISPOSITION_NON_DIEGETIC;
+
+return 0;
+}
+
 static const MOVParseTableEntry mov_default_parse_table[] = {
 { MKTAG('a','v','s','s'), mov_read_extradata },
 { MKTAG('c','h','p','l'), mov_read_chpl },
@@ -3523,6 +3619,8 @@ static const MOVParseTableEntry mov_default_parse_table[] 
= {
 { MKTAG('s','t','3','d'), mov_read_st3d }, /* stereoscopic 3D video box */
 { MKTAG('s','v','3','d'), mov_read_sv3d }, /* spherical video box */
 { MKTAG('u','u','i','d'), mov_read_uuid }, /* universal unique identifier */
+{ MKTAG('S','A','3','D'), mov_read_SA3D }, /* ambisonic audio box */
+{ MKTAG('S','A','N','D'), mov_read_SAND }, /* non diegetic audio box */
 { MKTAG('-','-','-','-'), mov_read_custom },
 { 0, NULL }
 };
-- 
2.13.1

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

[libav-devel] [PATCH 05/25] avtools: Use the new channel layout API in AVFrame

2017-06-28 Thread Vittorio Giovara
---
 avtools/avconv.c| 2 +-
 avtools/avconv_filter.c | 2 +-
 avtools/avplay.c| 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/avtools/avconv.c b/avtools/avconv.c
index 8dd11bb5fc..42cbfef592 100644
--- a/avtools/avconv.c
+++ b/avtools/avconv.c
@@ -1209,7 +1209,7 @@ static int ifilter_send_frame(InputFilter *ifilter, 
AVFrame *frame)
 switch (ifilter->ist->st->codecpar->codec_type) {
 case AVMEDIA_TYPE_AUDIO:
 need_reinit |= ifilter->sample_rate!= frame->sample_rate ||
-   ifilter->channel_layout != frame->channel_layout;
+   ifilter->channel_layout != frame->ch_layout.u.mask;
 break;
 case AVMEDIA_TYPE_VIDEO:
 need_reinit |= ifilter->width  != frame->width ||
diff --git a/avtools/avconv_filter.c b/avtools/avconv_filter.c
index 884478da27..e719c06658 100644
--- a/avtools/avconv_filter.c
+++ b/avtools/avconv_filter.c
@@ -798,7 +798,7 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, 
const AVFrame *frame)
 ifilter->sample_aspect_ratio = frame->sample_aspect_ratio;
 
 ifilter->sample_rate = frame->sample_rate;
-ifilter->channel_layout  = frame->channel_layout;
+ifilter->channel_layout  = frame->ch_layout.u.mask;
 
 if (frame->hw_frames_ctx) {
 ifilter->hw_frames_ctx = av_buffer_ref(frame->hw_frames_ctx);
diff --git a/avtools/avplay.c b/avtools/avplay.c
index b6dbc52cf7..6cc63258fc 100644
--- a/avtools/avplay.c
+++ b/avtools/avplay.c
@@ -1837,11 +1837,11 @@ static int audio_decode_frame(PlayerState *is, double 
*pts_ptr)
is->frame->format, 1);
 
 audio_resample = is->frame->format != is->sdl_sample_fmt   
  ||
- is->frame->channel_layout != 
is->sdl_channel_layout ||
+ is->frame->ch_layout.u.mask != 
is->sdl_channel_layout ||
  is->frame->sample_rate!= is->sdl_sample_rate;
 
 resample_changed = is->frame->format != 
is->resample_sample_fmt ||
-   is->frame->channel_layout != 
is->resample_channel_layout ||
+   is->frame->ch_layout.u.mask != 
is->resample_channel_layout ||
is->frame->sample_rate!= 
is->resample_sample_rate;
 
 if ((!is->avr && audio_resample) || resample_changed) {
-- 
2.13.1

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

[libav-devel] [PATCH 23/25] avprobe: Print the channel layout string

2017-06-28 Thread Vittorio Giovara
---
 avtools/avprobe.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/avtools/avprobe.c b/avtools/avprobe.c
index 7eab2573eb..9d7eecabb9 100644
--- a/avtools/avprobe.c
+++ b/avtools/avprobe.c
@@ -667,6 +667,7 @@ static void show_stream(InputFile *ifile, InputStream *ist)
 AVRational display_aspect_ratio, *sar = NULL;
 const AVPixFmtDescriptor *desc;
 const char *val;
+char *chlstr;
 
 probe_object_header("stream");
 
@@ -757,6 +758,9 @@ static void show_stream(InputFile *ifile, InputStream *ist)
par->sample_rate,
unit_hertz_str));
 probe_int("channels", par->ch_layout.nb_channels);
+chlstr = av_channel_layout_describe(>ch_layout);
+probe_str("layout", chlstr);
+av_free(chlstr);
 probe_int("bits_per_sample",
   av_get_bits_per_sample(par->codec_id));
 break;
-- 
2.13.1

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

[libav-devel] [PATCH 22/25] aac: Allow pass-through transcoding of ambisonic audio

2017-06-28 Thread Vittorio Giovara
The defacto mov standard mandates support for PCM and AAC: only the
latter decoder overrides the channel layout passed by the container,
so let this happen only when the layout order is native (or unspecified).

On the encoding side, until full ambisonic channel layout conversion
is implemented, add a temporary layout to allow pass-through transcoding
of files tagged with this specification.

Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 libavcodec/aacdec.c| 13 -
 libavcodec/libfdk-aacdec.c |  6 --
 libavcodec/libfdk-aacenc.c |  3 ++-
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index ab184b8634..33b6e3a40a 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -494,11 +494,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
 }
 }
 
-av_channel_layout_uninit(>oc[1].ch_layout);
-av_channel_layout_from_mask(>oc[1].ch_layout, layout);
-ret = av_channel_layout_copy(>ch_layout, >oc[1].ch_layout);
-if (ret < 0)
-return ret;
+if (avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ||
+avctx->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) {
+av_channel_layout_uninit(>oc[1].ch_layout);
+av_channel_layout_from_mask(>oc[1].ch_layout, layout);
+ret = av_channel_layout_copy(>ch_layout, >oc[1].ch_layout);
+if (ret < 0)
+return ret;
+}
 #if FF_API_OLD_CHANNEL_LAYOUT
 FF_DISABLE_DEPRECATION_WARNINGS
 avctx->channels   = avctx->ch_layout.nb_channels;
diff --git a/libavcodec/libfdk-aacdec.c b/libavcodec/libfdk-aacdec.c
index 6a77e90392..a8eeb6a1c9 100644
--- a/libavcodec/libfdk-aacdec.c
+++ b/libavcodec/libfdk-aacdec.c
@@ -184,8 +184,10 @@ static int get_stream_info(AVCodecContext *avctx)
 }
 }
 
-av_channel_layout_uninit(>ch_layout);
-av_channel_layout_from_mask(>ch_layout, ch_layout);
+if (avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE) {
+av_channel_layout_uninit(>ch_layout);
+av_channel_layout_from_mask(>ch_layout, ch_layout);
+}
 if (!ch_error && avctx->ch_layout.nb_channels != info->numChannels) {
 av_log(avctx, AV_LOG_WARNING, "unsupported channel configuration\n");
 ch_error = 1;
diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c
index f92c14d65f..ec29e1c6ad 100644
--- a/libavcodec/libfdk-aacenc.c
+++ b/libavcodec/libfdk-aacenc.c
@@ -410,7 +410,7 @@ static const uint64_t aac_channel_layout[] = {
 };
 #endif /* FF_API_OLD_CHANNEL_LAYOUT */
 
-static const AVChannelLayout aac_ch_layouts[16] = {
+static const AVChannelLayout aac_ch_layouts[17] = {
 AV_CHANNEL_LAYOUT_MONO,
 AV_CHANNEL_LAYOUT_STEREO,
 AV_CHANNEL_LAYOUT_SURROUND,
@@ -421,6 +421,7 @@ static const AVChannelLayout aac_ch_layouts[16] = {
 AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK,
 AV_CHANNEL_LAYOUT_7POINT1,
 #endif
+AV_CHANNEL_LAYOUT_AMBISONIC_FIRST_ORDER,
 { 0 },
 };
 
-- 
2.13.1

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

[libav-devel] [PATCH 20/25] lavf: Add non diegetic stream disposition flag

2017-06-28 Thread Vittorio Giovara
Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 libavformat/avformat.h | 6 ++
 libavformat/dump.c | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 1bf66b15d1..47f7a445dd 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -673,6 +673,12 @@ typedef struct AVIndexEntry {
  * It can also be accessed at any time in AVStream.attached_pic.
  */
 #define AV_DISPOSITION_ATTACHED_PIC  0x0400
+/**
+ * The stream is intended to be mixed with a spatial audio track. For example,
+ * it could be used for narration or stereo music, and may remain unchanged by
+ * listener head rotation.
+ */
+#define AV_DISPOSITION_NON_DIEGETIC 0x1000
 
 typedef struct AVStreamInternal AVStreamInternal;
 
diff --git a/libavformat/dump.c b/libavformat/dump.c
index e1f6848547..b29f0ad834 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -482,6 +482,8 @@ static void dump_stream_format(AVFormatContext *ic, int i,
 av_log(NULL, AV_LOG_INFO, " (visual impaired)");
 if (st->disposition & AV_DISPOSITION_CLEAN_EFFECTS)
 av_log(NULL, AV_LOG_INFO, " (clean effects)");
+if (st->disposition & AV_DISPOSITION_NON_DIEGETIC)
+av_log(NULL, AV_LOG_INFO, " (non diegetic)");
 av_log(NULL, AV_LOG_INFO, "\n");
 
 dump_metadata(NULL, st->metadata, "");
-- 
2.13.1

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

[libav-devel] [PATCH 25/25] Bump library versions, update Changelog and APIchanges

2017-06-28 Thread Vittorio Giovara
Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 Changelog  |  1 +
 doc/APIchanges | 22 ++
 2 files changed, 23 insertions(+)

diff --git a/Changelog b/Changelog
index e44df54c93..ecff7d0a2b 100644
--- a/Changelog
+++ b/Changelog
@@ -16,6 +16,7 @@ version :
 - FM Screen Capture Codec decoder
 - ClearVideo decoder (I-frames only)
 - support for decoding through D3D11VA in avconv
+- Opus and MP4/MOV ambisonic detection
 
 
 version 12:
diff --git a/doc/APIchanges b/doc/APIchanges
index 0f7c839573..50cf0eba12 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,28 @@ libavutil: 2017-03-23
 
 API changes, most recent first:
 
+20xx-xx-xx - lavu 56.xx.0 lavr 4.xx.0 lavfi 7.xx.0 lavc 58.xx.0 lavf 58.xx.0
+  xxx - Introduce AVChannelLayout and related API: use AVChannel and
+AVChannelOrder to describe a layout, deprecate old functions
+operating on channels and channel_layout fields.
+  xxx - Allow a new AVOption type AV_OPT_TYPE_CHANNEL_LAYOUT, with
+av_opt_set_channel_layout(), and av_opt_get_channel_layout().
+  xxx - Add AVFrame.ch_layout, deprecate channel_layout field.
+  xxx - Add avresample_build_matrix2(), in_ch_layout and out_ch_layout
+options to libavresample, deprecate avresample_build_matrix(), and
+in_channel_layout, out_channel_layout options.
+  xxx - Add AVFilterLink.ch_layout, deprecates channel_layout field.
+  xxx - Add AVBufferSrcParameters.ch_layout, deprecate channel_layout 
field.
+  xxx - Add AVCodecParameters.ch_layout, deprecate channel_layout and
+channels fields.
+  xxx - Add AVCodecContext.ch_layout, deprecate channel_layout and channels
+fields (and options), and replace request_channel_layout with a
+codec private option.
+  xxx - Support Ambisonic ordering in AVChannelLayout with
+AV_CHANNEL_ORDER_AMBISONIC and av_channel_layout_ambisonic() 
helper.
+  xxx - Add AV_DISPOSITION_NON_DIEGETIC flag for detecting streams that
+can be mixed with spatial audio.
+
 2017-xx-xx - xxx - lavc 58.4.0 - avcodec.h
   DXVA2 and D3D11 hardware accelerated decoding now supports the new hwaccel 
API,
   which can create the decoder context and allocate hardware frame 
automatically.
-- 
2.13.1

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

[libav-devel] [PATCH 12/25] lavc: switch to the new channel layout API

2017-06-28 Thread Vittorio Giovara
Since the request_channel_layout is used only by a handful of codecs,
move the option to codec private contexts.
---
 libavcodec/avcodec.h   |  31 +
 libavcodec/decode.c|  49 +-
 libavcodec/encode.c|   9 ++-
 libavcodec/internal.h  |   2 +
 libavcodec/options_table.h |   5 ++
 libavcodec/utils.c | 162 +
 libavformat/utils.c|  26 +++-
 7 files changed, 220 insertions(+), 64 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index bc7097c7bd..b0eac85f72 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1834,7 +1834,13 @@ typedef struct AVCodecContext {
 
 /* audio only */
 int sample_rate; ///< samples per second
+#if FF_API_OLD_CHANNEL_LAYOUT
+/**
+ * @deprecated use ch_layout.nb_channels
+ */
+attribute_deprecated
 int channels;///< number of audio channels
+#endif
 
 /**
  * audio sample format
@@ -1879,19 +1885,25 @@ typedef struct AVCodecContext {
  */
 int cutoff;
 
+#if FF_API_OLD_CHANNEL_LAYOUT
 /**
  * Audio channel layout.
  * - encoding: set by user.
  * - decoding: set by libavcodec.
+ *   @deprecated use ch_layout
  */
+attribute_deprecated
 uint64_t channel_layout;
 
 /**
  * Request decoder to use this channel layout if it can (0 for default)
  * - encoding: unused
  * - decoding: Set by user.
+ *   @deprecated use "downmix" codec private option
  */
+attribute_deprecated
 uint64_t request_channel_layout;
+#endif
 
 /**
  * Type of service that the audio stream conveys.
@@ -2730,6 +2742,14 @@ typedef struct AVCodecContext {
  * AVCodecContext.get_format callback)
  */
 int hwaccel_flags;
+
+/**
+ * Audio channel layout.
+ * - encoding: must be set by the caller, to one of AVCodec.ch_layouts.
+ * - decoding: may be set by the caller if known e.g. from the container.
+ * The decoder can then override during decoding as needed.
+ */
+AVChannelLayout ch_layout;
 } AVCodecContext;
 
 /**
@@ -2771,10 +2791,21 @@ typedef struct AVCodec {
 const enum AVPixelFormat *pix_fmts; ///< array of supported pixel 
formats, or NULL if unknown, array is terminated by -1
 const int *supported_samplerates;   ///< array of supported audio 
samplerates, or NULL if unknown, array is terminated by 0
 const enum AVSampleFormat *sample_fmts; ///< array of supported sample 
formats, or NULL if unknown, array is terminated by -1
+#if FF_API_OLD_CHANNEL_LAYOUT
+/**
+ * @deprecated use ch_layouts instead
+ */
+attribute_deprecated
 const uint64_t *channel_layouts; ///< array of support channel 
layouts, or NULL if unknown. array is terminated by 0
+#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}
 
+/**
+ * Array of supported channel layouts, terminated with a zeroed layout.
+ */
+const AVChannelLayout *ch_layouts;
+
 /*
  * No fields below this line are part of the public API. They
  * may not be used outside of libavcodec and can be changed and
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index b0d6b9fb33..c4bcfb95df 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1131,27 +1131,42 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame 
*frame, int flags)
 frame->sample_rate= avctx->sample_rate;
 if (frame->format < 0)
 frame->format = avctx->sample_fmt;
+#if FF_API_OLD_CHANNEL_LAYOUT
+FF_DISABLE_DEPRECATION_WARNINGS
+if (avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ||
+avctx->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) {
+if (!frame->ch_layout.nb_channels && (avctx->channel_layout || 
avctx->channels)) {
+if (avctx->channel_layout)
+av_channel_layout_from_mask(>ch_layout, 
avctx->channel_layout);
+else
+av_channel_layout_default(>ch_layout, 
avctx->channels);
+}
+}
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 if (!frame->ch_layout.nb_channels) {
-if (avctx->channel_layout)
-av_channel_layout_from_mask(>ch_layout, 
avctx->channel_layout);
-else
-av_channel_layout_default(>ch_layout, avctx->channels);
+ret = av_channel_layout_copy(>ch_layout, >ch_layout);
+if (ret < 0)
+return ret;
 }
 #if FF_API_OLD_CHANNEL_LAYOUT
 FF_DISABLE_DEPRECATION_WARNINGS
-/* set the deprecated channel_layout field for callers
- * that didn't update to the new API yet */
-if 

[libav-devel] [PATCH 16/25] tools, examples changes for the new channel layout API

2017-06-28 Thread Vittorio Giovara
This patch contains the following commits:

avplay: Support the new channel layout API

avconv: Support the new channel layout API

tools: Update to the new channel layout API

examples: Update to the new channel layout API
---
 avtools/avconv.c | 30 +++---
 avtools/avconv.h |  8 +++
 avtools/avconv_filter.c  | 44 ++
 avtools/avconv_opt.c | 48 --
 avtools/avplay.c | 50 +++-
 avtools/cmdutils.c   | 15 +++--
 avtools/cmdutils.h   |  8 ---
 doc/examples/decode_audio.c  |  2 +-
 doc/examples/encode_audio.c  | 36 ++-
 doc/examples/filter_audio.c  | 11 +-
 doc/examples/output.c| 30 ++
 doc/examples/transcode_aac.c | 29 +++--
 tools/graph2dot.c|  7 +++
 tools/ismindex.c |  2 +-
 tools/sidxindex.c|  2 +-
 15 files changed, 185 insertions(+), 137 deletions(-)

diff --git a/avtools/avconv.c b/avtools/avconv.c
index a1427e0cb4..904ea82de8 100644
--- a/avtools/avconv.c
+++ b/avtools/avconv.c
@@ -163,7 +163,7 @@ static void avconv_cleanup(int ret)
 for (j = 0; j < fg->nb_outputs; j++) {
 av_freep(>outputs[j]->name);
 av_freep(>outputs[j]->formats);
-av_freep(>outputs[j]->channel_layouts);
+av_freep(>outputs[j]->ch_layouts);
 av_freep(>outputs[j]->sample_rates);
 av_freep(>outputs[j]);
 }
@@ -1209,7 +1209,8 @@ static int ifilter_send_frame(InputFilter *ifilter, 
AVFrame *frame)
 switch (ifilter->ist->st->codecpar->codec_type) {
 case AVMEDIA_TYPE_AUDIO:
 need_reinit |= ifilter->sample_rate!= frame->sample_rate ||
-   ifilter->channel_layout != frame->ch_layout.u.mask;
+   av_channel_layout_compare(>ch_layout,
+ >ch_layout);
 break;
 case AVMEDIA_TYPE_VIDEO:
 need_reinit |= ifilter->width  != frame->width ||
@@ -1322,24 +1323,6 @@ static int decode(AVCodecContext *avctx, AVFrame *frame, 
int *got_frame, AVPacke
 return 0;
 }
 
-int guess_input_channel_layout(InputStream *ist)
-{
-AVCodecContext *dec = ist->dec_ctx;
-
-if (!dec->channel_layout) {
-char layout_name[256];
-
-dec->channel_layout = av_get_default_channel_layout(dec->channels);
-if (!dec->channel_layout)
-return 0;
-av_get_channel_layout_string(layout_name, sizeof(layout_name),
- dec->channels, dec->channel_layout);
-av_log(NULL, AV_LOG_WARNING, "Guessed Channel Layout for Input Stream "
-   "#%d.%d : %s\n", ist->file_index, ist->st->index, layout_name);
-}
-return 1;
-}
-
 static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output,
 int *decode_failed)
 {
@@ -1982,6 +1965,7 @@ static int init_output_stream_encode(OutputStream *ost)
 InputStream *ist = get_input_stream(ost);
 AVCodecContext *enc_ctx = ost->enc_ctx;
 AVCodecContext *dec_ctx = NULL;
+int ret;
 
 set_encoder_id(output_files[ost->file_index], ost);
 
@@ -1998,8 +1982,10 @@ static int init_output_stream_encode(OutputStream *ost)
 case AVMEDIA_TYPE_AUDIO:
 enc_ctx->sample_fmt = ost->filter->filter->inputs[0]->format;
 enc_ctx->sample_rate= ost->filter->filter->inputs[0]->sample_rate;
-enc_ctx->channel_layout = 
ost->filter->filter->inputs[0]->ch_layout.u.mask;
-enc_ctx->channels   = 
av_get_channel_layout_nb_channels(enc_ctx->channel_layout);
+ret = av_channel_layout_copy(_ctx->ch_layout,
+ 
>filter->filter->inputs[0]->ch_layout);
+if (ret < 0)
+return ret;
 enc_ctx->time_base  = (AVRational){ 1, enc_ctx->sample_rate };
 break;
 case AVMEDIA_TYPE_VIDEO:
diff --git a/avtools/avconv.h b/avtools/avconv.h
index 4c699333a5..2d3a77ba65 100644
--- a/avtools/avconv.h
+++ b/avtools/avconv.h
@@ -220,7 +220,7 @@ typedef struct InputFilter {
 AVRational sample_aspect_ratio;
 
 int sample_rate;
-uint64_t channel_layout;
+AVChannelLayout ch_layout;
 
 AVBufferRef *hw_frames_ctx;
 
@@ -242,11 +242,11 @@ typedef struct OutputFilter {
 AVRational frame_rate;
 int format;
 int sample_rate;
-uint64_t channel_layout;
+AVChannelLayout ch_layout;
 
 // those are only set if no format is specified and the encoder gives us 
multiple options
 int *formats;
-uint64_t *channel_layouts;
+AVChannelLayout *ch_layouts;
 int *sample_rates;
 } OutputFilter;
 
@@ -499,8 +499,6 @@ void opt_output_file(void *optctx, const char *filename);
 
 void assert_avoptions(AVDictionary *m);
 
-int 

[libav-devel] [PATCH 09/25] lavfi: Port filter negotiation to use the new channel layout API

2017-06-28 Thread Vittorio Giovara
Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 libavfilter/af_aformat.c  |  30 +---
 libavfilter/af_channelmap.c   |   2 +-
 libavfilter/af_channelsplit.c |   6 ++-
 libavfilter/af_join.c |   2 +-
 libavfilter/avfiltergraph.c   | 109 +++---
 libavfilter/buffersrc.c   |   2 +-
 libavfilter/formats.c |  45 +++--
 libavfilter/formats.h |   4 +-
 8 files changed, 153 insertions(+), 47 deletions(-)

diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c
index c5aa4f7148..259ece4c0b 100644
--- a/libavfilter/af_aformat.c
+++ b/libavfilter/af_aformat.c
@@ -94,11 +94,29 @@ static int get_sample_rate(const char *samplerate)
 return FFMAX(ret, 0);
 }
 
-static int get_channel_layout(const char *channel_layout)
+static int parse_channel_layout_string(AVFilterContext *ctx)
 {
-AVChannelLayout ch_layout = {0};
-av_channel_layout_from_string(_layout, channel_layout);
-return ch_layout.u.mask;
+AFormatContext *s = ctx->priv;
+char *next, *cur = s->channel_layouts_str, sep = '|';
+int ret;
+
+while (cur) {
+AVChannelLayout fmt = {0};
+next = strchr(cur, sep);
+if (next)
+*next++ = 0;
+
+ret = av_channel_layout_from_string(, cur);
+if (ret < 0) {
+av_log(ctx, AV_LOG_ERROR, "Error parsing channel layout: %s.\n", 
cur);\
+return ret;
+}
+ff_add_channel_layout(>channel_layouts, );
+
+cur = next;
+}
+
+return 0;
 }
 
 static av_cold int init(AVFilterContext *ctx)
@@ -109,10 +127,8 @@ static av_cold int init(AVFilterContext *ctx)
   ff_add_format, av_get_sample_fmt, AV_SAMPLE_FMT_NONE, 
"sample format");
 PARSE_FORMATS(s->sample_rates_str, int, s->sample_rates, ff_add_format,
   get_sample_rate, 0, "sample rate");
-PARSE_FORMATS(s->channel_layouts_str, uint64_t, s->channel_layouts,
-  ff_add_channel_layout, get_channel_layout, 0, "channel 
layout");
 
-return 0;
+return parse_channel_layout_string(ctx);
 }
 
 static int query_formats(AVFilterContext *ctx)
diff --git a/libavfilter/af_channelmap.c b/libavfilter/af_channelmap.c
index 939f056d6f..54ff146c5b 100644
--- a/libavfilter/af_channelmap.c
+++ b/libavfilter/af_channelmap.c
@@ -296,7 +296,7 @@ static int channelmap_query_formats(AVFilterContext *ctx)
 ChannelMapContext *s = ctx->priv;
 AVFilterChannelLayouts *channel_layouts = NULL;
 
-ff_add_channel_layout(_layouts, s->ch_layout.u.mask);
+ff_add_channel_layout(_layouts, >ch_layout);
 
 ff_set_common_formats(ctx, ff_planar_sample_fmts());
 ff_set_common_samplerates(ctx, ff_all_samplerates());
diff --git a/libavfilter/af_channelsplit.c b/libavfilter/af_channelsplit.c
index 41b3051c8c..b13919cdf0 100644
--- a/libavfilter/af_channelsplit.c
+++ b/libavfilter/af_channelsplit.c
@@ -85,16 +85,18 @@ static int query_formats(AVFilterContext *ctx)
 ff_set_common_formats(ctx, ff_planar_sample_fmts());
 ff_set_common_samplerates(ctx, ff_all_samplerates());
 
-ff_add_channel_layout(_layouts, s->ch_layout.u.mask);
+ff_add_channel_layout(_layouts, >ch_layout);
 ff_channel_layouts_ref(in_layouts, >inputs[0]->out_channel_layouts);
 
 for (i = 0; i < ctx->nb_outputs; i++) {
 AVFilterChannelLayouts *out_layouts = NULL;
+AVChannelLayout tmp = {0};
 int ret = av_channel_layout_get_channel(>ch_layout, i);
 if (ret < 0)
 return ret;
 
-ff_add_channel_layout(_layouts, 1ULL << ret);
+av_channel_layout_from_mask(, 1ULL << ret);
+ff_add_channel_layout(_layouts, );
 ff_channel_layouts_ref(out_layouts, 
>outputs[i]->in_channel_layouts);
 }
 
diff --git a/libavfilter/af_join.c b/libavfilter/af_join.c
index 6c000b9257..70dc2d00d7 100644
--- a/libavfilter/af_join.c
+++ b/libavfilter/af_join.c
@@ -234,7 +234,7 @@ static int join_query_formats(AVFilterContext *ctx)
 AVFilterChannelLayouts *layouts = NULL;
 int i;
 
-ff_add_channel_layout(, s->ch_layout.u.mask);
+ff_add_channel_layout(, >ch_layout);
 ff_channel_layouts_ref(layouts, >outputs[0]->in_channel_layouts);
 
 for (i = 0; i < ctx->nb_inputs; i++)
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index c72016d2c8..936a791175 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -374,6 +374,8 @@ static int query_formats(AVFilterGraph *graph, AVClass 
*log_ctx)
 
 static int pick_format(AVFilterLink *link)
 {
+int ret;
+
 if (!link || !link->in_formats)
 return 0;
 
@@ -399,11 +401,15 @@ static int pick_format(AVFilterLink *link)
 link->in_channel_layouts->nb_channel_layouts = 1;
 #if FF_API_OLD_CHANNEL_LAYOUT

[libav-devel] [PATCH 17/25] channel_layout: Add Ambisonic components and channel order

2017-06-28 Thread Vittorio Giovara
Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 libavutil/channel_layout.c | 86 --
 libavutil/channel_layout.h | 33 ++
 2 files changed, 116 insertions(+), 3 deletions(-)

diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c
index 285997446d..d4791a9b61 100644
--- a/libavutil/channel_layout.c
+++ b/libavutil/channel_layout.c
@@ -260,7 +260,7 @@ void av_channel_layout_from_mask(AVChannelLayout 
*channel_layout,
 int av_channel_layout_from_string(AVChannelLayout *channel_layout,
   const char *str)
 {
-int i, channels;
+int i, channels, order;
 const char *dup = str;
 uint64_t mask = 0;
 
@@ -309,6 +309,44 @@ int av_channel_layout_from_string(AVChannelLayout 
*channel_layout,
 return 0;
 }
 
+/* ambisonic */
+if (sscanf(str, "ambisonic channels %d order %d", , ) == 2) 
{
+AVChannelLayout extra = {0};
+int harmonics = 0;
+
+// handle nondiegetic channels or half-sphere harmonics
+dup = str;
+while (*dup) {
+char *chname = av_get_token(, "|");
+if (!chname)
+return AVERROR(ENOMEM);
+if (*dup)
+dup++; // skip separator
+
+// no extra channel found
+if (!strcmp(chname, str))
+break;
+
+if (av_channel_from_string(chname) == AV_CHAN_AMBISONIC)
+harmonics++;
+else {
+char *nondiegetic = strstr(str, chname);
+int ret = av_channel_layout_from_string(, nondiegetic);
+// no other channels allowed after nondiegetic
+av_free(chname);
+if (ret < 0)
+return ret;
+break;
+}
+av_free(chname);
+}
+
+channel_layout->nb_channels = channels + harmonics + extra.nb_channels;
+channel_layout->u.mask = extra.u.mask;
+
+return 0;
+}
+
 return AVERROR_INVALIDDATA;
 }
 
@@ -361,6 +399,35 @@ char *av_channel_layout_describe(const AVChannelLayout 
*channel_layout)
 }
 return ret;
 }
+case AV_CHANNEL_ORDER_AMBISONIC: {
+char buf[64];
+int order = floor(sqrt(channel_layout->nb_channels)) - 1;
+int channels = (order + 1) * (order + 1);
+
+snprintf(buf, sizeof(buf), "ambisonic channels %d order %d",
+ channels, order);
+
+// handle nondiegetic channels or half-sphere harmonics
+for (i = channels; i < channel_layout->nb_channels; i++) {
+enum AVChannel chan = 
av_channel_layout_get_channel(channel_layout, i);
+if (chan == AV_CHAN_AMBISONIC) {
+av_strlcat(buf, "|", sizeof(buf));
+av_strlcat(buf, av_channel_name(chan), sizeof(buf));
+}
+}
+if (channel_layout->u.mask) {
+AVChannelLayout extra = {0};
+char *chlstr;
+
+av_channel_layout_from_mask(, channel_layout->u.mask);
+chlstr = av_channel_layout_describe();
+av_strlcat(buf, "|", sizeof(buf));
+av_strlcat(buf, chlstr, sizeof(buf));
+av_free(chlstr);
+}
+
+return av_strdup(buf);
+}
 case AV_CHANNEL_ORDER_UNSPEC: {
 char buf[64];
 snprintf(buf, sizeof(buf), "%d channels", channel_layout->nb_channels);
@@ -381,6 +448,11 @@ int av_channel_layout_get_channel(const AVChannelLayout 
*channel_layout, int idx
 switch (channel_layout->order) {
 case AV_CHANNEL_ORDER_CUSTOM:
 return channel_layout->u.map[idx];
+case AV_CHANNEL_ORDER_AMBISONIC:
+idx -= channel_layout->nb_channels - 
av_popcount64(channel_layout->u.mask);
+if (idx < 0)
+return AV_CHAN_AMBISONIC;
+// fall-through
 case AV_CHANNEL_ORDER_NATIVE:
 for (i = 0; i < 64; i++) {
 if ((1ULL << i) & channel_layout->u.mask && !idx--)
@@ -394,7 +466,7 @@ int av_channel_layout_get_channel(const AVChannelLayout 
*channel_layout, int idx
 int av_channel_layout_channel_index(const AVChannelLayout *channel_layout,
 enum AVChannel channel)
 {
-int i;
+int i, off = 0;
 
 switch (channel_layout->order) {
 case AV_CHANNEL_ORDER_CUSTOM:
@@ -402,12 +474,17 @@ int av_channel_layout_channel_index(const AVChannelLayout 
*channel_layout,
 if (channel_layout->u.map[i] == channel)
 return i;
 return AVERROR(EINVAL);
+case AV_CHANNEL_ORDER_AMBISONIC:
+if (channel == AV_CHAN_AMBISONIC)
+return 0;
+off = channel_layout->nb_channels - 
av_popcount64(channel_layout->u.mask);
+// fall-through
 case AV_CHANN

[libav-devel] [PATCH 19/25] opus: Implement mapping type 2 for Ambisonic support

2017-06-28 Thread Vittorio Giovara
Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 libavcodec/opus.c | 36 
 1 file changed, 28 insertions(+), 8 deletions(-)

diff --git a/libavcodec/opus.c b/libavcodec/opus.c
index 308d104212..6aebb40155 100644
--- a/libavcodec/opus.c
+++ b/libavcodec/opus.c
@@ -347,7 +347,7 @@ av_cold int ff_opus_parse_extradata(AVCodecContext *avctx,
 streams= 1;
 stereo_streams = channels - 1;
 channel_map= default_channel_map;
-} else if (map_type == 1 || map_type == 255) {
+} else if (map_type == 1 || map_type == 2 || map_type == 255) {
 if (extradata_size < 21 + channels) {
 av_log(avctx, AV_LOG_ERROR, "Invalid extradata size: %d\n",
extradata_size);
@@ -363,6 +363,7 @@ av_cold int ff_opus_parse_extradata(AVCodecContext *avctx,
 return AVERROR_INVALIDDATA;
 }
 
+layout = 0;
 if (map_type == 1) {
 if (channels > 8) {
 av_log(avctx, AV_LOG_ERROR,
@@ -371,8 +372,24 @@ av_cold int ff_opus_parse_extradata(AVCodecContext *avctx,
 }
 layout = ff_vorbis_ch_layouts[channels - 1].u.mask;
 channel_reorder = channel_reorder_vorbis;
-} else
-layout = 0;
+} else if (map_type == 2) {
+int ambisonic_order = ff_sqrt(channels) - 1;
+int idx = (ambisonic_order + 1) * (ambisonic_order + 1);
+if (channels <= 227 && (channels == idx || channels == idx + 2)) {
+av_channel_layout_uninit(>ch_layout);
+avctx->ch_layout.order = AV_CHANNEL_ORDER_AMBISONIC;
+avctx->ch_layout.nb_channels = channels;
+
+/* ACN order, followed by two optional channels of 
non-diegetic stereo */
+if (idx != channels)
+avctx->ch_layout.u.mask = AV_CH_LAYOUT_STEREO;
+} else {
+av_log(avctx, AV_LOG_ERROR, "Channel map 2 is only valid for "
+   "channel counts equal to (n + 1)^2 + 2j for {n,j} >= 0 "
+   "(max 227 channels).\n");
+return AVERROR_INVALIDDATA;
+}
+}
 
 channel_map = extradata + 21;
 } else {
@@ -415,11 +432,14 @@ av_cold int ff_opus_parse_extradata(AVCodecContext *avctx,
 }
 }
 
-av_channel_layout_uninit(>ch_layout);
-if (layout)
-av_channel_layout_from_mask(>ch_layout, layout);
-else
-av_channel_layout_default(>ch_layout, channels);
+if (avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE) {
+av_channel_layout_uninit(>ch_layout);
+if (layout)
+av_channel_layout_from_mask(>ch_layout, layout);
+else
+av_channel_layout_default(>ch_layout, channels);
+}
+
 s->nb_streams = streams;
 s->nb_stereo_streams  = stereo_streams;
 
-- 
2.13.1

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

[libav-devel] [PATCH 04/25] avframe: switch to the new channel layout API

2017-06-28 Thread Vittorio Giovara
From: Anton Khirnov <an...@khirnov.net>

Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 libavcodec/decode.c | 67 
 libavcodec/encode.c |  9 ++
 libavutil/frame.c   | 88 +++--
 libavutil/frame.h   | 12 +++-
 4 files changed, 146 insertions(+), 30 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index a49cd77e51..b0d6b9fb33 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -132,7 +132,7 @@ static int unrefcount_frame(AVCodecInternal *avci, AVFrame 
*frame)
 memcpy(frame->data, avci->to_free->data, sizeof(frame->data));
 memcpy(frame->linesize, avci->to_free->linesize, sizeof(frame->linesize));
 if (avci->to_free->extended_data != avci->to_free->data) {
-int planes = 
av_get_channel_layout_nb_channels(avci->to_free->channel_layout);
+int planes = avci->to_free->ch_layout.nb_channels;
 int size   = planes * sizeof(*frame->extended_data);
 
 if (!size) {
@@ -153,9 +153,19 @@ static int unrefcount_frame(AVCodecInternal *avci, AVFrame 
*frame)
 frame->format = avci->to_free->format;
 frame->width  = avci->to_free->width;
 frame->height = avci->to_free->height;
+#if FF_API_OLD_CHANNEL_LAYOUT
+FF_DISABLE_DEPRECATION_WARNINGS
 frame->channel_layout = avci->to_free->channel_layout;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 frame->nb_samples = avci->to_free->nb_samples;
 
+ret = av_channel_layout_copy(>ch_layout, >to_free->ch_layout);
+if (ret < 0) {
+av_frame_unref(frame);
+return ret;
+}
+
 return 0;
 }
 
@@ -887,10 +897,20 @@ static int update_frame_pool(AVCodecContext *avctx, 
AVFrame *frame)
 break;
 }
 case AVMEDIA_TYPE_AUDIO: {
-int ch = av_get_channel_layout_nb_channels(frame->channel_layout);
+int ch = frame->ch_layout.nb_channels;
 int planar = av_sample_fmt_is_planar(frame->format);
 int planes = planar ? ch : 1;
 
+#if FF_API_OLD_CHANNEL_LAYOUT
+FF_DISABLE_DEPRECATION_WARNINGS
+if (!ch && frame->channel_layout) {
+av_channel_layout_from_mask(>ch_layout, 
frame->channel_layout);
+ch = frame->ch_layout.nb_channels;
+planes = planar ? ch : 1;
+}
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
 if (pool->format == frame->format && pool->planes == planes &&
 pool->channels == ch && frame->nb_samples == pool->samples)
 return 0;
@@ -,28 +1131,35 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame 
*frame, int flags)
 frame->sample_rate= avctx->sample_rate;
 if (frame->format < 0)
 frame->format = avctx->sample_fmt;
+if (!frame->ch_layout.nb_channels) {
+if (avctx->channel_layout)
+av_channel_layout_from_mask(>ch_layout, 
avctx->channel_layout);
+else
+av_channel_layout_default(>ch_layout, avctx->channels);
+}
+#if FF_API_OLD_CHANNEL_LAYOUT
+FF_DISABLE_DEPRECATION_WARNINGS
+/* set the deprecated channel_layout field for callers
+ * that didn't update to the new API yet */
+if (frame->ch_layout.nb_channels > FF_SANE_NB_CHANNELS) {
+av_log(avctx, AV_LOG_ERROR, "Too many channels.\n");
+return AVERROR(EINVAL);
+}
 if (!frame->channel_layout) {
-if (avctx->channel_layout) {
- if (av_get_channel_layout_nb_channels(avctx->channel_layout) 
!=
- avctx->channels) {
- av_log(avctx, AV_LOG_ERROR, "Inconsistent channel "
-"configuration.\n");
- return AVERROR(EINVAL);
- }
-
-frame->channel_layout = avctx->channel_layout;
-} else {
-if (avctx->channels > FF_SANE_NB_CHANNELS) {
-av_log(avctx, AV_LOG_ERROR, "Too many channels: %d.\n",
-   avctx->channels);
-return AVERROR(ENOSYS);
-}
-
-frame->channel_layout = 
av_get_default_channel_layout(avctx->channels);
+if (frame->ch_layout.order == AV_CHANNEL_ORDER_NATIVE)
+frame->channel_layout = frame->ch_layout.u.mask;
+else {
+frame->channel_layout = 
av_get_default_channel_layout(frame->ch_layout.nb_channels);
 if (!frame->channel_layout)
-frame->channel_layout = (1ULL << avctx-&g

[libav-devel] [PATCH 06/25] lavr: switch to the new channel layout API

2017-06-28 Thread Vittorio Giovara
From: Anton Khirnov <an...@khirnov.net>

Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 libavresample/audio_mix.c| 148 ++--
 libavresample/audio_mix_matrix.c | 477 ++-
 libavresample/avresample.h   |  42 +++-
 libavresample/internal.h |  10 +-
 libavresample/options.c  |   8 +
 libavresample/tests/avresample.c |  26 +--
 libavresample/utils.c| 127 +++
 7 files changed, 504 insertions(+), 334 deletions(-)

diff --git a/libavresample/audio_mix.c b/libavresample/audio_mix.c
index 89ecc6ba71..36dff2b979 100644
--- a/libavresample/audio_mix.c
+++ b/libavresample/audio_mix.c
@@ -20,6 +20,7 @@
 
 #include 
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
 #include "libavutil/libm.h"
 #include "libavutil/samplefmt.h"
@@ -34,10 +35,8 @@ struct AudioMix {
 AVAudioResampleContext *avr;
 enum AVSampleFormat fmt;
 enum AVMixCoeffType coeff_type;
-uint64_t in_layout;
-uint64_t out_layout;
-int in_channels;
-int out_channels;
+AVChannelLayout in_layout;
+AVChannelLayout out_layout;
 
 int ptr_align;
 int samples_align;
@@ -331,8 +330,8 @@ static av_cold int mix_function_init(AudioMix *am)
 if (!am->mix) {
 av_log(am->avr, AV_LOG_ERROR, "audio_mix: NO FUNCTION FOUND: [fmt=%s] "
"[c=%s] [%d to %d]\n", av_get_sample_fmt_name(am->fmt),
-   coeff_type_names[am->coeff_type], am->in_channels,
-   am->out_channels);
+   coeff_type_names[am->coeff_type], am->in_layout.nb_channels,
+   am->out_layout.nb_channels);
 return AVERROR_PATCHWELCOME;
 }
 return 0;
@@ -358,38 +357,42 @@ AudioMix *ff_audio_mix_alloc(AVAudioResampleContext *avr)
 
 am->fmt  = avr->internal_sample_fmt;
 am->coeff_type   = avr->mix_coeff_type;
-am->in_layout= avr->in_channel_layout;
-am->out_layout   = avr->out_channel_layout;
-am->in_channels  = avr->in_channels;
-am->out_channels = avr->out_channels;
+
+ret = av_channel_layout_copy(>in_layout, >in_ch_layout);
+if (ret < 0)
+goto error;
+ret = av_channel_layout_copy(>out_layout, >out_ch_layout);
+if (ret < 0)
+goto error;
 
 /* build matrix if the user did not already set one */
 if (avr->mix_matrix) {
-ret = ff_audio_mix_set_matrix(am, avr->mix_matrix, avr->in_channels);
+ret = ff_audio_mix_set_matrix(am, avr->mix_matrix, 
avr->in_ch_layout.nb_channels);
 if (ret < 0)
 goto error;
 av_freep(>mix_matrix);
 } else {
-double *matrix_dbl = av_mallocz(avr->out_channels * avr->in_channels *
+double *matrix_dbl = av_mallocz(avr->out_ch_layout.nb_channels *
+avr->in_ch_layout.nb_channels *
 sizeof(*matrix_dbl));
 if (!matrix_dbl)
 goto error;
 
-ret = avresample_build_matrix(avr->in_channel_layout,
-  avr->out_channel_layout,
-  avr->center_mix_level,
-  avr->surround_mix_level,
-  avr->lfe_mix_level,
-  avr->normalize_mix_level,
-  matrix_dbl,
-  avr->in_channels,
-  avr->matrix_encoding);
+ret = avresample_build_matrix2(>in_ch_layout,
+   >out_ch_layout,
+   avr->center_mix_level,
+   avr->surround_mix_level,
+   avr->lfe_mix_level,
+   avr->normalize_mix_level,
+   matrix_dbl,
+   avr->in_ch_layout.nb_channels,
+   avr->matrix_encoding);
 if (ret < 0) {
 av_free(matrix_dbl);
 goto error;
 }
 
-ret = ff_audio_mix_set_matrix(am, matrix_dbl, avr->in_channels);
+ret = ff_audio_mix_set_matrix(am, matrix_dbl, 
avr->in_ch_layout.nb_channels);
 if (ret < 0) {
 av_log(avr, AV_LOG_ERROR, "error setting mix matrix\n");
 av_free(matrix_dbl);
@@ -402,7 +405,7 @@ AudioMix *ff_audio_mix_alloc(AVAudioResampleContext *avr)
 return am;
 
 error:
-av_free(am);
+ff_audio_mix_free();
 return NULL;
 }
 
@@ -422,11 +425,16 @@ void ff_audio_mix_free(AudioMix **am_p)
 memset(am->matrix_q15, 0

[libav-devel] [PATCH 18/25] lavr: Only let pass-through ambisonic channel layouts

2017-06-28 Thread Vittorio Giovara
Resampling or conversion to/from ambisonic audio are currently
unsupported features.

Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 libavresample/utils.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/libavresample/utils.c b/libavresample/utils.c
index 15c827efbe..af2b9dbf2d 100644
--- a/libavresample/utils.c
+++ b/libavresample/utils.c
@@ -70,6 +70,14 @@ int avresample_open(AVAudioResampleContext *avr)
 av_channel_layout_default(>out_ch_layout, 
avr->out_ch_layout.nb_channels);
 }
 
+if (( avr->in_ch_layout.order == AV_CHANNEL_ORDER_AMBISONIC ||
+ avr->out_ch_layout.order == AV_CHANNEL_ORDER_AMBISONIC) &&
+av_channel_layout_compare(>in_ch_layout, >out_ch_layout)) {
+av_log(avr, AV_LOG_ERROR,
+   "Resampling to/from ambisonic channel layouts is not 
supported.\n");
+return AVERROR(ENOSYS);
+}
+
 /* set channel mixing parameters */
 #if FF_API_OLD_CHANNEL_LAYOUT
 if (avr->in_channel_layout) {
-- 
2.13.1

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

[libav-devel] [PATCH 13/25] aac: convert to new channel layout API

2017-06-28 Thread Vittorio Giovara
Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 libavcodec/aac.h|  7 +++--
 libavcodec/aac_ac3_parser.c |  9 --
 libavcodec/aaccoder.c   |  2 +-
 libavcodec/aacdec.c | 76 ++---
 libavcodec/aacdectab.h  | 16 ++
 libavcodec/aacenc.c |  2 +-
 libavcodec/aacpsy.c | 10 +++---
 7 files changed, 99 insertions(+), 23 deletions(-)

diff --git a/libavcodec/aac.h b/libavcodec/aac.h
index fed6bf4214..b72af09ca0 100644
--- a/libavcodec/aac.h
+++ b/libavcodec/aac.h
@@ -30,6 +30,7 @@
 #ifndef AVCODEC_AAC_H
 #define AVCODEC_AAC_H
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/float_dsp.h"
 #include "avcodec.h"
 #include "imdct15.h"
@@ -116,8 +117,7 @@ typedef struct OutputConfiguration {
 MPEG4AudioConfig m4ac;
 uint8_t layout_map[MAX_ELEM_ID*4][3];
 int layout_map_tags;
-int channels;
-uint64_t channel_layout;
+AVChannelLayout ch_layout;
 enum OCStatus status;
 } OutputConfiguration;
 
@@ -260,6 +260,7 @@ typedef struct ChannelElement {
  * main AAC context
  */
 typedef struct AACContext {
+const AVClass *class;
 AVCodecContext *avctx;
 AVFrame *frame;
 
@@ -306,6 +307,8 @@ typedef struct AACContext {
 DECLARE_ALIGNED(32, float, temp)[128];
 
 OutputConfiguration oc[2];
+
+AVChannelLayout downmix_layout;
 } AACContext;
 
 #endif /* AVCODEC_AAC_H */
diff --git a/libavcodec/aac_ac3_parser.c b/libavcodec/aac_ac3_parser.c
index a754f4a957..17e88435f8 100644
--- a/libavcodec/aac_ac3_parser.c
+++ b/libavcodec/aac_ac3_parser.c
@@ -82,8 +82,13 @@ get_next:
seconds is still correct (as is the number of bits in the frame). */
 if (avctx->codec_id != AV_CODEC_ID_AAC) {
 avctx->sample_rate = s->sample_rate;
-avctx->channels = s->channels;
-avctx->channel_layout = s->channel_layout;
+
+av_channel_layout_uninit(>ch_layout);
+if (s->channel_layout)
+av_channel_layout_from_mask(>ch_layout, s->channel_layout);
+else
+av_channel_layout_default(>ch_layout, s->channels);
+
 s1->duration = s->samples;
 avctx->audio_service_type = s->service_type;
 }
diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
index a654844cd0..ec936d89ad 100644
--- a/libavcodec/aaccoder.c
+++ b/libavcodec/aaccoder.c
@@ -710,7 +710,7 @@ static void search_for_quantizers_twoloop(AVCodecContext 
*avctx,
   const float lambda)
 {
 int start = 0, i, w, w2, g;
-int destbits = avctx->bit_rate * 1024.0 / avctx->sample_rate / 
avctx->channels * (lambda / 120.f);
+int destbits = avctx->bit_rate * 1024.0 / avctx->sample_rate / 
avctx->ch_layout.nb_channels * (lambda / 120.f);
 float dists[128] = { 0 }, uplims[128];
 float maxvals[128];
 int fflag, minscaler;
diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index e436b4f2f7..ab184b8634 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -81,6 +81,7 @@
  */
 
 #include "libavutil/float_dsp.h"
+#include "libavutil/opt.h"
 #include "avcodec.h"
 #include "internal.h"
 #include "get_bits.h"
@@ -193,7 +194,7 @@ static int frame_configure_elements(AVCodecContext *avctx)
 }
 
 /* map output channel pointers to AVFrame data */
-for (ch = 0; ch < avctx->channels; ch++) {
+for (ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
 if (ac->output_element[ch])
 ac->output_element[ch]->ret = (float 
*)ac->frame->extended_data[ch];
 }
@@ -432,8 +433,7 @@ static void push_output_configuration(AACContext *ac) {
 static void pop_output_configuration(AACContext *ac) {
 if (ac->oc[1].status != OC_LOCKED && ac->oc[0].status != OC_NONE) {
 ac->oc[1] = ac->oc[0];
-ac->avctx->channels = ac->oc[1].channels;
-ac->avctx->channel_layout = ac->oc[1].channel_layout;
+av_channel_layout_copy(>avctx->ch_layout, >oc[1].ch_layout);
 }
 }
 
@@ -464,7 +464,15 @@ static int output_configure(AACContext *ac,
 }
 // Try to sniff a reasonable channel order, otherwise output the
 // channels in the order the PCE declared them.
-if (avctx->request_channel_layout != AV_CH_LAYOUT_NATIVE)
+#if FF_API_OLD_CHANNEL_LAYOUT
+FF_DISABLE_DEPRECATION_WARNINGS
+if (avctx->request_channel_layout) {
+av_channel_layout_uninit(>downmix_layout);
+av_channel_layout_from_mask(>downmix_layout, 
avctx->request_channel_layout);
+}
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+if (ac->downmix_layout.order == AV_CHANNEL_ORDER_NATIVE)
 layout = sniff_channel_order(layout_map, tags);
 for (i = 0; i < tags; i++) {
 int type = layout_m

[libav-devel] [PATCH 14/25] ac3: convert to new channel layout API

2017-06-28 Thread Vittorio Giovara
Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 libavcodec/ac3dec.c   | 49 +---
 libavcodec/ac3dec.h   |  2 ++
 libavcodec/ac3enc.c   | 83 ---
 libavcodec/ac3enc.h   |  4 ++-
 libavcodec/ac3enc_fixed.c |  5 +++
 libavcodec/ac3enc_float.c |  5 +++
 libavcodec/eac3enc.c  |  5 +++
 tests/fate/ac3.mak| 12 +++
 8 files changed, 128 insertions(+), 37 deletions(-)

diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 4be0f1f411..3d3414f7d7 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -172,6 +172,8 @@ static av_cold void ac3_tables_init(void)
 static av_cold int ac3_decode_init(AVCodecContext *avctx)
 {
 AC3DecodeContext *s = avctx->priv_data;
+static AVChannelLayout mono   = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
+static AVChannelLayout stereo = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
 int i;
 
 s->avctx = avctx;
@@ -190,12 +192,23 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx)
 avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
 
 /* allow downmixing to stereo or mono */
-if (avctx->channels > 1 &&
-avctx->request_channel_layout == AV_CH_LAYOUT_MONO)
-avctx->channels = 1;
-else if (avctx->channels > 2 &&
- avctx->request_channel_layout == AV_CH_LAYOUT_STEREO)
-avctx->channels = 2;
+#if FF_API_OLD_CHANNEL_LAYOUT
+FF_DISABLE_DEPRECATION_WARNINGS
+if (avctx->request_channel_layout) {
+av_channel_layout_uninit(>downmix_layout);
+av_channel_layout_from_mask(>downmix_layout, 
avctx->request_channel_layout);
+}
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+if (avctx->ch_layout.nb_channels > 1 &&
+!av_channel_layout_compare(>downmix_layout, )) {
+av_channel_layout_uninit(>ch_layout);
+avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
+} else if (avctx->ch_layout.nb_channels > 2 &&
+ !av_channel_layout_compare(>downmix_layout, )) {
+av_channel_layout_uninit(>ch_layout);
+avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
+}
 s->downmixed = 1;
 
 for (i = 0; i < AC3_MAX_CHANNELS; i++) {
@@ -1364,6 +1377,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void 
*data,
 const float *output[AC3_MAX_CHANNELS];
 enum AVMatrixEncoding matrix_encoding;
 AVDownmixInfo *downmix_info;
+uint64_t mask;
 
 /* copy input buffer to decoder context to avoid reading past the end
of the buffer, which can be caused by a damaged input stream. */
@@ -1440,16 +1454,19 @@ static int ac3_decode_frame(AVCodecContext * avctx, 
void *data,
 
 /* channel config */
 if (!err || (s->channels && s->out_channels != s->channels)) {
+static AVChannelLayout mono   = 
(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
+static AVChannelLayout stereo = 
(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
+
 s->out_channels = s->channels;
 s->output_mode  = s->channel_mode;
 if (s->lfe_on)
 s->output_mode |= AC3_OUTPUT_LFEON;
 if (s->channels > 1 &&
-avctx->request_channel_layout == AV_CH_LAYOUT_MONO) {
+!av_channel_layout_compare(>downmix_layout, )) {
 s->out_channels = 1;
 s->output_mode  = AC3_CHMODE_MONO;
 } else if (s->channels > 2 &&
-   avctx->request_channel_layout == AV_CH_LAYOUT_STEREO) {
+   !av_channel_layout_compare(>downmix_layout, )) {
 s->out_channels = 2;
 s->output_mode  = AC3_CHMODE_STEREO;
 }
@@ -1466,10 +1483,19 @@ static int ac3_decode_frame(AVCodecContext * avctx, 
void *data,
 av_log(avctx, AV_LOG_ERROR, "unable to determine channel mode\n");
 return AVERROR_INVALIDDATA;
 }
-avctx->channels = s->out_channels;
-avctx->channel_layout = avpriv_ac3_channel_layout_tab[s->output_mode & 
~AC3_OUTPUT_LFEON];
+
+mask = avpriv_ac3_channel_layout_tab[s->output_mode & ~AC3_OUTPUT_LFEON];
 if (s->output_mode & AC3_OUTPUT_LFEON)
-avctx->channel_layout |= AV_CH_LOW_FREQUENCY;
+mask |= AV_CH_LOW_FREQUENCY;
+
+av_channel_layout_uninit(>ch_layout);
+av_channel_layout_from_mask(>ch_layout, mask);
+#if FF_API_OLD_CHANNEL_LAYOUT
+FF_DISABLE_DEPRECATION_WARNINGS
+avctx->channels = avctx->ch_layout.nb_channels;
+avctx->channel_layout = avctx->ch_layout.u.mask;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
 /* set audio service type based on bitstream mode for AC-3 */
 avctx->audio_service_type = s->bitstream_mode;
@@ -1588,6 +1614,7 @@ static av_cold int ac3_decode_end(AVCodecContext *avctx)

[libav-devel] [PATCH 03/25] lavc: deprecate channel count/layout changing side data

2017-06-28 Thread Vittorio Giovara
From: Anton Khirnov <an...@khirnov.net>

They are incompatible with the new channel layout scheme and no decoder
uses them.

Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 libavcodec/avcodec.h | 5 +
 libavcodec/decode.c  | 4 
 libavformat/dump.c   | 9 -
 libavformat/utils.c  | 9 +
 4 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 162f1abe4b..4089c08a24 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1165,8 +1165,13 @@ typedef struct AVPacket {
 #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted
 
 enum AVSideDataParamChangeFlags {
+#if FF_API_OLD_CHANNEL_LAYOUT
+/**
+ * @deprecated those are not used by any decoder
+ */
 AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT  = 0x0001,
 AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002,
+#endif
 AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE= 0x0004,
 AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008,
 };
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 175a6fae4c..a49cd77e51 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -60,6 +60,8 @@ static int apply_param_change(AVCodecContext *avctx, AVPacket 
*avpkt)
 flags = bytestream_get_le32();
 size -= 4;
 
+#if FF_API_OLD_CHANNEL_LAYOUT
+FF_DISABLE_DEPRECATION_WARNINGS
 if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) {
 if (size < 4)
 goto fail;
@@ -72,6 +74,8 @@ static int apply_param_change(AVCodecContext *avctx, AVPacket 
*avpkt)
 avctx->channel_layout = bytestream_get_le64();
 size -= 8;
 }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 if (flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) {
 if (size < 4)
 goto fail;
diff --git a/libavformat/dump.c b/libavformat/dump.c
index 261e21efd3..e1f6848547 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -142,8 +142,11 @@ static void dump_paramchange(void *ctx, AVPacketSideData 
*sd)
 {
 int size = sd->size;
 const uint8_t *data = sd->data;
-uint32_t flags, channels, sample_rate, width, height;
+uint32_t flags, sample_rate, width, height;
+#if FF_API_OLD_CHANNEL_LAYOUT
+uint32_t channels;
 uint64_t layout;
+#endif
 
 if (!data || sd->size < 4)
 goto fail;
@@ -152,6 +155,8 @@ static void dump_paramchange(void *ctx, AVPacketSideData 
*sd)
 data += 4;
 size -= 4;
 
+#if FF_API_OLD_CHANNEL_LAYOUT
+FF_DISABLE_DEPRECATION_WARNINGS
 if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) {
 if (size < 4)
 goto fail;
@@ -169,6 +174,8 @@ static void dump_paramchange(void *ctx, AVPacketSideData 
*sd)
 av_log(ctx, AV_LOG_INFO,
"channel layout: %s, ", av_get_channel_name(layout));
 }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif /* FF_API_OLD_CHANNEL_LAYOUT */
 if (flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) {
 if (size < 4)
 goto fail;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index eaba473914..c8bb04aa70 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3234,6 +3234,9 @@ int ff_add_param_change(AVPacket *pkt, int32_t channels,
 uint8_t *data;
 if (!pkt)
 return AVERROR(EINVAL);
+
+#if FF_API_OLD_CHANNEL_LAYOUT
+FF_DISABLE_DEPRECATION_WARNINGS
 if (channels) {
 size  += 4;
 flags |= AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT;
@@ -3242,6 +3245,8 @@ int ff_add_param_change(AVPacket *pkt, int32_t channels,
 size  += 8;
 flags |= AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT;
 }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 if (sample_rate) {
 size  += 4;
 flags |= AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE;
@@ -3254,10 +3259,14 @@ int ff_add_param_change(AVPacket *pkt, int32_t channels,
 if (!data)
 return AVERROR(ENOMEM);
 bytestream_put_le32(, flags);
+#if FF_API_OLD_CHANNEL_LAYOUT
+FF_DISABLE_DEPRECATION_WARNINGS
 if (channels)
 bytestream_put_le32(, channels);
 if (channel_layout)
 bytestream_put_le64(, channel_layout);
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 if (sample_rate)
 bytestream_put_le32(, sample_rate);
 if (width || height) {
-- 
2.13.1

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

[libav-devel] [PATCH 10/25] avcodecpar: switch to the new channel layout API

2017-06-28 Thread Vittorio Giovara
Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 libavcodec/avcodec.h  | 11 +++
 libavcodec/utils.c| 31 +++
 libavformat/audiointerleave.c |  2 +-
 libavformat/mux.c |  2 +-
 4 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 4089c08a24..bc7097c7bd 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3202,16 +3202,22 @@ typedef struct AVCodecParameters {
 enum AVColorSpace  color_space;
 enum AVChromaLocation  chroma_location;
 
+#if FF_API_OLD_CHANNEL_LAYOUT
 /**
  * Audio only. The channel layout bitmask. May be 0 if the channel layout 
is
  * unknown or unspecified, otherwise the number of bits set must be equal 
to
  * the channels field.
+ * @deprecated use ch_layout
  */
+attribute_deprecated
 uint64_t channel_layout;
 /**
  * Audio only. The number of audio channels.
+ * @deprecated use ch_layout.nb_channels
  */
+attribute_deprecated
 int  channels;
+#endif
 /**
  * Audio only. The number of audio samples per second.
  */
@@ -3238,6 +3244,11 @@ typedef struct AVCodecParameters {
  * audio without any trailing padding.
  */
 int trailing_padding;
+
+/**
+ * Audio only. The channel layout and number of channels.
+ */
+AVChannelLayout ch_layout;
 } AVCodecParameters;
 
 /**
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index bc421f67f8..f8ae415d52 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1300,8 +1300,15 @@ int av_get_audio_frame_duration(AVCodecContext *avctx, 
int frame_bytes)
 
 int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes)
 {
+int channels = par->ch_layout.nb_channels;
+#if FF_API_OLD_CHANNEL_LAYOUT
+FF_DISABLE_DEPRECATION_WARNINGS
+if (!channels)
+channels = par->channels;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 return get_audio_frame_duration(par->codec_id, par->sample_rate,
-par->channels, par->block_align,
+channels, par->block_align,
 par->codec_tag, par->bits_per_coded_sample,
 frame_bytes);
 }
@@ -1588,7 +1595,7 @@ int avcodec_parameters_copy(AVCodecParameters *dst, const 
AVCodecParameters *src
 dst->extradata_size = src->extradata_size;
 }
 
-return 0;
+return av_channel_layout_copy(>ch_layout, >ch_layout);
 }
 
 int avcodec_parameters_from_context(AVCodecParameters *par,
@@ -1620,8 +1627,16 @@ int avcodec_parameters_from_context(AVCodecParameters 
*par,
 break;
 case AVMEDIA_TYPE_AUDIO:
 par->format  = codec->sample_fmt;
+#if FF_API_OLD_CHANNEL_LAYOUT
+FF_DISABLE_DEPRECATION_WARNINGS
 par->channel_layout  = codec->channel_layout;
 par->channels= codec->channels;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+if (codec->channel_layout)
+av_channel_layout_from_mask(>ch_layout, 
codec->channel_layout);
+else
+av_channel_layout_default(>ch_layout, codec->channels);
 par->sample_rate = codec->sample_rate;
 par->block_align = codec->block_align;
 par->initial_padding = codec->initial_padding;
@@ -1666,8 +1681,16 @@ int avcodec_parameters_to_context(AVCodecContext *codec,
 break;
 case AVMEDIA_TYPE_AUDIO:
 codec->sample_fmt  = par->format;
-codec->channel_layout  = par->channel_layout;
-codec->channels= par->channels;
+#if FF_API_OLD_CHANNEL_LAYOUT
+FF_DISABLE_DEPRECATION_WARNINGS
+codec->channel_layout = par->channel_layout;
+codec->channels   = par->channels;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+if (par->ch_layout.u.mask)
+codec->channel_layout = par->ch_layout.u.mask;
+if (par->ch_layout.nb_channels)
+codec->channels = par->ch_layout.nb_channels;
 codec->sample_rate = par->sample_rate;
 codec->block_align = par->block_align;
 codec->initial_padding = par->initial_padding;
diff --git a/libavformat/audiointerleave.c b/libavformat/audiointerleave.c
index aa379f675e..4923c55b35 100644
--- a/libavformat/audiointerleave.c
+++ b/libavformat/audiointerleave.c
@@ -52,7 +52,7 @@ int ff_audio_interleave_init(AVFormatContext *s,
 AudioInterleaveContext *aic = st->priv_data;
 
 if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
-aic->sample_size = (st->codecpar->channels *
+aic->sample_size = (st->codecpar->ch_layout.nb_channels *
 
av_get_bits_per_sample(st->

[libav-devel] [PATCH 08/25] libavfilter changes for the new channel layout API

2017-06-28 Thread Vittorio Giovara
This patch contains the following commits:

avtools: Use the new channel layout API in libavfilter

af_aformat: convert to new channel layout API

Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>

af_amix: convert to new channel layout API

Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>

af_ashowinfo: convert to new channel layout API

Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>

af_asyncts: convert to new channel layout API

Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>

af_atrim: convert to new channel layout API

Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>

af_channelmap: convert to new channel layout API

Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>

af_channelsplit: convert to new channel layout API

Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>

af_compand: convert to new channel layout API

Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>

af_hdcd: convert to new channel layout API

af_join: convert to new channel layout API

af_resample: convert to new channel layout API

af_volume: convert to new channel layout
---
 avtools/avconv.c  |  2 +-
 avtools/avconv_filter.c   |  4 +-
 libavfilter/af_aformat.c  | 10 -
 libavfilter/af_amix.c | 11 --
 libavfilter/af_ashowinfo.c| 12 +++---
 libavfilter/af_asyncts.c  |  6 +--
 libavfilter/af_channelmap.c   | 92 ---
 libavfilter/af_channelsplit.c | 38 +-
 libavfilter/af_compand.c  |  8 ++--
 libavfilter/af_hdcd.c |  2 +-
 libavfilter/af_join.c | 84 ++-
 libavfilter/af_resample.c | 33 +---
 libavfilter/af_volume.c   |  2 +-
 libavfilter/trim.c|  3 +-
 14 files changed, 163 insertions(+), 144 deletions(-)

diff --git a/avtools/avconv.c b/avtools/avconv.c
index 42cbfef592..a1427e0cb4 100644
--- a/avtools/avconv.c
+++ b/avtools/avconv.c
@@ -1998,7 +1998,7 @@ static int init_output_stream_encode(OutputStream *ost)
 case AVMEDIA_TYPE_AUDIO:
 enc_ctx->sample_fmt = ost->filter->filter->inputs[0]->format;
 enc_ctx->sample_rate= ost->filter->filter->inputs[0]->sample_rate;
-enc_ctx->channel_layout = 
ost->filter->filter->inputs[0]->channel_layout;
+enc_ctx->channel_layout = 
ost->filter->filter->inputs[0]->ch_layout.u.mask;
 enc_ctx->channels   = 
av_get_channel_layout_nb_channels(enc_ctx->channel_layout);
 enc_ctx->time_base  = (AVRational){ 1, enc_ctx->sample_rate };
 break;
diff --git a/avtools/avconv_filter.c b/avtools/avconv_filter.c
index e719c06658..7df64c647a 100644
--- a/avtools/avconv_filter.c
+++ b/avtools/avconv_filter.c
@@ -591,7 +591,7 @@ static int configure_input_audio_filter(FilterGraph *fg, 
InputFilter *ifilter,
 par->time_base  = (AVRational){ 1, ifilter->sample_rate };
 par->sample_rate= ifilter->sample_rate;
 par->format = ifilter->format;
-par->channel_layout = ifilter->channel_layout;
+av_channel_layout_from_mask(>ch_layout, ifilter->channel_layout);
 
 ret = av_buffersrc_parameters_set(ifilter->filter, par);
 av_freep();
@@ -758,7 +758,7 @@ int configure_filtergraph(FilterGraph *fg)
 ofilter->height = link->h;
 
 ofilter->sample_rate= link->sample_rate;
-ofilter->channel_layout = link->channel_layout;
+ofilter->channel_layout = link->ch_layout.u.mask;
 }
 
 for (i = 0; i < fg->nb_inputs; i++) {
diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c
index f0746737dc..c5aa4f7148 100644
--- a/libavfilter/af_aformat.c
+++ b/libavfilter/af_aformat.c
@@ -94,6 +94,13 @@ static int get_sample_rate(const char *samplerate)
 return FFMAX(ret, 0);
 }
 
+static int get_channel_layout(const char *channel_layout)
+{
+AVChannelLayout ch_layout = {0};
+av_channel_layout_from_string(_layout, channel_layout);
+return ch_layout.u.mask;
+}
+
 static av_cold int init(AVFilterContext *ctx)
 {
 AFormatContext *s = ctx->priv;
@@ -103,8 +110,7 @@ static av_cold int init(AVFilterContext *ctx)
 PARSE_FORMATS(s->sample_rates_str, int, s->sample_rates, ff_add_format,
   get_sample_rate, 0, "sample rate");
 PARSE_FORMATS(s->channel_layouts_str, uint64_t, s->channel_layouts,
-  ff_add_channel_layout, av_get_channel_layout, 0,
-  "channel layout");
+  ff_add_channel_layout, get_channel_layout, 0, "channel 
layout");
 
 return 0;
 }
diff --git a/libavfilter/af_amix.c b/libavfilter/af_amix.c
index bfba1504ea..a35e04530f 100644
--- a/libavfilter/af_amix.c
+++ b/libavfi

[libav-devel] [PATCH 07/25] lavfi, buffersrc: switch to the new channel layout API

2017-06-28 Thread Vittorio Giovara
Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 libavfilter/audio.c | 17 +--
 libavfilter/avfilter.c  |  9 
 libavfilter/avfilter.h  | 13 ++-
 libavfilter/avfiltergraph.c | 35 +++---
 libavfilter/buffersink.c|  2 +-
 libavfilter/buffersrc.c | 53 -
 libavfilter/buffersrc.h | 12 +-
 libavfilter/fifo.c  |  7 +++---
 8 files changed, 106 insertions(+), 42 deletions(-)

diff --git a/libavfilter/audio.c b/libavfilter/audio.c
index 5fe9da95c3..afd8bdc169 100644
--- a/libavfilter/audio.c
+++ b/libavfilter/audio.c
@@ -31,7 +31,7 @@ AVFrame *ff_null_get_audio_buffer(AVFilterLink *link, int 
nb_samples)
 AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples)
 {
 AVFrame *frame = av_frame_alloc();
-int channels = av_get_channel_layout_nb_channels(link->channel_layout);
+int channels = link->ch_layout.nb_channels;
 int ret;
 
 if (!frame)
@@ -39,7 +39,20 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int 
nb_samples)
 
 frame->nb_samples = nb_samples;
 frame->format = link->format;
-frame->channel_layout = link->channel_layout;
+
+ret = av_channel_layout_copy(>ch_layout, >ch_layout);
+if (ret < 0) {
+av_frame_free();
+return NULL;
+}
+#if FF_API_OLD_CHANNEL_LAYOUT
+FF_DISABLE_DEPRECATION_WARNINGS
+if (link->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ||
+link->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC)
+frame->channel_layout = link->channel_layout;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
 frame->sample_rate= link->sample_rate;
 ret = av_frame_get_buffer(frame, 0);
 if (ret < 0) {
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 83c1a7c20d..f2adefff3d 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -247,16 +247,15 @@ void ff_dlog_link(void *ctx, AVFilterLink *link, int end)
 link->dst ? link->dst->filter->name : "",
 end ? "\n" : "");
 } else {
-char buf[128];
-av_get_channel_layout_string(buf, sizeof(buf), -1, 
link->channel_layout);
-
+char *chlstr = av_channel_layout_describe(>ch_layout);
 av_log(ctx, AV_LOG_TRACE,
 "link[%p r:%d cl:%s fmt:%-16s %-16s->%-16s]%s",
-link, link->sample_rate, buf,
+link, link->sample_rate, chlstr,
 av_get_sample_fmt_name(link->format),
 link->src ? link->src->filter->name : "",
 link->dst ? link->dst->filter->name : "",
 end ? "\n" : "");
+av_free(chlstr);
 }
 }
 
@@ -683,7 +682,7 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
 case AVMEDIA_TYPE_AUDIO:
 av_samples_copy(out->extended_data, frame->extended_data,
 0, 0, frame->nb_samples,
-
av_get_channel_layout_nb_channels(frame->channel_layout),
+frame->ch_layout.nb_channels,
 frame->format);
 break;
 default:
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 6df69dbbbf..5d5edf0ed3 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -36,6 +36,7 @@
 #include "libavutil/attributes.h"
 #include "libavutil/avutil.h"
 #include "libavutil/buffer.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/frame.h"
 #include "libavutil/log.h"
 #include "libavutil/samplefmt.h"
@@ -334,7 +335,12 @@ struct AVFilterLink {
 int h;  ///< agreed upon image height
 AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio
 /* These two parameters apply only to audio */
-uint64_t channel_layout;///< channel layout of current buffer (see 
libavutil/channel_layout.h)
+#if FF_API_OLD_CHANNEL_LAYOUT
+/**
+ * @deprecated use ch_layout instead
+ */
+attribute_deprecated uint64_t channel_layout;
+#endif
 int sample_rate;///< samples per second
 
 int format; ///< agreed upon media format
@@ -405,6 +411,11 @@ struct AVFilterLink {
  * AVHWFramesContext describing the frames.
  */
 AVBufferRef *hw_frames_ctx;
+
+/**
+ * Channel layout of current buffer.
+ */
+AVChannelLayout ch_layout;
 };
 
 /**
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index a0f797e283..c72016d2c8 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -397,7 +397,13 @@ static int pick_format(AVFilterLink *

[libav-devel] [PATCH 01/25] Add a new channel layout API

2017-06-28 Thread Vittorio Giovara
From: Anton Khirnov <an...@khirnov.net>

The new API is more extensible and allows for custom layouts.
More accurate information is exported, eg for decoders that do not
set a channel layout, lavc will not make one up for them.

Deprecate the old API working with just uint64_t bitmasks.

Expanded and completed by Vittorio Giovara <vittorio.giov...@gmail.com>.
Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 libavutil/channel_layout.c | 387 +
 libavutil/channel_layout.h | 362 +++---
 libavutil/version.h|   3 +
 3 files changed, 662 insertions(+), 90 deletions(-)

diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c
index 41340ecdb6..285997446d 100644
--- a/libavutil/channel_layout.c
+++ b/libavutil/channel_layout.c
@@ -31,77 +31,90 @@
 #include "common.h"
 
 static const char * const channel_names[] = {
-[0]  = "FL",/* front left */
-[1]  = "FR",/* front right */
-[2]  = "FC",/* front center */
-[3]  = "LFE",   /* low frequency */
-[4]  = "BL",/* back left */
-[5]  = "BR",/* back right */
-[6]  = "FLC",   /* front left-of-center  */
-[7]  = "FRC",   /* front right-of-center */
-[8]  = "BC",/* back-center */
-[9]  = "SL",/* side left */
-[10] = "SR",/* side right */
-[11] = "TC",/* top center */
-[12] = "TFL",   /* top front left */
-[13] = "TFC",   /* top front center */
-[14] = "TFR",   /* top front right */
-[15] = "TBL",   /* top back left */
-[16] = "TBC",   /* top back center */
-[17] = "TBR",   /* top back right */
-[29] = "DL",/* downmix left */
-[30] = "DR",/* downmix right */
-[31] = "WL",/* wide left */
-[32] = "WR",/* wide right */
-[33] = "SDL",   /* surround direct left */
-[34] = "SDR",   /* surround direct right */
-[35] = "LFE2",  /* low frequency 2 */
+[AV_CHAN_FRONT_LEFT  ] = "FL",
+[AV_CHAN_FRONT_RIGHT ] = "FR",
+[AV_CHAN_FRONT_CENTER] = "FC",
+[AV_CHAN_LOW_FREQUENCY   ] = "LFE",
+[AV_CHAN_BACK_LEFT   ] = "BL",
+[AV_CHAN_BACK_RIGHT  ] = "BR",
+[AV_CHAN_FRONT_LEFT_OF_CENTER] = "FLC",
+[AV_CHAN_FRONT_RIGHT_OF_CENTER   ] = "FRC",
+[AV_CHAN_BACK_CENTER ] = "BC",
+[AV_CHAN_SIDE_LEFT   ] = "SL",
+[AV_CHAN_SIDE_RIGHT  ] = "SR",
+[AV_CHAN_TOP_CENTER  ] = "TC",
+[AV_CHAN_TOP_FRONT_LEFT  ] = "TFL",
+[AV_CHAN_TOP_FRONT_CENTER] = "TFC",
+[AV_CHAN_TOP_FRONT_RIGHT ] = "TFR",
+[AV_CHAN_TOP_BACK_LEFT   ] = "TBL",
+[AV_CHAN_TOP_BACK_CENTER ] = "TBC",
+[AV_CHAN_TOP_BACK_RIGHT  ] = "TBR",
+[AV_CHAN_STEREO_LEFT ] = "DL",
+[AV_CHAN_STEREO_RIGHT] = "DR",
+[AV_CHAN_WIDE_LEFT   ] = "WL",
+[AV_CHAN_WIDE_RIGHT  ] = "WR",
+[AV_CHAN_SURROUND_DIRECT_LEFT] = "SDL",
+[AV_CHAN_SURROUND_DIRECT_RIGHT   ] = "SDR",
+[AV_CHAN_LOW_FREQUENCY_2 ] = "LFE2",
+[AV_CHAN_SILENCE ] = "PAD",
 };
 
-static const char *get_channel_name(int channel_id)
+const char *av_channel_name(enum AVChannel channel_id)
 {
-if (channel_id < 0 || channel_id >= FF_ARRAY_ELEMS(channel_names))
-return NULL;
+if ((unsigned) channel_id >= FF_ARRAY_ELEMS(channel_names))
+return "?";
 return channel_names[channel_id];
 }
 
+int av_channel_from_string(const char *str)
+{
+int i;
+for (i = 0; i < FF_ARRAY_ELEMS(channel_names); i++) {
+if (channel_names[i] && !strcmp(str, channel_names[i])) {
+return i;
+}
+}
+return AVERROR(EINVAL);
+}
+
 static const struct {
 const char *name;
-int nb_channels;
-uint64_t layout;
+AVChannelLayout layout;
 } channel_layout_map[] = {
-{ "mono",1,  AV_CH_LAYOUT_MONO },
-{ "stereo",  2,  AV_CH_LAYOUT_STEREO },
-{ "stereo",  2,  AV_CH_LAYOUT_STEREO_DOWNMIX },
-{ "2.1", 3,  AV_CH_LAYOUT_2POINT1 },
-{ "3.0", 3,  AV_CH_LAYOUT_SURROUND },
-{ &qu

[libav-devel] [PATCH 00/25] New channel API, review compatibility

2017-06-28 Thread Vittorio Giovara
Hello,
it has brought to my attention that reviewing 200 patches is not
desirable, and following the reviewers' suggestions, I squashed the
more mundane replacement patches across the codebase, and left the
more important or complex ones separate to simplify review.

Some of the single patches at the beginning have already been published
and reviewed, added for completeness.

Cheers,
Vittorio

Anton Khirnov (5):
  Add a new channel layout API
  lavu: support AVChannelLayout AVOptions
  lavc: deprecate channel count/layout changing side data
  avframe: switch to the new channel layout API
  lavr: switch to the new channel layout API

Vittorio Giovara (20):
  avtools: Use the new channel layout API in AVFrame
  lavfi, buffersrc: switch to the new channel layout API
  libavfilter changes for the new channel layout API
  lavfi: Port filter negotiation to use the new channel layout API
  avcodecpar: switch to the new channel layout API
  libavformat changes for the new channel layout API
  lavc: switch to the new channel layout API
  aac: convert to new channel layout API
  ac3: convert to new channel layout API
  libavcodec changes for the the new channel layout API
  tools, examples changes for the new channel layout API
  channel_layout: Add Ambisonic components and channel order
  lavr: Only let pass-through ambisonic channel layouts
  opus: Implement mapping type 2 for Ambisonic support
  lavf: Add non diegetic stream disposition flag
  mov: Implement spatial audio support
  aac: Allow pass-through transcoding of ambisonic audio
  avprobe: Print the channel layout string
  fate: Add ambisonic tests
  Bump library versions, update Changelog and APIchanges

 Changelog  |   1 +
 avtools/avconv.c   |  30 +--
 avtools/avconv.h   |   8 +-
 avtools/avconv_filter.c|  44 +++-
 avtools/avconv_opt.c   |  52 ++--
 avtools/avplay.c   |  52 ++--
 avtools/avprobe.c  |   6 +-
 avtools/cmdutils.c |  17 +-
 avtools/cmdutils.h |   8 -
 doc/APIchanges |  22 ++
 doc/examples/decode_audio.c|   2 +-
 doc/examples/encode_audio.c|  36 +--
 doc/examples/filter_audio.c|  11 +-
 doc/examples/output.c  |  30 ++-
 doc/examples/transcode_aac.c   |  29 ++-
 libavcodec/8svx.c  |  15 +-
 libavcodec/aac.h   |   7 +-
 libavcodec/aac_ac3_parser.c|   9 +-
 libavcodec/aaccoder.c  |   2 +-
 libavcodec/aacdec.c|  79 +-
 libavcodec/aacdectab.h |  16 ++
 libavcodec/aacenc.c|   2 +-
 libavcodec/aacpsy.c|  10 +-
 libavcodec/ac3dec.c|  49 +++-
 libavcodec/ac3dec.h|   2 +
 libavcodec/ac3enc.c|  83 +--
 libavcodec/ac3enc.h|   4 +-
 libavcodec/ac3enc_fixed.c  |   5 +
 libavcodec/ac3enc_float.c  |   5 +
 libavcodec/adpcm.c |  57 ++---
 libavcodec/adpcmenc.c  |  92 +++
 libavcodec/adx.c   |  16 +-
 libavcodec/adxdec.c|   6 +-
 libavcodec/adxenc.c|  11 +-
 libavcodec/alac.c  |  18 +-
 libavcodec/alac_data.c |  12 +
 libavcodec/alac_data.h |   6 +
 libavcodec/alacenc.c   |  20 +-
 libavcodec/alsdec.c|  65 ++---
 libavcodec/amrnbdec.c  |   6 +-
 libavcodec/amrwbdec.c  |   6 +-
 libavcodec/apedec.c|   9 +-
 libavcodec/atrac1.c|  10 +-
 libavcodec/atrac3.c|  26 +-
 libavcodec/atrac3plusdec.c |  25 +-
 libavcodec/avcodec.h   |  47 
 libavcodec/binkaudio.c |  17 +-
 libavcodec/bmvaudio.c  |   4 +-
 libavcodec/cngdec.c|   3 +-
 libavcodec/cngenc.c|   6 +-
 libavcodec/cook.c  |  22 +-
 libavcodec/cook_parser.c   |   4 +-
 libavcodec/dca.h   |   2 +
 libavcodec/dca_xll.c   |   6 +-
 libavcodec/dcadec.c|  54 +++--
 libavcodec/decode.c|  88 +--
 libavcodec/dpcm.c  |  14 +-
 libavcodec/dsicinaudio.c   |   4 +-
 libavcodec/dss_sp.c|   4 +-
 libavcodec/eac3enc.c   |   5 +
 libavcodec/encode.c|  18 +-
 libavcodec/flac.c  |  37 +--
 libavcodec/flac.h  |   2 +-
 libavcodec/flac_parser.c   |   7 +-
 libavcodec/flacdec.c   |  10 +-
 libavcodec/flacenc.c   |   2 +-
 libavcodec/g722dec.c   |   4 +-
 libavcodec/g722enc.c   |   8 +-
 libavcodec/g723_1dec.c |   4 +-
 libavcodec/g723_1enc.c |   8 +-
 libavcodec/g726.c  |   6 +-
 libavcodec/gsmdec.c|   4 +-
 libavcodec/imc.c

[libav-devel] [PATCH 02/25] lavu: support AVChannelLayout AVOptions

2017-06-28 Thread Vittorio Giovara
From: Anton Khirnov <an...@khirnov.net>

Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
---
 libavutil/opt.c | 47 +++
 libavutil/opt.h | 10 ++
 2 files changed, 57 insertions(+)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 44d6299117..698f6e97e0 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -242,6 +242,14 @@ static int set_string_number(void *obj, void *target_obj, 
const AVOption *o, con
 }
 }
 
+static int set_string_channel_layout(void *obj, const AVOption *o,
+ const char *val, void *dst)
+{
+AVChannelLayout *channel_layout = dst;
+av_channel_layout_uninit(channel_layout);
+return av_channel_layout_from_string(channel_layout, val);
+}
+
 int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
 {
 void *dst, *target_obj;
@@ -264,6 +272,8 @@ int av_opt_set(void *obj, const char *name, const char 
*val, int search_flags)
 case AV_OPT_TYPE_DOUBLE:
 case AV_OPT_TYPE_RATIONAL:
 return set_string_number(obj, target_obj, o, val, dst);
+case AV_OPT_TYPE_CHANNEL_LAYOUT:
+return set_string_channel_layout(obj, o, val, dst);
 }
 
 av_log(obj, AV_LOG_ERROR, "Invalid option type.\n");
@@ -365,6 +375,22 @@ int av_opt_set_dict_val(void *obj, const char *name, const 
AVDictionary *val,
 return 0;
 }
 
+int av_opt_set_channel_layout(void *obj, const char *name,
+  const AVChannelLayout *channel_layout,
+  int search_flags)
+{
+void *target_obj;
+const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, 
_obj);
+AVChannelLayout *dst;
+
+if (!o || !target_obj)
+return AVERROR_OPTION_NOT_FOUND;
+
+dst = (AVChannelLayout*)((uint8_t*)target_obj + o->offset);
+
+return av_channel_layout_copy(dst, channel_layout);
+}
+
 int av_opt_get(void *obj, const char *name, int search_flags, uint8_t 
**out_val)
 {
 void *dst, *target_obj;
@@ -414,6 +440,9 @@ int av_opt_get(void *obj, const char *name, int 
search_flags, uint8_t **out_val)
 for (i = 0; i < len; i++)
 snprintf(*out_val + i * 2, 3, "%02X", bin[i]);
 return 0;
+case AV_OPT_TYPE_CHANNEL_LAYOUT:
+*out_val = av_channel_layout_describe(dst);
+return *out_val ? 0 : AVERROR(EINVAL);
 default:
 return AVERROR(EINVAL);
 }
@@ -499,6 +528,20 @@ int av_opt_get_dict_val(void *obj, const char *name, int 
search_flags, AVDiction
 return 0;
 }
 
+int av_opt_get_channel_layout(void *obj, const char *name, int search_flags,
+  AVChannelLayout *channel_layout)
+{
+void *dst, *target_obj;
+const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, 
_obj);
+
+if (!o || !target_obj)
+return AVERROR_OPTION_NOT_FOUND;
+
+dst = ((uint8_t*)target_obj) + o->offset;
+
+return av_channel_layout_copy(channel_layout, dst);
+}
+
 int av_opt_flag_is_set(void *obj, const char *field_name, const char 
*flag_name)
 {
 const AVOption *field = av_opt_find(obj, field_name, NULL, 0, 0);
@@ -561,6 +604,9 @@ static void opt_list(void *obj, void *av_log_obj, const 
char *unit,
 case AV_OPT_TYPE_BINARY:
 av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "");
 break;
+case AV_OPT_TYPE_CHANNEL_LAYOUT:
+av_log(av_log_obj, AV_LOG_INFO, "%-7s", "");
+break;
 case AV_OPT_TYPE_CONST:
 default:
 av_log(av_log_obj, AV_LOG_INFO, "%-7s ", "");
@@ -626,6 +672,7 @@ void av_opt_set_defaults(void *s)
 }
 break;
 case AV_OPT_TYPE_STRING:
+case AV_OPT_TYPE_CHANNEL_LAYOUT:
 av_opt_set(s, opt->name, opt->default_val.str, 0);
 break;
 case AV_OPT_TYPE_BINARY:
diff --git a/libavutil/opt.h b/libavutil/opt.h
index b68a396da7..a30c53b0ab 100644
--- a/libavutil/opt.h
+++ b/libavutil/opt.h
@@ -29,6 +29,7 @@
 
 #include "rational.h"
 #include "avutil.h"
+#include "channel_layout.h"
 #include "dict.h"
 #include "log.h"
 
@@ -225,6 +226,11 @@ enum AVOptionType{
 AV_OPT_TYPE_RATIONAL,
 AV_OPT_TYPE_BINARY,  ///< offset must point to a pointer immediately 
followed by an int for the length
 AV_OPT_TYPE_DICT,
+/**
+ * The offset point to an AVChannelLayout, the default is .str, which gets
+ * passed to av_channel_layout_from_string().
+ */
+AV_OPT_TYPE_CHANNEL_LAYOUT,
 AV_OPT_TYPE_CONST = 128,
 };
 
@@ -499,6 +505,8 @@ int av_opt_set_bin (void *obj, const char *name, const 
uint8_t *val, int siz
  * caller still owns val is and responsible for freeing it.
  */
 int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, 
int search_flags);
+int av_opt_set_

Re: [libav-devel] [PATCH] hwframe: Support cropping in the default allocator

2017-06-25 Thread Vittorio Giovara
On Sat, Jun 24, 2017 at 12:18 PM, wm4  wrote:
> On Sat, 24 Jun 2017 15:51:20 +0200
> Luca Barbato  wrote:
>
>> From: Anton Khirnov 
>>
>> ---
>>
>> Better subject welcome. It is currently folded in wm4 mix fixes set.

It would be nice to have a short description about why this is
correct/needed in the commit log.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 4/6] avcodec/h264_cabac: Fix CABAC+8x8dct in 4:4:4

2017-06-15 Thread Vittorio Giovara
From: Anton Mitrofanov 

Use the correct ctxIdxInc calculation for coded_block_flag.
Keep old behavior for old versions of x264 for backward compatibility.
---
 libavcodec/h264_cabac.c | 47 +--
 1 file changed, 33 insertions(+), 14 deletions(-)

diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c
index b28e486e52..c28f5680de 100644
--- a/libavcodec/h264_cabac.c
+++ b/libavcodec/h264_cabac.c
@@ -2329,21 +2329,40 @@ decode_intra_mb:
 if (CHROMA444(h) && IS_8x8DCT(mb_type)){
 int i;
 uint8_t *nnz_cache = sl->non_zero_count_cache;
-for (i = 0; i < 2; i++){
-if (sl->left_type[LEFT(i)] && !IS_8x8DCT(sl->left_type[LEFT(i)])) {
-nnz_cache[3+8* 1 + 2*8*i]=
-nnz_cache[3+8* 2 + 2*8*i]=
-nnz_cache[3+8* 6 + 2*8*i]=
-nnz_cache[3+8* 7 + 2*8*i]=
-nnz_cache[3+8*11 + 2*8*i]=
-nnz_cache[3+8*12 + 2*8*i]= IS_INTRA(mb_type) ? 64 : 0;
+if (h->sei.unregistered.x264_build < 151U) {
+for (i = 0; i < 2; i++){
+if (sl->left_type[LEFT(i)] && 
!IS_8x8DCT(sl->left_type[LEFT(i)])) {
+nnz_cache[3+8* 1 + 2*8*i]=
+nnz_cache[3+8* 2 + 2*8*i]=
+nnz_cache[3+8* 6 + 2*8*i]=
+nnz_cache[3+8* 7 + 2*8*i]=
+nnz_cache[3+8*11 + 2*8*i]=
+nnz_cache[3+8*12 + 2*8*i]= IS_INTRA(mb_type) ? 64 : 0;
+}
+}
+if (sl->top_type && !IS_8x8DCT(sl->top_type)){
+uint32_t top_empty = !IS_INTRA(mb_type) ? 0 : 0x40404040;
+AV_WN32A(_cache[4+8* 0], top_empty);
+AV_WN32A(_cache[4+8* 5], top_empty);
+AV_WN32A(_cache[4+8*10], top_empty);
+}
+} else {
+for (i = 0; i < 2; i++){
+if (sl->left_type[LEFT(i)] && 
!IS_8x8DCT(sl->left_type[LEFT(i)])) {
+nnz_cache[3+8* 1 + 2*8*i]=
+nnz_cache[3+8* 2 + 2*8*i]=
+nnz_cache[3+8* 6 + 2*8*i]=
+nnz_cache[3+8* 7 + 2*8*i]=
+nnz_cache[3+8*11 + 2*8*i]=
+nnz_cache[3+8*12 + 2*8*i]= 
!IS_INTRA_PCM(sl->left_type[LEFT(i)]) ? 0 : 64;
+}
+}
+if (sl->top_type && !IS_8x8DCT(sl->top_type)){
+uint32_t top_empty = !IS_INTRA_PCM(sl->top_type) ? 0 : 
0x40404040;
+AV_WN32A(_cache[4+8* 0], top_empty);
+AV_WN32A(_cache[4+8* 5], top_empty);
+AV_WN32A(_cache[4+8*10], top_empty);
 }
-}
-if (sl->top_type && !IS_8x8DCT(sl->top_type)){
-uint32_t top_empty = !IS_INTRA(mb_type) ? 0 : 0x40404040;
-AV_WN32A(_cache[4+8* 0], top_empty);
-AV_WN32A(_cache[4+8* 5], top_empty);
-AV_WN32A(_cache[4+8*10], top_empty);
 }
 }
 h->cur_pic.mb_type[mb_xy] = mb_type;
-- 
2.13.1

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

[libav-devel] [PATCH 5/6] avcodec/h264_mb: Fix 8x8dct in lossless for new versions of x264

2017-06-15 Thread Vittorio Giovara
From: Anton Mitrofanov 

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

diff --git a/libavcodec/h264_mb.c b/libavcodec/h264_mb.c
index da6a31d577..917c6aa3fc 100644
--- a/libavcodec/h264_mb.c
+++ b/libavcodec/h264_mb.c
@@ -636,7 +636,7 @@ static av_always_inline void 
hl_decode_mb_predict_luma(const H264Context *h,
 uint8_t *const ptr = dest_y + block_offset[i];
 const int dir  = sl->intra4x4_pred_mode_cache[scan8[i]];
 if (transform_bypass && h->ps.sps->profile_idc == 244 && dir 
<= 1) {
-if (h->sei.unregistered.x264_build != -1) {
+if (h->sei.unregistered.x264_build < 151U) {
 h->hpc.pred8x8l_add[dir](ptr, sl->mb + (i * 16 + p * 
256 << pixel_shift), linesize);
 } else
 h->hpc.pred8x8l_filter_add[dir](ptr, sl->mb + (i * 16 
+ p * 256 << pixel_shift),
-- 
2.13.1

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

[libav-devel] [PATCH 3/6] avcodec/h264: fix Lossless Decoding (Profile 244) for 8x8 Intra Prediction

2017-06-15 Thread Vittorio Giovara
From: Yogender Kumar Gupta 

This is limited to the case where x264_build = -1, to not break x264 decoding

Signed-off-by: Michael Niedermayer 
---
 libavcodec/h264_mb.c   |  7 +++-
 libavcodec/h264pred.c  |  2 ++
 libavcodec/h264pred.h  |  2 ++
 libavcodec/h264pred_template.c | 73 ++
 4 files changed, 83 insertions(+), 1 deletion(-)

diff --git a/libavcodec/h264_mb.c b/libavcodec/h264_mb.c
index f037bd5163..da6a31d577 100644
--- a/libavcodec/h264_mb.c
+++ b/libavcodec/h264_mb.c
@@ -636,7 +636,12 @@ static av_always_inline void 
hl_decode_mb_predict_luma(const H264Context *h,
 uint8_t *const ptr = dest_y + block_offset[i];
 const int dir  = sl->intra4x4_pred_mode_cache[scan8[i]];
 if (transform_bypass && h->ps.sps->profile_idc == 244 && dir 
<= 1) {
-h->hpc.pred8x8l_add[dir](ptr, sl->mb + (i * 16 + p * 256 
<< pixel_shift), linesize);
+if (h->sei.unregistered.x264_build != -1) {
+h->hpc.pred8x8l_add[dir](ptr, sl->mb + (i * 16 + p * 
256 << pixel_shift), linesize);
+} else
+h->hpc.pred8x8l_filter_add[dir](ptr, sl->mb + (i * 16 
+ p * 256 << pixel_shift),
+(sl-> 
topleft_samples_available << i) & 0x8000,
+
(sl->topright_samples_available << i) & 0x4000, linesize);
 } else {
 const int nnz = sl->non_zero_count_cache[scan8[i + p * 
16]];
 h->hpc.pred8x8l[dir](ptr, (sl->topleft_samples_available 
<< i) & 0x8000,
diff --git a/libavcodec/h264pred.c b/libavcodec/h264pred.c
index 7627eb076d..135babcab4 100644
--- a/libavcodec/h264pred.c
+++ b/libavcodec/h264pred.c
@@ -552,6 +552,8 @@ av_cold void ff_h264_pred_init(H264PredContext *h, int 
codec_id,
 h->pred4x4_add  [ HOR_PRED   ]= FUNCC(pred4x4_horizontal_add  , 
depth);\
 h->pred8x8l_add [VERT_PRED   ]= FUNCC(pred8x8l_vertical_add   , 
depth);\
 h->pred8x8l_add [ HOR_PRED   ]= FUNCC(pred8x8l_horizontal_add , 
depth);\
+h->pred8x8l_filter_add [VERT_PRED   ]= FUNCC(pred8x8l_vertical_filter_add  
 , depth);\
+h->pred8x8l_filter_add [ HOR_PRED   ]= 
FUNCC(pred8x8l_horizontal_filter_add , depth);\
 if (chroma_format_idc <= 1) {\
 h->pred8x8_add  [VERT_PRED8x8]= FUNCC(pred8x8_vertical_add, 
depth);\
 h->pred8x8_add  [ HOR_PRED8x8]= FUNCC(pred8x8_horizontal_add  , 
depth);\
diff --git a/libavcodec/h264pred.h b/libavcodec/h264pred.h
index 60e74349c9..6e495f9fc6 100644
--- a/libavcodec/h264pred.h
+++ b/libavcodec/h264pred.h
@@ -101,6 +101,8 @@ typedef struct H264PredContext {
   int16_t *block /*align 16*/, ptrdiff_t stride);
 void(*pred8x8l_add[2])(uint8_t *pix /*align  8*/,
int16_t *block /*align 16*/, ptrdiff_t stride);
+void(*pred8x8l_filter_add[2])(uint8_t *pix /*align  8*/,
+   int16_t *block /*align 16*/, int topleft, int 
topright, ptrdiff_t stride);
 void(*pred8x8_add[3])(uint8_t *pix /*align  8*/,
   const int *block_offset,
   int16_t *block /*align 16*/, ptrdiff_t stride);
diff --git a/libavcodec/h264pred_template.c b/libavcodec/h264pred_template.c
index 8492b2b0a2..42ff350b4c 100644
--- a/libavcodec/h264pred_template.c
+++ b/libavcodec/h264pred_template.c
@@ -1123,6 +1123,79 @@ static void FUNCC(pred8x8l_horizontal_up)(uint8_t *_src, 
int has_topleft,
 SRC(5,6)=SRC(5,7)=SRC(6,4)=SRC(6,5)=SRC(6,6)=
 SRC(6,7)=SRC(7,4)=SRC(7,5)=SRC(7,6)=SRC(7,7)= l7;
 }
+
+static void FUNCC(pred8x8l_vertical_filter_add)(uint8_t *_src, int16_t 
*_block, int has_topleft,
+ int has_topright, ptrdiff_t _stride)
+{
+int i;
+pixel *src = (pixel*)_src;
+const dctcoef *block = (const dctcoef*)_block;
+pixel pix[8];
+int stride = _stride/sizeof(pixel);
+PREDICT_8x8_LOAD_TOP;
+
+pix[0] = t0;
+pix[1] = t1;
+pix[2] = t2;
+pix[3] = t3;
+pix[4] = t4;
+pix[5] = t5;
+pix[6] = t6;
+pix[7] = t7;
+
+for(i=0; i<8; i++){
+pixel v = pix[i];
+src[0*stride]= v += block[0];
+src[1*stride]= v += block[8];
+src[2*stride]= v += block[16];
+src[3*stride]= v += block[24];
+src[4*stride]= v += block[32];
+src[5*stride]= v += block[40];
+src[6*stride]= v += block[48];
+src[7*stride]= v +  block[56];
+src++;
+block++;
+}
+
+memset(_block, 0, sizeof(dctcoef) * 64);
+}
+
+static void FUNCC(pred8x8l_horizontal_filter_add)(uint8_t *_src, int16_t 
*_block, int has_topleft,
+   int has_topright, ptrdiff_t _stride)
+{
+int i;
+pixel 

[libav-devel] [PATCH 1/6] avcodec/h264_slice: Also copy x264_build in ff_h264_update_thread_context()

2017-06-15 Thread Vittorio Giovara
From: Michael Niedermayer 

Fixes fate-h264-lossless

Signed-off-by: Michael Niedermayer 
---
 libavcodec/h264_slice.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index c9f1dbb86f..0ce4127a1d 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -408,6 +408,7 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
 // extradata/NAL handling
 h->is_avc = h1->is_avc;
 h->nal_length_size = h1->nal_length_size;
+h->sei.unregistered.x264_build = h1->sei.unregistered.x264_build;
 
 memcpy(>poc,>poc,sizeof(h->poc));
 
-- 
2.13.1

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

[libav-devel] [PATCH 2/6] avcodec/h264: Don't reset the x264 build info once read

2017-06-15 Thread Vittorio Giovara
From: Anton Mitrofanov 

In order to fix fate-h264-lossless (change by Hendrik)
---
 libavcodec/h264_sei.c | 1 -
 libavcodec/h264dec.c  | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
index 3ca2b7a6cd..a2151bfaf6 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -38,7 +38,6 @@ static const uint8_t sei_num_clock_ts_table[9] = {
 
 void ff_h264_sei_uninit(H264SEIContext *h)
 {
-h->unregistered.x264_build   = -1;
 h->recovery_point.recovery_frame_cnt = -1;
 
 h->picture_timing.dpb_output_delay  = 0;
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 2a532a7ef7..c81510fc05 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -294,6 +294,7 @@ static int h264_init_context(AVCodecContext *avctx, 
H264Context *h)
 h->poc.prev_poc_msb  = 1 << 16;
 h->recovery_frame= -1;
 h->frame_recovered   = 0;
+h->sei.unregistered.x264_build = -1;
 
 h->next_outputed_poc = INT_MIN;
 for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++)
-- 
2.13.1

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

[libav-devel] [PATCH 6/6] avcodec/h264: Fix mix of lossless and lossy MBs decoding

2017-06-15 Thread Vittorio Giovara
From: Anton Mitrofanov 

---
 libavcodec/h264_cabac.c | 16 
 libavcodec/h264_cavlc.c | 16 
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c
index c28f5680de..e6dc5258a4 100644
--- a/libavcodec/h264_cabac.c
+++ b/libavcodec/h264_cabac.c
@@ -2371,14 +2371,6 @@ decode_intra_mb:
 const uint8_t *scan, *scan8x8;
 const uint32_t *qmul;
 
-if(IS_INTERLACED(mb_type)){
-scan8x8 = sl->qscale ? h->field_scan8x8 : h->field_scan8x8_q0;
-scan= sl->qscale ? h->field_scan : h->field_scan_q0;
-}else{
-scan8x8 = sl->qscale ? h->zigzag_scan8x8 : h->zigzag_scan8x8_q0;
-scan= sl->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
-}
-
 // decode_cabac_mb_dqp
 if(get_cabac_noinline( >cabac, >cabac_state[60 + 
(sl->last_qscale_diff != 0)])){
 int val = 1;
@@ -2409,6 +2401,14 @@ decode_intra_mb:
 }else
 sl->last_qscale_diff=0;
 
+if(IS_INTERLACED(mb_type)){
+scan8x8 = sl->qscale ? h->field_scan8x8 : h->field_scan8x8_q0;
+scan= sl->qscale ? h->field_scan : h->field_scan_q0;
+}else{
+scan8x8 = sl->qscale ? h->zigzag_scan8x8 : h->zigzag_scan8x8_q0;
+scan= sl->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
+}
+
 decode_cabac_luma_residual(h, sl, scan, scan8x8, pixel_shift, mb_type, 
cbp, 0);
 if (CHROMA444(h)) {
 decode_cabac_luma_residual(h, sl, scan, scan8x8, pixel_shift, 
mb_type, cbp, 1);
diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c
index c11e211bd8..d57062bc56 100644
--- a/libavcodec/h264_cavlc.c
+++ b/libavcodec/h264_cavlc.c
@@ -1093,14 +1093,6 @@ decode_intra_mb:
 const uint8_t *scan, *scan8x8;
 const int max_qp = 51 + 6 * (h->ps.sps->bit_depth_luma - 8);
 
-if(IS_INTERLACED(mb_type)){
-scan8x8 = sl->qscale ? h->field_scan8x8_cavlc : 
h->field_scan8x8_cavlc_q0;
-scan= sl->qscale ? h->field_scan : h->field_scan_q0;
-}else{
-scan8x8 = sl->qscale ? h->zigzag_scan8x8_cavlc : 
h->zigzag_scan8x8_cavlc_q0;
-scan= sl->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
-}
-
 dquant= get_se_golomb(>gb);
 
 sl->qscale += dquant;
@@ -1117,6 +1109,14 @@ decode_intra_mb:
 sl->chroma_qp[0] = get_chroma_qp(h->ps.pps, 0, sl->qscale);
 sl->chroma_qp[1] = get_chroma_qp(h->ps.pps, 1, sl->qscale);
 
+if(IS_INTERLACED(mb_type)){
+scan8x8 = sl->qscale ? h->field_scan8x8_cavlc : 
h->field_scan8x8_cavlc_q0;
+scan= sl->qscale ? h->field_scan : h->field_scan_q0;
+}else{
+scan8x8 = sl->qscale ? h->zigzag_scan8x8_cavlc : 
h->zigzag_scan8x8_cavlc_q0;
+scan= sl->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
+}
+
 if ((ret = decode_luma_residual(h, sl, gb, scan, scan8x8, pixel_shift, 
mb_type, cbp, 0)) < 0 ) {
 return -1;
 }
-- 
2.13.1

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

  1   2   3   4   5   6   7   8   9   10   >