[FFmpeg-cvslog] avformat: add MIDI Sample Dump Standard demuxer

2017-01-22 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Fri Jan 20 17:01:31 
2017 +0100| [7f9978b0bdfc80ac23248df743645d1efc7e123f] | committer: Paul B Mahol

avformat: add MIDI Sample Dump Standard demuxer

Signed-off-by: Paul B Mahol 

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

 Changelog|   1 +
 doc/general.texi |   1 +
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/sdsdec.c | 165 +++
 libavformat/version.h|   2 +-
 6 files changed, 170 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index e15d8e2..aabaefe 100644
--- a/Changelog
+++ b/Changelog
@@ -14,6 +14,7 @@ version :
 - Apple Pixlet decoder
 - QDMC audio decoder
 - NewTek SpeedHQ decoder
+- MIDI Sample Dump Standard demuxer
 
 version 3.2:
 - libopenmpt demuxer
diff --git a/doc/general.texi b/doc/general.texi
index a13a8fc..5e77191 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -387,6 +387,7 @@ library:
 @tab Audio format used on the PS3.
 @item Mirillis FIC video@tab   @tab X
 @tab No cursor rendering.
+@item MIDI Sample Dump Standard @tab   @tab X
 @item MIME multipart JPEG   @tab X @tab
 @item MSN TCP webcam@tab   @tab X
 @tab Used by MSN Messenger webcam streams.
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 872b30e..f30bc94 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -436,6 +436,7 @@ OBJS-$(CONFIG_SAP_MUXER) += sapenc.o
 OBJS-$(CONFIG_SBG_DEMUXER)   += sbgdec.o
 OBJS-$(CONFIG_SDP_DEMUXER)   += rtsp.o
 OBJS-$(CONFIG_SDR2_DEMUXER)  += sdr2.o
+OBJS-$(CONFIG_SDS_DEMUXER)   += sdsdec.o
 OBJS-$(CONFIG_SEGAFILM_DEMUXER)  += segafilm.o
 OBJS-$(CONFIG_SEGMENT_MUXER) += segment.o
 OBJS-$(CONFIG_SHORTEN_DEMUXER)   += shortendec.o rawdec.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 6a79b75..e30305b 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -275,6 +275,7 @@ void av_register_all(void)
 REGISTER_DEMUXER (SBG,  sbg);
 REGISTER_DEMUXER (SDP,  sdp);
 REGISTER_DEMUXER (SDR2, sdr2);
+REGISTER_DEMUXER (SDS,  sds);
 #if CONFIG_RTPDEC
 ff_register_rtp_dynamic_payload_handlers();
 ff_register_rdt_dynamic_payload_handlers();
