[FFmpeg-cvslog] avcodec/utils: Fix off by 1 error causing unneeded allocation in ff_fast_malloc()

2014-09-29 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon Sep 29 
05:41:54 2014 +0200| [8ba694548782c1821ab119c18fe02360a81c6768] | committer: 
Michael Niedermayer

avcodec/utils: Fix off by 1 error causing unneeded allocation in 
ff_fast_malloc()

Reviewed-by: Benoit Fouet 
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index b27f918..9eb2b5b 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -122,7 +122,7 @@ static void *avformat_mutex;
 static inline int ff_fast_malloc(void *ptr, unsigned int *size, size_t 
min_size, int zero_realloc)
 {
 void **p = ptr;
-if (min_size < *size)
+if (min_size <= *size && *p)
 return 0;
 min_size = FFMAX(17 * min_size / 16 + 32, min_size);
 av_free(*p);

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


[FFmpeg-cvslog] avcodec/put_bits: Add rebase_put_bits()

2014-09-29 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon Sep 29 
05:42:24 2014 +0200| [cf32181b70116309b3a33c8f6bf017a0d0a33089] | committer: 
Michael Niedermayer

avcodec/put_bits: Add rebase_put_bits()

Reviewed-by: Benoit Fouet 
Signed-off-by: Michael Niedermayer 

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

 libavcodec/put_bits.h |   18 ++
 1 file changed, 18 insertions(+)

diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h
index 8081fb9..8858caa 100644
--- a/libavcodec/put_bits.h
+++ b/libavcodec/put_bits.h
@@ -63,6 +63,24 @@ static inline void init_put_bits(PutBitContext *s, uint8_t 
*buffer,
 }
 
 /**
+ * Rebase the bit writer onto a reallocated buffer.
+ *
+ * @param buffer the buffer where to put bits
+ * @param buffer_size the size in bytes of buffer,
+ *must be larger than the previous size
+ */
+static inline void rebase_put_bits(PutBitContext *s, uint8_t *buffer,
+   int buffer_size)
+{
+av_assert0(8*buffer_size > s->size_in_bits);
+
+s->buf_end = buffer + buffer_size;
+s->buf_ptr = buffer + (s->buf_ptr - s->buf);
+s->buf = buffer;
+s->size_in_bits = 8 * buffer_size;
+}
+
+/**
  * @return the total number of bits written to the bitstream.
  */
 static inline int put_bits_count(PutBitContext *s)

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


[FFmpeg-cvslog] Merge commit 'a05f5052fef3b3743fab7846da12861d8a8098ec'

2014-09-29 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon Sep 29 
20:26:12 2014 +0200| [77ab7407c2728de7517be81311bf84426b898685] | committer: 
Michael Niedermayer

Merge commit 'a05f5052fef3b3743fab7846da12861d8a8098ec'

* commit 'a05f5052fef3b3743fab7846da12861d8a8098ec':
  sdp: Make opus declaration conform to the spec

Merged-by: Michael Niedermayer 

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



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


[FFmpeg-cvslog] sdp: Make opus declaration conform to the spec

2014-09-29 Thread Timothy B. Terriberry
ffmpeg | branch: master | Timothy B. Terriberry  | Wed Sep 
24 17:43:22 2014 -0700| [a05f5052fef3b3743fab7846da12861d8a8098ec] | committer: 
Martin Storsjö

sdp: Make opus declaration conform to the spec

Signed-off-by: Martin Storsjö 

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

 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
@@ -583,8 +583,18 @@ static char *sdp_write_media_attributes(char *buff, int 
size, AVCodecContext *c,
  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... */

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


[FFmpeg-cvslog] Merge commit 'e3a00acde05c925617dc19b5373969d864bf8414'

2014-09-29 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon Sep 29 
20:33:09 2014 +0200| [46807921f768477c9339ad92a785cc64d9407d20] | committer: 
Michael Niedermayer

Merge commit 'e3a00acde05c925617dc19b5373969d864bf8414'

* commit 'e3a00acde05c925617dc19b5373969d864bf8414':
  hevc: Initialize mergecand_list to 0

Merged-by: Michael Niedermayer 

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



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


[FFmpeg-cvslog] hevc: Initialize mergecand_list to 0

2014-09-29 Thread Luca Barbato
ffmpeg | branch: master | Luca Barbato  | Wed Sep 17 
19:51:40 2014 +0200| [e3a00acde05c925617dc19b5373969d864bf8414] | committer: 
Vittorio Giovara

hevc: Initialize mergecand_list to 0

Unbreak cf6090dc6252f2b276aa4133e3d73a89f4c6046c.

CC: libav-sta...@libav.org
Sample-Id: hevc-conformance-LTRPSPS_A_Qualcomm_1

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

 libavcodec/hevc_mvs.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/hevc_mvs.c b/libavcodec/hevc_mvs.c
index cc5a16c..a611b76 100644
--- a/libavcodec/hevc_mvs.c
+++ b/libavcodec/hevc_mvs.c
@@ -556,6 +556,8 @@ void ff_hevc_luma_mv_merge_mode(HEVCContext *s, int x0, int 
y0, int nPbW,
 int nPbH2 = nPbH;
 HEVCLocalContext *lc = &s->HEVClc;
 
+memset(mergecand_list, 0, MRG_MAX_NUM_CANDS * sizeof(*mergecand_list));
+
 if (s->pps->log2_parallel_merge_level > 2 && nCS == 8) {
 singleMCLFlag = 1;
 x0= lc->cu.x;

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


[FFmpeg-cvslog] h264: reset ret to avoid propagating minor failures

2014-09-29 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Sun Sep 28 
00:46:50 2014 +0100| [2cd7c99498b1bcb450c328459cf85a686ce83456] | committer: 
Vittorio Giovara

h264: reset ret to avoid propagating minor failures

Unbreak 772d150a6e82542c06b0c251e73dd299d98d1027.

CC: libav-sta...@libav.org
Bug-Id: 750 / 905753
Signed-off-by: Vittorio Giovara 

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

 libavcodec/h264.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 1fd5e50..562b102 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -1679,6 +1679,7 @@ again:
 goto end;
 }
 
+ret = 0;
 end:
 /* clean up */
 if (h->cur_pic_ptr && !h->droppable) {

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


[FFmpeg-cvslog] Merge commit '2cd7c99498b1bcb450c328459cf85a686ce83456'

2014-09-29 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon Sep 29 
21:02:45 2014 +0200| [56c47364c3b50c66c54b3372650f7fd542d998bb] | committer: 
Michael Niedermayer

Merge commit '2cd7c99498b1bcb450c328459cf85a686ce83456'

* commit '2cd7c99498b1bcb450c328459cf85a686ce83456':
  h264: reset ret to avoid propagating minor failures

See: 47048aa30b5c35fc8b030e819b9769b6bca03c08
Merged-by: Michael Niedermayer 

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



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


[FFmpeg-cvslog] lavf: fix memleaks in avformat_find_stream_info()

2014-09-29 Thread Justin Ruggles
ffmpeg | branch: master | Justin Ruggles  | Mon Sep 
16 15:51:46 2013 -0400| [19133e96d30e3f80dbae236ef081aedef419a6bf] | committer: 
Anton Khirnov

lavf: fix memleaks in avformat_find_stream_info()

When AVFMT_FLAG_NOBUFFER is set, the packets are not added to the
AVFormatContext packet list, so they need to be freed when they are
no longer needed.

Signed-off-by: Anton Khirnov 

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

 libavformat/utils.c |5 +
 1 file changed, 5 insertions(+)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index faad9c9..8757c10 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2228,6 +2228,8 @@ int avformat_find_stream_info(AVFormatContext *ic, 
AVDictionary **options)
  AV_TIME_BASE_Q) >= ic->max_analyze_duration) {
 av_log(ic, AV_LOG_WARNING, "max_analyze_duration %d reached\n",
ic->max_analyze_duration);
+if (ic->flags & AVFMT_FLAG_NOBUFFER)
+av_packet_unref(pkt);
 break;
 }
 }
@@ -2256,6 +2258,9 @@ int avformat_find_stream_info(AVFormatContext *ic, 
AVDictionary **options)
 try_decode_frame(st, pkt,
  (options && i < orig_nb_streams) ? &options[i] : 
NULL);
 
+if (ic->flags & AVFMT_FLAG_NOBUFFER)
+av_packet_unref(pkt);
+
 st->codec_info_nb_frames++;
 count++;
 }

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


