[FFmpeg-cvslog] avcodec/hevc_ps: Check num_long_term_ref_pics_sps

2014-11-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Fri Nov 28 
03:46:56 2014 +0100| [ea38e5a6b75706477898eb1e6582d667dbb9946c] | committer: 
Michael Niedermayer

avcodec/hevc_ps: Check num_long_term_ref_pics_sps

Fixes out of array access
Fixes: signal_sigsegv_35bd0f0_1182_cov_791726764_STRUCT_B_Samsung_4.bit
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer 

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

 libavcodec/hevc_ps.c |5 +
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 1f64971..6b5e13f 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -951,6 +951,11 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
 sps->long_term_ref_pics_present_flag = get_bits1(gb);
 if (sps->long_term_ref_pics_present_flag) {
 sps->num_long_term_ref_pics_sps = get_ue_golomb_long(gb);
+if (sps->num_long_term_ref_pics_sps > 31U) {
+av_log(0, AV_LOG_ERROR, "num_long_term_ref_pics_sps %d is out of 
range.\n",
+   sps->num_long_term_ref_pics_sps);
+goto err;
+}
 for (i = 0; i < sps->num_long_term_ref_pics_sps; i++) {
 sps->lt_ref_pic_poc_lsb_sps[i]   = get_bits(gb, 
sps->log2_max_poc_lsb);
 sps->used_by_curr_pic_lt_sps_flag[i] = get_bits1(gb);

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


[FFmpeg-cvslog] avcodec/pngdec: split P frames handling to a separate function.

2014-11-27 Thread Benoit Fouet
ffmpeg | branch: master | Benoit Fouet  | Thu Nov 27 
15:26:26 2014 +0100| [7dfee8d69793030e5829fc19715982c580a752f8] | committer: 
Michael Niedermayer

avcodec/pngdec: split P frames handling to a separate function.

Signed-off-by: Michael Niedermayer 

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

 libavcodec/pngdec.c |   29 +
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index 35dcd76..8529956 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -825,6 +825,22 @@ static int decode_fctl_chunk(AVCodecContext *avctx, 
PNGDecContext *s,
 return 0;
 }
 
+static void handle_p_frame_png(PNGDecContext *s, AVFrame *p)
+{
+int i, j;
+uint8_t *pd  = p->data[0];
+uint8_t *pd_last = s->last_picture.f->data[0];
+int ls = FFMIN(av_image_get_linesize(p->format, s->width, 0), s->width * 
s->bpp);
+
+ff_thread_await_progress(&s->last_picture, INT_MAX, 0);
+for (j = 0; j < s->height; j++) {
+for (i = 0; i < ls; i++)
+pd[i] += pd_last[i];
+pd  += s->image_linesize;
+pd_last += s->image_linesize;
+}
+}
+
 static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
AVFrame *p, AVPacket *avpkt)
 {
@@ -936,18 +952,7 @@ exit_loop:
 && s->last_picture.f->height== p->height
 && s->last_picture.f->format== p->format
  ) {
-int i, j;
-uint8_t *pd  = p->data[0];
-uint8_t *pd_last = s->last_picture.f->data[0];
-int ls = FFMIN(av_image_get_linesize(p->format, s->width, 0), 
s->width * s->bpp);
-
-ff_thread_await_progress(&s->last_picture, INT_MAX, 0);
-for (j = 0; j < s->height; j++) {
-for (i = 0; i < ls; i++)
-pd[i] += pd_last[i];
-pd  += s->image_linesize;
-pd_last += s->image_linesize;
-}
+handle_p_frame_png(s, p);
 }
 }
 ff_thread_report_progress(&s->picture, INT_MAX, 0);

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


[FFmpeg-cvslog] avcodec/pngdec: add support for 'over' blend operation for 'none' dispose operation.

2014-11-27 Thread Benoit Fouet
ffmpeg | branch: master | Benoit Fouet  | Thu Nov 27 
15:26:27 2014 +0100| [cfd83a8af6bfc1c75f019816200f36cbf0418c1b] | committer: 
Michael Niedermayer

avcodec/pngdec: add support for 'over' blend operation for 'none' dispose 
operation.

Signed-off-by: Michael Niedermayer 

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

 libavcodec/pngdec.c |  160 ++-
 1 file changed, 133 insertions(+), 27 deletions(-)

diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index 8529956..4c9d321 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -29,6 +29,7 @@
 #include "png.h"
 #include "pngdsp.h"
 #include "thread.h"
+#include "libavformat/apng.h"
 
 #include 
 
@@ -42,6 +43,9 @@ typedef struct PNGDecContext {
 
 int state;
 int width, height;
+int cur_w, cur_h;
+int x_offset, y_offset;
+uint8_t dispose_op, blend_op;
 int bit_depth;
 int color_type;
 int compression_type;
@@ -300,7 +304,7 @@ static void png_handle_row(PNGDecContext *s)
 int got_line;
 
 if (!s->interlace_type) {
-ptr = s->image_buf + s->image_linesize * s->y;
+ptr = s->image_buf + s->image_linesize * (s->y + s->y_offset) + 
s->x_offset * s->bpp;
 if (s->y == 0)
 last_row = s->last_row;
 else
@@ -319,7 +323,7 @@ static void png_handle_row(PNGDecContext *s)
 }
 }
 s->y++;