diff --git a/libavformat/sdsdec.c b/libavformat/sdsdec.c
new file mode 100644
index 000..081bb4c
--- /dev/null
+++ b/libavformat/sdsdec.c
@@ -0,0 +1,165 @@
+/*
+ * MIDI Sample Dump Standard format demuxer
+ * Copyright (c) 2017 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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.
+ *
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/intreadwrite.h"
+#include "avformat.h"
+#include "internal.h"
+
+typedef struct SDSContext {
+uint8_t data[120];
+int bit_depth;
+int size;
+void (*read_block)(const uint8_t *src, uint32_t *dst);
+} SDSContext;
+
+static int sds_probe(AVProbeData *p)
+{
+if (AV_RB32(p->buf) == 0xF07E0001 && p->buf[20] == 0xF7 &&
+p->buf[6] >= 8 && p->buf[6] <= 28)
+return AVPROBE_SCORE_EXTENSION;
+return 0;
+}
+
+static void byte2_read(const uint8_t *src, uint32_t *dst)
+{
+int i;
+
+for (i = 0; i < 120; i += 2) {
+unsigned sample = (src[i + 0] << 25) + (src[i + 1] << 18);
+
+dst[i / 2] = sample;
+}
+}
+
+static void byte3_read(const uint8_t *src, uint32_t *dst)
+{
+int i;
+
+for (i = 0; i < 120; i += 3) {
+unsigned sample;
+
+sample = (src[i + 0] << 25) | (src[i + 1] << 18) | (src[i + 2] << 11);
+dst[i / 3] = sample;
+}
+}
+
+static void byte4_read(const uint8_t *src, uint32_t *dst)
+{
+int i;
+
+for (i = 0; i < 120; i += 4) {
+unsigned sample;
+
+sample = (src[i + 0] << 25) | (src[i + 1] << 18) | (src[i + 2] << 11) 
| (src[i + 3] << 4);
+dst[i / 4] = sample;
+}
+}
+
+#define SDS_3BYTE_TO_INT_DECODE(x) (((x) & 0x7F) | (((x) & 0x7F00) >> 1) | 
(((x) & 0x7F) >> 2))
+
+static int sds_read_header(AVFormatContext *ctx)
+{
+SDSContext *s = ctx->priv_data;
+unsigned sample_period;
+AVIOContext *pb = ctx->pb;
+AVStr

[FFmpeg-cvslog] ffplay: fix indentation after last commit

2017-01-22 Thread Marton Balint
ffmpeg | branch: master | Marton Balint  | Sun Jan 15 17:43:15 
2017 +0100| [f1214ad5d9ece179955f9326f3e33e0049660134] | committer: Marton 
Balint

ffplay: fix indentation after last commit

Signed-off-by: Marton Balint 

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

 ffplay.c | 130 +++
 1 file changed, 65 insertions(+), 65 deletions(-)

diff --git a/ffplay.c b/ffplay.c
index d76e41c..7ea172f 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -894,81 +894,81 @@ static void video_image_display(VideoState *is)
 SDL_Rect rect;
 
 vp = frame_queue_peek_last(&is->pictq);
-if (is->subtitle_st) {
-if (frame_queue_nb_remaining(&is->subpq) > 0) {
-sp = frame_queue_peek(&is->subpq);
-
-if (vp->pts >= sp->pts + ((float) sp->sub.start_display_time / 
1000)) {
-if (!sp->uploaded) {
-uint8_t* pixels[4];
-int pitch[4];
-int i;
-if (!sp->width || !sp->height) {
-sp->width = vp->width;
-sp->height = vp->height;
-}
-if (realloc_texture(&is->sub_texture, 
SDL_PIXELFORMAT_ARGB, sp->width, sp->height, SDL_BLENDMODE_BLEND, 1) < 0)
+if (is->subtitle_st) {
+if (frame_queue_nb_remaining(&is->subpq) > 0) {
+sp = frame_queue_peek(&is->subpq);
+
+if (vp->pts >= sp->pts + ((float) sp->sub.start_display_time / 
1000)) {
+if (!sp->uploaded) {
+uint8_t* pixels[4];
+int pitch[4];
+int i;
+if (!sp->width || !sp->height) {
+sp->width = vp->width;
+sp->height = vp->height;
+}
+if (realloc_texture(&is->sub_texture, 
SDL_PIXELFORMAT_ARGB, sp->width, sp->height, SDL_BLENDMODE_BLEND, 1) < 0)
+return;
+
+for (i = 0; i < sp->sub.num_rects; i++) {
+AVSubtitleRect *sub_rect = sp->sub.rects[i];
+
+sub_rect->x = av_clip(sub_rect->x, 0, sp->width );
+sub_rect->y = av_clip(sub_rect->y, 0, sp->height);
+sub_rect->w = av_clip(sub_rect->w, 0, sp->width  - 
sub_rect->x);
+sub_rect->h = av_clip(sub_rect->h, 0, sp->height - 
sub_rect->y);
+
+is->sub_convert_ctx = 
sws_getCachedContext(is->sub_convert_ctx,
+sub_rect->w, sub_rect->h, AV_PIX_FMT_PAL8,
+sub_rect->w, sub_rect->h, AV_PIX_FMT_BGRA,
+0, NULL, NULL, NULL);
+if (!is->sub_convert_ctx) {
+av_log(NULL, AV_LOG_FATAL, "Cannot initialize the 
conversion context\n");
 return;
-
-for (i = 0; i < sp->sub.num_rects; i++) {
-AVSubtitleRect *sub_rect = sp->sub.rects[i];
-
-sub_rect->x = av_clip(sub_rect->x, 0, sp->width );
-sub_rect->y = av_clip(sub_rect->y, 0, sp->height);
-sub_rect->w = av_clip(sub_rect->w, 0, sp->width  - 
sub_rect->x);
-sub_rect->h = av_clip(sub_rect->h, 0, sp->height - 
sub_rect->y);
-
-is->sub_convert_ctx = 
sws_getCachedContext(is->sub_convert_ctx,
-sub_rect->w, sub_rect->h, AV_PIX_FMT_PAL8,
-sub_rect->w, sub_rect->h, AV_PIX_FMT_BGRA,
-0, NULL, NULL, NULL);
-if (!is->sub_convert_ctx) {
-av_log(NULL, AV_LOG_FATAL, "Cannot initialize 
the conversion context\n");
-return;
-}
-if (!SDL_LockTexture(is->sub_texture, (SDL_Rect 
*)sub_rect, (void **)pixels, pitch)) {
-sws_scale(is->sub_convert_ctx, (const uint8_t 
* const *)sub_rect->data, sub_rect->linesize,
-  0, sub_rect->h, pixels, pitch);
-SDL_UnlockTexture(is->sub_texture);
-}
 }
-sp->uploaded = 1;
+if (!SDL_LockTexture(is->sub_texture, (SDL_Rect 
*)sub_rect, (void **)pixels, pitch)) {
+sws_scale(is->sub_convert_ctx, (const uint8_t * 
const *)sub_rect->data, sub_rect->linesize,
+  0, sub_rect->h, pixels, pitch);
+SDL_UnlockTexture(is->sub_texture);
+}

[FFmpeg-cvslog] ffplay: do not preallocate video texture

2017-01-22 Thread Marton Balint
ffmpeg | branch: master | Marton Balint  | Sun Jul 27 22:11:38 
2014 +0200| [076fc75bdb8eb8de5e3f641dcc5f0299f7e7d0eb] | committer: Marton 
Balint

ffplay: do not preallocate video texture

Since the uploads happen in the main display function, it does not matter much.

Signed-off-by: Marton Balint 

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

 ffplay.c | 120 +++
 1 file changed, 20 insertions(+), 100 deletions(-)

diff --git a/ffplay.c b/ffplay.c
index 967679e..d76e41c 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -158,8 +158,6 @@ typedef struct Frame {
 double pts;   /* presentation timestamp for the frame */
 double duration;  /* estimated duration of the frame */
 int64_t pos;  /* byte position of the frame in the input file */