[FFmpeg-cvslog] Merge commit '19133e96d30e3f80dbae236ef081aedef419a6bf'

2014-09-29 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon Sep 29 
21:25:09 2014 +0200| [a2d5f6b9dbcc81dda68309c96e9c2a227cb37976] | committer: 
Michael Niedermayer

Merge commit '19133e96d30e3f80dbae236ef081aedef419a6bf'

* commit '19133e96d30e3f80dbae236ef081aedef419a6bf':
  lavf: fix memleaks in avformat_find_stream_info()

Conflicts:
libavformat/utils.c

Merged-by: Michael Niedermayer 

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



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


[FFmpeg-cvslog] avcodec/mpegvideo_enc: Allocate only a small buffer and reallocate as needed

2014-09-29 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon Sep 29 
05:42:59 2014 +0200| [1441641d786a2deecae49c6dc2979af8791ce962] | committer: 
Michael Niedermayer

avcodec/mpegvideo_enc: Allocate only a small buffer and reallocate as needed

This should reduce the memory requirement

Signed-off-by: Michael Niedermayer 

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

 libavcodec/mpegvideo_enc.c |   36 ++--
 1 file changed, 34 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 81298c8..045ef3d 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1701,7 +1701,11 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, 
AVPacket *pkt,
 
 /* output? */
 if (s->new_picture.f->data[0]) {
-if ((ret = ff_alloc_packet2(avctx, pkt, 
s->mb_width*s->mb_height*(MAX_MB_BYTES+100)+1)) < 0)
+int growing_buffer = context_count == 1 && !pkt->data && 
!s->data_partitioning;
+int pkt_size = growing_buffer ? 
FFMAX(s->mb_width*s->mb_height*64+1, avctx->internal->byte_buffer_size) - 
FF_INPUT_BUFFER_PADDING_SIZE
+  :
+  
s->mb_width*s->mb_height*(MAX_MB_BYTES+100)+1;
+if ((ret = ff_alloc_packet2(avctx, pkt, pkt_size)) < 0)
 return ret;
 if (s->mb_info) {
 s->mb_info_ptr = av_packet_new_side_data(pkt,
@@ -1726,7 +1730,13 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, 
AVPacket *pkt,
 if (ret < 0)
 return ret;
 vbv_retry:
-if (encode_picture(s, s->picture_number) < 0)
+ret = encode_picture(s, s->picture_number);
+if (growing_buffer) {
+av_assert0(s->pb.buf == avctx->internal->byte_buffer);
+pkt->data = s->pb.buf;
+pkt->size = avctx->internal->byte_buffer_size;
+}
+if (ret < 0)
 return -1;
 
 avctx->header_bits = s->header_bits;
@@ -2770,6 +2780,28 @@ static int encode_thread(AVCodecContext *c, void *arg){
 int dmin= INT_MAX;
 int dir;
 
+if (   s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < 
MAX_MB_BYTES
+&& s->slice_context_count == 1
+&& s->pb.buf == s->avctx->internal->byte_buffer) {
+int new_size =  s->avctx->internal->byte_buffer_size
+  + s->avctx->internal->byte_buffer_size/4
+  + s->mb_width*MAX_MB_BYTES;
+int lastgob_pos = s->ptr_lastgob - s->pb.buf;
+int vbv_pos = s->vbv_delay_ptr - s->pb.buf;
+
+uint8_t *new_buffer = NULL;
+int new_buffer_size = 0;
+
+av_fast_padded_malloc(&new_buffer, &new_buffer_size, new_size);
+if (new_buffer) {
+memcpy(new_buffer, s->avctx->internal->byte_buffer, 
s->avctx->internal->byte_buffer_size);
+s->avctx->internal->byte_buffer  = new_buffer;
+s->avctx->internal->byte_buffer_size = new_buffer_size;
+rebase_put_bits(&s->pb, new_buffer, new_buffer_size);
+s->ptr_lastgob   = s->pb.buf + lastgob_pos;
+s->vbv_delay_ptr = s->pb.buf + vbv_pos;
+}
+}
 if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < 
MAX_MB_BYTES){
 av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
 return -1;

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


[FFmpeg-cvslog] avcodec/mpegvideo_enc: Fix leak on bitstream buffer reallocation

2014-09-29 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Tue Sep 30 
05:11:19 2014 +0200| [61c0683080176cfc6c325e556a3b7a4ca9566d5c] | committer: 
Michael Niedermayer

avcodec/mpegvideo_enc: Fix leak on bitstream buffer reallocation

Signed-off-by: Michael Niedermayer 

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

 libavcodec/mpegvideo_enc.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 045ef3d..d045179 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -2795,6 +2795,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
 av_fast_padded_malloc(&new_buffer, &new_buffer_size, new_size);
 if (new_buffer) {
 memcpy(new_buffer, s->avctx->internal->byte_buffer, 
s->avctx->internal->byte_buffer_size);
+av_free(s->avctx->internal->byte_buffer);
 s->avctx->internal->byte_buffer  = new_buffer;
 s->avctx->internal->byte_buffer_size = new_buffer_size;
 rebase_put_bits(&s->pb, new_buffer, new_buffer_size);

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