Re: [libav-devel] [PATCHv2] x11grab: fix drawing cursor in multi-screen setup

2014-09-26 Thread Luca Barbato

On 19/09/14 11:35, Antonio Ospite wrote:

The paint_mouse_pointer() code uses XFixes to retrieve the cursor
coordinates, but XFixes gives no information about what screen the
pointer is on; this results in always drawing the cursor on the captured
screen even if the mouse pointer was on another screen.

For example, when capturing from screen 1 (i.e. -f x11grab -i ":0.1")
the cursor was being drawn in the captured image even when the mouse
pointer was actually on screen 0, which is wrong and visually confusing.

Use XQueryPointer to check that the pointer is actually on the screen
which is being captured and if it is not, don't draw the cursor.

Also, don't follow the mouse or redraw the region when the pointer is on
another screen.

Signed-off-by: Antonio Ospite 
---

Hey Luca, let me know if/when you manage to test this yourself, some more
feedback is always welcome.



Last night I was too tired and for some reason this patch wasn't in my 
pending queue...




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


Re: [libav-devel] [PATCH] sdp: Make opus declaration conform to the spec

2014-09-26 Thread Luca Barbato

On 27/09/14 00:52, Timothy B. Terriberry wrote:

Err, trying again with an actual attached patch



Ok.

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


Re: [libav-devel] [PATCH] sdp: Make opus declaration conform to the spec

2014-09-26 Thread Timothy B. Terriberry

Err, trying again with an actual attached patch
>From 983a39d730f7d961e25befada3951f3285a82155 Mon Sep 17 00:00:00 2001
From: "Timothy B. Terriberry" 
Date: Wed, 24 Sep 2014 17:43:22 -0700
Subject: [PATCH] sdp: Make opus declaration conform to the spec

---
 libavformat/sdp.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/libavformat/sdp.c b/libavformat/sdp.c
index 3c39ac7..eccd676 100644
--- a/libavformat/sdp.c
+++ b/libavformat/sdp.c
@@ -578,18 +578,28 @@ static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c,
  payload_type, c->sample_rate,
  payload_type, c->block_align == 38 ? 20 : 30);
 break;
 case AV_CODEC_ID_SPEEX:
 av_strlcatf(buff, size, "a=rtpmap:%d speex/%d\r\n",
  payload_type, c->sample_rate);
 break;
 case AV_CODEC_ID_OPUS:
-av_strlcatf(buff, size, "a=rtpmap:%d opus/48000\r\n",
+/* The opus RTP draft says that all opus streams MUST be declared
+   as stereo, to avoid negotiation failures. The actual number of
+   channels can change on a packet-by-packet basis. The number of
+   channels a receiver prefers to receive or a sender plans to send
+   can be declared via fmtp parameters (both default to mono), but
+   receivers MUST be able to receive and process stereo packets. */
+av_strlcatf(buff, size, "a=rtpmap:%d opus/48000/2\r\n",
  payload_type);
+if (c->channels == 2) {
+av_strlcatf(buff, size, "a=fmtp:%d sprop-stereo:1\r\n",
+ payload_type);
+}
 break;
 default:
 /* Nothing special to do here... */
 break;
 }
 
 av_free(config);
 
-- 
1.8.3.2

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

[libav-devel] [PATCH] sdp: Make opus declaration conform to the spec

2014-09-26 Thread Timothy B. Terriberry


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


[libav-devel] [PATCH] configure: Place all temporary files in one separate directory

2014-09-26 Thread Diego Biurrun
This reduces TMPDIR pollution and possibly avoids race conditions with
temporary files that are not atomically created.

Based on a patch from Michał Górny .
---

Now uses "mktemp -d" if available.

 configure | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index 6125bcb..64f8b6d 100755
--- a/configure
+++ b/configure
@@ -2589,19 +2589,23 @@ if ! check_cmd mktemp -u XX; then
 # simple replacement for missing mktemp
 # NOT SAFE FOR GENERAL USE
 mktemp(){
-echo "${2%%XXX*}.${HOSTNAME}.${UID}.$$"
+tmpname="${2%%XXX*}.${HOSTNAME}.${UID}.$$"
+echo "$tmpname"
+mkdir "$tmpname"
 }
 fi
 
+AVTMPDIR=$(mktemp -d "${TMPDIR}/avconf." 2> /dev/null) ||
+die "Unable to create temporary directory in $TMPDIR."
+
 tmpfile(){
-tmp=$(mktemp -u "${TMPDIR}/ffconf.")$2 &&
-(set -C; exec > $tmp) 2>/dev/null ||
+tmp="${AVTMPDIR}/avconf"$2
+(set -C; exec > $tmp) 2> /dev/null ||
 die "Unable to create temporary file in $TMPDIR."
-append TMPFILES $tmp
 eval $1=$tmp
 }
 
-trap 'rm -f -- $TMPFILES' EXIT
+trap 'rm -rf -- "$AVTMPDIR"' EXIT
 
 tmpfile TMPASM .asm
 tmpfile TMPC   .c
-- 
1.9.1

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

Re: [libav-devel] [PATCH] x11grab: Check the XQueryPointer return value

2014-09-26 Thread Antonio Ospite
On Fri, 26 Sep 2014 21:20:15 +0200
Luca Barbato  wrote:

> Disable follow_mouse and draw_mouse accordingly to prevent spurious
> updates on multi screen setups.
> 
> Developed from an initial patch from Antonio Ospite .
> 
> CC: libav-sta...@libav.org
> ---
> 
> Addressed some of Antonio's feedback. Let me know it is fine for you like
> this or should be changed otherwise.
>

I see no need to hold this back any further, if you want feel free to
use my commit message from https://patches.libav.org/patch/54021/

Thanks,
   Antonio