-if (s->y == s->height) {
+if (s->y == s->cur_h) {
 s->state |= PNG_ALLIMAGE;
 if (s->filter_type == PNG_FILTER_TYPE_LOCO) {
 if (s->bit_depth == 16) {
@@ -334,7 +338,7 @@ static void png_handle_row(PNGDecContext *s)
 } else {
 got_line = 0;
 for (;;) {
-ptr = s->image_buf + s->image_linesize * s->y;
+ptr = s->image_buf + s->image_linesize * (s->y + s->y_offset) + 
s->x_offset * s->bpp;
 if ((ff_png_pass_ymask[s->pass] << (s->y & 7)) & 0x80) {
 /* if we already read one row, it is time to stop to
  * wait for the next one */
@@ -347,11 +351,11 @@ static void png_handle_row(PNGDecContext *s)
 got_line = 1;
 }
 if ((png_pass_dsp_ymask[s->pass] << (s->y & 7)) & 0x80) {
-png_put_interlaced_row(ptr, s->width, s->bits_per_pixel, 
s->pass,
+png_put_interlaced_row(ptr, s->cur_w, s->bits_per_pixel, 
s->pass,
s->color_type, s->last_row);
 }
 s->y++;
-if (s->y == s->height) {
+if (s->y == s->cur_h) {
 memset(s->last_row, 0, s->row_size);
 for (;;) {
 if (s->pass == NB_PASSES - 1) {
@@ -362,7 +366,7 @@ static void png_handle_row(PNGDecContext *s)
 s->y = 0;
 s->pass_row_size = ff_png_pass_row_size(s->pass,
 
s->bits_per_pixel,
-s->width);
+s->cur_w);
 s->crow_size = s->pass_row_size + 1;
 if (s->pass_row_size != 0)
 break;
@@ -532,8 +536,8 @@ static int decode_ihdr_chunk(AVCodecContext *avctx, 
PNGDecContext *s,
 return AVERROR_INVALIDDATA;
 }
 
-s->width  = bytestream2_get_be32(&s->gb);
-s->height = bytestream2_get_be32(&s->gb);
+s->width  = s->cur_w = bytestream2_get_be32(&s->gb);
+s->height = s->cur_h = bytestream2_get_be32(&s->gb);
 if (av_image_check_size(s->width, s->height, 0, avctx)) {
 s->width = s->height = 0;
 av_log(avctx, AV_LOG_ERROR, "Invalid image size\n");
@@ -588,7 +592,7 @@ static int decode_idat_chunk(AVCodecContext *avctx, 
PNGDecContext *s,
 s->channels   = ff_png_get_nb_channels(s->color_type);
 s->bits_per_pixel = s->bit_depth * s->channels;
 s->bpp= (s->bits_per_pixel + 7) >> 3;
-s->row_size   = (avctx->width * s->bits_per_pixel + 7) >> 3;
+s->row_size   = (s->cur_w * s->bits_per_pixel + 7) >> 3;
 
 if ((s->bit_depth == 2 || s->bit_depth == 4 || s->bit_depth == 8) &&
 s->color_type == PNG_COLOR_TYPE_RGB) {
@@ -641,7 +645,7 @@ static int decode_idat_chunk(AVCodecContext *avctx, 
PNGDecContext *s,
 s->pass  = 0;
 s->pass_row_size = ff_png_pass_row_size(s->pass,
 s->bits_per_pixel,
-s->width);
+s->cur_w);
 s->crow_size = s->pass_row_size + 1;
 }
 av_dlog(avctx, "row_size=%d crow_size =%d\n",
@@ -670,6 +674,10 @@ static int decode_idat_chunk(AVCodecContext *avctx, 
PNGDecContext *s,
 s->crow_buf  = s->buffer + 15;

[FFmpeg-cvslog] Move extralibs variables using ldl after ldl definition

2014-11-27 Thread Timo Rothenpieler
ffmpeg | branch: master | Timo Rothenpieler  | Thu Nov 
27 13:35:48 2014 +0100| [95fc80672ffeebbedc1700065b8b914db8b5d277] | committer: 
Michael Niedermayer

Move extralibs variables using ldl after ldl definition

Signed-off-by: Michael Niedermayer 

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

 configure |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 2810a03..d4a86c0 100755
--- a/configure
+++ b/configure
@@ -2570,16 +2570,13 @@ drawtext_filter_deps="libfreetype"
 ebur128_filter_deps="gpl"
 flite_filter_deps="libflite"
 frei0r_filter_deps="frei0r dlopen"
-frei0r_filter_extralibs='$ldl'
 frei0r_src_filter_deps="frei0r dlopen"
-frei0r_src_filter_extralibs='$ldl'
 geq_filter_deps="gpl"
 histeq_filter_deps="gpl"
 hqdn3d_filter_deps="gpl"
 interlace_filter_deps="gpl"
 kerndeint_filter_deps="gpl"
 ladspa_filter_deps="ladspa dlopen"
-ladspa_filter_extralibs='$ldl'
 mcdeint_filter_deps="avcodec gpl"
 movie_filter_deps="avcodec avformat"
 mp_filter_deps="gpl avcodec swscale"
@@ -4651,6 +4648,10 @@ elif check_func dlopen -ldl; then
 ldl=-ldl
 fi
 
+frei0r_filter_extralibs='$ldl'
+frei0r_src_filter_extralibs='$ldl'
+ladspa_filter_extralibs='$ldl'
+
 if ! disabled network; then
 check_func getaddrinfo $network_extralibs
 check_func getservbyport $network_extralibs

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


[FFmpeg-cvslog] avutil/buffer_internal: leave the buffer pool entries volatile

2014-11-27 Thread Michael Niedermayer
ffmpeg | branch: release/2.4 | Michael Niedermayer  | Fri Nov 
28 01:17:56 2014 +0100| [0e216ed40789e382eb6725d1cd0941927bfd1400] | committer: 
Michael Niedermayer

avutil/buffer_internal: leave the buffer pool entries volatile

Theres no reason to remove the volatile keyword in a release branch

Signed-off-by: Michael Niedermayer 

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

 libavutil/buffer_internal.h |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavutil/buffer_internal.h b/libavutil/buffer_internal.h
index e653048..befeb68 100644
--- a/libavutil/buffer_internal.h
+++ b/libavutil/buffer_internal.h
@@ -69,12 +69,12 @@ typedef struct BufferPoolEntry {
 void (*free)(void *opaque, uint8_t *data);
 
 AVBufferPool *pool;
-struct BufferPoolEntry *next;
+struct BufferPoolEntry * volatile next;
 } BufferPoolEntry;
 
 struct AVBufferPool {
 AVMutex mutex;
-BufferPoolEntry *pool;
+BufferPoolEntry * volatile pool;
 
 /*
  * This is used to track when the pool is to be freed.

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


[FFmpeg-cvslog] Merge commit 'ca78ee73db9e059f501706ba6108e23902e84933' into release/2.4

2014-11-27 Thread Michael Niedermayer
ffmpeg | branch: release/2.4 | Michael Niedermayer  | Fri Nov 
28 01:19:28 2014 +0100| [56b84b023d705a2716a5a52948584874c8db7b05] | committer: 
Michael Niedermayer

Merge commit 'ca78ee73db9e059f501706ba6108e23902e84933' into release/2.4

* commit 'ca78ee73db9e059f501706ba6108e23902e84933':
  opusdec: make sure all substreams have the same number of coded samples

Merged-by: Michael Niedermayer 

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



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


[FFmpeg-cvslog] opusdec: make sure all substreams have the same number of coded samples

2014-11-27 Thread Anton Khirnov
ffmpeg | branch: release/2.4 | Anton Khirnov  | Mon Nov 24 
11:16:46 2014 +0100| [ca78ee73db9e059f501706ba6108e23902e84933] | committer: 
Anton Khirnov

opusdec: make sure all substreams have the same number of coded samples

Fixes invalid writes with invalid multichannel streams.

CC:libav-sta...@libav.org
(cherry picked from commit 1973079417e8701b52ba810a72cb6c7c6f7f9a56)
Signed-off-by: Anton Khirnov 

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

 libavcodec/opusdec.c |6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/opusdec.c b/libavcodec/opusdec.c
index bf3a54b..771922e 100644
--- a/libavcodec/opusdec.c
+++ b/libavcodec/opusdec.c
@@ -500,6 +500,12 @@ static int opus_decode_packet(AVCodecContext *avctx, void 
*data,
 av_log(avctx, AV_LOG_ERROR, "Error parsing the packet 
header.\n");
 return ret;
 }
+if (coded_samples != s->packet.frame_count * 
s->packet.frame_duration) {
+av_log(avctx, AV_LOG_ERROR,
+   "Mismatching coded sample count in substream %d.\n", i);
+return AVERROR_INVALIDDATA;
+}
+
 s->silk_samplerate = get_silk_samplerate(s->packet.config);
 }
 

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


[FFmpeg-cvslog] avutil/buffer: use the old atomics based code for the release branch

2014-11-27 Thread Michael Niedermayer
ffmpeg | branch: release/2.4 | Michael Niedermayer  | Fri Nov 
28 01:01:17 2014 +0100| [f783259fdb37e288643fe54ac162d723b1bec548] | committer: 
Michael Niedermayer

avutil/buffer: use the old atomics based code for the release branch

the old code worked fine for a long time and was not affected by
the bug the new code fixes and the new is not widely tested yet.
This can be reverted once the code received more testing in
master

Signed-off-by: Michael Niedermayer 

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

 libavutil/buffer.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavutil/buffer.c b/libavutil/buffer.c
index 0f9f1a2..4e2a94b 100644
--- a/libavutil/buffer.c
+++ b/libavutil/buffer.c
@@ -25,7 +25,8 @@
 #include "mem.h"
 #include "thread.h"
 
-#define USE_ATOMICS !(HAVE_PTHREADS || HAVE_W32THREADS)
+//#define USE_ATOMICS !(HAVE_PTHREADS || HAVE_W32THREADS)
+#define USE_ATOMICS 1 // can be changed to the above once it received more 
testing in master
 
 AVBufferRef *av_buffer_create(uint8_t *data, int size,
   void (*free)(void *opaque, uint8_t *data),

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


[FFmpeg-cvslog] lavu: fix memory leaks by using a mutex instead of atomics

2014-11-27 Thread wm4
ffmpeg | branch: release/2.4 | wm4  | Fri Nov 14 
13:34:50 2014 +0100| [517ce1d09b5e6b72afc2ef9490b5f8ca42fa6a65] | committer: 
Anton Khirnov

lavu: fix memory leaks by using a mutex instead of atomics

The buffer pool has to atomically add and remove entries from the linked
list of available buffers. This was done by removing the entire list
with a CAS operation, working on it, and then setting it back again
(using a retry-loop in case another thread was doing the same thing).

This could effectively cause memory leaks: while a thread was working on
the buffer list, other threads would allocate new buffers, increasing
the pool's total size. There was no real leak, but since these extra
buffers were not needed, but not free'd either (except when the buffer
pool was destroyed), this had the same effects as a real leak. For some
reason, growth was exponential, and could easily kill the process due
to OOM in real-world uses.

Fix this by using a mutex to protect the list operations. The fancy
way atomics remove the whole list to work on it is not needed anymore,
which also avoids the situation which was causing the leak.

Signed-off-by: Anton Khirnov 
(cherry picked from commit fbd6c97f9ca858140df16dd07200ea0d4bdc1a83)
Signed-off-by: Anton Khirnov 

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

 libavutil/buffer.c  |   79 ++-
 libavutil/buffer_internal.h |6 ++--
 2 files changed, 29 insertions(+), 56 deletions(-)

diff --git a/libavutil/buffer.c b/libavutil/buffer.c
index 2b38081..1bc4a93 100644
--- a/libavutil/buffer.c
+++ b/libavutil/buffer.c
@@ -23,6 +23,7 @@
 #include "buffer_internal.h"
 #include "common.h"
 #include "mem.h"
+#include "thread.h"
 
 AVBufferRef *av_buffer_create(uint8_t *data, int size,
   void (*free)(void *opaque, uint8_t *data),
@@ -199,6 +200,8 @@ AVBufferPool *av_buffer_pool_init(int size, AVBufferRef* 
(*alloc)(int size))
 if (!pool)
 return NULL;
 
+ff_mutex_init(&pool->mutex, NULL);
+
 pool->size = size;
 pool->alloc= alloc ? alloc : av_buffer_alloc;
 
@@ -220,6 +223,7 @@ static void buffer_pool_free(AVBufferPool *pool)
 buf->free(buf->opaque, buf->data);
 av_freep(&buf);
 }
+ff_mutex_destroy(&pool->mutex);
 av_freep(&pool);
 }
 
@@ -236,47 +240,16 @@ void av_buffer_pool_uninit(AVBufferPool **ppool)
 buffer_pool_free(pool);
 }
 
-/* remove the whole buffer list from the pool and return it */
-static BufferPoolEntry *get_pool(AVBufferPool *pool)
-{
-BufferPoolEntry *cur = NULL, *last = NULL;
-
-do {
-FFSWAP(BufferPoolEntry*, cur, last);
-cur = avpriv_atomic_ptr_cas((void * volatile *)&pool->pool, last, 
NULL);
-if (!cur)
-return NULL;
-} while (cur != last);
-
-return cur;
-}
-
-static void add_to_pool(BufferPoolEntry *buf)
-{
-AVBufferPool *pool;
-BufferPoolEntry *cur, *end = buf;
-
-if (!buf)
-return;
-pool = buf->pool;
-
-while (end->next)
-end = end->next;
-
-while ((cur = avpriv_atomic_ptr_cas((void * volatile *)&pool->pool, NULL, 
buf))) {
-/* pool is not empty, retrieve it and append it to our list */
-cur = get_pool(pool);
-end->next = cur;
-while (end->next)
-end = end->next;
-}
-}
-
 static void pool_release_buffer(void *opaque, uint8_t *data)
 {
 BufferPoolEntry *buf = opaque;
 AVBufferPool *pool = buf->pool;
-add_to_pool(buf);
+
+ff_mutex_lock(&pool->mutex);
+buf->next = pool->pool;
+pool->pool = buf;
+ff_mutex_unlock(&pool->mutex);
+
 if (!avpriv_atomic_int_add_and_fetch(&pool->refcount, -1))
 buffer_pool_free(pool);
 }
@@ -306,8 +279,6 @@ static AVBufferRef *pool_alloc_buffer(AVBufferPool *pool)
 ret->buffer->opaque = buf;
 ret->buffer->free   = pool_release_buffer;
 
-avpriv_atomic_int_add_and_fetch(&pool->refcount, 1);
-
 return ret;
 }
 
@@ -316,22 +287,22 @@ AVBufferRef *av_buffer_pool_get(AVBufferPool *pool)
 AVBufferRef *ret;
 BufferPoolEntry *buf;
 
-/* check whether the pool is empty */
-buf = get_pool(pool);
-if (!buf)
-return pool_alloc_buffer(pool);
-
-/* keep the first entry, return the rest of the list to the pool */
-add_to_pool(buf->next);
-buf->next = NULL;
-
-ret = av_buffer_create(buf->data, pool->size, pool_release_buffer,
-   buf, 0);
-if (!ret) {
-add_to_pool(buf);
-return NULL;
+ff_mutex_lock(&pool->mutex);
+buf = pool->pool;
+if (buf) {
+ret = av_buffer_create(buf->data, pool->size, pool_release_buffer,
+   buf, 0);
+if (ret) {
+pool->pool = buf->next;
+buf->next = NULL;
+}
+} else {
+ret = pool_alloc_buffer(pool);
 }
-avpriv_atomic_int_add_and_fetch(&pool-

[FFmpeg-cvslog] Merge commit '517ce1d09b5e6b72afc2ef9490b5f8ca42fa6a65' into release/2.4

2014-11-27 Thread Michael Niedermayer
ffmpeg | branch: release/2.4 | Michael Niedermayer  | Fri Nov 
28 00:57:32 2014 +0100| [b6691fba77afb0ca6ce6d7ca33fa8285f3c78911] | committer: 
Michael Niedermayer

Merge commit '517ce1d09b5e6b72afc2ef9490b5f8ca42fa6a65' into release/2.4

* commit '517ce1d09b5e6b72afc2ef9490b5f8ca42fa6a65':
  lavu: fix memory leaks by using a mutex instead of atomics

Conflicts:
libavutil/buffer.c

The atomics code is left in place as a fallback for synchronization in the
absence of p/w32 threads. Our ABI did not requires applications to
only use threads (and matching ones) to what libavutil was build with
Our code also was not affected by the leak this change fixes, though
no question the atomics based implementation is not pretty at all.
First and foremost the code must work, being pretty comes after that.

If this causes problems, for example when libavutil is used by multiple
applications each using a different kind of threading system then the
default possibly has to be changed to the uglier atomics.

See: cea3a63ba3d89d8403eef008f7a7c54d645cff70
Merged-by: Michael Niedermayer 

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



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


[FFmpeg-cvslog] Merge commit '46a17d886b8559723c40b9f5cdf0e0c6b1c95180' into release/2.4

2014-11-27 Thread Michael Niedermayer
ffmpeg | branch: release/2.4 | Michael Niedermayer  | Fri Nov 
28 00:36:23 2014 +0100| [15fd62110fd82f19f9e127cf8401756231112ce0] | committer: 
Michael Niedermayer

Merge commit '46a17d886b8559723c40b9f5cdf0e0c6b1c95180' into release/2.4

* commit '46a17d886b8559723c40b9f5cdf0e0c6b1c95180':
  lavu: add wrappers for the pthreads mutex API

Merged-by: Michael Niedermayer 

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



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


[FFmpeg-cvslog] lavu: add wrappers for the pthreads mutex API

2014-11-27 Thread Anton Khirnov
ffmpeg | branch: release/2.4 | Anton Khirnov  | Sun Nov 23 
21:25:05 2014 +0100| [46a17d886b8559723c40b9f5cdf0e0c6b1c95180] | committer: 
Anton Khirnov

lavu: add wrappers for the pthreads mutex API

Also add no-op fallbacks when threading is disabled.

This helps keeping the code clean if Libav is compiled for targets
without threading. Since we assume that no threads of any kind are used
in such configurations, doing nothing is ok by definition.

Based on a patch by wm4 .

(cherry picked from commit 2443e522f0059176ff8717c9c753eb6fe7e7bbf1)
Signed-off-by: Anton Khirnov 

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

 libavutil/thread.h |   53 
 1 file changed, 53 insertions(+)

diff --git a/libavutil/thread.h b/libavutil/thread.h
new file mode 100644
index 000..07e3d4a
--- /dev/null
+++ b/libavutil/thread.h
@@ -0,0 +1,53 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+// This header should only be used to simplify code where
+// threading is optional, not as a generic threading abstraction.
+
+#ifndef AVUTIL_THREAD_H
+#define AVUTIL_THREAD_H
+
+#include "config.h"
+
+#if HAVE_PTHREADS || HAVE_W32THREADS
+
+#if HAVE_PTHREADS
+#include 
+#else
+#include 
+#endif
+
+#define AVMutex pthread_mutex_t
+
+#define ff_mutex_initpthread_mutex_init
+#define ff_mutex_lockpthread_mutex_lock
+#define ff_mutex_unlock  pthread_mutex_unlock
+#define ff_mutex_destroy pthread_mutex_destroy
+
+#else
+
+#define AVMutex char
+
+#define ff_mutex_init(mutex, attr) (0)
+#define ff_mutex_lock(mutex) (0)
+#define ff_mutex_unlock(mutex) (0)
+#define ff_mutex_destroy(mutex) (0)
+
+#endif
+
+#endif /* AVUTIL_THREAD_H */

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


[FFmpeg-cvslog] Merge commit '12700b0219521a5f20c8ba47b3ad7857ea9e0554' into release/2.4

2014-11-27 Thread Michael Niedermayer
ffmpeg | branch: release/2.4 | Michael Niedermayer  | Fri Nov 
28 00:35:35 2014 +0100| [86b532898d8a2dbd9ddd303434bd8a5a395b15a7] | committer: 
Michael Niedermayer

Merge commit '12700b0219521a5f20c8ba47b3ad7857ea9e0554' into release/2.4

* commit '12700b0219521a5f20c8ba47b3ad7857ea9e0554':
  mp3enc: fix a triggerable assert

Conflicts:
libavformat/mp3enc.c

No change as the faulty assert is not in FFmpeg

Merged-by: Michael Niedermayer 

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



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


[FFmpeg-cvslog] mp3enc: fix a triggerable assert

2014-11-27 Thread Anton Khirnov
ffmpeg | branch: release/2.4 | Anton Khirnov  | Fri Nov 14 
20:20:50 2014 +0100| [12700b0219521a5f20c8ba47b3ad7857ea9e0554] | committer: 
Anton Khirnov

mp3enc: fix a triggerable assert

We have to check against the number of bytes actually needed, not the
theoretical maximum size.

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

 libavformat/mp3enc.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index 476d7f7..1eaa585 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -196,7 +196,7 @@ static void mp3_write_xing(AVFormatContext *s)
 
 avpriv_mpegaudio_decode_header(&mpah, header);
 
-av_assert0(mpah.frame_size >= XING_MAX_SIZE);
+av_assert0(mpah.frame_size >= bytes_needed);
 
 ffio_fill(s->pb, 0, xing_offset);
 mp3->xing_offset = avio_tell(s->pb);

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


[FFmpeg-cvslog] Merge commit '1973079417e8701b52ba810a72cb6c7c6f7f9a56'

2014-11-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Fri Nov 28 
00:00:06 2014 +0100| [fae545ca2a34973e60e9c918bfefe2b2dd7cffb8] | committer: 
Michael Niedermayer

Merge commit '1973079417e8701b52ba810a72cb6c7c6f7f9a56'

* commit '1973079417e8701b52ba810a72cb6c7c6f7f9a56':
  opusdec: make sure all substreams have the same number of coded samples

Merged-by: Michael Niedermayer 

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



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


[FFmpeg-cvslog] opusdec: make sure all substreams have the same number of coded samples

2014-11-27 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Nov 24 
11:16:46 2014 +0100| [1973079417e8701b52ba810a72cb6c7c6f7f9a56] | committer: 
Anton Khirnov

opusdec: make sure all substreams have the same number of coded samples

Fixes invalid writes with invalid multichannel streams.

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

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

 libavcodec/opusdec.c |6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/opusdec.c b/libavcodec/opusdec.c
index bf3a54b..771922e 100644
--- a/libavcodec/opusdec.c
+++ b/libavcodec/opusdec.c
@@ -500,6 +500,12 @@ static int opus_decode_packet(AVCodecContext *avctx, void 
*data,
 av_log(avctx, AV_LOG_ERROR, "Error parsing the packet 
header.\n");
 return ret;
 }
+if (coded_samples != s->packet.frame_count * 
s->packet.frame_duration) {
+av_log(avctx, AV_LOG_ERROR,
+   "Mismatching coded sample count in substream %d.\n", i);
+return AVERROR_INVALIDDATA;
+}
+
 s->silk_samplerate = get_silk_samplerate(s->packet.config);
 }
 

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


[FFmpeg-cvslog] vf_interlace: get rid of useless loads

2014-11-27 Thread Kieran Kunhya
ffmpeg | branch: master | Kieran Kunhya  | Tue Nov 25 
17:14:32 2014 +0100| [96fda42a8f9bf84beaaf7f5991d17f2a057de86c] | committer: 
Anton Khirnov

vf_interlace: get rid of useless loads

Signed-off-by: Anton Khirnov 

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

 libavfilter/x86/vf_interlace.asm |2 --
 1 file changed, 2 deletions(-)

diff --git a/libavfilter/x86/vf_interlace.asm b/libavfilter/x86/vf_interlace.asm
index b8d8616..85811da 100644
--- a/libavfilter/x86/vf_interlace.asm
+++ b/libavfilter/x86/vf_interlace.asm
@@ -42,8 +42,6 @@ cglobal lowpass_line, 5, 5, 7
 mova m1, [r3+r1+mmsize]
 pavgb m0, [r4+r1]
 pavgb m1, [r4+r1+mmsize]
-mova m2, [r2+r1]
-mova m3, [r2+r1+mmsize]
 pxor m0, m6
 pxor m1, m6
 pxor m2, m6, [r2+r1]

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


[FFmpeg-cvslog] Merge commit '96fda42a8f9bf84beaaf7f5991d17f2a057de86c'

2014-11-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu Nov 27 
23:46:12 2014 +0100| [449bd3c0c33c2ea52ae232d149d0207d53f34a88] | committer: 
Michael Niedermayer

Merge commit '96fda42a8f9bf84beaaf7f5991d17f2a057de86c'

* commit '96fda42a8f9bf84beaaf7f5991d17f2a057de86c':
  vf_interlace: get rid of useless loads

See: ca59b5b6eceb1adbf96b8248128e58bfbb79c9a6
Merged-by: Michael Niedermayer 

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



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


[FFmpeg-cvslog] lavu: fix memory leaks by using a mutex instead of atomics

2014-11-27 Thread wm4
ffmpeg | branch: master | wm4  | Fri Nov 14 13:34:50 
2014 +0100| [fbd6c97f9ca858140df16dd07200ea0d4bdc1a83] | committer: Anton 
Khirnov

lavu: fix memory leaks by using a mutex instead of atomics

The buffer pool has to atomically add and remove entries from the linked
list of available buffers. This was done by removing the entire list
with a CAS operation, working on it, and then setting it back again
(using a retry-loop in case another thread was doing the same thing).

This could effectively cause memory leaks: while a thread was working on
the buffer list, other threads would allocate new buffers, increasing
the pool's total size. There was no real leak, but since these extra
buffers were not needed, but not free'd either (except when the buffer
pool was destroyed), this had the same effects as a real leak. For some
reason, growth was exponential, and could easily kill the process due
to OOM in real-world uses.

Fix this by using a mutex to protect the list operations. The fancy
way atomics remove the whole list to work on it is not needed anymore,
which also avoids the situation which was causing the leak.

Signed-off-by: Anton Khirnov 

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

 libavutil/buffer.c  |   79 ++-
 libavutil/buffer_internal.h |6 ++--
 2 files changed, 29 insertions(+), 56 deletions(-)

diff --git a/libavutil/buffer.c b/libavutil/buffer.c
index 2b38081..1bc4a93 100644
--- a/libavutil/buffer.c
+++ b/libavutil/buffer.c
@@ -23,6 +23,7 @@
 #include "buffer_internal.h"
 #include "common.h"
 #include "mem.h"
+#include "thread.h"
 
 AVBufferRef *av_buffer_create(uint8_t *data, int size,
   void (*free)(void *opaque, uint8_t *data),
@@ -199,6 +200,8 @@ AVBufferPool *av_buffer_pool_init(int size, AVBufferRef* 
(*alloc)(int size))
 if (!pool)
 return NULL;
 
+ff_mutex_init(&pool->mutex, NULL);
+
 pool->size = size;
 pool->alloc= alloc ? alloc : av_buffer_alloc;
 
@@ -220,6 +223,7 @@ static void buffer_pool_free(AVBufferPool *pool)
 buf->free(buf->opaque, buf->data);
 av_freep(&buf);
 }
+ff_mutex_destroy(&pool->mutex);
 av_freep(&pool);
 }
 
@@ -236,47 +240,16 @@ void av_buffer_pool_uninit(AVBufferPool **ppool)
 buffer_pool_free(pool);
 }
 
-/* remove the whole buffer list from the pool and return it */
-static BufferPoolEntry *get_pool(AVBufferPool *pool)
-{
-BufferPoolEntry *cur = NULL, *last = NULL;
-
-do {
-FFSWAP(BufferPoolEntry*, cur, last);
-cur = avpriv_atomic_ptr_cas((void * volatile *)&pool->pool, last, 
NULL);
-if (!cur)
-return NULL;
-} while (cur != last);
-
-return cur;
-}
-
-static void add_to_pool(BufferPoolEntry *buf)
-{
-AVBufferPool *pool;
-BufferPoolEntry *cur, *end = buf;
-
-if (!buf)
-return;
-pool = buf->pool;
-
-while (end->next)
-end = end->next;
-
-while ((cur = avpriv_atomic_ptr_cas((void * volatile *)&pool->pool, NULL, 
buf))) {
-/* pool is not empty, retrieve it and append it to our list */
-cur = get_pool(pool);
-end->next = cur;
-while (end->next)
-end = end->next;
-}
-}
-
 static void pool_release_buffer(void *opaque, uint8_t *data)
 {
 BufferPoolEntry *buf = opaque;
 AVBufferPool *pool = buf->pool;
-add_to_pool(buf);
+
+ff_mutex_lock(&pool->mutex);
+buf->next = pool->pool;
+pool->pool = buf;
+ff_mutex_unlock(&pool->mutex);
+
 if (!avpriv_atomic_int_add_and_fetch(&pool->refcount, -1))
 buffer_pool_free(pool);
 }
@@ -306,8 +279,6 @@ static AVBufferRef *pool_alloc_buffer(AVBufferPool *pool)
 ret->buffer->opaque = buf;
 ret->buffer->free   = pool_release_buffer;
 
-avpriv_atomic_int_add_and_fetch(&pool->refcount, 1);
-
 return ret;
 }
 
@@ -316,22 +287,22 @@ AVBufferRef *av_buffer_pool_get(AVBufferPool *pool)
 AVBufferRef *ret;
 BufferPoolEntry *buf;
 
-/* check whether the pool is empty */
-buf = get_pool(pool);
-if (!buf)
-return pool_alloc_buffer(pool);
-
-/* keep the first entry, return the rest of the list to the pool */
-add_to_pool(buf->next);
-buf->next = NULL;
-
-ret = av_buffer_create(buf->data, pool->size, pool_release_buffer,
-   buf, 0);
-if (!ret) {
-add_to_pool(buf);
-return NULL;
+ff_mutex_lock(&pool->mutex);
+buf = pool->pool;
+if (buf) {
+ret = av_buffer_create(buf->data, pool->size, pool_release_buffer,
+   buf, 0);
+if (ret) {
+pool->pool = buf->next;
+buf->next = NULL;
+}
+} else {
+ret = pool_alloc_buffer(pool);
 }
-avpriv_atomic_int_add_and_fetch(&pool->refcount, 1);
+ff_mutex_unlock(&pool->mutex);
+
+if (ret)
+avpriv_atomic_int_add_and_fe

[FFmpeg-cvslog] Merge commit 'fbd6c97f9ca858140df16dd07200ea0d4bdc1a83'

2014-11-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu Nov 27 
23:03:07 2014 +0100| [6db8cd8f37b72c5397541a9689a5378bf1a559ce] | committer: 
Michael Niedermayer

Merge commit 'fbd6c97f9ca858140df16dd07200ea0d4bdc1a83'

* commit 'fbd6c97f9ca858140df16dd07200ea0d4bdc1a83':
  lavu: fix memory leaks by using a mutex instead of atomics

Conflicts:
libavutil/buffer.c

The atomics code is left in place as a fallback for synchronization in the
absence of p/w32 threads. Our ABI did not requires applications to
only use threads (and matching ones) to what libavutil was build with
Our code also was not affected by the leak this change fixes, though
no question the atomics based implementation is not pretty at all.
First and foremost the code must work, being pretty comes after that.

If this causes problems, for example when libavutil is used by multiple
applications each using a different kind of threading system then the
default possibly has to be changed to the uglier atomics.

See: cea3a63ba3d89d8403eef008f7a7c54d645cff70
Merged-by: Michael Niedermayer 

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



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


[FFmpeg-cvslog] lavu/opt: add consts where possible

2014-11-27 Thread Lukasz Marek
ffmpeg | branch: master | Lukasz Marek  | Thu Nov 27 
00:11:01 2014 +0100| [f00e9c4b10f5ab7cd382d3019eb7bee13fcc3866] | committer: 
Lukasz Marek

lavu/opt: add consts where possible

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

 libavutil/opt.c |8 
 libavutil/opt.h |7 ---
 libavutil/version.h |7 +++
 3 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 5b26a00..64ce896 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -42,13 +42,13 @@
 #include 
 
 #if FF_API_OLD_AVOPTIONS
-const AVOption *av_next_option(void *obj, const AVOption *last)
+const AVOption *av_next_option(FF_CONST_AVUTIL55 void *obj, const AVOption 
*last)
 {
 return av_opt_next(obj, last);
 }
 #endif
 
-const AVOption *av_opt_next(void *obj, const AVOption *last)
+const AVOption *av_opt_next(FF_CONST_AVUTIL55 void *obj, const AVOption *last)
 {
 const AVClass *class;
 if (!obj)
@@ -61,7 +61,7 @@ const AVOption *av_opt_next(void *obj, const AVOption *last)
 return NULL;
 }
 
-static int read_number(const AVOption *o, void *dst, double *num, int *den, 
int64_t *intnum)
+static int read_number(const AVOption *o, const void *dst, double *num, int 
*den, int64_t *intnum)
 {
 switch (o->type) {
 case AV_OPT_TYPE_FLAGS: *intnum = *(unsigned int*)dst;return 0;
@@ -1573,7 +1573,7 @@ static int opt_size(enum AVOptionType type)
 return 0;
 }
 
-int av_opt_copy(void *dst, void *src)
+int av_opt_copy(void *dst, FF_CONST_AVUTIL55 void *src)
 {
 const AVOption *o = NULL;
 const AVClass *c;
diff --git a/libavutil/opt.h b/libavutil/opt.h
index 7338e78..d611c9b 100644
--- a/libavutil/opt.h
+++ b/libavutil/opt.h
@@ -33,6 +33,7 @@
 #include "log.h"
 #include "pixfmt.h"
 #include "samplefmt.h"
+#include "version.h"
 
 /**
  * @defgroup avoptions AVOptions
@@ -416,7 +417,7 @@ double av_get_double(void *obj, const char *name, const 
AVOption **o_out);
 AVRational av_get_q(void *obj, const char *name, const AVOption **o_out);
 int64_t av_get_int(void *obj, const char *name, const AVOption **o_out);
 attribute_deprecated const char *av_get_string(void *obj, const char *name, 
const AVOption **o_out, char *buf, int buf_len);
-attribute_deprecated const AVOption *av_next_option(void *obj, const AVOption 
*last);
+attribute_deprecated const AVOption *av_next_option(FF_CONST_AVUTIL55 void 
*obj, const AVOption *last);
 #endif
 
 /**
@@ -673,7 +674,7 @@ const AVOption *av_opt_find2(void *obj, const char *name, 
const char *unit,
  * or NULL
  * @return next AVOption or NULL
  */
-const AVOption *av_opt_next(void *obj, const AVOption *prev);
+const AVOption *av_opt_next(FF_CONST_AVUTIL55 void *obj, const AVOption *prev);
 
 /**
  * Iterate over AVOptions-enabled children of obj.
@@ -825,7 +826,7 @@ int av_opt_query_ranges(AVOptionRanges **, void *obj, const 
char *key, int flags
  * @param src  Object to copy into
  * @return 0 on success, negative on error
  */
-int av_opt_copy(void *dest, void *src);
+int av_opt_copy(void *dest, FF_CONST_AVUTIL55 void *src);
 
 /**
  * Get a default list of allowed ranges for the given option.
diff --git a/libavutil/version.h b/libavutil/version.h
index 8b357de..c19e943 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -120,6 +120,13 @@
 #define FF_API_OPT_TYPE_METADATA(LIBAVUTIL_VERSION_MAJOR < 55)
 #endif
 
+#ifndef FF_CONST_AVUTIL55
+#if LIBAVUTIL_VERSION_MAJOR >= 55
+#define FF_CONST_AVUTIL55 const
+#else
+#define FF_CONST_AVUTIL55
+#endif
+#endif
 
 /**
  * @}

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


[FFmpeg-cvslog] lavf/ffmenc: store recommended encoder configuration

2014-11-27 Thread Lukasz Marek
ffmpeg | branch: master | Lukasz Marek  | Sun Nov 16 
21:55:14 2014 +0100| [500d6088618a8a1b23d8190455430dcdd9230c9c] | committer: 
Lukasz Marek

lavf/ffmenc: store recommended encoder configuration

ffmenc will store recommended encoder configuration if present.
This will allow the user to base on local defaults and
apply only explicitly set options.

If recommended encoder configuration is not present, then
non-default context's options are stored.

Signed-off-by: Lukasz Marek 

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

 libavformat/ffmenc.c  |   74 ++---
 libavformat/version.h |2 +-
 2 files changed, 71 insertions(+), 5 deletions(-)

diff --git a/libavformat/ffmenc.c b/libavformat/ffmenc.c
index c64c26b..e6d1a31 100644
--- a/libavformat/ffmenc.c
+++ b/libavformat/ffmenc.c
@@ -162,6 +162,60 @@ static int ffm_write_header_codec_ctx(AVIOContext *pb, 
AVCodecContext *ctx, unsi
 #undef ENC
 }
 
+static int ffm_write_recommended_config(AVIOContext *pb, AVCodecContext *ctx, 
unsigned tag,
+const char *configuration)
+{
+int ret;
+const AVCodec *enc = ctx->codec ? ctx->codec : 
avcodec_find_encoder(ctx->codec_id);
+AVIOContext *tmp;
+AVDictionaryEntry *t = NULL;
+AVDictionary *all = NULL, *comm = NULL, *prv = NULL;
+char *buf = NULL;
+
+if (!enc || !enc->priv_class || !enc->priv_data_size) {
+/* codec is not known/has no private options, so save everything as 
common options */
+if (avio_open_dyn_buf(&tmp) < 0)
+return AVERROR(ENOMEM);
+avio_put_str(tmp, configuration);
+write_header_chunk(pb, tmp, tag);
+return 0;
+}
+
+if ((ret = av_dict_parse_string(&all, configuration, "=", ",", 0)) < 0)
+return ret;
+
+while ((t = av_dict_get(all, "", t, AV_DICT_IGNORE_SUFFIX))) {
+if (av_opt_find((void *)&enc->priv_class, t->key, NULL, 0, 
AV_OPT_SEARCH_FAKE_OBJ)) {
+if ((ret = av_dict_set(&prv, t->key, t->value, 0)) < 0)
+goto fail;
+} else if ((ret = av_dict_set(&comm, t->key, t->value, 0)) < 0)
+goto fail;
+}
+
+if (comm) {
+if ((ret = av_dict_get_string(comm, &buf, '=', ',')) < 0 ||
+(ret = avio_open_dyn_buf(&tmp)) < 0)
+goto fail;
+avio_put_str(tmp, buf);
+av_freep(&buf);
+write_header_chunk(pb, tmp, tag);
+}
+if (prv) {
+if ((ret = av_dict_get_string(prv, &buf, '=', ',')) < 0 ||
+(ret = avio_open_dyn_buf(&tmp)) < 0)
+goto fail;
+avio_put_str(tmp, buf);
+write_header_chunk(pb, tmp, MKBETAG('C', 'P', 'R', 'V'));
+}
+
+  fail:
+av_free(buf);
+av_dict_free(&all);
+av_dict_free(&comm);
+av_dict_free(&prv);
+return ret;
+}
+
 static int ffm_write_header(AVFormatContext *s)
 {
 FFMContext *ffm = s->priv_data;
@@ -220,13 +274,25 @@ static int ffm_write_header(AVFormatContext *s)
 /* specific info */
 switch(codec->codec_type) {
 case AVMEDIA_TYPE_VIDEO:
-if ((ret = ffm_write_header_codec_ctx(s->pb, codec, MKBETAG('S', 
'2', 'V', 'I'), AV_OPT_FLAG_VIDEO_PARAM)) < 0 ||
-(ret = ffm_write_header_codec_private_ctx(s->pb, codec, 
AV_OPT_FLAG_VIDEO_PARAM)) < 0)
+if (st->recommended_encoder_configuration) {
+av_log(NULL, AV_LOG_DEBUG, "writing recommended configuration: 
%s\n",
+   st->recommended_encoder_configuration);
+if ((ret = ffm_write_recommended_config(s->pb, codec, 
MKBETAG('S', '2', 'V', 'I'),
+
st->recommended_encoder_configuration)) < 0)
+return ret;
+} else if ((ret = ffm_write_header_codec_ctx(s->pb, codec, 
MKBETAG('S', '2', 'V', 'I'), AV_OPT_FLAG_VIDEO_PARAM)) < 0 ||
+   (ret = ffm_write_header_codec_private_ctx(s->pb, codec, 
AV_OPT_FLAG_VIDEO_PARAM)) < 0)
 return ret;
 break;
 case AVMEDIA_TYPE_AUDIO:
-if ((ret = ffm_write_header_codec_ctx(s->pb, codec, MKBETAG('S', 
'2', 'A', 'U'), AV_OPT_FLAG_AUDIO_PARAM)) < 0 ||
-(ret = ffm_write_header_codec_private_ctx(s->pb, codec, 
AV_OPT_FLAG_AUDIO_PARAM)) < 0)
+if (st->recommended_encoder_configuration) {
+av_log(NULL, AV_LOG_DEBUG, "writing recommended configuration: 
%s\n",
+   st->recommended_encoder_configuration);
+if ((ret = ffm_write_recommended_config(s->pb, codec, 
MKBETAG('S', '2', 'A', 'U'),
+
st->recommended_encoder_configuration)) < 0)
+return ret;
+} else if ((ret = ffm_write_header_codec_ctx(s->pb, codec, 
MKBETAG('S', '2', 'A', 'U'), AV_OPT_FLAG_AUDIO_PARAM)) < 0 ||
+ 

[FFmpeg-cvslog] lavf/ffmdec: add common options to recommended encoder configuration

2014-11-27 Thread Lukasz Marek
ffmpeg | branch: master | Lukasz Marek  | Sun Nov 16 
21:53:59 2014 +0100| [568853b8f533c7bf04b75dee8383224db35471e7] | committer: 
Lukasz Marek

lavf/ffmdec: add common options to recommended encoder configuration

Signed-off-by: Lukasz Marek 

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

 libavformat/ffmdec.c |   36 +++-
 1 file changed, 31 insertions(+), 5 deletions(-)

diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
index 7ae906b..987f419 100644
--- a/libavformat/ffmdec.c
+++ b/libavformat/ffmdec.c
@@ -24,6 +24,8 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/intfloat.h"
 #include "libavutil/opt.h"
+#include "libavutil/avassert.h"
+#include "libavutil/avstring.h"
 #include "avformat.h"
 #include "internal.h"
 #include "ffm.h"
@@ -231,6 +233,27 @@ static int ffm_close(AVFormatContext *s)
 return 0;
 }
 
+static int ffm_append_recommended_configuration(AVStream *st, char **conf)
+{
+int ret;
+size_t newsize;
+av_assert0(conf && st);
+if (!*conf)
+return 0;
+if (!st->recommended_encoder_configuration) {
+st->recommended_encoder_configuration = *conf;
+*conf = 0;
+return 0;
+}
+newsize = strlen(*conf) + strlen(st->recommended_encoder_configuration) + 
2;
+if ((ret = av_reallocp(&st->recommended_encoder_configuration, newsize)) < 
0)
+return ret;
+av_strlcat(st->recommended_encoder_configuration, ",", newsize);
+av_strlcat(st->recommended_encoder_configuration, *conf, newsize);
+av_freep(conf);
+return 0;
+}
+
 static int ffm2_read_header(AVFormatContext *s)
 {
 FFMContext *ffm = s->priv_data;
@@ -367,12 +390,14 @@ static int ffm2_read_header(AVFormatContext *s)
 }
 enc = avcodec_find_encoder(codec->codec_id);
 if (enc && enc->priv_data_size && enc->priv_class) {
-st->recommended_encoder_configuration = av_malloc(size + 1);
-if (!st->recommended_encoder_configuration) {
+buffer = av_malloc(size + 1);
+if (!buffer) {
 ret = AVERROR(ENOMEM);
 goto fail;
 }
-avio_get_str(pb, size, st->recommended_encoder_configuration, 
size + 1);
+avio_get_str(pb, size, buffer, size + 1);
+if ((ret = ffm_append_recommended_configuration(st, &buffer)) 
< 0)
+goto fail;
 }
 break;
 case MKBETAG('S', '2', 'V', 'I'):
@@ -387,7 +412,8 @@ static int ffm2_read_header(AVFormatContext *s)
 }
 avio_get_str(pb, INT_MAX, buffer, size);
 av_set_options_string(codec, buffer, "=", ",");
-av_freep(&buffer);
+if ((ret = ffm_append_recommended_configuration(st, &buffer)) < 0)
+goto fail;
 break;
 case MKBETAG('S', '2', 'A', 'U'):
 if (f_stau++) {
@@ -401,7 +427,7 @@ static int ffm2_read_header(AVFormatContext *s)
 }
 avio_get_str(pb, INT_MAX, buffer, size);
 av_set_options_string(codec, buffer, "=", ",");
-av_freep(&buffer);
+ffm_append_recommended_configuration(st, &buffer);
 break;
 }
 avio_seek(pb, next, SEEK_SET);

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


[FFmpeg-cvslog] ffmpeg_opt: make use of recommended encoder configuration

2014-11-27 Thread Lukasz Marek
ffmpeg | branch: master | Lukasz Marek  | Sun Nov 16 
21:57:54 2014 +0100| [3ff39901049f430f82d252eab3f4c0800ef144e5] | committer: 
Lukasz Marek

ffmpeg_opt: make use of recommended encoder configuration

So far ffmpeg used recommended configuration only for codec priv options.
ffmpeg will use now codec defaults and then apply recommended configuration
for all options. Recommended configuration possibly contains minimal
set of options to filful user configuration.

Signed-off-by: Lukasz Marek 

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

 ffmpeg_opt.c |   41 -
 1 file changed, 12 insertions(+), 29 deletions(-)

diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index 85466c7..03e049b 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -1617,31 +1617,6 @@ static int copy_chapters(InputFile *ifile, OutputFile 
*ofile, int copy_metadata)
 return 0;
 }
 
-static int ffserver_streams_copy_context(AVCodecContext *dest, const 
AVCodecContext *src,
- const char *configuration)
-{
-int ret;
-if ((ret = avcodec_copy_context(dest, src)) < 0)
-return ret;
-dest->codec = avcodec_find_encoder(src->codec_id);
-if (!dest->codec)
-return AVERROR(EINVAL);
-if (!dest->codec->priv_class || !dest->codec->priv_data_size)
-return 0;
-if (!dest->priv_data) {
-dest->priv_data = av_mallocz(dest->codec->priv_data_size);
-if (!dest->priv_data)
-return AVERROR(ENOMEM);
-*(const AVClass**)dest->priv_data = dest->codec->priv_class;
-}
-av_opt_set_defaults(dest->priv_data);
-if (av_set_options_string(dest->priv_data, configuration, "=", ",") < 0) {
-av_log(dest, AV_LOG_WARNING, "Cannot copy private codec options. Using 
defaults.\n");
-av_opt_set_defaults(dest->priv_data);
-}
-return 0;
-}
-
 static int read_ffserver_streams(OptionsContext *o, AVFormatContext *s, const 
char *filename)
 {
 int i, err;
@@ -1656,6 +1631,7 @@ static int read_ffserver_streams(OptionsContext *o, 
AVFormatContext *s, const ch
 AVStream *st;
 OutputStream *ost;
 AVCodec *codec;
+const char *enc_config;
 
 codec = avcodec_find_encoder(ic->streams[i]->codec->codec_id);
 if (!codec) {
@@ -1669,15 +1645,22 @@ static int read_ffserver_streams(OptionsContext *o, 
AVFormatContext *s, const ch
 ost   = new_output_stream(o, s, codec->type, -1);
 st= ost->st;
 
-ffserver_streams_copy_context(st->codec, ic->streams[i]->codec,
-  
av_stream_get_recommended_encoder_configuration(ic->streams[i]));
+avcodec_get_context_defaults3(st->codec, codec);
+enc_config = 
av_stream_get_recommended_encoder_configuration(ic->streams[i]);
+if (enc_config) {
+AVDictionary *opts = NULL;
+av_dict_parse_string(&opts, enc_config, "=", ",", 0);
+av_opt_set_dict2(st->codec, &opts, AV_OPT_SEARCH_CHILDREN);
+av_dict_free(&opts);
+}
 
 if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && !ost->stream_copy)
 choose_sample_fmt(st, codec);
 else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && 
!ost->stream_copy)
 choose_pixel_fmt(st, st->codec, codec, st->codec->pix_fmt);
-ffserver_streams_copy_context(ost->enc_ctx, st->codec,
-  
av_stream_get_recommended_encoder_configuration(ic->streams[i]));
+avcodec_copy_context(ost->enc_ctx, st->codec);
+if (enc_config)
+av_dict_parse_string(&ost->encoder_opts, enc_config, "=", ",", 0);
 }
 
 avformat_close_input(&ic);

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


[FFmpeg-cvslog] Merge commit '2443e522f0059176ff8717c9c753eb6fe7e7bbf1'

2014-11-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu Nov 27 
22:07:53 2014 +0100| [4760278007213bafadb231451f79f763a5a4b07a] | committer: 
Michael Niedermayer

Merge commit '2443e522f0059176ff8717c9c753eb6fe7e7bbf1'

* commit '2443e522f0059176ff8717c9c753eb6fe7e7bbf1':
  lavu: add wrappers for the pthreads mutex API

Merged-by: Michael Niedermayer 

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



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


[FFmpeg-cvslog] lavu: add wrappers for the pthreads mutex API

2014-11-27 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sun Nov 23 
21:25:05 2014 +0100| [2443e522f0059176ff8717c9c753eb6fe7e7bbf1] | committer: 
Anton Khirnov

lavu: add wrappers for the pthreads mutex API

Also add no-op fallbacks when threading is disabled.

This helps keeping the code clean if Libav is compiled for targets
without threading. Since we assume that no threads of any kind are used
in such configurations, doing nothing is ok by definition.

Based on a patch by wm4 .

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

 libavutil/thread.h |   53 
 1 file changed, 53 insertions(+)

diff --git a/libavutil/thread.h b/libavutil/thread.h
new file mode 100644
index 000..07e3d4a
--- /dev/null
+++ b/libavutil/thread.h
@@ -0,0 +1,53 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+// This header should only be used to simplify code where
+// threading is optional, not as a generic threading abstraction.
+
+#ifndef AVUTIL_THREAD_H
+#define AVUTIL_THREAD_H
+
+#include "config.h"
+
+#if HAVE_PTHREADS || HAVE_W32THREADS
+
+#if HAVE_PTHREADS
+#include 
+#else
+#include 
+#endif
+
+#define AVMutex pthread_mutex_t
+
+#define ff_mutex_initpthread_mutex_init
+#define ff_mutex_lockpthread_mutex_lock
+#define ff_mutex_unlock  pthread_mutex_unlock
+#define ff_mutex_destroy pthread_mutex_destroy
+
+#else
+
+#define AVMutex char
+
+#define ff_mutex_init(mutex, attr) (0)
+#define ff_mutex_lock(mutex) (0)
+#define ff_mutex_unlock(mutex) (0)
+#define ff_mutex_destroy(mutex) (0)
+
+#endif
+
+#endif /* AVUTIL_THREAD_H */

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


[FFmpeg-cvslog] avformat/udp: Allow to specify DSCP class

2014-11-27 Thread Vincent Bernat
ffmpeg | branch: master | Vincent Bernat  | Fri May 23 
15:26:32 2014 +0200| [5269cef4087f3e46e734eb5dfc38085e630514d9] | committer: 
Michael Niedermayer

avformat/udp: Allow to specify DSCP class

By appending `?dscp=26` to the URL, IP packets will be classified as
AF31 (assured forwarding for multimedia flows with low probability of
loss). On congested network, this allows a user to assign priorities to
flows.

Signed-off-by: Vincent Bernat 

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

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

diff --git a/libavformat/udp.c b/libavformat/udp.c
index 828b741..91c7910 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -556,7 +556,7 @@ static int parse_source_list(char *buf, char **sources, int 
*num_sources,
 static int udp_open(URLContext *h, const char *uri, int flags)
 {
 char hostname[1024], localaddr[1024] = "";
-int port, udp_fd = -1, tmp, bind_ret = -1;
+int port, udp_fd = -1, tmp, bind_ret = -1, dscp = -1;
 UDPContext *s = h->priv_data;
 int is_output;
 const char *p;
@@ -612,6 +612,9 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 if (av_find_info_tag(buf, sizeof(buf), "connect", p)) {
 s->is_connected = strtol(buf, NULL, 10);
 }
+if (av_find_info_tag(buf, sizeof(buf), "dscp", p)) {
+dscp = strtol(buf, NULL, 10);
+}
 if (av_find_info_tag(buf, sizeof(buf), "fifo_size", p)) {
 s->circular_buffer_size = strtol(buf, NULL, 10);
 if (!HAVE_PTHREAD_CANCEL)
@@ -695,6 +698,12 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 av_log(h, AV_LOG_WARNING, "socket option UDPLITE_RECV_CSCOV not 
available");
 }
 
+if (dscp >= 0) {
+dscp <<= 2;
+if (setsockopt (udp_fd, IPPROTO_IP, IP_TOS, &dscp, sizeof(dscp)) != 0)
+goto fail;
+}
+
 /* If multicast, try binding the multicast address first, to avoid
  * receiving UDP packets from other sources aimed at the same UDP
  * port. This fails on windows. This makes sending to the same address

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


[FFmpeg-cvslog] avformat/rtpproto: Allow to specify DSCP class

2014-11-27 Thread Vincent Bernat
ffmpeg | branch: master | Vincent Bernat  | Fri May 23 
15:31:17 2014 +0200| [d0f8b94b432ef99337c2a890c02571cba6ae3a71] | committer: 
Michael Niedermayer

avformat/rtpproto: Allow to specify DSCP class

By appending `?dscp=26` to the URL, IP packets will be classified as
AF31 (assured forwarding for multimedia flows with low probability of
loss). On congested network, this allows a user to assign priorities to
flows.

Signed-off-by: Vincent Bernat 

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

 libavformat/rtpproto.c |   16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c
index 71e6f03..0ea9568 100644
--- a/libavformat/rtpproto.c
+++ b/libavformat/rtpproto.c
@@ -192,6 +192,7 @@ static void build_udp_url(char *buf, int buf_size,
   const char *hostname, int port,
   int local_port, int ttl,
   int max_packet_size, int connect,
+  int dscp,
   const char *include_sources,
   const char *exclude_sources)
 {
@@ -204,6 +205,8 @@ static void build_udp_url(char *buf, int buf_size,
 url_add_option(buf, buf_size, "pkt_size=%d", max_packet_size);
 if (connect)
 url_add_option(buf, buf_size, "connect=1");
+if (dscp >= 0)
+url_add_option(buf, buf_size, "dscp=%d", dscp);
 url_add_option(buf, buf_size, "fifo_size=0");
 if (include_sources && include_sources[0])
 url_add_option(buf, buf_size, "sources=%s", include_sources);
@@ -264,6 +267,7 @@ static void rtp_parse_addr_list(URLContext *h, char *buf,
  * 'sources=ip[,ip]'  : list allowed source IP addresses
  * 'block=ip[,ip]': list disallowed source IP addresses
  * 'write_to_source=0/1' : send packets to the source address of the 
latest received packet
+ * 'dscp=n'   : set DSCP value to n (QoS)
  * deprecated option:
  * 'localport=n'  : set the local port to n
  *
@@ -278,7 +282,7 @@ static int rtp_open(URLContext *h, const char *uri, int 
flags)
 RTPContext *s = h->priv_data;
 int rtp_port, rtcp_port,
 ttl, connect,
-local_rtp_port, local_rtcp_port, max_packet_size;
+local_rtp_port, local_rtcp_port, max_packet_size, dscp;
 char hostname[256], include_sources[1024] = "", exclude_sources[1024] = "";
 char buf[1024];
 char path[1024];
@@ -294,6 +298,7 @@ static int rtp_open(URLContext *h, const char *uri, int 
flags)
 local_rtcp_port = -1;
 max_packet_size = -1;
 connect = 0;
+dscp = -1;
 
 p = strchr(uri, '?');
 if (p) {
@@ -321,6 +326,9 @@ static int rtp_open(URLContext *h, const char *uri, int 
flags)
 if (av_find_info_tag(buf, sizeof(buf), "write_to_source", p)) {
 s->write_to_source = strtol(buf, NULL, 10);
 }
+if (av_find_info_tag(buf, sizeof(buf), "dscp", p)) {
+dscp = strtol(buf, NULL, 10);
+}
 if (av_find_info_tag(buf, sizeof(buf), "sources", p)) {
 av_strlcpy(include_sources, buf, sizeof(include_sources));
 rtp_parse_addr_list(h, buf, &s->ssm_include_addrs, 
&s->nb_ssm_include_addrs);
@@ -334,7 +342,7 @@ static int rtp_open(URLContext *h, const char *uri, int 
flags)
 for (i = 0;i < max_retry_count;i++) {
 build_udp_url(buf, sizeof(buf),
   hostname, rtp_port, local_rtp_port, ttl, max_packet_size,
-  connect, include_sources, exclude_sources);
+  connect, dscp, include_sources, exclude_sources);
 if (ffurl_open(&s->rtp_hd, buf, flags, &h->interrupt_callback, NULL) < 
0)
 goto fail;
 local_rtp_port = ff_udp_get_local_port(s->rtp_hd);
@@ -346,7 +354,7 @@ static int rtp_open(URLContext *h, const char *uri, int 
flags)
 local_rtcp_port = local_rtp_port + 1;
 build_udp_url(buf, sizeof(buf),
   hostname, rtcp_port, local_rtcp_port, ttl, 
max_packet_size,
-  connect, include_sources, exclude_sources);
+  connect, dscp, include_sources, exclude_sources);
 if (ffurl_open(&s->rtcp_hd, buf, flags, &h->interrupt_callback, 
NULL) < 0) {
 local_rtp_port = local_rtcp_port = -1;
 continue;
@@ -355,7 +363,7 @@ static int rtp_open(URLContext *h, const char *uri, int 
flags)
 }
 build_udp_url(buf, sizeof(buf),
   hostname, rtcp_port, local_rtcp_port, ttl, 
max_packet_size,
-  connect, include_sources, exclude_sources);
+  connect, dscp, include_sources, exclude_sources);
 if (ffurl_open(&s->rtcp_hd, buf, flags, &h->interrupt_callback, NULL) 
< 0)
 goto fail;
 break;

___

[FFmpeg-cvslog] avcodec/mjpegdec: Fix integer overflow in shift

2014-11-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu Nov 27 
19:27:05 2014 +0100| [970a8f1c256f08d2f6414d573a54f2fa035c8e7a] | committer: 
Michael Niedermayer

avcodec/mjpegdec: Fix integer overflow in shift

Fixes: signal_sigabrt_76ac7bb9_2683_cov_4120310995_m_ijpg.avi
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer 

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

 libavcodec/mjpegdec.c |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index f2c81e6..a29a533 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -244,7 +244,8 @@ int ff_mjpeg_decode_dht(MJpegDecodeContext *s)
 
 int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 {
-int len, nb_components, i, width, height, bits, pix_fmt_id, ret;
+int len, nb_components, i, width, height, bits, ret;
+unsigned pix_fmt_id;
 int h_count[MAX_COMPONENTS];
 int v_count[MAX_COMPONENTS];
 
@@ -383,7 +384,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 else if (!s->lossless)
 s->rgb = 0;
 /* XXX: not complete test ! */
-pix_fmt_id = (s->h_count[0] << 28) | (s->v_count[0] << 24) |
+pix_fmt_id = ((unsigned)s->h_count[0] << 28) | (s->v_count[0] << 24) |
  (s->h_count[1] << 20) | (s->v_count[1] << 16) |
  (s->h_count[2] << 12) | (s->v_count[2] <<  8) |
  (s->h_count[3] <<  4) |  s->v_count[3];

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


[FFmpeg-cvslog] avformat/mov: change conjugation for "Duplicate"

2014-11-27 Thread Clément Bœsch
ffmpeg | branch: master | Clément Bœsch  | Thu Nov 27 
18:13:57 2014 +0100| [92fa1d9231b808ebad2c5651fb41cd025d5cd4b8] | committer: 
Clément Bœsch

avformat/mov: change conjugation for "Duplicate"

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

 libavformat/mov.c |   14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 5be683e..64c2c10 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1274,7 +1274,7 @@ static int mov_read_stco(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 return 0;
 
 if (sc->chunk_offsets)
-av_log(c->fc, AV_LOG_WARNING, "Duplicate STCO atom\n");
+av_log(c->fc, AV_LOG_WARNING, "Duplicated STCO atom\n");
 av_free(sc->chunk_offsets);
 sc->chunk_count = 0;
 sc->chunk_offsets = av_malloc_array(entries, sizeof(*sc->chunk_offsets));
@@ -1872,7 +1872,7 @@ static int mov_read_stsc(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 if (!entries)
 return 0;
 if (sc->stsc_data)
-av_log(c->fc, AV_LOG_WARNING, "Duplicate STSC atom\n");
+av_log(c->fc, AV_LOG_WARNING, "Duplicated STSC atom\n");
 av_free(sc->stsc_data);
 sc->stsc_count = 0;
 sc->stsc_data = av_malloc_array(entries, sizeof(*sc->stsc_data));
@@ -1908,7 +1908,7 @@ static int mov_read_stps(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 
 entries = avio_rb32(pb);
 if (sc->stps_data)
-av_log(c->fc, AV_LOG_WARNING, "Duplicate STPS atom\n");
+av_log(c->fc, AV_LOG_WARNING, "Duplicated STPS atom\n");
 av_free(sc->stps_data);
 sc->stps_count = 0;
 sc->stps_data = av_malloc_array(entries, sizeof(*sc->stps_data));
@@ -1954,7 +1954,7 @@ static int mov_read_stss(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 return 0;
 }
 if (sc->keyframes)
-av_log(c->fc, AV_LOG_WARNING, "Duplicate STSS atom\n");
+av_log(c->fc, AV_LOG_WARNING, "Duplicated STSS atom\n");
 av_free(sc->keyframes);
 sc->keyframe_count = 0;
 sc->keyframes = av_malloc_array(entries, sizeof(*sc->keyframes));
@@ -2019,7 +2019,7 @@ static int mov_read_stsz(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 if (entries >= (UINT_MAX - 4) / field_size)
 return AVERROR_INVALIDDATA;
 if (sc->sample_sizes)
-av_log(c->fc, AV_LOG_WARNING, "Duplicate STSZ atom\n");
+av_log(c->fc, AV_LOG_WARNING, "Duplicated STSZ atom\n");
 av_free(sc->sample_sizes);
 sc->sample_count = 0;
 sc->sample_sizes = av_malloc_array(entries, sizeof(*sc->sample_sizes));
@@ -2077,7 +2077,7 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 c->fc->nb_streams-1, entries);
 
 if (sc->stts_data)
-av_log(c->fc, AV_LOG_WARNING, "Duplicate STTS atom\n");
+av_log(c->fc, AV_LOG_WARNING, "Duplicated STTS atom\n");
 av_free(sc->stts_data);
 sc->stts_count = 0;
 sc->stts_data = av_malloc_array(entries, sizeof(*sc->stts_data));
@@ -2220,7 +2220,7 @@ static int mov_read_sbgp(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 if (!entries)
 return 0;
 if (sc->rap_group)
-av_log(c->fc, AV_LOG_WARNING, "Duplicate SBGP atom\n");
+av_log(c->fc, AV_LOG_WARNING, "Duplicated SBGP atom\n");
 av_free(sc->rap_group);
 sc->rap_group_count = 0;
 sc->rap_group = av_malloc_array(entries, sizeof(*sc->rap_group));

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


[FFmpeg-cvslog] avformat/mov: strengthen some table allocations

2014-11-27 Thread Clément Bœsch
ffmpeg | branch: master | Clément Bœsch  | Mon Nov 10 
18:21:28 2014 +0100| [5ab882d7283f57560c889919c35f2688253b1d9c] | committer: 
Clément Bœsch

avformat/mov: strengthen some table allocations

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

 libavformat/mov.c |   48 +++-
 1 file changed, 27 insertions(+), 21 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index a71e36d..5be683e 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1272,14 +1272,12 @@ static int mov_read_stco(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 
 if (!entries)
 return 0;
-if (entries >= UINT_MAX/sizeof(int64_t))
-return AVERROR_INVALIDDATA;
 
 if (sc->chunk_offsets)
 av_log(c->fc, AV_LOG_WARNING, "Duplicate STCO atom\n");
 av_free(sc->chunk_offsets);
 sc->chunk_count = 0;
-sc->chunk_offsets = av_malloc(entries * sizeof(int64_t));
+sc->chunk_offsets = av_malloc_array(entries, sizeof(*sc->chunk_offsets));
 if (!sc->chunk_offsets)
 return AVERROR(ENOMEM);
 sc->chunk_count = entries;
@@ -1873,13 +1871,11 @@ static int mov_read_stsc(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 
 if (!entries)
 return 0;
-if (entries >= UINT_MAX / sizeof(*sc->stsc_data))
-return AVERROR_INVALIDDATA;
 if (sc->stsc_data)
 av_log(c->fc, AV_LOG_WARNING, "Duplicate STSC atom\n");
 av_free(sc->stsc_data);
 sc->stsc_count = 0;
-sc->stsc_data = av_malloc(entries * sizeof(*sc->stsc_data));
+sc->stsc_data = av_malloc_array(entries, sizeof(*sc->stsc_data));
 if (!sc->stsc_data)
 return AVERROR(ENOMEM);
 
@@ -1911,9 +1907,11 @@ static int mov_read_stps(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 avio_rb32(pb); // version + flags
 
 entries = avio_rb32(pb);
-if (entries >= UINT_MAX / sizeof(*sc->stps_data))
-return AVERROR_INVALIDDATA;
-sc->stps_data = av_malloc(entries * sizeof(*sc->stps_data));
+if (sc->stps_data)
+av_log(c->fc, AV_LOG_WARNING, "Duplicate STPS atom\n");
+av_free(sc->stps_data);
+sc->stps_count = 0;
+sc->stps_data = av_malloc_array(entries, sizeof(*sc->stps_data));
 if (!sc->stps_data)
 return AVERROR(ENOMEM);
 
@@ -1955,9 +1953,11 @@ static int mov_read_stss(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 st->need_parsing = AVSTREAM_PARSE_HEADERS;
 return 0;
 }
-if (entries >= UINT_MAX / sizeof(int))
-return AVERROR_INVALIDDATA;
-sc->keyframes = av_malloc(entries * sizeof(int));
+if (sc->keyframes)
+av_log(c->fc, AV_LOG_WARNING, "Duplicate STSS atom\n");
+av_free(sc->keyframes);
+sc->keyframe_count = 0;
+sc->keyframes = av_malloc_array(entries, sizeof(*sc->keyframes));
 if (!sc->keyframes)
 return AVERROR(ENOMEM);
 
@@ -2016,9 +2016,13 @@ static int mov_read_stsz(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 
 if (!entries)
 return 0;
-if (entries >= UINT_MAX / sizeof(int) || entries >= (UINT_MAX - 4) / 
field_size)
+if (entries >= (UINT_MAX - 4) / field_size)
 return AVERROR_INVALIDDATA;
-sc->sample_sizes = av_malloc(entries * sizeof(int));
+if (sc->sample_sizes)
+av_log(c->fc, AV_LOG_WARNING, "Duplicate STSZ atom\n");
+av_free(sc->sample_sizes);
+sc->sample_count = 0;
+sc->sample_sizes = av_malloc_array(entries, sizeof(*sc->sample_sizes));
 if (!sc->sample_sizes)
 return AVERROR(ENOMEM);
 
@@ -2072,11 +2076,11 @@ static int mov_read_stts(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 av_dlog(c->fc, "track[%i].stts.entries = %i\n",
 c->fc->nb_streams-1, entries);
 
-if (entries >= UINT_MAX / sizeof(*sc->stts_data))
-return -1;
-
+if (sc->stts_data)
+av_log(c->fc, AV_LOG_WARNING, "Duplicate STTS atom\n");
 av_free(sc->stts_data);
-sc->stts_data = av_malloc(entries * sizeof(*sc->stts_data));
+sc->stts_count = 0;
+sc->stts_data = av_malloc_array(entries, sizeof(*sc->stts_data));
 if (!sc->stts_data)
 return AVERROR(ENOMEM);
 
@@ -2215,9 +2219,11 @@ static int mov_read_sbgp(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 entries = avio_rb32(pb);
 if (!entries)
 return 0;
-if (entries >= UINT_MAX / sizeof(*sc->rap_group))
-return AVERROR_INVALIDDATA;
-sc->rap_group = av_malloc(entries * sizeof(*sc->rap_group));
+if (sc->rap_group)
+av_log(c->fc, AV_LOG_WARNING, "Duplicate SBGP atom\n");
+av_free(sc->rap_group);
+sc->rap_group_count = 0;
+sc->rap_group = av_malloc_array(entries, sizeof(*sc->rap_group));
 if (!sc->rap_group)
 return AVERROR(ENOMEM);
 

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


[FFmpeg-cvslog] avcodec/hevc_ps: More complete window reset

2014-11-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu Nov 27 
15:03:35 2014 +0100| [57e5812198aada016e9ba4149123c541f8c8a7ec] | committer: 
Michael Niedermayer

avcodec/hevc_ps: More complete window reset

Fixes out of array read
Fixes: signal_sigsegv_35bcf26_471_cov_2806540268_CAINIT_A_SHARP_4.bit
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 0d6ede2..1f64971 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -1025,10 +1025,8 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
 }
 av_log(s->avctx, AV_LOG_WARNING,
"Displaying the whole video surface.\n");
-sps->pic_conf_win.left_offset   =
-sps->pic_conf_win.right_offset  =
-sps->pic_conf_win.top_offset=
-sps->pic_conf_win.bottom_offset = 0;
+memset(&sps->pic_conf_win, 0, sizeof(sps->pic_conf_win));
+memset(&sps->output_window, 0, sizeof(sps->output_window));
 sps->output_width   = sps->width;
 sps->output_height  = sps->height;
 }

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


[FFmpeg-cvslog] ffmpeg: Print a debug message if the frame parameters mismatch the context

2014-11-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu Nov 27 
14:16:31 2014 +0100| [98e8a9e2f2385d1094390ec5b9823eee6f70146a] | committer: 
Michael Niedermayer

ffmpeg: Print a debug message if the frame parameters mismatch the context

Signed-off-by: Michael Niedermayer 

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

 ffmpeg.c |   14 ++
 1 file changed, 14 insertions(+)

diff --git a/ffmpeg.c b/ffmpeg.c
index 2586dcf..57abd30 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1948,6 +1948,20 @@ static int decode_video(InputStream *ist, AVPacket *pkt, 
int *got_output)
 if (*got_output || ret<0 || pkt->size)
 decode_error_stat[ret<0] ++;
 
+if (*got_output && ret >= 0) {
+if (ist->dec_ctx->width  != decoded_frame->width ||
+ist->dec_ctx->height != decoded_frame->height ||
+ist->dec_ctx->pix_fmt != decoded_frame->format) {
+av_log(NULL, AV_LOG_DEBUG, "Frame parameters mismatch context 
%d,%d,%d != %d,%d,%d\n",
+decoded_frame->width,
+decoded_frame->height,
+decoded_frame->format,
+ist->dec_ctx->width,
+ist->dec_ctx->height,
+ist->dec_ctx->pix_fmt);
+}
+}
+
 if (!*got_output || ret < 0) {
 if (!pkt->size) {
 for (i = 0; i < ist->nb_filters; i++)

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


[FFmpeg-cvslog] lavu/imgutils: remove redundant and wrong check in av_image_fill_arrays

2014-11-27 Thread Stefano Sabatini
ffmpeg | branch: master | Stefano Sabatini  | Thu Nov 27 
12:27:48 2014 +0100| [29208e6dcf944bbea696d37a354a8bac9b552709] | committer: 
Stefano Sabatini

lavu/imgutils: remove redundant and wrong check in av_image_fill_arrays

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

 libavutil/imgutils.c |3 ---
 1 file changed, 3 deletions(-)

diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index 00b2031..7f3032b 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -331,9 +331,6 @@ int av_image_fill_arrays(uint8_t *dst_data[4], int 
dst_linesize[4],
 for (i = 0; i < 4; i++)
 dst_linesize[i] = FFALIGN(dst_linesize[i], align);
 
-if ((ret = av_image_fill_pointers(dst_data, pix_fmt, width, NULL, 
dst_linesize)) < 0)
-return ret;
-
 return av_image_fill_pointers(dst_data, pix_fmt, height, (uint8_t *)src, 
dst_linesize);
 }
 

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


[FFmpeg-cvslog] msvc: Fix compilation errors due to header include order.

2014-11-27 Thread Matthew Oliver
ffmpeg | branch: master | Matthew Oliver  | Thu Nov 27 
19:00:36 2014 +1100| [0167fa00604443aa20a2fb627081a46f1c0be4ff] | committer: 
Michael Niedermayer

msvc: Fix compilation errors due to header include order.

Ensures that the header include order is such that winsock2.h is always
included before windows.h or that windows.h does not include winsock.h.

Signed-off-by: Michael Niedermayer 

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

 libavdevice/dshow_capture.h |1 +
 libavdevice/opengl_enc.c|1 +
 libavformat/matroskadec.c   |   13 +++--
 libavutil/atomic_win32.h|1 +
 4 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/libavdevice/dshow_capture.h b/libavdevice/dshow_capture.h
index e4b4dce..0252070 100644
--- a/libavdevice/dshow_capture.h
+++ b/libavdevice/dshow_capture.h
@@ -27,6 +27,7 @@
 #include "avdevice.h"
 
 #define COBJMACROS
+#define WIN32_LEAN_AND_MEAN
 #include 
 #define NO_DSHOW_STRSAFE
 #include 
diff --git a/libavdevice/opengl_enc.c b/libavdevice/opengl_enc.c
index 5f5b800..434ae97 100644
--- a/libavdevice/opengl_enc.c
+++ b/libavdevice/opengl_enc.c
@@ -31,6 +31,7 @@
 #include "config.h"
 
 #if HAVE_WINDOWS_H
+#define WIN32_LEAN_AND_MEAN
 #include 
 #endif
 #if HAVE_OPENGL_GL3_H
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 3b45c3b..c81b5a04 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -32,12 +32,6 @@
 
 #include 
 #include 
-#if CONFIG_BZLIB
-#include 
-#endif
-#if CONFIG_ZLIB
-#include 
-#endif
 
 #include "libavutil/avstring.h"
 #include "libavutil/base64.h"
@@ -62,6 +56,13 @@
 #include "riff.h"
 #include "rmsipr.h"
 
+#if CONFIG_BZLIB
+#include 
+#endif
+#if CONFIG_ZLIB
+#include 
+#endif
+
 typedef enum {
 EBML_NONE,
 EBML_UINT,
diff --git a/libavutil/atomic_win32.h b/libavutil/atomic_win32.h
index 20b99df..f729933 100644
--- a/libavutil/atomic_win32.h
+++ b/libavutil/atomic_win32.h
@@ -21,6 +21,7 @@
 #ifndef AVUTIL_ATOMIC_WIN32_H
 #define AVUTIL_ATOMIC_WIN32_H
 
+#define WIN32_LEAN_AND_MEAN
 #include 
 
 #define avpriv_atomic_int_get atomic_int_get_win32

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


[FFmpeg-cvslog] Merge commit '675ac56b7ee0f204963fde55295197c5df80aa91'

2014-11-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu Nov 27 
11:52:33 2014 +0100| [4ae1d6021be96dcded093e51d04294075b14e511] | committer: 
Michael Niedermayer

Merge commit '675ac56b7ee0f204963fde55295197c5df80aa91'

* commit '675ac56b7ee0f204963fde55295197c5df80aa91':
  Revert "lavf: Don't try to update files atomically with renames on windows"

Conflicts:
libavformat/dashenc.c
libavformat/hdsenc.c
libavformat/internal.h
libavformat/smoothstreamingenc.c

Merged-by: Michael Niedermayer 

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



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


[FFmpeg-cvslog] libavutil/ppc/util_altivec.h : fix load_with_perm_vec() add marcos vcswapi2s() vcswapc() VEC_SPLAT16() VEC_SLD16() for POWER LE

2014-11-27 Thread Rong Yan
ffmpeg | branch: master | Rong Yan  | Thu Nov 27 05:45:58 
2014 +| [22e557917d08ed93e9c657f13c9669482341eb02] | committer: Michael 
Niedermayer

libavutil/ppc/util_altivec.h : fix load_with_perm_vec() add marcos vcswapi2s() 
vcswapc() VEC_SPLAT16() VEC_SLD16() for POWER LE

Signed-off-by: Michael Niedermayer 

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

 libavutil/ppc/util_altivec.h |   38 +++---
 1 file changed, 31 insertions(+), 7 deletions(-)

diff --git a/libavutil/ppc/util_altivec.h b/libavutil/ppc/util_altivec.h
index 2f0c6eb..c0b71c8 100644
--- a/libavutil/ppc/util_altivec.h
+++ b/libavutil/ppc/util_altivec.h
@@ -46,9 +46,21 @@
 #define WORD_s1 0x14,0x15,0x16,0x17
 #define WORD_s2 0x18,0x19,0x1a,0x1b
 #define WORD_s3 0x1c,0x1d,0x1e,0x1f
-
 #define vcprm(a,b,c,d) (const vector unsigned char){WORD_ ## a, WORD_ ## b, 
WORD_ ## c, WORD_ ## d}
 
+#define SWP_W2S0 0x02,0x03,0x00,0x01
+#define SWP_W2S1 0x06,0x07,0x04,0x05
+#define SWP_W2S2 0x0a,0x0b,0x08,0x09
+#define SWP_W2S3 0x0e,0x0f,0x0c,0x0d
+#define SWP_W2Ss0 0x12,0x13,0x10,0x11
+#define SWP_W2Ss1 0x16,0x17,0x14,0x15
+#define SWP_W2Ss2 0x1a,0x1b,0x18,0x19
+#define SWP_W2Ss3 0x1e,0x1f,0x1c,0x1d
+#define vcswapi2s(a,b,c,d) (const vector unsigned char){SWP_W2S ## a, SWP_W2S 
## b, SWP_W2S ## c, SWP_W2S ## d}
+
+#define vcswapc() \
+  (const vector unsigned 
char){0x0f,0x0e,0x0d,0x0c,0x0b,0x0a,0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00}
+
 
 // Transpose 8x8 matrix of 16-bit elements (in-place)
 #define TRANSPOSE8(a,b,c,d,e,f,g,h) \
@@ -103,8 +115,15 @@ static inline vector unsigned char unaligned_load(int 
offset, const uint8_t *src
 register vector unsigned char mask = vec_lvsl(offset, src);
 return vec_perm(first, second, mask);
 }
+static inline vec_u8 load_with_perm_vec(int offset, const uint8_t *src, vec_u8 
perm_vec)
+{
+vec_u8 a = vec_ld(offset, src);
+vec_u8 b = vec_ld(offset+15, src);
+return vec_perm(a, b, perm_vec);
+}
 #else
 #define unaligned_load(a,b) VEC_LD(a,b)
+#define load_with_perm_vec(a,b,c) VEC_LD(a,b)
 #endif
 
 
@@ -112,12 +131,6 @@ static inline vector unsigned char unaligned_load(int 
offset, const uint8_t *src
  * loads vector known misalignment
  * @param perm_vec the align permute vector to combine the two loads from lvsl
  */
-static inline vec_u8 load_with_perm_vec(int offset, const uint8_t *src, vec_u8 
perm_vec)
-{
-vec_u8 a = vec_ld(offset, src);
-vec_u8 b = vec_ld(offset+15, src);
-return vec_perm(a, b, perm_vec);
-}
 
 #define vec_unaligned_load(b)  VEC_LD(0, b)
 
@@ -135,6 +148,17 @@ static inline vec_u8 load_with_perm_vec(int offset, const 
uint8_t *src, vec_u8 p
 #define VEC_ST(a,b,c) vec_vsx_st(a,b,c)
 #endif
 
+#if HAVE_BIGENDIAN
+#define VEC_SPLAT16(a,b) vec_splat((vec_s16)a, b)
+#else
+#define VEC_SPLAT16(a,b) vec_splat((vec_s16)(vec_perm(a, a, 
vcswapi2s(0,1,2,3))), b)
+#endif
+
+#if HAVE_BIGENDIAN
+#define VEC_SLD16(a,b,c) vec_sld(a, b, c)
+#else
+#define VEC_SLD16(a,b,c) vec_sld(b, a, c)
+#endif
 
 #endif /* HAVE_ALTIVEC */
 

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


[FFmpeg-cvslog] Revert "lavf: Don't try to update files atomically with renames on windows "

2014-11-27 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö  | Tue Nov 25 
10:51:23 2014 +0200| [675ac56b7ee0f204963fde55295197c5df80aa91] | committer: 
Martin Storsjö

Revert "lavf: Don't try to update files atomically with renames on windows"

This reverts commit b9d08c77a44390b0848c06f20bc0e9e951ba6a3c.

After taking MoveFileEx into use, we can replace files with renames
on windows as well.

Signed-off-by: Martin Storsjö 

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

 libavformat/dashenc.c|   14 +-
 libavformat/hdsenc.c |   16 ++--
 libavformat/internal.h   |6 --
 libavformat/smoothstreamingenc.c |8 +++-
 4 files changed, 14 insertions(+), 30 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 57ce85f..0654661 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -296,15 +296,13 @@ static int write_manifest(AVFormatContext *s, int final)
 DASHContext *c = s->priv_data;
 AVIOContext *out;
 char temp_filename[1024];
-const char *write_filename;
 int ret, i;
 AVDictionaryEntry *title = av_dict_get(s->metadata, "title", NULL, 0);
 
 snprintf(temp_filename, sizeof(temp_filename), "%s.tmp", s->filename);
-write_filename = USE_RENAME_REPLACE ? temp_filename : s->filename;
-ret = avio_open2(&out, write_filename, AVIO_FLAG_WRITE, 
&s->interrupt_callback, NULL);
+ret = avio_open2(&out, temp_filename, AVIO_FLAG_WRITE, 
&s->interrupt_callback, NULL);
 if (ret < 0) {
-av_log(s, AV_LOG_ERROR, "Unable to open %s for writing\n", 
write_filename);
+av_log(s, AV_LOG_ERROR, "Unable to open %s for writing\n", 
temp_filename);
 return ret;
 }
 avio_printf(out, "\n");
@@ -394,7 +392,7 @@ static int write_manifest(AVFormatContext *s, int final)
 avio_printf(out, "\n");
 avio_flush(out);
 avio_close(out);
-return USE_RENAME_REPLACE ? ff_rename(temp_filename, s->filename) : 0;
+return ff_rename(temp_filename, s->filename);
 }
 
 static int dash_write_header(AVFormatContext *s)
@@ -607,7 +605,6 @@ static int dash_flush(AVFormatContext *s, int final, int 
stream)
 for (i = 0; i < s->nb_streams; i++) {
 OutputStream *os = &c->streams[i];
 char filename[1024] = "", full_path[1024], temp_path[1024];
-const char *write_path;
 int64_t start_pos = avio_tell(os->ctx->pb);
 int range_length, index_length = 0;
 
@@ -630,8 +627,7 @@ static int dash_flush(AVFormatContext *s, int final, int 
stream)
 snprintf(filename, sizeof(filename), "chunk-stream%d-%05d.m4s", i, 
os->segment_index);
 snprintf(full_path, sizeof(full_path), "%s%s", c->dirname, 
filename);
 snprintf(temp_path, sizeof(temp_path), "%s.tmp", full_path);
-write_path = USE_RENAME_REPLACE ? temp_path : full_path;
-ret = ffurl_open(&os->out, write_path, AVIO_FLAG_WRITE, 
&s->interrupt_callback, NULL);
+ret = ffurl_open(&os->out, temp_path, AVIO_FLAG_WRITE, 
&s->interrupt_callback, NULL);
 if (ret < 0)
 break;
 write_styp(os->ctx->pb);
@@ -646,7 +642,7 @@ static int dash_flush(AVFormatContext *s, int final, int 
stream)
 } else {
 ffurl_close(os->out);
 os->out = NULL;
-ret = USE_RENAME_REPLACE ? ff_rename(temp_path, full_path) : 0;
+ret = ff_rename(temp_path, full_path);
 if (ret < 0)
 break;
 }
diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c
index 326f886..d96a3d5 100644
--- a/libavformat/hdsenc.c
+++ b/libavformat/hdsenc.c
@@ -163,7 +163,6 @@ static int write_manifest(AVFormatContext *s, int final)
 HDSContext *c = s->priv_data;
 AVIOContext *out;
 char filename[1024], temp_filename[1024];
-const char *write_filename;
 int ret, i;
 float duration = 0;
 
@@ -172,11 +171,10 @@ static int write_manifest(AVFormatContext *s, int final)
 
 snprintf(filename, sizeof(filename), "%s/index.f4m", s->filename);
 snprintf(temp_filename, sizeof(temp_filename), "%s/index.f4m.tmp", 
s->filename);
-write_filename = USE_RENAME_REPLACE ? temp_filename : filename;
-ret = avio_open2(&out, write_filename, AVIO_FLAG_WRITE,
+ret = avio_open2(&out, temp_filename, AVIO_FLAG_WRITE,
  &s->interrupt_callback, NULL);
 if (ret < 0) {
-av_log(s, AV_LOG_ERROR, "Unable to open %s for writing\n", 
write_filename);
+av_log(s, AV_LOG_ERROR, "Unable to open %s for writing\n", 
temp_filename);
 return ret;
 }
 avio_printf(out, "\n");
@@ -206,7 +204,7 @@ static int write_manifest(AVFormatContext *s, int final)
 avio_printf(out, "\n");
 avio_flush(out);
 avio_close(out);
-return USE_RENAME_REPLACE ? ff_rename(temp_filename, filename) : 0;
+return ff_rename(temp_filename, filename);
 }
 
 static void updat

[FFmpeg-cvslog] lavf: Use MoveFileEx instead of rename/_wrename on windows

2014-11-27 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö  | Tue Nov 25 
11:08:59 2014 +0200| [79fd186a5035cf16fc0ab288d8f59da8b1ba2c0e] | committer: 
Martin Storsjö

lavf: Use MoveFileEx instead of rename/_wrename on windows

This allows getting the normal unix semantics, where a rename
allows replacing an existing file.

Based on a suggestion by Reimar Döffinger.

Signed-off-by: Martin Storsjö 

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

 configure|2 ++
 libavformat/os_support.h |   21 +++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 7b3faae..355a95b 100755
--- a/configure
+++ b/configure
@@ -1466,6 +1466,7 @@ SYSTEM_FUNCS="
 localtime_r
 mach_absolute_time
 MapViewOfFile
+MoveFileExA
 memalign
 mkstemp
 mmap
@@ -4096,6 +4097,7 @@ check_func_headers windows.h GetProcessAffinityMask
 check_func_headers windows.h GetProcessTimes
 check_func_headers windows.h GetSystemTimeAsFileTime
 check_func_headers windows.h MapViewOfFile
+check_func_headers windows.h MoveFileExA
 check_func_headers windows.h SetConsoleTextAttribute
 check_func_headers windows.h Sleep
 check_func_headers windows.h VirtualAlloc
diff --git a/libavformat/os_support.h b/libavformat/os_support.h
index 4aa98bd..4949065 100644
--- a/libavformat/os_support.h
+++ b/libavformat/os_support.h
@@ -170,14 +170,31 @@ static inline int win32_rename(const char *src_utf8, 
const char *dest_utf8)
 goto fallback;
 }
 
-ret = _wrename(src_w, dest_w);
+ret = MoveFileExW(src_w, dest_w, MOVEFILE_REPLACE_EXISTING);
 av_free(src_w);
 av_free(dest_w);
+// Lacking proper mapping from GetLastError() error codes to errno codes
+if (ret)
+errno = EPERM;
 return ret;
 
 fallback:
 /* filename may be be in CP_ACP */
-return rename(src_utf8, dest_utf8);
+#if HAVE_MOVEFILEEXA
+ret = MoveFileExA(src_utf8, dest_utf8, MOVEFILE_REPLACE_EXISTING);
+if (ret)
+errno = EPERM;
+#else
+/* Windows Phone doesn't have MoveFileExA. However, it's unlikely
+ * that anybody would input filenames in CP_ACP there, so this
+ * fallback is kept mostly for completeness. Alternatively we could
+ * do MultiByteToWideChar(CP_ACP) and use MoveFileExW, but doing
+ * explicit conversions with CP_ACP is allegedly forbidden in windows
+ * store apps (or windows phone), and the notion of a native code page
+ * doesn't make much sense there. */
+ret = rename(src_utf8, dest_utf8);
+#endif
+return ret;
 }
 
 #define mkdir(a, b) win32_mkdir(a)

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


[FFmpeg-cvslog] Merge commit '79fd186a5035cf16fc0ab288d8f59da8b1ba2c0e'

2014-11-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu Nov 27 
11:35:54 2014 +0100| [cc663bd13a97a92a3b3ba838393e77f2e1c490ad] | committer: 
Michael Niedermayer

Merge commit '79fd186a5035cf16fc0ab288d8f59da8b1ba2c0e'

* commit '79fd186a5035cf16fc0ab288d8f59da8b1ba2c0e':
  lavf: Use MoveFileEx instead of rename/_wrename on windows

Conflicts:
configure

Merged-by: Michael Niedermayer 

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



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


[FFmpeg-cvslog] Merge commit '9326d64ed1baadd7af60df6bbcc59cf1fefede48'

2014-11-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu Nov 27 
11:10:26 2014 +0100| [097de4d1d68fb5aef5fc8881b2afc65db3f0dac0] | committer: 
Michael Niedermayer

Merge commit '9326d64ed1baadd7af60df6bbcc59cf1fefede48'

* commit '9326d64ed1baadd7af60df6bbcc59cf1fefede48':
  Share the utf8 to wchar conversion routine between lavf and lavu

Conflicts:
libavformat/os_support.h
libavutil/file_open.c

Merged-by: Michael Niedermayer 

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



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


[FFmpeg-cvslog] Share the utf8 to wchar conversion routine between lavf and lavu

2014-11-27 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö  | Tue Nov 25 
10:39:50 2014 +0200| [9326d64ed1baadd7af60df6bbcc59cf1fefede48] | committer: 
Martin Storsjö

Share the utf8 to wchar conversion routine between lavf and lavu

This doesn't add any dependency on library internals, since this
only is a static inline function that gets built into each of the
calling functions - this is only to reduce the code duplication.

Signed-off-by: Martin Storsjö 

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

 libavformat/os_support.h   |   19 +--
 libavutil/file_open.c  |   13 -
 libavutil/wchar_filename.h |   44 
 3 files changed, 49 insertions(+), 27 deletions(-)

diff --git a/libavformat/os_support.h b/libavformat/os_support.h
index 50846d0..4aa98bd 100644
--- a/libavformat/os_support.h
+++ b/libavformat/os_support.h
@@ -127,24 +127,7 @@ int ff_poll(struct pollfd *fds, nfds_t numfds, int 
timeout);
 #elif defined(_WIN32)
 #include 
 #include 
-#include "libavutil/mem.h"
-
-static inline int utf8towchar(const char *filename_utf8, wchar_t **filename_w)
-{
-int num_chars;
-num_chars = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, 
filename_utf8, -1, NULL, 0);
-if (num_chars <= 0) {
-*filename_w = NULL;
-return 0;
-}
-*filename_w = av_mallocz(sizeof(wchar_t) * num_chars);
-if (!*filename_w) {
-errno = ENOMEM;
-return -1;
-}
-MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, *filename_w, num_chars);
-return 0;
-}
+#include "libavutil/wchar_filename.h"
 
 #define DEF_FS_FUNCTION(name, wfunc, afunc)   \
 static inline int win32_##name(const char *filename_utf8) \
diff --git a/libavutil/file_open.c b/libavutil/file_open.c
index 765eb60..f14ea70 100644
--- a/libavutil/file_open.c
+++ b/libavutil/file_open.c
@@ -37,23 +37,18 @@
 #include 
 #include 
 #include 
+#include "wchar_filename.h"
 
 static int win32_open(const char *filename_utf8, int oflag, int pmode)
 {
 int fd;
-int num_chars;
 wchar_t *filename_w;
 
 /* convert UTF-8 to wide chars */
-num_chars = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, 
filename_utf8, -1, NULL, 0);
-if (num_chars <= 0)
-goto fallback;
-filename_w = av_mallocz(sizeof(wchar_t) * num_chars);
-if (!filename_w) {
-errno = ENOMEM;
+if (utf8towchar(filename_utf8, &filename_w))
 return -1;
-}
-MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, filename_w, num_chars);
+if (!filename_w)
+goto fallback;
 
 fd = _wsopen(filename_w, oflag, SH_DENYNO, pmode);
 av_freep(&filename_w);
diff --git a/libavutil/wchar_filename.h b/libavutil/wchar_filename.h
new file mode 100644
index 000..2781773
--- /dev/null
+++ b/libavutil/wchar_filename.h
@@ -0,0 +1,44 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVUTIL_WCHAR_FILENAME_H
+#define AVUTIL_WCHAR_FILENAME_H
+
+#if defined(_WIN32) && !defined(__MINGW32CE__)
+#include 
+#include "mem.h"
+
+static inline int utf8towchar(const char *filename_utf8, wchar_t **filename_w)
+{
+int num_chars;
+num_chars = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, 
filename_utf8, -1, NULL, 0);
+if (num_chars <= 0) {
+*filename_w = NULL;
+return 0;
+}
+*filename_w = av_mallocz(sizeof(wchar_t) * num_chars);
+if (!*filename_w) {
+errno = ENOMEM;
+return -1;
+}
+MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, *filename_w, num_chars);
+return 0;
+}
+#endif
+
+#endif /* AVUTIL_WCHAR_FILENAME_H */

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