-SDL_Texture *bmp;
-int allocated;
 int width;
 int height;
 int format;
@@ -274,6 +272,7 @@ typedef struct VideoState {
 double last_vis_time;
 SDL_Texture *vis_texture;
 SDL_Texture *sub_texture;
+SDL_Texture *vid_texture;
 
 int subtitle_stream;
 AVStream *subtitle_st;
@@ -357,7 +356,6 @@ static int64_t audio_callback_time;
 
 static AVPacket flush_pkt;
 
-#define FF_ALLOC_EVENT   (SDL_USEREVENT)
 #define FF_QUIT_EVENT(SDL_USEREVENT + 2)
 
 static SDL_Window *window;
@@ -392,8 +390,6 @@ int64_t get_valid_channel_layout(int64_t channel_layout, 
int channels)
 return 0;
 }
 
-static void free_picture(Frame *vp);
-
 static int packet_queue_put_private(PacketQueue *q, AVPacket *pkt)
 {
 MyAVPacketList *pkt1;
@@ -677,7 +673,6 @@ static void frame_queue_destory(FrameQueue *f)
 Frame *vp = &f->queue[i];
 frame_queue_unref_item(vp);
 av_frame_free(&vp->frame);
-free_picture(vp);
 }
 SDL_DestroyMutex(f->mutex);
 SDL_DestroyCond(f->cond);