>  libavdevice/x11grab.c | 18 ++
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c
> index 1f91be9..3aa4294 100644
> --- a/libavdevice/x11grab.c
> +++ b/libavdevice/x11grab.c
> @@ -487,8 +487,8 @@ static int x11grab_read_packet(AVFormatContext *s1, 
> AVPacket *pkt)
>  int x_off = s->x_off;
>  int y_off = s->y_off;
>  int follow_mouse  = s->follow_mouse;
> -int screen;
> -Window root;
> +int screen, pointer_x, pointer_y, _, same_screen = 1;
> +Window w, root;
>  int64_t curtime, delay;
>  struct timespec ts;
> 
> @@ -516,14 +516,16 @@ static int x11grab_read_packet(AVFormatContext *s1, 
> AVPacket *pkt)
> 
>  screen = DefaultScreen(dpy);
>  root   = RootWindow(dpy, screen);
> -if (follow_mouse) {
> +
> +if (follow_mouse || s->draw_mouse)
> +same_screen = XQueryPointer(dpy, root, &w, &w,
> +&pointer_x, &pointer_y, &_, &_, &_);
> +
> +if (follow_mouse && same_screen) {
>  int screen_w, screen_h;
> -int pointer_x, pointer_y, _;
> -Window w;
> 
>  screen_w = DisplayWidth(dpy, screen);
>  screen_h = DisplayHeight(dpy, screen);
> -XQueryPointer(dpy, root, &w, &w, &pointer_x, &pointer_y, &_, &_, &_);
>  if (follow_mouse == -1) {
>  // follow the mouse, put it at center of grabbing region
>  x_off += pointer_x - s->width / 2 - x_off;
> @@ -550,7 +552,7 @@ static int x11grab_read_packet(AVFormatContext *s1, 
> AVPacket *pkt)
>  s->y_off - REGION_WIN_BORDER);
>  }
> 
> -if (s->show_region) {
> +if (s->show_region && same_screen) {
>  if (s->region_win) {
>  XEvent evt = { .type = NoEventMask };
>  // Clean up the events, and do the initial draw or redraw.
> @@ -572,7 +574,7 @@ static int x11grab_read_packet(AVFormatContext *s1, 
> AVPacket *pkt)
>  av_log(s1, AV_LOG_INFO, "XGetZPixmap() failed\n");
>  }
> 
> -if (s->draw_mouse)
> +if (s->draw_mouse && same_screen)
>  paint_mouse_pointer(image, s);
> 
>  return s->frame_size;
> --
> 2.1.0
> 
> ___
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel
> 


-- 
Antonio Ospite
http://ao2.it

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/6] pixdesc: return color properties names

2014-09-26 Thread Diego Biurrun
On Fri, Sep 26, 2014 at 05:22:35PM +0100, Vittorio Giovara wrote:
> --- a/libavutil/pixdesc.c
> +++ b/libavutil/pixdesc.c
> @@ -1700,3 +1727,34 @@ enum AVPixelFormat av_pix_fmt_swap_endianness(enum 
> AVPixelFormat pix_fmt)
> +
> +const char *av_color_range_name(enum AVColorRange range)
> +{
> +return (unsigned)range < AVCOL_RANGE_NB ?
> +color_range_names[range] : NULL;

   return (unsigned)range < AVCOL_RANGE_NB ?
  color_range_names[range] : NULL;


But it would also comfortably fit on one line, same below.

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


Re: [libav-devel] [PATCH 1/8] vdpau: add helper for VDPAU to libav error codes conversion

2014-09-26 Thread Diego Biurrun
On Wed, Sep 24, 2014 at 11:29:03AM +0200, Luca Barbato wrote:
> 
> The set seems fine to me, if nobody beats me I'd add to my queue and
> merge it with the rest of the pending stuff.

Set queued.  I'll fix some nits and push it on Monday as I need to
run out now and will be away over the weekend.

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


Re: [libav-devel] [PATCH 0/2] Consistently invoke get_format()

2014-09-26 Thread Rémi Denis-Courmont
Le jeudi 25 septembre 2014, 11:04:36 Luca Barbato a écrit :
> On 25/09/14 10:58, Rémi Denis-Courmont wrote:
> > Hello,
> > 
> > In H.264 and MPEG-1/2, the decoded pixel format can change mid-stream.
> > Yet, get_format() is only called if the new pixel format is compatible
> > with hardware acceleration. This triggers undefined behaviour in
> > hwaccel-enabled applications when hardware acceleration is first
> > enabled, and then the new pixel format changes to unaccelerated.
> > 
> > Forcing the callback to be called lets the application detect the change
> > and disable hardware acceleration cleanly.
> > 
> > (Note: The other get_format()-using codecs are not patched as they do
> > not seem to allow mid-stream change of the pixel format.)
> 
> The set seems fine to me.

Hmm? Just to be clear, unlike my other hwaccel patches, I consider this is a 
bugfix. Existing applications potentially crash right now without it.

Of course someone could argue the application are buggy. But I would find that 
very contrived.

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

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

Re: [libav-devel] [PATCH] hwaccel: Call ->get_format again if hwaccel init fails

2014-09-26 Thread Rémi Denis-Courmont
Le jeudi 25 septembre 2014, 10:27:15 Luca Barbato a écrit :
> From: Rémi Denis-Courmont 
> 
> This allows the application to fallback to another hwaccel, or more
> likely, to software decoding.
> 
> Signed-off-by: Luca Barbato 
> ---
> 
> Review in patch form, I moved the hwaccel allocation away to not have
> err vs ret, since it confused me.

It seems semantically equivalent. I find it more confusing that new way. YMMV.

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

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

Re: [libav-devel] [PATCH 1/6] hwaccel: Mark the capabilities field as unused

2014-09-26 Thread Luca Barbato

On 25/09/14 21:36, Rémi Denis-Courmont wrote:

Le jeudi 25 septembre 2014, 20:50:52 Luca Barbato a écrit :

On 31/08/14 21:24, Luca Barbato wrote:

Nothing is using it right now.
---

   libavcodec/avcodec.h | 3 +--
   1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 14440fe..c5fd990 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2920,8 +2920,7 @@ typedef struct AVHWAccel {

   enum AVPixelFormat pix_fmt;

   /**

- * Hardware accelerated codec capabilities.
- * see FF_HWACCEL_CODEC_CAP_*
+ * Hardware accelerated codec capabilities. (currently unused)

*/

   int capabilities;


Rémi started using it so I'd drop the patch.


Did I?



If I hadn't misread, you started using the capabilities in vdpau, sigh I 
want plaid deployed (and completed =_=).


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

[libav-devel] [PATCH] x11grab: Check the XQueryPointer return value

2014-09-26 Thread Luca Barbato
Disable follow_mouse and draw_mouse accordingly to prevent spurious
updates on multi screen setups.

Developed from an initial patch from Antonio Ospite .

CC: libav-sta...@libav.org
---

Addressed some of Antonio's feedback. Let me know it is fine for you like
this or should be changed otherwise.

 libavdevice/x11grab.c | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c
index 1f91be9..3aa4294 100644
--- a/libavdevice/x11grab.c
+++ b/libavdevice/x11grab.c
@@ -487,8 +487,8 @@ static int x11grab_read_packet(AVFormatContext *s1, 
AVPacket *pkt)
 int x_off = s->x_off;
 int y_off = s->y_off;
 int follow_mouse  = s->follow_mouse;
-int screen;
-Window root;
+int screen, pointer_x, pointer_y, _, same_screen = 1;
+Window w, root;
 int64_t curtime, delay;
 struct timespec ts;

@@ -516,14 +516,16 @@ static int x11grab_read_packet(AVFormatContext *s1, 
AVPacket *pkt)

 screen = DefaultScreen(dpy);
 root   = RootWindow(dpy, screen);
-if (follow_mouse) {
+
+if (follow_mouse || s->draw_mouse)
+same_screen = XQueryPointer(dpy, root, &w, &w,
+&pointer_x, &pointer_y, &_, &_, &_);
+
+if (follow_mouse && same_screen) {
 int screen_w, screen_h;
-int pointer_x, pointer_y, _;
-Window w;

 screen_w = DisplayWidth(dpy, screen);
 screen_h = DisplayHeight(dpy, screen);
-XQueryPointer(dpy, root, &w, &w, &pointer_x, &pointer_y, &_, &_, &_);
 if (follow_mouse == -1) {
 // follow the mouse, put it at center of grabbing region
 x_off += pointer_x - s->width / 2 - x_off;
@@ -550,7 +552,7 @@ static int x11grab_read_packet(AVFormatContext *s1, 
AVPacket *pkt)
 s->y_off - REGION_WIN_BORDER);
 }

-if (s->show_region) {
+if (s->show_region && same_screen) {
 if (s->region_win) {
 XEvent evt = { .type = NoEventMask };
 // Clean up the events, and do the initial draw or redraw.
@@ -572,7 +574,7 @@ static int x11grab_read_packet(AVFormatContext *s1, 
AVPacket *pkt)
 av_log(s1, AV_LOG_INFO, "XGetZPixmap() failed\n");
 }

-if (s->draw_mouse)
+if (s->draw_mouse && same_screen)
 paint_mouse_pointer(image, s);

 return s->frame_size;
--
2.1.0

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


Re: [libav-devel] [PATCH] avutil: clean description of channel layouts

2014-09-26 Thread Diego Biurrun
On Tue, Sep 23, 2014 at 02:38:18PM +0200, Marc-Antoine Arnaud wrote:
> --- a/libavutil/channel_layout.c
> +++ b/libavutil/channel_layout.c
> @@ -70,34 +70,33 @@ static const struct {
>  } channel_layout_map[] = {
> -{ "3.0", 3,  AV_CH_LAYOUT_SURROUND },
> -{ "3.0(back)",   3,  AV_CH_LAYOUT_2_1 },
> +{ "3.0(surround)",   3,  AV_CH_LAYOUT_SURROUND },
> +{ "3.0(back)",   3,  AV_CH_LAYOUT_2_1 },

Why did you change this part?

It also breaks the fate-lavr-mix-output-zero test.

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


Re: [libav-devel] [PATCH 2/6] pixdesc: return color properties names

2014-09-26 Thread Luca Barbato

On 26/09/14 18:22, Vittorio Giovara wrote:

---
  doc/APIchanges  |  3 +++
  libavutil/pixdesc.c | 58 +
  libavutil/pixdesc.h | 25 +++
  libavutil/version.h |  4 ++--
  4 files changed, 88 insertions(+), 2 deletions(-)



Looks ok to me, I didn't check that every value matches one by one, but 
looks like so.


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


Re: [libav-devel] [PATCH 1/6] pixfmt: mark further reserved values

2014-09-26 Thread Luca Barbato

On 26/09/14 18:22, Vittorio Giovara wrote:

---
  libavutil/pixfmt.h  | 2 ++
  libavutil/version.h | 2 +-
  2 files changed, 3 insertions(+), 1 deletion(-)



Looks fine to me.

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


Re: [libav-devel] [PATCH 1/6] pixfmt: mark further reserved values

2014-09-26 Thread Luca Barbato

On 26/09/14 18:22, Vittorio Giovara wrote:

---
  libavutil/pixfmt.h  | 2 ++
  libavutil/version.h | 2 +-
  2 files changed, 3 insertions(+), 1 deletion(-)



Is this set covered by fate? If yes oracle might like it.

lu

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


Re: [libav-devel] [PATCH 1/2] mlpdec: support major sync headers with optional extension blocks

2014-09-26 Thread Diego Biurrun
On Fri, Sep 26, 2014 at 01:49:20PM +0200, Hendrik Leppkes wrote:
> --- a/libavcodec/mlp_parser.c
> +++ b/libavcodec/mlp_parser.c
> @@ -119,6 +119,23 @@ static uint64_t truehd_layout(int chanmap)
>  
> +static int ff_mlp_get_major_sync_size(const uint8_t * buf, int bufsize)
> +{
> +int has_extension, extensions = 0;
> +int size = 28;
> +if (bufsize < 28)
> +return -1;

AVERROR_INVALIDDATA is likely more appropriate.

> +if (AV_RB32(buf) == 0xf8726fba) {
> +has_extension = buf[25] & 1;
> +if (has_extension) {
> +extensions = buf[26] >> 4;
> +size += 2 + extensions * 2;
> +}
> +}
> +return size;
> +}
> @@ -127,18 +144,19 @@ static uint64_t truehd_layout(int chanmap)
>  
>  int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, GetBitContext *gb)
>  {
> -if (gb->size_in_bits < 28 << 3) {
> +header_size = ff_mlp_get_major_sync_size(gb->buffer, gb->size_in_bits >> 
> 3);
> +if (header_size < 0 || gb->size_in_bits < header_size << 3) {
>  av_log(log, AV_LOG_ERROR, "packet too short, unable to read major 
> sync\n");
>  return -1;
>  }
>  
> -checksum = ff_mlp_checksum16(gb->buffer, 26);
> -if (checksum != AV_RL16(gb->buffer+26)) {
> +checksum = ff_mlp_checksum16(gb->buffer, header_size - 2);
> +if (checksum != AV_RL16(gb->buffer+header_size-2)) {
>  av_log(log, AV_LOG_ERROR, "major sync info header checksum error\n");
>  return AVERROR_INVALIDDATA;
>  }
> @@ -197,7 +216,7 @@ int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, 
> GetBitContext *gb)
>  
>  mh->num_substreams = get_bits(gb, 4);
>  
> -skip_bits_long(gb, 4 + 11 * 8);
> +skip_bits_long(gb, 4 + (header_size - 17) * 8);
>  
>  return 0;
>  }
> --- a/libavcodec/mlpdec.c
> +++ b/libavcodec/mlpdec.c
> @@ -1105,7 +1110,7 @@ static int read_access_unit(AVCodecContext *avctx, 
> void* data,
>  if (read_major_sync(m, &gb) < 0)
>  goto error;
>  m->is_major_sync_unit = 1;
> -header_size += 28;
> +header_size += m->major_sync_header_size;
>  }

Do you know what all the magic numbers mean?  25, 26, 28, 0xf8726fba ...
The parser code is quite difficult to follow because of this.

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


[libav-devel] [PATCH 4/6] dump: print detailed color space information

2014-09-26 Thread Vittorio Giovara
---
 libavcodec/utils.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index ac5fb87..9cb3ef8 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1885,6 +1885,24 @@ void avcodec_string(char *buf, int buf_size, 
AVCodecContext *enc, int encode)
  "%s",
  av_get_pix_fmt_name(enc->pix_fmt));
 }
+
+if (enc->color_range != AVCOL_RANGE_UNSPECIFIED)
+snprintf(buf + strlen(buf), buf_size - strlen(buf), ", %s",
+ av_color_range_name(enc->color_range));
+if (enc->colorspace != AVCOL_SPC_UNSPECIFIED ||
+enc->color_primaries != AVCOL_PRI_UNSPECIFIED ||
+enc->color_trc != AVCOL_TRC_UNSPECIFIED) {
+new_line = 1;
+snprintf(buf + strlen(buf), buf_size - strlen(buf), ", %s/%s/%s",
+ av_color_space_name(enc->colorspace),
+ av_color_primaries_name(enc->color_primaries),
+ av_color_transfer_name(enc->color_trc));
+}
+if (av_log_get_level() >= AV_LOG_DEBUG &&
+enc->chroma_sample_location != AVCHROMA_LOC_UNSPECIFIED)
+snprintf(buf + strlen(buf), buf_size - strlen(buf), ", %s",
+ av_chroma_location_name(enc->chroma_sample_location));
+
 if (enc->width) {
 if (new_line)
 snprintf(buf + strlen(buf), buf_size - strlen(buf), "\n  
");
-- 
1.9.3 (Apple Git-50)

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


[libav-devel] [PATCH 2/6] pixdesc: return color properties names

2014-09-26 Thread Vittorio Giovara
---
 doc/APIchanges  |  3 +++
 libavutil/pixdesc.c | 58 +
 libavutil/pixdesc.h | 25 +++
 libavutil/version.h |  4 ++--
 4 files changed, 88 insertions(+), 2 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index f17f1cf..1a57e73 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil: 2014-08-09
 
 API changes, most recent first:
 
+2014-08-xx - xxx - lavu 54.04.0 - pixdesc.h
+  Add API to return the name of frame and context color properties.
+
 2014-08-xx - xxx - lavc 56.1.0 - avcodec.h
   Add AV_PKT_DATA_STEREO3D to export container-level stereo3d information.
 
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 3215276..61d5f92 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -1523,6 +1523,33 @@ const AVPixFmtDescriptor 
av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
 },
 };
 
+static const char *color_range_names[AVCOL_RANGE_NB] = {
+"unknown", "tv", "pc",
+};
+
+static const char *color_primaries_names[AVCOL_PRI_NB] = {
+"reserved", "bt709", "unknown", "reserved", "bt470m",
+"bt470bg", "smpte170m", "smpte240m", "film", "bt2020",
+};
+
+static const char *color_transfer_names[AVCOL_TRC_NB] = {
+"reserved", "bt709", "unknown", "reserved", "bt470m",
+"bt470bg", "smpte170m", "smpte240m", "linear", "log",
+"sqrt", "iec61966-2-4", "bt1361", "iec61966-2-1",
+"bt2020_10", "bt2020_20",
+};
+
+static const char *color_space_names[AVCOL_SPC_NB] = {
+"rgb", "bt709", "unknown", "reserved", "fcc",
+"bt470bg", "smpte170m", "smpte240m", "ycgco",
+"bt2020_ncl", "bt2020_cl",
+};
+
+static const char *chroma_location_names[AVCHROMA_LOC_NB] = {
+"unspecified", "left", "center", "topleft",
+"top", "bottomleft", "bottom",
+};
+
 FF_DISABLE_DEPRECATION_WARNINGS
 static enum AVPixelFormat get_pix_fmt_internal(const char *name)
 {
@@ -1700,3 +1727,34 @@ enum AVPixelFormat av_pix_fmt_swap_endianness(enum 
AVPixelFormat pix_fmt)
 }
 #undef PIX_FMT_SWAP_ENDIANNESS
 }
+
+const char *av_color_range_name(enum AVColorRange range)
+{
+return (unsigned)range < AVCOL_RANGE_NB ?
+color_range_names[range] : NULL;
+}
+
+const char *av_color_primaries_name(enum AVColorPrimaries primaries)
+{
+return (unsigned)primaries < AVCOL_PRI_NB ?
+color_primaries_names[primaries] : NULL;
+}
+
+const char *av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
+{
+return (unsigned)transfer < AVCOL_TRC_NB ?
+color_transfer_names[transfer] : NULL;
+}
+
+const char *av_color_space_name(enum AVColorSpace space)
+{
+return (unsigned)space < AVCOL_SPC_NB ?
+color_space_names[space] : NULL;
+}
+
+const char *av_chroma_location_name(enum AVChromaLocation location)
+{
+return (unsigned)location < AVCHROMA_LOC_NB ?
+chroma_location_names[location] : NULL;
+}
+
diff --git a/libavutil/pixdesc.h b/libavutil/pixdesc.h
index 1c9e0af..23dc009 100644
--- a/libavutil/pixdesc.h
+++ b/libavutil/pixdesc.h
@@ -291,4 +291,29 @@ int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt);
  */
 enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt);
 
+/**
+ * @return the name for provided color range or NULL if unknown.
+ */
+const char *av_color_range_name(enum AVColorRange range);
+
+/**
+ * @return the name for provided color primaries or NULL if unknown.
+ */
+const char *av_color_primaries_name(enum AVColorPrimaries primaries);
+
+/**
+ * @return the name for provided color transfer or NULL if unknown.
+ */
+const char *av_color_transfer_name(enum AVColorTransferCharacteristic 
transfer);
+
+/**
+ * @return the name for provided color space or NULL if unknown.
+ */
+const char *av_color_space_name(enum AVColorSpace space);
+
+/**
+ * @return the name for provided chroma location or NULL if unknown.
+ */
+const char *av_chroma_location_name(enum AVChromaLocation location);
+
 #endif /* AVUTIL_PIXDESC_H */
diff --git a/libavutil/version.h b/libavutil/version.h
index 79da1aa..8279635 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -54,8 +54,8 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR 54
-#define LIBAVUTIL_VERSION_MINOR  3
-#define LIBAVUTIL_VERSION_MICRO  1
+#define LIBAVUTIL_VERSION_MINOR  4
+#define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
-- 
1.9.3 (Apple Git-50)

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


[libav-devel] [PATCH 6/6] avcodec: make sure color_range is properly initialized

2014-09-26 Thread Vittorio Giovara
---
 libavcodec/utils.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 0c36548..7fce674 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1153,6 +1153,11 @@ int attribute_align_arg avcodec_open2(AVCodecContext 
*avctx, const AVCodec *code
 ret = AVERROR(EINVAL);
 goto free_and_end;
 }
+if (avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ420P ||
+avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ422P ||
+avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ440P ||
+avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ444P)
+avctx->color_range = AVCOL_RANGE_JPEG;
 }
 if (avctx->codec->supported_samplerates) {
 for (i = 0; avctx->codec->supported_samplerates[i] != 0; i++)
-- 
1.9.3 (Apple Git-50)

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


[libav-devel] [PATCH 5/6] dump: print the original coded dimensions when available

2014-09-26 Thread Vittorio Giovara
---
 libavcodec/utils.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 9cb3ef8..0c36548 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1912,6 +1912,12 @@ void avcodec_string(char *buf, int buf_size, 
AVCodecContext *enc, int encode)
 snprintf(buf + strlen(buf), buf_size - strlen(buf),
  "%dx%d",
  enc->width, enc->height);
+if (av_log_get_level() >= AV_LOG_VERBOSE &&
+(enc->width != enc->coded_width ||
+ enc->height != enc->coded_height))
+snprintf(buf + strlen(buf), buf_size - strlen(buf),
+ " (%dx%d)", enc->coded_width, enc->coded_height);
+
 av_strlcat(buf, ", ", buf_size);
 if (enc->sample_aspect_ratio.num) {
 av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
-- 
1.9.3 (Apple Git-50)

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


[libav-devel] [PATCH 1/6] pixfmt: mark further reserved values

2014-09-26 Thread Vittorio Giovara
---
 libavutil/pixfmt.h  | 2 ++
 libavutil/version.h | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 47951e0..0cfa1c7 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -304,6 +304,7 @@ enum AVPixelFormat {
   * Chromaticity coordinates of the source primaries.
   */
 enum AVColorPrimaries {
+AVCOL_PRI_RESERVED0   = 0,
 AVCOL_PRI_BT709   = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE 
RP177 Annex B
 AVCOL_PRI_UNSPECIFIED = 2,
 AVCOL_PRI_RESERVED= 3,
@@ -320,6 +321,7 @@ enum AVColorPrimaries {
  * Color Transfer Characteristic.
  */
 enum AVColorTransferCharacteristic {
+AVCOL_TRC_RESERVED0= 0,
 AVCOL_TRC_BT709= 1,  ///< also ITU-R BT1361
 AVCOL_TRC_UNSPECIFIED  = 2,
 AVCOL_TRC_RESERVED = 3,
diff --git a/libavutil/version.h b/libavutil/version.h
index c22d0c5..79da1aa 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -55,7 +55,7 @@
 
 #define LIBAVUTIL_VERSION_MAJOR 54
 #define LIBAVUTIL_VERSION_MINOR  3
-#define LIBAVUTIL_VERSION_MICRO  0
+#define LIBAVUTIL_VERSION_MICRO  1
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
-- 
1.9.3 (Apple Git-50)

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


[libav-devel] [PATCH 3/6] dump: split audio and video probing on multiple lines

2014-09-26 Thread Vittorio Giovara
---
 libavcodec/utils.c | 22 +++---
 libavformat/dump.c | 22 ++
 2 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index c5fa50d..ac5fb87 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1846,6 +1846,7 @@ void avcodec_string(char *buf, int buf_size, 
AVCodecContext *enc, int encode)
 const AVCodec *p;
 char buf1[32];
 int bitrate;
+int new_line = 0;
 AVRational display_aspect_ratio;
 
 if (enc->codec)
@@ -1878,35 +1879,42 @@ void avcodec_string(char *buf, int buf_size, 
AVCodecContext *enc, int encode)
 if (profile)
 snprintf(buf + strlen(buf), buf_size - strlen(buf),
  " (%s)", profile);
+snprintf(buf + strlen(buf), buf_size - strlen(buf), "\n  ");
 if (enc->pix_fmt != AV_PIX_FMT_NONE) {
 snprintf(buf + strlen(buf), buf_size - strlen(buf),
- ", %s",
+ "%s",
  av_get_pix_fmt_name(enc->pix_fmt));
 }
 if (enc->width) {
+if (new_line)
+snprintf(buf + strlen(buf), buf_size - strlen(buf), "\n  
");
+else
+av_strlcat(buf, ", ", buf_size);
+
 snprintf(buf + strlen(buf), buf_size - strlen(buf),
- ", %dx%d",
+ "%dx%d",
  enc->width, enc->height);
+av_strlcat(buf, ", ", buf_size);
 if (enc->sample_aspect_ratio.num) {
 av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
   enc->width * enc->sample_aspect_ratio.num,
   enc->height * enc->sample_aspect_ratio.den,
   1024 * 1024);
 snprintf(buf + strlen(buf), buf_size - strlen(buf),
- " [PAR %d:%d DAR %d:%d]",
+ "[PAR %d:%d DAR %d:%d] ",
  enc->sample_aspect_ratio.num, 
enc->sample_aspect_ratio.den,
  display_aspect_ratio.num, display_aspect_ratio.den);
 }
 if (av_log_get_level() >= AV_LOG_DEBUG) {
 int g = av_gcd(enc->time_base.num, enc->time_base.den);
 snprintf(buf + strlen(buf), buf_size - strlen(buf),
- ", %d/%d",
+ "%d/%d, ",
  enc->time_base.num / g, enc->time_base.den / g);
 }
 }
 if (encode) {
 snprintf(buf + strlen(buf), buf_size - strlen(buf),
- ", q=%d-%d", enc->qmin, enc->qmax);
+ "q=%d-%d", enc->qmin, enc->qmax);
 }
 break;
 case AVMEDIA_TYPE_AUDIO:
@@ -1920,7 +1928,7 @@ void avcodec_string(char *buf, int buf_size, 
AVCodecContext *enc, int encode)
 snprintf(buf + strlen(buf), buf_size - strlen(buf),
  ", %d Hz", enc->sample_rate);
 }
-av_strlcat(buf, ", ", buf_size);
+snprintf(buf + strlen(buf), buf_size - strlen(buf), "\n  ");
 av_get_channel_layout_string(buf + strlen(buf), buf_size - 
strlen(buf), enc->channels, enc->channel_layout);
 if (enc->sample_fmt != AV_SAMPLE_FMT_NONE) {
 snprintf(buf + strlen(buf), buf_size - strlen(buf),
@@ -1951,7 +1959,7 @@ void avcodec_string(char *buf, int buf_size, 
AVCodecContext *enc, int encode)
 bitrate = get_bit_rate(enc);
 if (bitrate != 0) {
 snprintf(buf + strlen(buf), buf_size - strlen(buf),
- ", %d kb/s", bitrate / 1000);
+ "%d kb/s", bitrate / 1000);
 }
 }
 
diff --git a/libavformat/dump.c b/libavformat/dump.c
index 58ed654..649678c 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -116,11 +116,11 @@ static void print_fps(double d, const char *postfix)
 {
 uint64_t v = lrintf(d * 100);
 if (v % 100)
-av_log(NULL, AV_LOG_INFO, ", %3.2f %s", d, postfix);
+av_log(NULL, AV_LOG_INFO, "%3.2f %s", d, postfix);
 else if (v % (100 * 1000))
-av_log(NULL, AV_LOG_INFO, ", %1.0f %s", d, postfix);
+av_log(NULL, AV_LOG_INFO, "%1.0f %s", d, postfix);
 else
-av_log(NULL, AV_LOG_INFO, ", %1.0fk %s", d / 1000, postfix);
+av_log(NULL, AV_LOG_INFO, "%1.0fk %s", d / 1000, postfix);
 }
 
 static void dump_metadata(void *ctx, AVDictionary *m, const char *indent)
@@ -357,11 +357,17 @@ static void dump_stream_format(AVFormatContext *ic, int i,
 }
 
 if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
-if (st->avg_frame_rate.den && st->avg_frame_rate.num)
-print_fps(av_q2d(st->avg_frame_rate), "fps");
-if (st->time_base.den && st->time_base.num)
-print_fps(1 / av_q2d(st->time_base), "tbn");
-if (st->codec->time_base.den && st->codec->time_base.num)
+int fps = st->avg_frame_rate.den && st->avg_frame_rate.num;
+ 

Re: [libav-devel] [PATCH 2/2] mlpdec: support TrueHD streams with an Atmos substream

2014-09-26 Thread Tim Walker
On 26 Sep 2014, at 13:49, Hendrik Leppkes  wrote:

> The fourth substream is being discarded, since its not raw audio data,
> but an encoded Atmos stream which needs a specialized decoder.
> 
> Fixes decoding of the true hd stream from Transformers\ -\ Age\ of\ 
> Extinction\ 2014\ 1080P-003.mkv

s/true hd/truehd

> 
> Signed-off-by: Michael Niedermayer 

If you believe in the patch, signed it off too ;-)

> ---
> libavcodec/mlp.h| 2 +-
> libavcodec/mlpdec.c | 4 +++-
> 2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/mlp.h b/libavcodec/mlp.h
> index 5a4ee5f..8a1584e 100644
> --- a/libavcodec/mlp.h
> +++ b/libavcodec/mlp.h
> @@ -45,7 +45,7 @@
> /** Maximum number of substreams that can be decoded.
>  *  MLP's limit is 2. TrueHD supports at least up to 3.
>  */
> -#define MAX_SUBSTREAMS  3
> +#define MAX_SUBSTREAMS  4
> 
> /** which multiple of 48000 the maximum sample rate is */
> #define MAX_RATEFACTOR  4
> diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
> index ad9e54f..5ace18d 100644
> --- a/libavcodec/mlpdec.c
> +++ b/libavcodec/mlpdec.c
> @@ -355,7 +355,9 @@ static int read_major_sync(MLPDecodeContext *m, 
> GetBitContext *gb)
> m->access_unit_size_pow2 = mh.access_unit_size_pow2;
> 
> m->num_substreams= mh.num_substreams;
> -m->max_decoded_substream = m->num_substreams - 1;
> +
> +/* limit to decoding 3 substreams, as the 4th is used by Dolby Atmos for 
> non-audio data */

I don't really like this comment. Maybe "non-MLP data"? Also, but even more 
minor: "limit decoding to 3 substreams" perhaps? And while we're at it, "can be 
used"?

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


Re: [libav-devel] [PATCH 2/2] mlpdec: support TrueHD streams with an Atmos substream

2014-09-26 Thread Diego Biurrun
On Fri, Sep 26, 2014 at 01:49:21PM +0200, Hendrik Leppkes wrote:
> The fourth substream is being discarded, since its not raw audio data,
> but an encoded Atmos stream which needs a specialized decoder.
> 
> Fixes decoding of the true hd stream from Transformers\ -\ Age\ of\ 
> Extinction\ 2014\ 1080P-003.mkv
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/mlp.h| 2 +-
>  libavcodec/mlpdec.c | 4 +++-
>  2 files changed, 4 insertions(+), 2 deletions(-)

probably OK

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


Re: [libav-devel] [PATCH] x11grab: Check the XQueryPointer return value

2014-09-26 Thread Luca Barbato

On 26/09/14 12:15, Antonio Ospite wrote:

On Fri, 26 Sep 2014 00:49:03 +0200
Luca Barbato  wrote:


And disable follow_mouse and draw_mouse accordingly.

Prevent spurious updates on multi screen setups.

Reported-By: Antonio Ospite 


Only Reported-By?


---

Eventually I had time to reload X11 and test the setup Antonio suggested.
I wonder if follow_mouse shouldn't follow across multiple screens now.




BTW, I see that you rewrote the fix instead of using the one I sent.

In general I'd like people to ask me to fix and resend, especially
considering the fact that I put a _lot_ of effort and time in writing
commit messages...


I told you before that follow_mouse required the same fix, while 
checking the code I came up with this patch.



If you wanted to do minor adjustments to the code yourself, fine, but my
commit message and authorship should have been preserved, I put the
brain power in this case ;P



Anyway, the _most_ important thing is that the problem gets fixed, but
please, next time, some more diplomacy wouldn't hurt.


The patch can be changed =)


The reader have to think about yet another condition when just calling
the function unconditionally has a negligible performance effect.
Same goes for xcbgrab.


I'm not sure about that.


+if (same_screen && follow_mouse) {
  int screen_w, screen_h;
-int pointer_x, pointer_y, _;
-Window w;

  screen_w = DisplayWidth(dpy, screen);
  screen_h = DisplayHeight(dpy, screen);
-XQueryPointer(dpy, root, &w, &w, &pointer_x, &pointer_y, &_, &_, &_);
  if (follow_mouse == -1) {
  // follow the mouse, put it at center of grabbing region
  x_off += pointer_x - s->width / 2 - x_off;
@@ -572,7 +574,7 @@ static int x11grab_read_packet(AVFormatContext *s1, 
AVPacket *pkt)
  av_log(s1, AV_LOG_INFO, "XGetZPixmap() failed\n");
  }



What about the check for show_region?
For symmetry it makes sense to check for same_screen there too.


If the position doesn't change show region does nothing we can add the 
same check for consistency indeed.


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


[libav-devel] [PATCH 1/2] mlpdec: support major sync headers with optional extension blocks

2014-09-26 Thread Hendrik Leppkes
Signed-off-by: Michael Niedermayer 
---
 libavcodec/mlp_parser.c | 29 -
 libavcodec/mlp_parser.h |  1 +
 libavcodec/mlpdec.c |  7 ++-
 3 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/libavcodec/mlp_parser.c b/libavcodec/mlp_parser.c
index 075227f..0c7d4a2 100644
--- a/libavcodec/mlp_parser.c
+++ b/libavcodec/mlp_parser.c
@@ -119,6 +119,23 @@ static uint64_t truehd_layout(int chanmap)
 return layout;
 }
 
+static int ff_mlp_get_major_sync_size(const uint8_t * buf, int bufsize)
+{
+int has_extension, extensions = 0;
+int size = 28;
+if (bufsize < 28)
+return -1;
+
+if (AV_RB32(buf) == 0xf8726fba) {
+has_extension = buf[25] & 1;
+if (has_extension) {
+extensions = buf[26] >> 4;
+size += 2 + extensions * 2;
+}
+}
+return size;
+}
+
 /** Read a major sync info header - contains high level information about
  *  the stream - sample rate, channel arrangement etc. Most of this
  *  information is not actually necessary for decoding, only for playback.
@@ -127,18 +144,19 @@ static uint64_t truehd_layout(int chanmap)
 
 int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, GetBitContext *gb)
 {
-int ratebits, channel_arrangement;
+int ratebits, channel_arrangement, header_size;
 uint16_t checksum;
 
 assert(get_bits_count(gb) == 0);
 
-if (gb->size_in_bits < 28 << 3) {
+header_size = ff_mlp_get_major_sync_size(gb->buffer, gb->size_in_bits >> 
3);
+if (header_size < 0 || gb->size_in_bits < header_size << 3) {
 av_log(log, AV_LOG_ERROR, "packet too short, unable to read major 
sync\n");
 return -1;
 }
 
-checksum = ff_mlp_checksum16(gb->buffer, 26);
-if (checksum != AV_RL16(gb->buffer+26)) {
+checksum = ff_mlp_checksum16(gb->buffer, header_size - 2);
+if (checksum != AV_RL16(gb->buffer+header_size-2)) {
 av_log(log, AV_LOG_ERROR, "major sync info header checksum error\n");
 return AVERROR_INVALIDDATA;
 }
@@ -147,6 +165,7 @@ int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, 
GetBitContext *gb)
 return AVERROR_INVALIDDATA;
 
 mh->stream_type = get_bits(gb, 8);
+mh->header_size = header_size;
 
 if (mh->stream_type == 0xbb) {
 mh->group1_bits = mlp_quants[get_bits(gb, 4)];
@@ -197,7 +216,7 @@ int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, 
GetBitContext *gb)
 
 mh->num_substreams = get_bits(gb, 4);
 
-skip_bits_long(gb, 4 + 11 * 8);
+skip_bits_long(gb, 4 + (header_size - 17) * 8);
 
 return 0;
 }
diff --git a/libavcodec/mlp_parser.h b/libavcodec/mlp_parser.h
index 7530fac..06ab421 100644
--- a/libavcodec/mlp_parser.h
+++ b/libavcodec/mlp_parser.h
@@ -32,6 +32,7 @@
 typedef struct MLPHeaderInfo
 {
 int stream_type;///< 0xBB for MLP, 0xBA for TrueHD
+int header_size;///< Size of the major sync 
header, in bytes
 
 int group1_bits;///< The bit depth of the first 
substream
 int group2_bits;///< Bit depth of the second 
substream (MLP only)
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index 6baf4c1..ad9e54f 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -132,6 +132,9 @@ typedef struct MLPDecodeContext {
 /// Current access unit being read has a major sync.
 int is_major_sync_unit;
 
+/// Size of the major sync unit, in bytes
+int major_sync_header_size;
+
 /// Set if a valid major sync block has been read. Otherwise no decoding 
is possible.
 uint8_t params_valid;
 
@@ -346,6 +349,8 @@ static int read_major_sync(MLPDecodeContext *m, 
GetBitContext *gb)
 return AVERROR_PATCHWELCOME;
 }
 
+m->major_sync_header_size = mh.header_size;
+
 m->access_unit_size  = mh.access_unit_size;
 m->access_unit_size_pow2 = mh.access_unit_size_pow2;
 
@@ -1105,7 +1110,7 @@ static int read_access_unit(AVCodecContext *avctx, void* 
data,
 if (read_major_sync(m, &gb) < 0)
 goto error;
 m->is_major_sync_unit = 1;
-header_size += 28;
+header_size += m->major_sync_header_size;
 }
 
 if (!m->params_valid) {
-- 
1.9.4.msysgit.1

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


[libav-devel] [PATCH 2/2] mlpdec: support TrueHD streams with an Atmos substream

2014-09-26 Thread Hendrik Leppkes
The fourth substream is being discarded, since its not raw audio data,
but an encoded Atmos stream which needs a specialized decoder.

Fixes decoding of the true hd stream from Transformers\ -\ Age\ of\ Extinction\ 
2014\ 1080P-003.mkv

Signed-off-by: Michael Niedermayer 
---
 libavcodec/mlp.h| 2 +-
 libavcodec/mlpdec.c | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mlp.h b/libavcodec/mlp.h
index 5a4ee5f..8a1584e 100644
--- a/libavcodec/mlp.h
+++ b/libavcodec/mlp.h
@@ -45,7 +45,7 @@
 /** Maximum number of substreams that can be decoded.
  *  MLP's limit is 2. TrueHD supports at least up to 3.
  */
-#define MAX_SUBSTREAMS  3
+#define MAX_SUBSTREAMS  4
 
 /** which multiple of 48000 the maximum sample rate is */
 #define MAX_RATEFACTOR  4
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index ad9e54f..5ace18d 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -355,7 +355,9 @@ static int read_major_sync(MLPDecodeContext *m, 
GetBitContext *gb)
 m->access_unit_size_pow2 = mh.access_unit_size_pow2;
 
 m->num_substreams= mh.num_substreams;
-m->max_decoded_substream = m->num_substreams - 1;
+
+/* limit to decoding 3 substreams, as the 4th is used by Dolby Atmos for 
non-audio data */
+m->max_decoded_substream = FFMIN(m->num_substreams - 1, 2);
 
 m->avctx->sample_rate= mh.group1_samplerate;
 m->avctx->frame_size = mh.access_unit_size;
-- 
1.9.4.msysgit.1

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


Re: [libav-devel] [PATCH] x11grab: Check the XQueryPointer return value

2014-09-26 Thread Antonio Ospite
On Fri, 26 Sep 2014 00:49:03 +0200
Luca Barbato  wrote:

> And disable follow_mouse and draw_mouse accordingly.
> 
> Prevent spurious updates on multi screen setups.
> 
> Reported-By: Antonio Ospite 

Only Reported-By?

> ---
> 
> Eventually I had time to reload X11 and test the setup Antonio suggested.
> I wonder if follow_mouse shouldn't follow across multiple screens now.
>

Naah, when you pass "-i :0.1" you are specifying what _screen_ to
capture, and when you say "-i :0" X11 automatically interprets this as
":0.0", so also in this case, from a logic point of view, capture is
meant to be restricted to one screen only.

BTW, I see that you rewrote the fix instead of using the one I sent.

In general I'd like people to ask me to fix and resend, especially
considering the fact that I put a _lot_ of effort and time in writing
commit messages...

If you wanted to do minor adjustments to the code yourself, fine, but my
commit message and authorship should have been preserved, I put the
brain power in this case ;P

Anyway, the _most_ important thing is that the problem gets fixed, but
please, next time, some more diplomacy wouldn't hurt.

A couple of comments inlined.

Thanks,
   Antonio

>  libavdevice/x11grab.c | 16 +---
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c
> index 1f91be9..0cb4414 100644
> --- a/libavdevice/x11grab.c
> +++ b/libavdevice/x11grab.c
> @@ -487,8 +487,8 @@ static int x11grab_read_packet(AVFormatContext *s1, 
> AVPacket *pkt)
>  int x_off = s->x_off;
>  int y_off = s->y_off;
>  int follow_mouse  = s->follow_mouse;
> -int screen;
> -Window root;
> +int screen, pointer_x, pointer_y, _, same_screen = 0;
> +Window w, root;
>  int64_t curtime, delay;
>  struct timespec ts;
> 
> @@ -516,14 +516,16 @@ static int x11grab_read_packet(AVFormatContext *s1, 
> AVPacket *pkt)
> 
>  screen = DefaultScreen(dpy);
>  root   = RootWindow(dpy, screen);
> -if (follow_mouse) {
> +
> +if (follow_mouse || s->draw_mouse)
> +same_screen = XQueryPointer(dpy, root, &w, &w,
> +&pointer_x, &pointer_y, &_, &_, &_);
> +

Although this logic is correct I feel it makes the code heavier on
the reader's mind.

The reader have to think about yet another condition when just calling
the function unconditionally has a negligible performance effect.
Same goes for xcbgrab.

> +if (same_screen && follow_mouse) {
>  int screen_w, screen_h;
> -int pointer_x, pointer_y, _;
> -Window w;
> 
>  screen_w = DisplayWidth(dpy, screen);
>  screen_h = DisplayHeight(dpy, screen);
> -XQueryPointer(dpy, root, &w, &w, &pointer_x, &pointer_y, &_, &_, &_);
>  if (follow_mouse == -1) {
>  // follow the mouse, put it at center of grabbing region
>  x_off += pointer_x - s->width / 2 - x_off;
> @@ -572,7 +574,7 @@ static int x11grab_read_packet(AVFormatContext *s1, 
> AVPacket *pkt)
>  av_log(s1, AV_LOG_INFO, "XGetZPixmap() failed\n");
>  }
>

What about the check for show_region?
For symmetry it makes sense to check for same_screen there too.

> -if (s->draw_mouse)
> +if (same_screen && s->draw_mouse)
>  paint_mouse_pointer(image, s);
> 
>  return s->frame_size;
> --
> 2.1.0
> 
> ___
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel


-- 
Antonio Ospite
http://ao2.it

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] pcm-dvd: Move a variable to a smaller scope

2014-09-26 Thread Luca Barbato

On 26/09/14 09:42, Diego Biurrun wrote:

This avoids an unused variable warning on big-endian systems.
---
  libavcodec/pcm-dvd.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/pcm-dvd.c b/libavcodec/pcm-dvd.c
index 0872d29..791df54 100644
--- a/libavcodec/pcm-dvd.c
+++ b/libavcodec/pcm-dvd.c
@@ -154,21 +154,22 @@ static void *pcm_dvd_decode_samples(AVCodecContext 
*avctx, const uint8_t *src,
  GetByteContext gb;
  int i;
  uint8_t t;
-int samples;

  bytestream2_init(&gb, src, blocks * s->block_size);
  switch (avctx->bits_per_coded_sample) {
  case 16:
+{


Usually we put it in front of ": "


  #if HAVE_BIGENDIAN
  bytestream2_get_buffer(&gb, dst16, blocks * s->block_size);
  dst16 += blocks * s->block_size / 2;
  #else
-samples = blocks * avctx->channels;
+int samples = blocks * avctx->channels;
  do {
  *dst16++ = bytestream2_get_be16u(&gb);
  } while (--samples);
  #endif
  return dst16;
+}
  case 20:
  do {
  for (i = s->groups_per_block; i; i--) {



Beside that looks fine to me.

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


[libav-devel] [PATCH] pcm-dvd: Move a variable to a smaller scope

2014-09-26 Thread Diego Biurrun
This avoids an unused variable warning on big-endian systems.
---
 libavcodec/pcm-dvd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/pcm-dvd.c b/libavcodec/pcm-dvd.c
index 0872d29..791df54 100644
--- a/libavcodec/pcm-dvd.c
+++ b/libavcodec/pcm-dvd.c
@@ -154,21 +154,22 @@ static void *pcm_dvd_decode_samples(AVCodecContext 
*avctx, const uint8_t *src,
 GetByteContext gb;
 int i;
 uint8_t t;
-int samples;
 
 bytestream2_init(&gb, src, blocks * s->block_size);
 switch (avctx->bits_per_coded_sample) {
 case 16:
+{
 #if HAVE_BIGENDIAN
 bytestream2_get_buffer(&gb, dst16, blocks * s->block_size);
 dst16 += blocks * s->block_size / 2;
 #else
-samples = blocks * avctx->channels;
+int samples = blocks * avctx->channels;
 do {
 *dst16++ = bytestream2_get_be16u(&gb);
 } while (--samples);
 #endif
 return dst16;
+}
 case 20:
 do {
 for (i = s->groups_per_block; i; i--) {
-- 
2.1.0

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