[FFmpeg-cvslog] swresample/resample: speed up build_filter for Blackman-Nuttall filter

2015-11-05 Thread Ganesh Ajjanagadde
ffmpeg | branch: master | Ganesh Ajjanagadde  | Wed Nov 
 4 22:02:13 2015 -0500| [c8780822bacc38a8d84c882d564b07dd152366ed] | committer: 
Ganesh Ajjanagadde

swresample/resample: speed up build_filter for Blackman-Nuttall filter

This uses the trigonometric double and triple angle formulae to avoid
repeated (expensive) evaluation of libc's cos().

Sample benchmark (x86-64, Haswell, GNU/Linux)
test: fate-swr-resample-dblp-44100-2626
old:
1104466600 decicycles in build_filter(loop 1000), 256 runs,  0 skips
1096765286 decicycles in build_filter(loop 1000), 512 runs,  0 skips
1070479590 decicycles in build_filter(loop 1000),1024 runs,  0 skips

new:
588861423 decicycles in build_filter(loop 1000), 256 runs,  0 skips
591262754 decicycles in build_filter(loop 1000), 512 runs,  0 skips
577355145 decicycles in build_filter(loop 1000),1024 runs,  0 skips

This results in small differences with the old expression:
difference (worst case on [0, 2*M_PI]), argmax 0.008:
max diff (relative): 0.157289807188
blackman_old(0.008): 0.000363951585488813192382
blackman_new(0.008): 0.000363951585488755946507

These are judged to be insignificant for the performance gain. PSNR to
reference file is unchanged up to second decimal point for instance.

Reviewed-by: Michael Niedermayer 
Signed-off-by: Ganesh Ajjanagadde 

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

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

diff --git a/libswresample/resample.c b/libswresample/resample.c
index c881ed8..6f2ca98 100644
--- a/libswresample/resample.c
+++ b/libswresample/resample.c
@@ -73,7 +73,7 @@ static double bessel(double x){
 static int build_filter(ResampleContext *c, void *filter, double factor, int 
tap_count, int alloc, int phase_count, int scale,
 int filter_type, int kaiser_beta){
 int ph, i;
-double x, y, w;
+double x, y, w, t;
 double *tab = av_malloc_array(tap_count+1,  sizeof(*tab));
 const int center= (tap_count-1)/2;
 
@@ -100,7 +100,8 @@ static int build_filter(ResampleContext *c, void *filter, 
double factor, int tap
 break;}
 case SWR_FILTER_TYPE_BLACKMAN_NUTTALL:
 w = 2.0*x / (factor*tap_count) + M_PI;
-y *= 0.3635819 - 0.4891775 * cos(w) + 0.1365995 * cos(2*w) - 
0.0106411 * cos(3*w);
+t = cos(w);
+y *= 0.3635819 - 0.4891775 * t + 0.1365995 * (2*t*t-1) - 
0.0106411 * (4*t*t*t - 3*t);
 break;
 case SWR_FILTER_TYPE_KAISER:
 w = 2.0*x / (factor*tap_count*M_PI);

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


[FFmpeg-cvslog] mpegtsenc: Add support for muxing Opus in MPEG-TS

2015-11-05 Thread Sebastian Dröge
ffmpeg | branch: master | Sebastian Dröge  | Thu Nov 
 5 23:35:42 2015 +0100| [01509cdf9287b975eced1fd609a8201fbd1438e3] | committer: 
Michael Niedermayer

mpegtsenc: Add support for muxing Opus in MPEG-TS

Signed-off-by: Sebastian Dröge 
Previous version reviewed-by: Kieran Kunhya 
Signed-off-by: Michael Niedermayer 

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

 libavformat/mpegtsenc.c |  180 ++-
 1 file changed, 179 insertions(+), 1 deletion(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 4d74252..96d277e 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -227,6 +227,9 @@ typedef struct MpegTSWriteStream {
 uint8_t *payload;
 AVFormatContext *amux;
 AVRational user_tb;
+
+/* For Opus */
+int opus_queued_samples;
 } MpegTSWriteStream;
 
 static void mpegts_write_pat(AVFormatContext *s)
@@ -314,6 +317,9 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 case AV_CODEC_ID_TRUEHD:
 stream_type = STREAM_TYPE_AUDIO_TRUEHD;
 break;
+case AV_CODEC_ID_OPUS:
+stream_type = STREAM_TYPE_PRIVATE_DATA;
+break;
 default:
 stream_type = STREAM_TYPE_PRIVATE_DATA;
 break;
@@ -340,6 +346,82 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 *q++ = 'S';
 *q++ = 'D';
 }
+if (st->codec->codec_id==AV_CODEC_ID_OPUS) {
+/* 6 bytes registration descriptor, 4 bytes Opus audio 
descriptor */
+if (q - data > SECTION_LENGTH - 6 - 4) {
+err = 1;
+break;
+}
+
+*q++ = 0x05; /* MPEG-2 registration descriptor*/
+*q++ = 4;
+*q++ = 'O';
+*q++ = 'p';
+*q++ = 'u';
+*q++ = 's';
+
+*q++ = 0x7f; /* DVB extension descriptor */
+*q++ = 2;
+*q++ = 0x80;
+
+if (st->codec->extradata && st->codec->extradata_size >= 19) {
+if (st->codec->extradata[18] == 0 && st->codec->channels 
<= 2) {
+/* RTP mapping family */
+*q++ = st->codec->channels;
+} else if (st->codec->extradata[18] == 1 && 
st->codec->channels <= 8 &&
+   st->codec->extradata_size >= 21 + 
st->codec->channels) {
+static const uint8_t coupled_stream_counts[9] = {
+1, 0, 1, 1, 2, 2, 2, 3, 3
+};
+static const uint8_t channel_map_a[8][8] = {
+{0},
+{0, 1},
+{0, 2, 1},
+{0, 1, 2, 3},
+{0, 4, 1, 2, 3},
+{0, 4, 1, 2, 3, 5},
+{0, 4, 1, 2, 3, 5, 6},
+{0, 6, 1, 2, 3, 4, 5, 7},
+};
+static const uint8_t channel_map_b[8][8] = {
+{0},
+{0, 1},
+{0, 1, 2},
+{0, 1, 2, 3},
+{0, 1, 2, 3, 4},
+{0, 1, 2, 3, 4, 5},
+{0, 1, 2, 3, 4, 5, 6},
+{0, 1, 2, 3, 4, 5, 6, 7},
+};
+/* Vorbis mapping family */
+
+if (st->codec->extradata[19] == st->codec->channels - 
coupled_stream_counts[st->codec->channels] &&
+st->codec->extradata[20] == 
coupled_stream_counts[st->codec->channels] &&
+memcmp(&st->codec->extradata[21], 
channel_map_a[st->codec->channels], st->codec->channels) == 0) {
+*q++ = st->codec->channels;
+} else if (st->codec->channels >= 2 && 
st->codec->extradata[19] == st->codec->channels &&
+   st->codec->extradata[20] == 0 &&
+   memcmp(&st->codec->extradata[21], 
channel_map_b[st->codec->channels], st->codec->channels) == 0) {
+*q++ = st->codec->channels | 0x80;
+} else {
+/* Unsupported, could write an extended descriptor 
here */
+av_log(s, AV_LOG_ERROR, "Unsupported Opus 
Vorbis-style channel mapping");
+*q++ = 0xff;
+}
+} else {
+/* Unsupported */
+av_log(s, AV_LOG_ERROR, "Unsupported Opus channel 
mapping for family %d", st->codec-

[FFmpeg-cvslog] mpegtsenc: Implement writing of Opus trim_start/trim_end control values

2015-11-05 Thread Sebastian Dröge
ffmpeg | branch: master | Sebastian Dröge  | Mon Nov 
 2 09:06:19 2015 +0200| [7d6a4797f17f29ed6f48eecbf9c50ae99a8fb04d] | committer: 
Michael Niedermayer

mpegtsenc: Implement writing of Opus trim_start/trim_end control values

Signed-off-by: Sebastian Dröge 
Reviewed-by: Kieran Kunhya 
Signed-off-by: Michael Niedermayer 

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

 libavformat/mpegtsenc.c |   43 ---
 1 file changed, 40 insertions(+), 3 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 96d277e..252f9c6 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -230,6 +230,7 @@ typedef struct MpegTSWriteStream {
 
 /* For Opus */
 int opus_queued_samples;
+int opus_pending_trim_start;
 } MpegTSWriteStream;
 
 static void mpegts_write_pat(AVFormatContext *s)
@@ -825,6 +826,9 @@ static int mpegts_write_header(AVFormatContext *s)
 if (ret < 0)
 goto fail;
 }
+if (st->codec->codec_id == AV_CODEC_ID_OPUS) {
+ts_st->opus_pending_trim_start = st->codec->initial_padding * 
48000 / st->codec->sample_rate;
+}
 }
 
 av_freep(&pids);
@@ -1513,17 +1517,38 @@ static int mpegts_write_packet_internal(AVFormatContext 
*s, AVPacket *pkt)
 
 /* Add Opus control header */
 if ((AV_RB16(pkt->data) >> 5) != 0x3ff) {
+uint8_t *side_data;
+int side_data_size;
 int i, n;
+int ctrl_header_size;
+int trim_start = 0, trim_end = 0;
 
 opus_samples = opus_get_packet_samples(s, pkt);
 
-data = av_malloc(pkt->size + 2 + pkt->size / 255 + 1);
+side_data = av_packet_get_side_data(pkt,
+AV_PKT_DATA_SKIP_SAMPLES,
+&side_data_size);
+
+if (side_data && side_data_size >= 10) {
+trim_end = AV_RL32(side_data + 4) * 48000 / 
st->codec->sample_rate;
+}
+
+ctrl_header_size = pkt->size + 2 + pkt->size / 255 + 1;
+if (ts_st->opus_pending_trim_start)
+  ctrl_header_size += 2;
+if (trim_end)
+  ctrl_header_size += 2;
+
+data = av_malloc(ctrl_header_size);
 if (!data)
 return AVERROR(ENOMEM);
 
-/* TODO: Write trim if needed */
 data[0] = 0x7f;
 data[1] = 0xe0;
+if (ts_st->opus_pending_trim_start)
+data[1] |= 0x10;
+if (trim_end)
+data[1] |= 0x08;
 
 n = pkt->size;
 i = 2;
@@ -1535,9 +1560,21 @@ static int mpegts_write_packet_internal(AVFormatContext 
*s, AVPacket *pkt)
 
 av_assert0(2 + pkt->size / 255 + 1 == i);
 
+if (ts_st->opus_pending_trim_start) {
+trim_start = FFMIN(ts_st->opus_pending_trim_start, 
opus_samples);
+AV_WB16(data + i, trim_start);
+i += 2;
+ts_st->opus_pending_trim_start -= trim_start;
+}
+if (trim_end) {
+trim_end = FFMIN(trim_end, opus_samples - trim_start);
+AV_WB16(data + i, trim_end);
+i += 2;
+}
+
 memcpy(data + i, pkt->data, pkt->size);
 buf = data;
-size= pkt->size + 2 + pkt->size / 255 + 1;
+size= ctrl_header_size;
 } else {
 /* TODO: Can we get TS formatted data here? If so we will
  * need to count the samples of that too! */

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


[FFmpeg-cvslog] avformat/xmv: Discard remainder of packet on error

2015-11-05 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Fri 
Nov  6 02:13:36 2015 +0100| [79c4a338e4b2bf0bc6f81c9f455994f673a92f78] | 
committer: Michael Niedermayer

avformat/xmv: Discard remainder of packet on error

Fixes infinite loop
Fixes: 
9c48ae2680c5f23bca3d20ff0f325fd8/asan_generic_4c254d_1374_993f1e5967dd6f844b8d72f978ce2a6c.pss

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer 

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

 libavformat/xmv.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavformat/xmv.c b/libavformat/xmv.c
index 06c070c..14d007a 100644
--- a/libavformat/xmv.c
+++ b/libavformat/xmv.c
@@ -554,8 +554,11 @@ static int xmv_read_packet(AVFormatContext *s,
 
 result = xmv_fetch_audio_packet(s, pkt, xmv->current_stream - 1);
 }
-if (result)
+if (result) {
+xmv->current_stream = 0;
+xmv->video.current_frame = xmv->video.frame_count;
 return result;
+}
 
 
 /* Increase our counters */

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


[FFmpeg-cvslog] avformat/xmv: factor return check out of if/else

2015-11-05 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Fri 
Nov  6 02:11:01 2015 +0100| [9b6fac11da470274d4b93d46ef66527aa1824179] | 
committer: Michael Niedermayer

avformat/xmv: factor return check out of if/else

Signed-off-by: Michael Niedermayer 

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

 libavformat/xmv.c |8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/libavformat/xmv.c b/libavformat/xmv.c
index 45c2464..06c070c 100644
--- a/libavformat/xmv.c
+++ b/libavformat/xmv.c
@@ -549,16 +549,14 @@ static int xmv_read_packet(AVFormatContext *s,
 /* Fetch a video frame */
 
 result = xmv_fetch_video_packet(s, pkt);
-if (result)
-return result;
-
 } else {
 /* Fetch an audio frame */
 
 result = xmv_fetch_audio_packet(s, pkt, xmv->current_stream - 1);
-if (result)
-return result;
 }
+if (result)
+return result;
+
 
 /* Increase our counters */
 if (++xmv->current_stream >= xmv->stream_count) {

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


[FFmpeg-cvslog] avcodec/mpeg12dec: Do not call show_bits() with invalid bits

2015-11-05 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Fri 
Nov  6 00:56:04 2015 +0100| [973c3dba27d0b1a88c70f6661b6a90d2f2e50665] | 
committer: Michael Niedermayer

avcodec/mpeg12dec: Do not call show_bits() with invalid bits

Fixes assertion failure
Fixes: 
63e50545709a6440d3d59f6426d58db9/signal_sigabrt_76ae7cc9_8189_3272a3010fd98ddf947c662bbde1ac13.ts

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 21a3470..66bc4dc 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1949,7 +1949,7 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y,
 (left && show_bits(&s->gb, FFMIN(left, 23)) && !is_d10) ||
 ((avctx->err_recognition & (AV_EF_BITSTREAM | 
AV_EF_AGGRESSIVE)) && left > 8)) {
 av_log(avctx, AV_LOG_ERROR, "end mismatch left=%d %0X\n",
-   left, show_bits(&s->gb, FFMIN(left, 23)));
+   left, left>0 ? show_bits(&s->gb, FFMIN(left, 23)) : 
0);
 return AVERROR_INVALIDDATA;
 } else
 goto eos;

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


[FFmpeg-cvslog] avcodec/dnxhddec: Make mb_scan_index a fixed length array

2015-11-05 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Nov  5 23:04:48 2015 +0100| [cea9eb9520fab9e5ec79d3a2d4dbd03eb71b7fa3] | 
committer: Michael Niedermayer

avcodec/dnxhddec: Make mb_scan_index a fixed length array

Fixes null pointer dereference
Fixes: 
5c9d1a6f74a12763fc7c9dd7834022b9/signal_sigsegv_11f78d9_1461_ecee3c5e7205457498e79b3ffaf21d0c.mxf

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer 

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

 libavcodec/dnxhddec.c |   12 ++--
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
index 2eb07ec..f0fdbb9 100644
--- a/libavcodec/dnxhddec.c
+++ b/libavcodec/dnxhddec.c
@@ -57,7 +57,7 @@ typedef struct DNXHDContext {
 unsigned int width, height;
 enum AVPixelFormat pix_fmt;
 unsigned int mb_width, mb_height;
-uint32_t *mb_scan_index;
+uint32_t mb_scan_index[256];
 int data_offset;// End of mb_scan_index, where 
macroblocks start
 int cur_field;  ///< current interlaced field
 VLC ac_vlc, dc_vlc, run_vlc;
@@ -164,7 +164,6 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame 
*frame,
 static const uint8_t header_prefixhr2[] = { 0x00, 0x00, 0x03, 0x8C, 0x03 };
 int i, cid, ret;
 int old_bit_depth = ctx->bit_depth, bitdepth;
-int old_mb_height = ctx->mb_height;
 
 if (buf_size < 0x280) {
 av_log(ctx->avctx, AV_LOG_ERROR,
@@ -293,13 +292,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame 
*frame,
 return AVERROR_INVALIDDATA;
 }
 
-if (ctx->mb_height != old_mb_height) {
-av_freep(&ctx->mb_scan_index);
-
-ctx->mb_scan_index = av_mallocz_array(ctx->mb_height, 
sizeof(uint32_t));
-if (!ctx->mb_scan_index)
-return AVERROR(ENOMEM);
-}
+av_assert0((unsigned)ctx->mb_height <= FF_ARRAY_ELEMS(ctx->mb_scan_index));
 
 for (i = 0; i < ctx->mb_height; i++) {
 ctx->mb_scan_index[i] = AV_RB32(buf + 0x170 + (i << 2));
@@ -681,7 +674,6 @@ static av_cold int dnxhd_decode_close(AVCodecContext *avctx)
 ff_free_vlc(&ctx->dc_vlc);
 ff_free_vlc(&ctx->run_vlc);
 
-av_freep(&ctx->mb_scan_index);
 av_freep(&ctx->rows);
 
 return 0;

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


[FFmpeg-cvslog] avcodec/faxcompr: Add missing runs check in decode_uncompressed()

2015-11-05 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Nov  5 21:35:23 2015 +0100| [d4a731b84a08f0f3839eaaaf82e97d8d9c67da46] | 
committer: Michael Niedermayer

avcodec/faxcompr: Add missing runs check in decode_uncompressed()

Fixes out of array access
Fixes: 
54e488b9da4abbceaf405d6492515697/asan_heap-oob_32769b0_160_a8755eb08ee8f9579348501945a33955.TIF

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer 

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

 libavcodec/faxcompr.c |4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/faxcompr.c b/libavcodec/faxcompr.c
index 80df418..2a1d2bc 100644
--- a/libavcodec/faxcompr.c
+++ b/libavcodec/faxcompr.c
@@ -189,6 +189,10 @@ static int decode_uncompressed(AVCodecContext *avctx, 
GetBitContext *gb,
 *mode = !*mode;
 if (newmode != *mode) { //FIXME CHECK
 *(*runs)++ = 0;
+if (*runs >= runend) {
+av_log(avctx, AV_LOG_ERROR, "uncompressed run overrun\n");
+return AVERROR_INVALIDDATA;
+}
 *mode = newmode;
 }
 return 0;

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


[FFmpeg-cvslog] libavutil/channel_layout: Check strtol*() for failure

2015-11-05 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Nov  5 19:24:33 2015 +0100| [c9bfd6a8c35a2102e730aca12f6e09d1627f76b3] | 
committer: Michael Niedermayer

libavutil/channel_layout: Check strtol*() for failure

Fixes assertion failure
Fixes: 
4f5814bb15d2dda6fc18ef9791b13816/signal_sigabrt_76ae7cc9_65_7209d160d168b76f311be6cd64a548eb.wv

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer 

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

 libavutil/channel_layout.c |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c
index a59ba46..601c7e6 100644
--- a/libavutil/channel_layout.c
+++ b/libavutil/channel_layout.c
@@ -122,13 +122,16 @@ static uint64_t get_channel_layout_single(const char 
*name, int name_len)
 strlen(channel_names[i].name) == name_len &&
 !memcmp(channel_names[i].name, name, name_len))
 return (int64_t)1 << i;
+
+errno = 0;
 i = strtol(name, &end, 10);
 
-if ((end + 1 - name == name_len && *end  == 'c'))
+if (!errno && (end + 1 - name == name_len && *end  == 'c'))
 return av_get_default_channel_layout(i);
 
+errno = 0;
 layout = strtoll(name, &end, 0);
-if (end - name == name_len)
+if (!errno && end - name == name_len)
 return FFMAX(layout, 0);
 return 0;
 }

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


[FFmpeg-cvslog] avformat/mpegts: Only start probing data streams within probe_packets

2015-11-05 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Nov  5 17:04:37 2015 +0100| [3692d859f45fa8765fa5a330e79108b03c17c6bd] | 
committer: Michael Niedermayer

avformat/mpegts: Only start probing data streams within probe_packets

Fixes assertion failure
Fixes: 
4321db8ac331f5967ebfbfe80ce5eb78/signal_sigabrt_76ae7cc9_7213_0d6457b9d6897fa7c78507fa5de53510.ts

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer 

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

 libavformat/mpegts.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 1d57947..bc1e03e 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -841,6 +841,7 @@ static int mpegts_set_stream_info(AVStream *st, PESContext 
*pes,
 if ((st->codec->codec_id == AV_CODEC_ID_NONE ||
 (st->request_probe > 0 && st->request_probe < 
AVPROBE_SCORE_STREAM_RETRY / 5)) &&
 !avcodec_is_open(st->codec) &&
+st->probe_packets > 0 &&
 stream_type == STREAM_TYPE_PRIVATE_DATA) {
 st->codec->codec_type = AVMEDIA_TYPE_DATA;
 st->codec->codec_id   = AV_CODEC_ID_BIN_DATA;

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


[FFmpeg-cvslog] avcodec/truemotion1: Initialize mb_change_byte only when needed

2015-11-05 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Nov  5 03:15:24 2015 +0100| [a813cdda487e252681df36f675332b04c2e0e5a6] | 
committer: Michael Niedermayer

avcodec/truemotion1: Initialize mb_change_byte only when needed

Fixes out of array read
Fixes: 
d92114d8c2a019b8a6e50cd2a7301b54/asan_heap-oob_26bf563_60_1d3420277533de9dbf8aba3f93af346f.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=a813cdda487e252681df36f675332b04c2e0e5a6
---

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

diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c
index b8d0de4..da843c4 100644
--- a/libavcodec/truemotion1.c
+++ b/libavcodec/truemotion1.c
@@ -645,7 +645,8 @@ static void truemotion1_decode_16bit(TrueMotion1Context *s)
 current_pixel_pair = (unsigned int *)current_line;
 vert_pred = s->vert_pred;
 mb_change_index = 0;
-mb_change_byte = mb_change_bits[mb_change_index++];
+if (!keyframe)
+mb_change_byte = mb_change_bits[mb_change_index++];
 mb_change_byte_mask = 0x01;
 pixels_left = s->avctx->width;
 

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


[FFmpeg-cvslog] avcodec/hevc_ps: Check chroma_format_idc

2015-11-05 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Nov  5 14:52:33 2015 +0100| [93f30f825c08477fe8f76be00539e96014cc83c8] | 
committer: Michael Niedermayer

avcodec/hevc_ps: Check chroma_format_idc

Fixes out of array access
Fixes: 
24d05e8b84676799c735c9e27d97895e/asan_heap-oob_1b70f6a_2955_7c3652a7f370f9f3ef40642bc2c99bb2.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=93f30f825c08477fe8f76be00539e96014cc83c8
---

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

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 427cf09..14f908e 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -834,6 +834,10 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
unsigned int *sps_id,
 }
 
 sps->chroma_format_idc = get_ue_golomb_long(gb);
+if (sps->chroma_format_idc > 3U) {
+av_log(avctx, AV_LOG_ERROR, "chroma_format_idc %d is invalid\n", 
sps->chroma_format_idc);
+return AVERROR_INVALIDDATA;
+}
 
 if (sps->chroma_format_idc == 3)
 sps->separate_colour_plane_flag = get_bits1(gb);

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