@@ -798,14 +793,6 @@ static inline void fill_rectangle(int x, int y, int w, int 
h)
 SDL_RenderFillRect(renderer, &rect);
 }
 
-static void free_picture(Frame *vp)
-{
- if (vp->bmp) {
- SDL_DestroyTexture(vp->bmp);
- vp->bmp = NULL;
- }
-}
-
 static int realloc_texture(SDL_Texture **texture, Uint32 new_format, int 
new_width, int new_height, SDL_BlendMode blendmode, int init_texture)
 {
 Uint32 format;
@@ -907,7 +894,6 @@ static void video_image_display(VideoState *is)
 SDL_Rect rect;
 
 vp = frame_queue_peek_last(&is->pictq);
-if (vp->bmp) {
 if (is->subtitle_st) {
 if (frame_queue_nb_remaining(&is->subpq) > 0) {
 sp = frame_queue_peek(&is->subpq);
@@ -956,13 +942,16 @@ static void video_image_display(VideoState *is)
 calculate_display_rect(&rect, is->xleft, is->ytop, is->width, 
is->height, vp->width, vp->height, vp->sar);
 
 if (!vp->uploaded) {
-if (upload_texture(vp->bmp, vp->frame, &is->img_convert_ctx) < 0)
+int sdl_pix_fmt = vp->frame->format == AV_PIX_FMT_YUV420P ? 
SDL_PIXELFORMAT_YV12 : SDL_PIXELFORMAT_ARGB;
+if (realloc_texture(&is->vid_texture, sdl_pix_fmt, 
vp->frame->width, vp->frame->height, SDL_BLENDMODE_NONE, 0) < 0)
+return;
+if (upload_texture(is->vid_texture, vp->frame, 
&is->img_convert_ctx) < 0)
 return;
 vp->uploaded = 1;
 vp->flip_v = vp->frame->linesize[0] < 0;
 }
 
-SDL_RenderCopyEx(renderer, vp->bmp, NULL, &rect, 0, NULL, vp->flip_v ? 
SDL_FLIP_VERTICAL : 0);
+SDL_RenderCopyEx(renderer, is->vid_texture, NULL, &rect, 0, NULL, 
vp->flip_v ? SDL_FLIP_VERTICAL : 0);
 if (sp) {
 #if USE_ONEPASS_SUBTITLE_RENDER
 SDL_RenderCopy(renderer, is->sub_texture, NULL, &rect);
@@ -980,7 +969,6 @@ static void video_image_display(VideoState *is)
 }
 #endif
 }
-}
 }
 
 static inline int compute_mod(int a, int b)
@@ -1217,6 +1205,8 @@ static void stream_close(VideoState *is)
 av_free(is->filename);
 if (is->vis_texture)
 SDL_DestroyTexture(is->vis_texture);
+if (is->vid_texture)
+SDL_DestroyTexture(is->vid_texture);
 if (is->sub_texture)
 SDL_DestroyTexture(is->sub_texture);
 av_free(is);
@@ -1257,13 +1247,10 @@ static void set_default_window_size(int width, int 
height, AVRational sar)
 default_height = rect.h;
 }
 
-static int video_open(VideoState *is, Frame *vp)
+static int video_open(VideoState *is)
 {
 int w,h;
 
-if (vp && vp->width)
-set_default_window_size(vp->width, vp->height, vp->sar);
-
 if (screen_width) {
 w = screen_width;
 h = screen_height;
@@ -1311,7 +1298,7 @@ static int video_open(VideoState *is, Frame *vp)
 static void video_display(VideoState *is)
 {
 if (!window)
-video_open(is, NULL);
+video_open(is);
 
 SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
 SDL_RenderClear(renderer);
@@ -1678,38 

[FFmpeg-cvslog] avcodec/error_resilience: Optimize motion recovery code by using blcok lists

2017-01-22 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Sun 
Jan 22 21:14:05 2017 +0100| [d9d9fd9446eb722fd288f56d905f0dfde661af8f] | 
committer: Michael Niedermayer

avcodec/error_resilience: Optimize motion recovery code by using blcok lists

This makes the code 7 times faster with the testcase from libfuzzer
and should reduce the amount of timeouts we hit in automated fuzzing.
(for example 438/fuzz-2-ffmpeg_VIDEO_AV_CODEC_ID_RV40_fuzzer)

The code is also faster with more realistic input though the difference
is small here as that is far from the worst cases the fuzzers pick out

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer 

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

 libavcodec/error_resilience.c | 113 ++
 libavcodec/h264dec.c  |   2 +-
 libavcodec/mpeg_er.c  |   2 +-
 3 files changed, 83 insertions(+), 34 deletions(-)

diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
index c7dbe17..6b457a9 100644
--- a/libavcodec/error_resilience.c
+++ b/libavcodec/error_resilience.c
@@ -373,23 +373,39 @@ static void v_block_filter(ERContext *s, uint8_t *dst, 
int w, int h,
 }
 }
 
+#define MV_FROZEN8
+#define MV_CHANGED   4
+#define MV_UNCHANGED 2
+#define MV_LISTED1
+static av_always_inline void add_blocklist(int (*blocklist)[2], int 
*blocklist_length, uint8_t *fixed, int mb_x, int mb_y, int mb_xy)
+{
+if (fixed[mb_xy])
+return;
+fixed[mb_xy] = MV_LISTED;
+blocklist[ *blocklist_length   ][0] = mb_x;
+blocklist[(*blocklist_length)++][1] = mb_y;
+}
+
 static void guess_mv(ERContext *s)
 {
-uint8_t *fixed = s->er_temp_buffer;
-#define MV_FROZEN4
-#define MV_CHANGED   2
-#define MV_UNCHANGED 1
+int (*blocklist)[2], (*next_blocklist)[2];
+uint8_t *fixed;
 const int mb_stride = s->mb_stride;
 const int mb_width  = s->mb_width;
 int mb_height = s->mb_height;
 int i, depth, num_avail;
 int mb_x, mb_y, mot_step, mot_stride;
+int blocklist_length, next_blocklist_length;
 
 if (s->last_pic.f && s->last_pic.f->data[0])
 mb_height = FFMIN(mb_height, (s->last_pic.f->height+15)>>4);
 if (s->next_pic.f && s->next_pic.f->data[0])
 mb_height = FFMIN(mb_height, (s->next_pic.f->height+15)>>4);
 
+blocklist  =  s->er_temp_buffer;
+next_blocklist = (s->er_temp_buffer + 2 * sizeof(int) * s->mb_stride * 
s->mb_height);
+fixed  =  s->er_temp_buffer + 4 * sizeof(int) * s->mb_stride * 
s->mb_height;
+
 set_mv_strides(s, &mot_step, &mot_stride);
 
 num_avail = 0;
@@ -439,8 +455,22 @@ static void guess_mv(ERContext *s)
 return;
 }
 
+blocklist_length = 0;
+for (mb_y = 0; mb_y < mb_height; mb_y++) {
+for (mb_x = 0; mb_x < mb_width; mb_x++) {
+const int mb_xy = mb_x + mb_y * mb_stride;
+if (fixed[mb_xy] == MV_FROZEN) {
+if (mb_x)   add_blocklist(blocklist, 
&blocklist_length, fixed, mb_x - 1, mb_y, mb_xy - 1);
+if (mb_y)   add_blocklist(blocklist, 
&blocklist_length, fixed, mb_x, mb_y - 1, mb_xy - mb_stride);
+if (mb_x+1 < mb_width)  add_blocklist(blocklist, 
&blocklist_length, fixed, mb_x + 1, mb_y, mb_xy + 1);
+if (mb_y+1 < mb_height) add_blocklist(blocklist, 
&blocklist_length, fixed, mb_x, mb_y + 1, mb_xy + mb_stride);
+}
+}
+}
+
 for (depth = 0; ; depth++) {
 int changed, pass, none_left;
+int blocklist_index;
 
 none_left = 1;
 changed   = 1;
@@ -449,20 +479,24 @@ static void guess_mv(ERContext *s)
 int score_sum = 0;
 
 changed = 0;
-for (mb_y = 0; mb_y < mb_height; mb_y++) {
-for (mb_x = (mb_y ^ pass) & 1; mb_x < s->mb_width; mb_x+=2) {
-const int mb_xy= mb_x + mb_y * s->mb_stride;
-int mv_predictor[8][2];
-int ref[8];
-int pred_count;
-int j;
-int best_score;
-int best_pred;
-int mot_index;
-int prev_x, prev_y, prev_ref;
-
-if (fixed[mb_xy] == MV_FROZEN)
-continue;
+for (blocklist_index = 0; blocklist_index < blocklist_length; 
blocklist_index++) {
+const int mb_x = blocklist[blocklist_index][0];
+const int mb_y = blocklist[blocklist_index][1];
+const int mb_xy = mb_x + mb_y * mb_stride;
+int mv_predictor[8][2];
+int ref[8];
+int pred_count;
+int j;
+int best_score;
+int best_pred;
+int mot_index;
+int prev_x, prev_y, prev_

[FFmpeg-cvslog] avcodec/error_resilience: update indention after last commit

2017-01-22 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Sun 
Jan 22 21:43:06 2017 +0100| [a0341b4d74f4db289e15dac0d2988eaa2d18a1bb] | 
committer: Michael Niedermayer

avcodec/error_resilience: update indention after last commit

Signed-off-by: Michael Niedermayer 

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

 libavcodec/error_resilience.c | 346 +-
 1 file changed, 173 insertions(+), 173 deletions(-)

diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
index 6b457a9..c73d4a7 100644
--- a/libavcodec/error_resilience.c
+++ b/libavcodec/error_resilience.c
@@ -497,196 +497,196 @@ static void guess_mv(ERContext *s)
 av_assert2(fixed[mb_xy] != MV_FROZEN);
 
 
-av_assert1(!IS_INTRA(s->cur_pic.mb_type[mb_xy]));
-av_assert1(s->last_pic.f && s->last_pic.f->data[0]);
-
-j = 0;
-if (mb_x > 0)
-j |= fixed[mb_xy - 1];
-if (mb_x + 1 < mb_width)
-j |= fixed[mb_xy + 1];
-if (mb_y > 0)
-j |= fixed[mb_xy - mb_stride];
-if (mb_y + 1 < mb_height)
-j |= fixed[mb_xy + mb_stride];
-
-av_assert2(j & MV_FROZEN);
-
-if (!(j & MV_CHANGED) && pass > 1)
-continue;
+av_assert1(!IS_INTRA(s->cur_pic.mb_type[mb_xy]));
+av_assert1(s->last_pic.f && s->last_pic.f->data[0]);
 
-none_left = 0;
-pred_count = 0;
-mot_index  = (mb_x + mb_y * mot_stride) * mot_step;
+j = 0;
+if (mb_x > 0)
+j |= fixed[mb_xy - 1];
+if (mb_x + 1 < mb_width)
+j |= fixed[mb_xy + 1];
+if (mb_y > 0)
+j |= fixed[mb_xy - mb_stride];
+if (mb_y + 1 < mb_height)
+j |= fixed[mb_xy + mb_stride];
 
-if (mb_x > 0 && fixed[mb_xy - 1] > 1) {
-mv_predictor[pred_count][0] =
-s->cur_pic.motion_val[0][mot_index - mot_step][0];
-mv_predictor[pred_count][1] =
-s->cur_pic.motion_val[0][mot_index - mot_step][1];
-ref[pred_count] =
-s->cur_pic.ref_index[0][4 * (mb_xy - 1)];
-pred_count++;
-}
-if (mb_x + 1 < mb_width && fixed[mb_xy + 1] > 1) {
-mv_predictor[pred_count][0] =
-s->cur_pic.motion_val[0][mot_index + mot_step][0];
-mv_predictor[pred_count][1] =
-s->cur_pic.motion_val[0][mot_index + mot_step][1];
-ref[pred_count] =
-s->cur_pic.ref_index[0][4 * (mb_xy + 1)];
-pred_count++;
-}
-if (mb_y > 0 && fixed[mb_xy - mb_stride] > 1) {
-mv_predictor[pred_count][0] =
-s->cur_pic.motion_val[0][mot_index - mot_stride * 
mot_step][0];
-mv_predictor[pred_count][1] =
-s->cur_pic.motion_val[0][mot_index - mot_stride * 
mot_step][1];
-ref[pred_count] =
-s->cur_pic.ref_index[0][4 * (mb_xy - 
s->mb_stride)];
-pred_count++;
-}
-if (mb_y + 1 1) {
-mv_predictor[pred_count][0] =
-s->cur_pic.motion_val[0][mot_index + mot_stride * 
mot_step][0];
-mv_predictor[pred_count][1] =
-s->cur_pic.motion_val[0][mot_index + mot_stride * 
mot_step][1];
-ref[pred_count] =
-s->cur_pic.ref_index[0][4 * (mb_xy + 
s->mb_stride)];
-pred_count++;
-}
-if (pred_count == 0)
-continue;
+av_assert2(j & MV_FROZEN);
 
-if (pred_count > 1) {
-int sum_x = 0, sum_y = 0, sum_r = 0;
-int max_x, max_y, min_x, min_y, max_r, min_r;
-
-for (j = 0; j < pred_count; j++) {
-sum_x += mv_predictor[j][0];
-sum_y += mv_predictor[j][1];
-sum_r += ref[j];
-if (j && ref[j] != ref[j - 1])
-goto skip_mean_and_median;
-}
-
-/* mean */
-mv_predictor[pred_count][0]

[FFmpeg-cvslog] avcodec/pngdec: Fix off by 1 size in decode_zbuf()

2017-01-22 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon 
Jan 23 01:25:27 2017 +0100| [e371f031b942d73e02c090170975561fabd5c264] | 
committer: Michael Niedermayer

avcodec/pngdec: Fix off by 1 size in decode_zbuf()

Fixes out of array access
Fixes: 444/fuzz-2-ffmpeg_VIDEO_AV_CODEC_ID_PNG_fuzzer

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer 

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

 libavcodec/pngdec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index 2f8d266..50a0a29 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -437,13 +437,13 @@ static int decode_zbuf(AVBPrint *bp, const uint8_t *data,
 av_bprint_init(bp, 0, -1);
 
 while (zstream.avail_in > 0) {
-av_bprint_get_buffer(bp, 1, &buf, &buf_size);
-if (!buf_size) {
+av_bprint_get_buffer(bp, 2, &buf, &buf_size);
+if (buf_size < 2) {
 ret = AVERROR(ENOMEM);
 goto fail;
 }
 zstream.next_out  = buf;
-zstream.avail_out = buf_size;
+zstream.avail_out = buf_size - 1;
 ret = inflate(&zstream, Z_PARTIAL_FLUSH);
 if (ret != Z_OK && ret != Z_STREAM_END) {
 ret = AVERROR_EXTERNAL;

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


Re: [FFmpeg-cvslog] [FFmpeg-devel] ffmpeg: Add -time_base option to hint the time base

2017-01-22 Thread Michael Bradshaw
On Sat, Jan 14, 2017 at 1:12 PM, Clément Bœsch  wrote:
>
> erm. We have at least a codec option with that same name. How much does it
> conflict with this?
>

The only use of a "time_base" option I'm aware of is in buffer/abuffer in
libavfilter. Is there another one somewhere else?

Can we have some FATE test too? We have a lot of nasty hack wrt time
> bases, and it's likely to break in a merge.


I'll work on adding a fate test.
___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog