[FFmpeg-cvslog] movenc: Add a flag for indicating a discontinuous fragment

2014-11-26 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö  | Thu Nov 20 
09:51:05 2014 +0200| [ee37620b6ae4783cda637408422044b2d14a688c] | committer: 
Martin Storsjö

movenc: Add a flag for indicating a discontinuous fragment

This allows creating a later mp4 fragment without sequentially
writing the earlier ones before (when called from a segmenter).

Normally when writing a fragmented mp4 file sequentially, the
first timestamps of a fragment are adjusted to match the
end of the previous fragment, to make sure the timestamp is the
same, even if it is calculated as the sum of previous fragment
durations. (And for the first packet in a file, the offset of
the first packet is written using an edit list.)

When writing an individual mp4 fragment discontinuously like this
(with potentially writing the earlier fragments separately later),
there's a risk of getting a gap in the timeline if the duration
field of the last packet in the previous fragment doesn't match up
with the start time of the next fragment.

Using this requires setting -avoid_negative_ts make_non_negative
(or -avoid_negative_ts 0).

Signed-off-by: Martin Storsjö 

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

 libavformat/movenc.c |   34 --
 libavformat/movenc.h |2 ++
 2 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 3ba1cc8..80531d0 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -60,6 +60,7 @@ static const AVOption options[] = {
 { "disable_chpl", "Disable Nero chapter atom", 0, AV_OPT_TYPE_CONST, {.i64 
= FF_MOV_FLAG_DISABLE_CHPL}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, 
"movflags" },
 { "default_base_moof", "Set the default-base-is-moof flag in tfhd atoms", 
0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_DEFAULT_BASE_MOOF}, INT_MIN, INT_MAX, 
AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
 { "dash", "Write DASH compatible fragmented MP4", 0, AV_OPT_TYPE_CONST, 
{.i64 = FF_MOV_FLAG_DASH}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, 
"movflags" },
+{ "frag_discont", "Signal that the next fragment is discontinuous from 
earlier ones", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_FRAG_DISCONT}, 
INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
 FF_RTP_FLAG_OPTS(MOVMuxContext, rtp_flags),
 { "skip_iods", "Skip writing iods atom.", offsetof(MOVMuxContext, 
iods_skip), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM},
 { "iods_audio_profile", "iods audio profile atom.", 
offsetof(MOVMuxContext, iods_audio_profile), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 
255, AV_OPT_FLAG_ENCODING_PARAM},
@@ -3282,11 +3283,19 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 trk->cluster[trk->entry].entries  = samples_in_chunk;
 trk->cluster[trk->entry].dts  = pkt->dts;
 if (!trk->entry && trk->start_dts != AV_NOPTS_VALUE) {
-/* First packet of a new fragment. We already wrote the duration
- * of the last packet of the previous fragment based on track_duration,
- * which might not exactly match our dts. Therefore adjust the dts
- * of this packet to be what the previous packets duration implies. */
-trk->cluster[trk->entry].dts = trk->start_dts + trk->track_duration;
+if (!trk->frag_discont) {
+/* First packet of a new fragment. We already wrote the duration
+ * of the last packet of the previous fragment based on 
track_duration,
+ * which might not exactly match our dts. Therefore adjust the dts
+ * of this packet to be what the previous packets duration 
implies. */
+trk->cluster[trk->entry].dts = trk->start_dts + 
trk->track_duration;
+} else {
+/* New fragment, but discontinuous from previous fragments.
+ * Pretend the duration sum of the earlier fragments is
+ * pkt->dts - trk->start_dts. */
+trk->frag_start = pkt->dts - trk->start_dts;
+trk->frag_discont = 0;
+}
 }
 if (!trk->entry && trk->start_dts == AV_NOPTS_VALUE && !mov->use_editlist 
&&
 s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO) {
@@ -3299,7 +3308,13 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 }
 if (trk->start_dts == AV_NOPTS_VALUE) {
 trk->start_dts = pkt->dts;
-if (pkt->dts && mov->flags & FF_MOV_FLAG_EMPTY_MOOV)
+if (trk->frag_discont) {
+/* Pretend the whole stream started at dts=0, with earlier 
framgents
+ * already written, with a duration summing up to pkt->dts. */
+trk->frag_start   = pkt->dts;
+trk->start_dts= 0;
+trk->frag_discont = 0;
+} else if (pkt->dts && mov->flags & FF_MOV_FLAG_EMPTY_MOOV)
 av_log(s, AV_LOG_WARNING,
"Track %d starts with a nonzero dts %"PRId64". This "

[FFmpeg-cvslog] Merge commit 'ee37620b6ae4783cda637408422044b2d14a688c'

2014-11-26 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Wed Nov 26 
11:27:17 2014 +0100| [b78074fd13ad340b8ea4bb83440da336a0de1e40] | committer: 
Michael Niedermayer

Merge commit 'ee37620b6ae4783cda637408422044b2d14a688c'

* commit 'ee37620b6ae4783cda637408422044b2d14a688c':
  movenc: Add a flag for indicating a discontinuous fragment

Conflicts:
libavformat/movenc.c

Merged-by: Michael Niedermayer 

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



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


[FFmpeg-cvslog] Merge commit '234fb81e3145e9c9aec4ec16266676fab7dc21fa'

2014-11-26 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Wed Nov 26 
12:26:44 2014 +0100| [0df95fa327c8526271b7e50aa944b66149bd48e8] | committer: 
Michael Niedermayer

Merge commit '234fb81e3145e9c9aec4ec16266676fab7dc21fa'

* commit '234fb81e3145e9c9aec4ec16266676fab7dc21fa':
  movenc: Expose the fragment index as an avoption

Merged-by: Michael Niedermayer 

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



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


[FFmpeg-cvslog] movenc: Expose the fragment index as an avoption

2014-11-26 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö  | Mon Nov  3 
22:38:09 2014 +0200| [234fb81e3145e9c9aec4ec16266676fab7dc21fa] | committer: 
Martin Storsjö

movenc: Expose the fragment index as an avoption

This allows setting the right fragment number if doing
random-access writing of fragments, and also allows reading the
current sequence number.

Signed-off-by: Martin Storsjö 

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

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

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 80531d0..f6109e6 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -71,6 +71,7 @@ static const AVOption options[] = {
 { "ism_lookahead", "Number of lookahead entries for ISM files", 
offsetof(MOVMuxContext, ism_lookahead), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 
INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
 { "brand","Override major brand", offsetof(MOVMuxContext, 
major_brand),   AV_OPT_TYPE_STRING, {.str = NULL}, .flags = 
AV_OPT_FLAG_ENCODING_PARAM },
 { "use_editlist", "use edit list", offsetof(MOVMuxContext, use_editlist), 
AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, AV_OPT_FLAG_ENCODING_PARAM},
+{ "fragment_index", "Fragment number of the next fragment", 
offsetof(MOVMuxContext, fragments), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, 
AV_OPT_FLAG_ENCODING_PARAM},
 { NULL },
 };
 

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


[FFmpeg-cvslog] avformat/apngdec: use packet pts and duration instead of altering stream framerate.

2014-11-26 Thread Benoit Fouet
ffmpeg | branch: master | Benoit Fouet  | Wed Nov 26 
11:22:45 2014 +0100| [8b8cb30d11885b406ce0dd896b42992386d98594] | committer: 
Michael Niedermayer

avformat/apngdec: use packet pts and duration instead of altering stream 
framerate.

Signed-off-by: Michael Niedermayer 

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

 libavformat/apngdec.c |   15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/libavformat/apngdec.c b/libavformat/apngdec.c
index dac71f1..8aa70a0 100644
--- a/libavformat/apngdec.c
+++ b/libavformat/apngdec.c
@@ -44,6 +44,9 @@ typedef struct APNGDemuxContext {
 int max_fps;
 int default_fps;
 
+int64_t pkt_pts;
+int pkt_duration;
+
 int is_key_frame;
 
 /*
@@ -163,6 +166,9 @@ static int apng_read_header(AVFormatContext *s)
 if (!st)
 return AVERROR(ENOMEM);
 
+/* set the timebase to something large enough (1/100,000 of second)
+ * to hopefully cope with all sane frame durations */
+avpriv_set_pts_info(st, 64, 1, 10);
 st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
 st->codec->codec_id   = AV_CODEC_ID_APNG;
 st->codec->width  = avio_rb32(pb);
@@ -266,9 +272,9 @@ static int decode_fctl_chunk(AVFormatContext *s, 
APNGDemuxContext *ctx, AVPacket
 delay_num = 1;
 delay_den = ctx->default_fps;
 }
-s->streams[0]->r_frame_rate.num = delay_den;
-s->streams[0]->r_frame_rate.den = delay_num;
-pkt->duration = 1;
+ctx->pkt_duration = av_rescale_q(delay_num,
+ (AVRational){ 1, delay_den },
+ s->streams[0]->time_base);
 
 av_log(s, AV_LOG_DEBUG, "%s: "
 "sequence_number: %"PRId32", "
@@ -379,6 +385,9 @@ static int apng_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 
 if (ctx->is_key_frame)
 pkt->flags |= AV_PKT_FLAG_KEY;
+pkt->pts = ctx->pkt_pts;
+pkt->duration = ctx->pkt_duration;
+ctx->pkt_pts += ctx->pkt_duration;
 return ret;
 case MKTAG('I', 'E', 'N', 'D'):
 ctx->cur_loop++;

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


[FFmpeg-cvslog] avcodec/pngdec: Check IHDR/IDAT order

2014-11-26 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Wed Nov 26 
15:45:47 2014 +0100| [79ceaf827be0b070675d4cd0a55c3386542defd8] | committer: 
Michael Niedermayer

avcodec/pngdec: Check IHDR/IDAT order

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

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

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

diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index ee6a2ba..f80a3fe 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -524,6 +524,12 @@ static int decode_ihdr_chunk(AVCodecContext *avctx, 
PNGDecContext *s,
 {
 if (length != 13)
 return AVERROR_INVALIDDATA;
+
+if (s->state & PNG_IDAT) {
+av_log(avctx, AV_LOG_ERROR, "IHDR after IDAT\n");
+return AVERROR_INVALIDDATA;
+}
+
 s->width  = bytestream2_get_be32(&s->gb);
 s->height = bytestream2_get_be32(&s->gb);
 if (av_image_check_size(s->width, s->height, 0, avctx)) {

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


[FFmpeg-cvslog] avcodec/pngdec: Fix paeth prediction with small images

2014-11-26 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Wed Nov 26 
17:00:17 2014 +0100| [9a53707e86eb066e1c77460215c716f7962c71e7] | committer: 
Michael Niedermayer

avcodec/pngdec: Fix paeth prediction with small images

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

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

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

diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index f80a3fe..35dcd76 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -267,8 +267,10 @@ static void png_filter_row(PNGDSPContext *dsp, uint8_t 
*dst, int filter_type,
 /* would write off the end of the array if we let it process
  * the last pixel with bpp=3 */
 int w = bpp == 4 ? size : size - 3;
-dsp->add_paeth_prediction(dst + i, src + i, last + i, w - i, bpp);
-i = w;
+if (w > i) {
+dsp->add_paeth_prediction(dst + i, src + i, last + i, w - i, 
bpp);
+i = w;
+}
 }
 ff_add_png_paeth_prediction(dst + i, src + i, last + i, size - i, bpp);
 break;

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


[FFmpeg-cvslog] avcodec/rawdec: Check the return code of avpicture_get_size()

2014-11-26 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Wed Nov 26 
18:56:39 2014 +0100| [1d3a3b9f8907625b361420d48fe05716859620ff] | committer: 
Michael Niedermayer

avcodec/rawdec: Check the return code of avpicture_get_size()

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

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

 libavcodec/rawdec.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
index 28792a1..647dfa9 100644
--- a/libavcodec/rawdec.c
+++ b/libavcodec/rawdec.c
@@ -172,6 +172,9 @@ static int raw_decode(AVCodecContext *avctx, void *data, 
int *got_frame,
 context->frame_size = avpicture_get_size(avctx->pix_fmt, avctx->width,
  avctx->height);
 }
+if (context->frame_size < 0)
+return context->frame_size;
+
 need_copy = !avpkt->buf || context->is_2_4_bpp || context->is_yuv2 || 
context->is_lt_16bpp;
 
 frame->pict_type= AV_PICTURE_TYPE_I;

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


[FFmpeg-cvslog] avformat/mov: Fix memleaks for duplicate STCO/CO64/STSC atoms

2014-11-26 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Wed Nov 26 
18:16:15 2014 +0100| [1b5d11240692025f036e945bc37968735679320a] | committer: 
Michael Niedermayer

avformat/mov: Fix memleaks for duplicate STCO/CO64/STSC atoms

Also see [FFmpeg-devel] [PATCH] avformat/mov: strengthen some table allocations
which contains more fixes but is unfinished

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

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

 libavformat/mov.c |8 
 1 file changed, 8 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index d65e40f..a71e36d 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1275,6 +1275,10 @@ static int mov_read_stco(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 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));
 if (!sc->chunk_offsets)
 return AVERROR(ENOMEM);
@@ -1871,6 +1875,10 @@ static int mov_read_stsc(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 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));
 if (!sc->stsc_data)
 return AVERROR(ENOMEM);

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


[FFmpeg-cvslog] v210enc: Add SIMD optimised 8-bit and 10-bit encoders

2014-11-26 Thread Kieran Kunhya
ffmpeg | branch: master | Kieran Kunhya  | Wed Nov 26 15:59:14 
2014 +| [36091742d182b3ad4411aae22682354b3834a974] | committer: Michael 
Niedermayer

v210enc: Add SIMD optimised 8-bit and 10-bit encoders

Signed-off-by: Michael Niedermayer 

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

 libavcodec/v210enc.c  |  191 -
 libavcodec/v210enc.h  |   33 +++
 libavcodec/x86/Makefile   |2 +
 libavcodec/x86/v210enc.asm|  145 +++
 libavcodec/x86/v210enc_init.c |   37 
 libavutil/x86/x86util.asm |5 ++
 tests/ref/vsynth/vsynth1-v210 |6 +-
 tests/ref/vsynth/vsynth2-v210 |6 +-
 tests/ref/vsynth/vsynth3-v210 |6 +-
 9 files changed, 381 insertions(+), 50 deletions(-)

diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c
index 1e53bdb..0d40f99 100644
--- a/libavcodec/v210enc.c
+++ b/libavcodec/v210enc.c
@@ -24,82 +24,190 @@
 #include "avcodec.h"
 #include "bytestream.h"
 #include "internal.h"
+#include "v210enc.h"
+
+#define CLIP(v) av_clip(v, 4, 1019)
+#define CLIP8(v) av_clip(v, 1, 254)
+
+#define WRITE_PIXELS(a, b, c)   \
+do {\
+val =   CLIP(*a++); \
+val |= (CLIP(*b++) << 10) | \
+   (CLIP(*c++) << 20);  \
+AV_WL32(dst, val);  \
+dst += 4;   \
+} while (0)
+
+#define WRITE_PIXELS8(a, b, c)  \
+do {\
+val =  (CLIP8(*a++) << 2);   \
+val |= (CLIP8(*b++) << 12) | \
+   (CLIP8(*c++) << 22);  \
+AV_WL32(dst, val);  \
+dst += 4;   \
+} while (0)
+
+static void v210_planar_pack_8_c(const uint8_t *y, const uint8_t *u,
+ const uint8_t *v, uint8_t *dst, ptrdiff_t 
width)
+{
+uint32_t val;
+int i;
+
+/* unroll this to match the assembly */
+for( i = 0; i < width-11; i += 12 ){
+WRITE_PIXELS8(u, y, v);
+WRITE_PIXELS8(y, u, y);
+WRITE_PIXELS8(v, y, u);
+WRITE_PIXELS8(y, v, y);
+WRITE_PIXELS8(u, y, v);
+WRITE_PIXELS8(y, u, y);
+WRITE_PIXELS8(v, y, u);
+WRITE_PIXELS8(y, v, y);
+}
+}
+
+static void v210_planar_pack_10_c(const uint16_t *y, const uint16_t *u,
+  const uint16_t *v, uint8_t *dst, ptrdiff_t 
width)
+{
+uint32_t val;
+int i;
+
+for( i = 0; i < width-5; i += 6 ){
+WRITE_PIXELS(u, y, v);
+WRITE_PIXELS(y, u, y);
+WRITE_PIXELS(v, y, u);
+WRITE_PIXELS(y, v, y);
+}
+}
 
 static av_cold int encode_init(AVCodecContext *avctx)
 {
+V210EncContext *s = avctx->priv_data;
+
 if (avctx->width & 1) {
 av_log(avctx, AV_LOG_ERROR, "v210 needs even width\n");
 return AVERROR(EINVAL);
 }
 
-if (avctx->bits_per_raw_sample != 10)
-av_log(avctx, AV_LOG_WARNING, "bits per raw sample: %d != 10-bit\n",
-   avctx->bits_per_raw_sample);
-
 avctx->coded_frame = av_frame_alloc();
 if (!avctx->coded_frame)
 return AVERROR(ENOMEM);
 
 avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
 
+s->pack_line_8  = v210_planar_pack_8_c;
+s->pack_line_10 = v210_planar_pack_10_c;
+
+if (ARCH_X86)
+ff_v210enc_init_x86(s);
+
 return 0;
 }
 
 static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 const AVFrame *pic, int *got_packet)
 {
+V210EncContext *s = avctx->priv_data;
+
 int aligned_width = ((avctx->width + 47) / 48) * 48;
 int stride = aligned_width * 8 / 3;
 int line_padding = stride - ((avctx->width * 8 + 11) / 12) * 4;
 int h, w, ret;
-const uint16_t *y = (const uint16_t*)pic->data[0];
-const uint16_t *u = (const uint16_t*)pic->data[1];
-const uint16_t *v = (const uint16_t*)pic->data[2];
-PutByteContext p;
+uint8_t *dst;
 
-if ((ret = ff_alloc_packet2(avctx, pkt, avctx->height * stride)) < 0)
+if ((ret = ff_alloc_packet(pkt, avctx->height * stride)) < 0) {
+av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
 return ret;
+}
 
-bytestream2_init_writer(&p, pkt->data, pkt->size);
+dst = pkt->data;
+
+if (pic->format == AV_PIX_FMT_YUV422P10) {
+const uint16_t *y = (const uint16_t*)pic->data[0];
+const uint16_t *u = (const uint16_t*)pic->data[1];
+const uint16_t *v = (const uint16_t*)pic->data[2];
+for (h = 0; h < avctx->height; h++) {
+uint32_t val;
+w = (avctx->width / 6) * 6;
+s->pack_line_10(y, u, v, dst, w);
+
+y += w;
+u += w >> 1;
+v += w >> 1;
+dst += (w / 6) * 16;
+if (w < avctx->width - 1) {
+WRITE_PIXELS(u, y, v);
+
+

[FFmpeg-cvslog] avfilter/signalstats: remove pointless sub filter init system

2014-11-26 Thread Clément Bœsch
ffmpeg | branch: master | Clément Bœsch  | Sun Nov 16 21:12:52 
2014 +0100| [c7e8f610f281765d2958a3dfbbc70a8cb0ac87bf] | committer: Clément 
Bœsch

avfilter/signalstats: remove pointless sub filter init system

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

 libavfilter/vf_signalstats.c |   57 +++---
 1 file changed, 15 insertions(+), 42 deletions(-)

diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c
index 8c6a2d6..b5b45b8 100644
--- a/libavfilter/vf_signalstats.c
+++ b/libavfilter/vf_signalstats.c
@@ -43,7 +43,6 @@ typedef struct {
 enum FilterMode outfilter;
 int filters;
 AVFrame *frame_prev;
-char *vrep_line;
 uint8_t rgba_color[4];
 int yuv_color[3];
 } SignalstatsContext;
@@ -88,7 +87,6 @@ static av_cold void uninit(AVFilterContext *ctx)
 {
 SignalstatsContext *s = ctx->priv;
 av_frame_free(&s->frame_prev);
-av_freep(&s->vrep_line);
 }
 
 static int query_formats(AVFilterContext *ctx)
@@ -124,12 +122,6 @@ static int config_props(AVFilterLink *outlink)
 s->fs = inlink->w * inlink->h;
 s->cfs = s->chromaw * s->chromah;
 
-if (s->filters & 1h * sizeof(*s->vrep_line));
-if (!s->vrep_line)
-return AVERROR(ENOMEM);
-}
-
 return 0;
 }
 
@@ -209,49 +201,34 @@ filter_tout_outlier(p[(y-j) * lw + x + i], \
 
 #define VREP_START 4
 
-static void filter_init_vrep(SignalstatsContext *s, const AVFrame *p, int w, 
int h)
-{
-int i, y;
-int lw = p->linesize[0];
-
-for (y = VREP_START; y < h; y++) {
-int totdiff = 0;
-int y2lw = (y - VREP_START) * lw;
-int ylw = y * lw;
-
-for (i = 0; i < w; i++)
-totdiff += abs(p->data[0][y2lw + i] - p->data[0][ylw + i]);
-
-/* this value should be definable */
-s->vrep_line[y] = totdiff < w;
-}
-}
-
 static int filter_vrep(SignalstatsContext *s, const AVFrame *in, AVFrame *out, 
int y, int w, int h)
 {
-int x, score = 0;
+const uint8_t *p = in->data[0];
+const int lw = in->linesize[0];
+int x, score, totdiff = 0;
+const int y2lw = (y - VREP_START) * lw;
+const int ylw  =  y   * lw;
 
 if (y < VREP_START)
 return 0;
 
-for (x = 0; x < w; x++) {
-if (s->vrep_line[y]) {
-score++;
-if (out)
-burn_frame(s, out, x, y);
-}
-}
+for (x = 0; x < w; x++)
+totdiff += abs(p[y2lw + x] - p[ylw + x]);
+
+score = (totdiff < w) * w;
+if (score && out)
+for (x = 0; x < w; x++)
+burn_frame(s, out, x, y);
 return score;
 }
 
 static const struct {
 const char *name;
-void (*init)(SignalstatsContext *s, const AVFrame *p, int w, int h);
 int (*process)(SignalstatsContext *s, const AVFrame *in, AVFrame *out, int 
y, int w, int h);
 } filters_def[] = {
-{"TOUT", NULL,  filter_tout},
-{"VREP", filter_init_vrep,  filter_vrep},
-{"BRNG", NULL,  filter_brng},
+{"TOUT", filter_tout},
+{"VREP", filter_vrep},
+{"BRNG", filter_brng},
 {NULL}
 };
 
@@ -299,10 +276,6 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 av_frame_make_writable(out);
 }
 
-for (fil = 0; fil < FILT_NUMB; fil ++)
-if ((s->filters & 1h);
-
 // Calculate luma histogram and difference with previous frame or field.
 for (j = 0; j < link->h; j++) {
 for (i = 0; i < link->w; i++) {

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


[FFmpeg-cvslog] avfilter/signalstats: fix different buffers for out frame if burn is enabled

2014-11-26 Thread Clément Bœsch
ffmpeg | branch: master | Clément Bœsch  | Sun Nov 16 21:12:50 
2014 +0100| [b424e67abf0dc9b5f8ca4d281baceee7d7b932f2] | committer: Clément 
Bœsch

avfilter/signalstats: fix different buffers for out frame if burn is enabled

This was the original intend.

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

 libavfilter/vf_signalstats.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c
index 47545aa..8c6a2d6 100644
--- a/libavfilter/vf_signalstats.c
+++ b/libavfilter/vf_signalstats.c
@@ -294,8 +294,10 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 
 prev = s->frame_prev;
 
-if (s->outfilter != FILTER_NONE)
+if (s->outfilter != FILTER_NONE) {
 out = av_frame_clone(in);
+av_frame_make_writable(out);
+}
 
 for (fil = 0; fil < FILT_NUMB; fil ++)
 if ((s->filters & 1

[FFmpeg-cvslog] avfilter/signalstats: re-use yuv/yuvu/yuvv vars in diff

2014-11-26 Thread Clément Bœsch
ffmpeg | branch: master | Clément Bœsch  | Sun Nov 23 00:33:19 
2014 +0100| [c2ea7069c4895dffac4e4765373ad0032e9f7d72] | committer: Clément 
Bœsch

avfilter/signalstats: re-use yuv/yuvu/yuvv vars in diff

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

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

diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c
index 3ef689f..4b2792f 100644
--- a/libavfilter/vf_signalstats.c
+++ b/libavfilter/vf_signalstats.c
@@ -413,7 +413,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 for (i = 0; i < link->w; i++) {
 const int yuv = in->data[0][w + i];
 histy[yuv]++;
-dify += abs(in->data[0][w + i] - prev->data[0][pw + i]);
+dify += abs(yuv - prev->data[0][pw + i]);
 }
 w  += in->linesize[0];
 pw += prev->linesize[0];
@@ -425,9 +425,9 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 const int yuvu = in->data[1][cw+i];
 const int yuvv = in->data[2][cw+i];
 histu[yuvu]++;
-difu += abs(in->data[1][cw+i] - prev->data[1][cpw+i]);
+difu += abs(yuvu - prev->data[1][cpw+i]);
 histv[yuvv]++;
-difv += abs(in->data[2][cw+i] - prev->data[2][cpw+i]);
+difv += abs(yuvv - prev->data[2][cpw+i]);
 
 histsat[p_sat[i]]++;
 histhue[((int16_t*)p_hue)[i]]++;

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


[FFmpeg-cvslog] avfilter/signalstats: add threading in compute_sat_hue_metrics

2014-11-26 Thread Clément Bœsch
ffmpeg | branch: master | Clément Bœsch  | Sun Nov 23 00:10:19 
2014 +0100| [82dda8e4eaa6cb5fac3a1975ed367eec6b6fa89c] | committer: Clément 
Bœsch

avfilter/signalstats: add threading in compute_sat_hue_metrics

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

 libavfilter/vf_signalstats.c |   37 -
 1 file changed, 28 insertions(+), 9 deletions(-)

diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c
index 0403a6d..014b87d 100644
--- a/libavfilter/vf_signalstats.c
+++ b/libavfilter/vf_signalstats.c
@@ -57,6 +57,11 @@ typedef struct ThreadData {
 AVFrame *out;
 } ThreadData;
 
+typedef struct ThreadDataHueSatMetrics {
+const AVFrame *src;
+AVFrame *dst_sat, *dst_hue;
+} ThreadDataHueSatMetrics;
+
 #define OFFSET(x) offsetof(SignalstatsContext, x)
 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
@@ -308,23 +313,29 @@ static const struct {
 
 #define DEPTH 256
 
-static void compute_sat_hue_metrics(const SignalstatsContext *s,
-const AVFrame *src,
-AVFrame *dst_sat, AVFrame *dst_hue)
+static int compute_sat_hue_metrics(AVFilterContext *ctx, void *arg, int jobnr, 
int nb_jobs)
 {
 int i, j;
+ThreadDataHueSatMetrics *td = arg;
+const SignalstatsContext *s = ctx->priv;
+const AVFrame *src = td->src;
+AVFrame *dst_sat = td->dst_sat;
+AVFrame *dst_hue = td->dst_hue;
+
+const int slice_start = (s->chromah *  jobnr   ) / nb_jobs;
+const int slice_end   = (s->chromah * (jobnr+1)) / nb_jobs;
 
-const uint8_t *p_u = src->data[1];
-const uint8_t *p_v = src->data[2];
 const int lsz_u = src->linesize[1];
 const int lsz_v = src->linesize[2];
+const uint8_t *p_u = src->data[1] + slice_start * lsz_u;
+const uint8_t *p_v = src->data[2] + slice_start * lsz_v;
 
-uint8_t *p_sat = dst_sat->data[0];
-uint8_t *p_hue = dst_hue->data[0];
 const int lsz_sat = dst_sat->linesize[0];
 const int lsz_hue = dst_hue->linesize[0];
+uint8_t *p_sat = dst_sat->data[0] + slice_start * lsz_sat;
+uint8_t *p_hue = dst_hue->data[0] + slice_start * lsz_hue;
 
-for (j = 0; j < s->chromah; j++) {
+for (j = slice_start; j < slice_end; j++) {
 for (i = 0; i < s->chromaw; i++) {
 const int yuvu = p_u[i];
 const int yuvv = p_v[i];
@@ -336,6 +347,8 @@ static void compute_sat_hue_metrics(const 
SignalstatsContext *s,
 p_sat += lsz_sat;
 p_hue += lsz_hue;
 }
+
+return 0;
 }
 
 static int filter_frame(AVFilterLink *link, AVFrame *in)
@@ -377,6 +390,11 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 const uint8_t *p_hue = hue->data[0];
 const int lsz_sat = sat->linesize[0];
 const int lsz_hue = hue->linesize[0];
+ThreadDataHueSatMetrics td_huesat = {
+.src = in,
+.dst_sat = sat,
+.dst_hue = hue,
+};
 
 if (!s->frame_prev)
 s->frame_prev = av_frame_clone(in);
@@ -388,7 +406,8 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 av_frame_make_writable(out);
 }
 
-compute_sat_hue_metrics(s, in, sat, hue);
+ctx->internal->execute(ctx, compute_sat_hue_metrics, &td_huesat,
+   NULL, FFMIN(s->chromah, ctx->graph->nb_threads));
 
 // Calculate luma histogram and difference with previous frame or field.
 for (j = 0; j < link->h; j++) {

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


[FFmpeg-cvslog] avfilter/signalstats: add slice threading for subfilters

2014-11-26 Thread Clément Bœsch
ffmpeg | branch: master | Clément Bœsch  | Sun Nov 16 21:12:55 
2014 +0100| [9db78a296c37ab854dab87d991ce666e9a2e30ea] | committer: Clément 
Bœsch

avfilter/signalstats: add slice threading for subfilters

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

 libavfilter/vf_signalstats.c |   72 +++---
 1 file changed, 60 insertions(+), 12 deletions(-)

diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c
index 5983e61..960e98a 100644
--- a/libavfilter/vf_signalstats.c
+++ b/libavfilter/vf_signalstats.c
@@ -45,8 +45,15 @@ typedef struct {
 AVFrame *frame_prev;
 uint8_t rgba_color[4];
 int yuv_color[3];
+int nb_jobs;
+int *jobs_rets;
 } SignalstatsContext;
 
+typedef struct ThreadData {
+const AVFrame *in;
+AVFrame *out;
+} ThreadData;
+
 #define OFFSET(x) offsetof(SignalstatsContext, x)
 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
@@ -87,6 +94,7 @@ static av_cold void uninit(AVFilterContext *ctx)
 {
 SignalstatsContext *s = ctx->priv;
 av_frame_free(&s->frame_prev);
+av_freep(&s->jobs_rets);
 }
 
 static int query_formats(AVFilterContext *ctx)
@@ -122,10 +130,14 @@ static int config_props(AVFilterLink *outlink)
 s->fs = inlink->w * inlink->h;
 s->cfs = s->chromaw * s->chromah;
 
+s->nb_jobs   = FFMAX(1, FFMIN(inlink->h, ctx->graph->nb_threads));
+s->jobs_rets = av_malloc_array(s->nb_jobs, sizeof(*s->jobs_rets));
+if (!s->jobs_rets)
+return AVERROR(ENOMEM);
 return 0;
 }
 
-static void burn_frame(SignalstatsContext *s, AVFrame *f, int x, int y)
+static void burn_frame(const SignalstatsContext *s, AVFrame *f, int x, int y)
 {
 const int chromax = x >> s->hsub;
 const int chromay = y >> s->vsub;
@@ -134,11 +146,19 @@ static void burn_frame(SignalstatsContext *s, AVFrame *f, 
int x, int y)
 f->data[2][chromay * f->linesize[2] + chromax] = s->yuv_color[2];
 }
 
-static int filter_brng(SignalstatsContext *s, const AVFrame *in, AVFrame *out, 
int w, int h)
+static int filter_brng(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 {
+ThreadData *td = arg;
+const SignalstatsContext *s = ctx->priv;
+const AVFrame *in = td->in;
+AVFrame *out = td->out;
+const int w = in->width;
+const int h = in->height;
+const int slice_start = (h *  jobnr   ) / nb_jobs;
+const int slice_end   = (h * (jobnr+1)) / nb_jobs;
 int x, y, score = 0;
 
-for (y = 0; y < h; y++) {
+for (y = slice_start; y < slice_end; y++) {
 const int yc = y >> s->vsub;
 const uint8_t *pluma= &in->data[0][y  * in->linesize[0]];
 const uint8_t *pchromau = &in->data[1][yc * in->linesize[1]];
@@ -165,13 +185,21 @@ static int filter_tout_outlier(uint8_t x, uint8_t y, 
uint8_t z)
 return ((abs(x - y) + abs (z - y)) / 2) - abs(z - x) > 4; // make 4 
configurable?
 }
 
-static int filter_tout(SignalstatsContext *s, const AVFrame *in, AVFrame *out, 
int w, int h)
+static int filter_tout(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 {
+ThreadData *td = arg;
+const SignalstatsContext *s = ctx->priv;
+const AVFrame *in = td->in;
+AVFrame *out = td->out;
+const int w = in->width;
+const int h = in->height;
+const int slice_start = (h *  jobnr   ) / nb_jobs;
+const int slice_end   = (h * (jobnr+1)) / nb_jobs;
 const uint8_t *p = in->data[0];
 int lw = in->linesize[0];
 int x, y, score = 0, filt;
 
-for (y = 0; y < h; y++) {
+for (y = slice_start; y < slice_end; y++) {
 
 if (y - 1 < 0 || y + 1 >= h)
 continue;
@@ -207,17 +235,28 @@ static int filter_tout(SignalstatsContext *s, const 
AVFrame *in, AVFrame *out, i
 
 #define VREP_START 4
 
-static int filter_vrep(SignalstatsContext *s, const AVFrame *in, AVFrame *out, 
int w, int h)
+static int filter_vrep(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 {
+ThreadData *td = arg;
+const SignalstatsContext *s = ctx->priv;
+const AVFrame *in = td->in;
+AVFrame *out = td->out;
+const int w = in->width;
+const int h = in->height;
+const int slice_start = (h *  jobnr   ) / nb_jobs;
+const int slice_end   = (h * (jobnr+1)) / nb_jobs;
 const uint8_t *p = in->data[0];
 const int lw = in->linesize[0];
 int x, y, score = 0;
 
-for (y = VREP_START; y < h; y++) {
+for (y = slice_start; y < slice_end; y++) {
 const int y2lw = (y - VREP_START) * lw;
 const int ylw  =  y   * lw;
 int filt, totdiff = 0;
 
+if (y < VREP_START)
+continue;
+
 for (x = 0; x < w; x++)
 totdiff += abs(p[y2lw + x] - p[ylw + x]);
 filt = totdiff < w;
@@ -232,7 +271,7 @@ static int filter_vrep(SignalstatsContext *s, const AVFrame 
*in, AVFrame *out, i
 
 static const struct {
 const char *name;
-int (*process)(SignalstatsContext *s, const

[FFmpeg-cvslog] avfilter/signalstats: localize a few variables

2014-11-26 Thread Clément Bœsch
ffmpeg | branch: master | Clément Bœsch  | Sun Nov 23 00:29:50 
2014 +0100| [9cb1d81a60bd335190175bd168470e077e237579] | committer: Clément 
Bœsch

avfilter/signalstats: localize a few variables

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

 libavfilter/vf_signalstats.c |7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c
index 014b87d..3ef689f 100644
--- a/libavfilter/vf_signalstats.c
+++ b/libavfilter/vf_signalstats.c
@@ -360,7 +360,6 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 int i, j;
 int  w = 0,  cw = 0, // in
 pw = 0, cpw = 0; // prev
-int yuv, yuvu, yuvv;
 int fil;
 char metabuf[128];
 unsigned int histy[DEPTH] = {0},
@@ -412,7 +411,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 // Calculate luma histogram and difference with previous frame or field.
 for (j = 0; j < link->h; j++) {
 for (i = 0; i < link->w; i++) {
-yuv = in->data[0][w + i];
+const int yuv = in->data[0][w + i];
 histy[yuv]++;
 dify += abs(in->data[0][w + i] - prev->data[0][pw + i]);
 }
@@ -423,8 +422,8 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 // Calculate chroma histogram and difference with previous frame or field.
 for (j = 0; j < s->chromah; j++) {
 for (i = 0; i < s->chromaw; i++) {
-yuvu = in->data[1][cw+i];
-yuvv = in->data[2][cw+i];
+const int yuvu = in->data[1][cw+i];
+const int yuvv = in->data[2][cw+i];
 histu[yuvu]++;
 difu += abs(in->data[1][cw+i] - prev->data[1][cpw+i]);
 histv[yuvv]++;

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


[FFmpeg-cvslog] avfilter/signalstats: integrate height loop into subfilters

2014-11-26 Thread Clément Bœsch
ffmpeg | branch: master | Clément Bœsch  | Sun Nov 16 21:12:53 
2014 +0100| [56b98dfc4f0933727b9e83ab80f377f2c1836f87] | committer: Clément 
Bœsch

avfilter/signalstats: integrate height loop into subfilters

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

 libavfilter/vf_signalstats.c |   40 +++-
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c
index b5b45b8..e0ee3ee 100644
--- a/libavfilter/vf_signalstats.c
+++ b/libavfilter/vf_signalstats.c
@@ -134,9 +134,11 @@ static void burn_frame(SignalstatsContext *s, AVFrame *f, 
int x, int y)
 f->data[2][chromay * f->linesize[2] + chromax] = s->yuv_color[2];
 }
 
-static int filter_brng(SignalstatsContext *s, const AVFrame *in, AVFrame *out, 
int y, int w, int h)
+static int filter_brng(SignalstatsContext *s, const AVFrame *in, AVFrame *out, 
int w, int h)
 {
-int x, score = 0;
+int x, y, score = 0;
+
+for (y = 0; y < h; y++) {
 const int yc = y >> s->vsub;
 const uint8_t *pluma= &in->data[0][y  * in->linesize[0]];
 const uint8_t *pchromau = &in->data[1][yc * in->linesize[1]];
@@ -154,6 +156,7 @@ static int filter_brng(SignalstatsContext *s, const AVFrame 
*in, AVFrame *out, i
 if (out && filt)
 burn_frame(s, out, x, y);
 }
+}
 return score;
 }
 
@@ -162,14 +165,16 @@ static int filter_tout_outlier(uint8_t x, uint8_t y, 
uint8_t z)
 return ((abs(x - y) + abs (z - y)) / 2) - abs(z - x) > 4; // make 4 
configurable?
 }
 
-static int filter_tout(SignalstatsContext *s, const AVFrame *in, AVFrame *out, 
int y, int w, int h)
+static int filter_tout(SignalstatsContext *s, const AVFrame *in, AVFrame *out, 
int w, int h)
 {
 const uint8_t *p = in->data[0];
 int lw = in->linesize[0];
-int x, score = 0, filt;
+int x, y, score = 0, filt;
+
+for (y = 0; y < h; y++) {
 
 if (y - 1 < 0 || y + 1 >= h)
-return 0;
+continue;
 
 // detect two pixels above and below (to eliminate interlace artefacts)
 // should check that video format is infact interlaced.
@@ -196,35 +201,38 @@ filter_tout_outlier(p[(y-j) * lw + x + i], \
 burn_frame(s, out, x, y);
 }
 }
+}
 return score;
 }
 
 #define VREP_START 4
 
-static int filter_vrep(SignalstatsContext *s, const AVFrame *in, AVFrame *out, 
int y, int w, int h)
+static int filter_vrep(SignalstatsContext *s, const AVFrame *in, AVFrame *out, 
int w, int h)
 {
 const uint8_t *p = in->data[0];
 const int lw = in->linesize[0];
-int x, score, totdiff = 0;
+int x, y, score = 0;
+
+for (y = VREP_START; y < h; y++) {
 const int y2lw = (y - VREP_START) * lw;
 const int ylw  =  y   * lw;
-
-if (y < VREP_START)
-return 0;
+int filt, totdiff = 0;
 
 for (x = 0; x < w; x++)
 totdiff += abs(p[y2lw + x] - p[ylw + x]);
+filt = totdiff < w;
 
-score = (totdiff < w) * w;
-if (score && out)
+score += filt;
+if (filt && out)
 for (x = 0; x < w; x++)
 burn_frame(s, out, x, y);
-return score;
+}
+return score * w;
 }
 
 static const struct {
 const char *name;
-int (*process)(SignalstatsContext *s, const AVFrame *in, AVFrame *out, int 
y, int w, int h);
+int (*process)(SignalstatsContext *s, const AVFrame *in, AVFrame *out, int 
w, int h);
 } filters_def[] = {
 {"TOUT", filter_tout},
 {"VREP", filter_vrep},
@@ -309,14 +317,12 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 cpw += prev->linesize[1];
 }
 
-for (j = 0; j < link->h; j++) {
 for (fil = 0; fil < FILT_NUMB; fil ++) {
 if (s->filters & 1w, link->h);
+filtot[fil] = filters_def[fil].process(s, in, dbg, link->w, 
link->h);
 }
 }
-}
 
 // find low / high based on histogram percentile
 // these only need to be calculated once.

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


[FFmpeg-cvslog] avfilter/signalstats: isolate sat hue computation metrics in a function

2014-11-26 Thread Clément Bœsch
ffmpeg | branch: master | Clément Bœsch  | Sat Nov 22 23:50:10 
2014 +0100| [7acbd56a8a996c984d4799039b72ecf2cfbec615] | committer: Clément 
Bœsch

avfilter/signalstats: isolate sat hue computation metrics in a function

This will be useful for the following commit

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

 libavfilter/vf_signalstats.c |   77 ++
 1 file changed, 70 insertions(+), 7 deletions(-)

diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c
index 960e98a..0403a6d 100644
--- a/libavfilter/vf_signalstats.c
+++ b/libavfilter/vf_signalstats.c
@@ -47,6 +47,9 @@ typedef struct {
 int yuv_color[3];
 int nb_jobs;
 int *jobs_rets;
+
+AVFrame *frame_sat;
+AVFrame *frame_hue;
 } SignalstatsContext;
 
 typedef struct ThreadData {
@@ -94,6 +97,8 @@ static av_cold void uninit(AVFilterContext *ctx)
 {
 SignalstatsContext *s = ctx->priv;
 av_frame_free(&s->frame_prev);
+av_frame_free(&s->frame_sat);
+av_frame_free(&s->frame_hue);
 av_freep(&s->jobs_rets);
 }
 
@@ -112,6 +117,22 @@ static int query_formats(AVFilterContext *ctx)
 return 0;
 }
 
+static AVFrame *alloc_frame(enum AVPixelFormat pixfmt, int w, int h)
+{
+AVFrame *frame = av_frame_alloc();
+if (!frame)
+return NULL;
+
+frame->format = pixfmt;
+frame->width  = w;
+frame->height = h;
+
+if (av_frame_get_buffer(frame, 32) < 0)
+return NULL;
+
+return frame;
+}
+
 static int config_props(AVFilterLink *outlink)
 {
 AVFilterContext *ctx = outlink->src;
@@ -134,6 +155,12 @@ static int config_props(AVFilterLink *outlink)
 s->jobs_rets = av_malloc_array(s->nb_jobs, sizeof(*s->jobs_rets));
 if (!s->jobs_rets)
 return AVERROR(ENOMEM);
+
+s->frame_sat = alloc_frame(AV_PIX_FMT_GRAY8,  inlink->w, inlink->h);
+s->frame_hue = alloc_frame(AV_PIX_FMT_GRAY16, inlink->w, inlink->h);
+if (!s->frame_sat || !s->frame_hue)
+return AVERROR(ENOMEM);
+
 return 0;
 }
 
@@ -281,6 +308,36 @@ static const struct {
 
 #define DEPTH 256
 
+static void compute_sat_hue_metrics(const SignalstatsContext *s,
+const AVFrame *src,
+AVFrame *dst_sat, AVFrame *dst_hue)
+{
+int i, j;
+
+const uint8_t *p_u = src->data[1];
+const uint8_t *p_v = src->data[2];
+const int lsz_u = src->linesize[1];
+const int lsz_v = src->linesize[2];
+
+uint8_t *p_sat = dst_sat->data[0];
+uint8_t *p_hue = dst_hue->data[0];
+const int lsz_sat = dst_sat->linesize[0];
+const int lsz_hue = dst_hue->linesize[0];
+
+for (j = 0; j < s->chromah; j++) {
+for (i = 0; i < s->chromaw; i++) {
+const int yuvu = p_u[i];
+const int yuvv = p_v[i];
+p_sat[i] = hypot(yuvu - 128, yuvv - 128); // int or round?
+((int16_t*)p_hue)[i] = floor((180 / M_PI) * atan2f(yuvu-128, 
yuvv-128) + 180);
+}
+p_u   += lsz_u;
+p_v   += lsz_v;
+p_sat += lsz_sat;
+p_hue += lsz_hue;
+}
+}
+
 static int filter_frame(AVFilterLink *link, AVFrame *in)
 {
 AVFilterContext *ctx = link->dst;
@@ -314,6 +371,13 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 int filtot[FILT_NUMB] = {0};
 AVFrame *prev;
 
+AVFrame *sat = s->frame_sat;
+AVFrame *hue = s->frame_hue;
+const uint8_t *p_sat = sat->data[0];
+const uint8_t *p_hue = hue->data[0];
+const int lsz_sat = sat->linesize[0];
+const int lsz_hue = hue->linesize[0];
+
 if (!s->frame_prev)
 s->frame_prev = av_frame_clone(in);
 
@@ -324,6 +388,8 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 av_frame_make_writable(out);
 }
 
+compute_sat_hue_metrics(s, in, sat, hue);
+
 // Calculate luma histogram and difference with previous frame or field.
 for (j = 0; j < link->h; j++) {
 for (i = 0; i < link->w; i++) {
@@ -338,8 +404,6 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 // Calculate chroma histogram and difference with previous frame or field.
 for (j = 0; j < s->chromah; j++) {
 for (i = 0; i < s->chromaw; i++) {
-int sat, hue;
-
 yuvu = in->data[1][cw+i];
 yuvv = in->data[2][cw+i];
 histu[yuvu]++;
@@ -347,14 +411,13 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 histv[yuvv]++;
 difv += abs(in->data[2][cw+i] - prev->data[2][cpw+i]);
 
-// int or round?
-sat = hypot(yuvu - 128, yuvv - 128);
-histsat[sat]++;
-hue = floor((180 / M_PI) * atan2f(yuvu-128, yuvv-128) + 180);
-histhue[hue]++;
+histsat[p_sat[i]]++;
+histhue[((int16_t*)p_hue)[i]]++;
 }
 cw  += in->linesize[1];
 cpw += prev->linesize[1];
+p_sat += lsz_sat;
+p_hue +=

[FFmpeg-cvslog] avfilter/signalstats: fix repitition/repetition typo

2014-11-26 Thread Clément Bœsch
ffmpeg | branch: master | Clément Bœsch  | Sun Nov 16 21:12:54 
2014 +0100| [fad6865748c74f7d4472a43d447c571c7e5cdfe2] | committer: Clément 
Bœsch

avfilter/signalstats: fix repitition/repetition typo

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

 libavfilter/vf_signalstats.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c
index d6d9c3e..5983e61 100644
--- a/libavfilter/vf_signalstats.c
+++ b/libavfilter/vf_signalstats.c
@@ -53,11 +53,11 @@ typedef struct {
 static const AVOption signalstats_options[] = {
 {"stat", "set statistics filters", OFFSET(filters), AV_OPT_TYPE_FLAGS, 
{.i64=0}, 0, INT_MAX, FLAGS, "filters"},
 {"tout", "analyze pixels for temporal outliers",0, 
AV_OPT_TYPE_CONST, {.i64=1

[FFmpeg-cvslog] avfilter/signalstats: reindent after previous commit

2014-11-26 Thread Clément Bœsch
ffmpeg | branch: master | Clément Bœsch  | Sun Nov 16 21:12:54 
2014 +0100| [cc5c667eb13ba6b00e775dada2c92741ed3425ba] | committer: Clément 
Bœsch

avfilter/signalstats: reindent after previous commit

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

 libavfilter/vf_signalstats.c |  106 +-
 1 file changed, 53 insertions(+), 53 deletions(-)

diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c
index e0ee3ee..d6d9c3e 100644
--- a/libavfilter/vf_signalstats.c
+++ b/libavfilter/vf_signalstats.c
@@ -139,23 +139,23 @@ static int filter_brng(SignalstatsContext *s, const 
AVFrame *in, AVFrame *out, i
 int x, y, score = 0;
 
 for (y = 0; y < h; y++) {
-const int yc = y >> s->vsub;
-const uint8_t *pluma= &in->data[0][y  * in->linesize[0]];
-const uint8_t *pchromau = &in->data[1][yc * in->linesize[1]];
-const uint8_t *pchromav = &in->data[2][yc * in->linesize[2]];
-
-for (x = 0; x < w; x++) {
-const int xc = x >> s->hsub;
-const int luma= pluma[x];
-const int chromau = pchromau[xc];
-const int chromav = pchromav[xc];
-const int filt = luma< 16 || luma> 235 ||
- chromau < 16 || chromau > 240 ||
- chromav < 16 || chromav > 240;
-score += filt;
-if (out && filt)
-burn_frame(s, out, x, y);
-}
+const int yc = y >> s->vsub;
+const uint8_t *pluma= &in->data[0][y  * in->linesize[0]];
+const uint8_t *pchromau = &in->data[1][yc * in->linesize[1]];
+const uint8_t *pchromav = &in->data[2][yc * in->linesize[2]];
+
+for (x = 0; x < w; x++) {
+const int xc = x >> s->hsub;
+const int luma= pluma[x];
+const int chromau = pchromau[xc];
+const int chromav = pchromav[xc];
+const int filt = luma< 16 || luma> 235 ||
+chromau < 16 || chromau > 240 ||
+chromav < 16 || chromav > 240;
+score += filt;
+if (out && filt)
+burn_frame(s, out, x, y);
+}
 }
 return score;
 }
@@ -173,35 +173,35 @@ static int filter_tout(SignalstatsContext *s, const 
AVFrame *in, AVFrame *out, i
 
 for (y = 0; y < h; y++) {
 
-if (y - 1 < 0 || y + 1 >= h)
-continue;
+if (y - 1 < 0 || y + 1 >= h)
+continue;
 
-// detect two pixels above and below (to eliminate interlace artefacts)
-// should check that video format is infact interlaced.
+// detect two pixels above and below (to eliminate interlace artefacts)
+// should check that video format is infact interlaced.
 
 #define FILTER(i, j) \
-filter_tout_outlier(p[(y-j) * lw + x + i], \
-p[y * lw + x + i], \
-p[(y+j) * lw + x + i])
+filter_tout_outlier(p[(y-j) * lw + x + i], \
+p[y * lw + x + i], \
+p[(y+j) * lw + x + i])
 
 #define FILTER3(j) (FILTER(-1, j) && FILTER(0, j) && FILTER(1, j))
 
-if (y - 2 >= 0 && y + 2 < h) {
-for (x = 1; x < w - 1; x++) {
-filt = FILTER3(2) && FILTER3(1);
-score += filt;
-if (filt && out)
-burn_frame(s, out, x, y);
-}
-} else {
-for (x = 1; x < w - 1; x++) {
-filt = FILTER3(1);
-score += filt;
-if (filt && out)
-burn_frame(s, out, x, y);
+if (y - 2 >= 0 && y + 2 < h) {
+for (x = 1; x < w - 1; x++) {
+filt = FILTER3(2) && FILTER3(1);
+score += filt;
+if (filt && out)
+burn_frame(s, out, x, y);
+}
+} else {
+for (x = 1; x < w - 1; x++) {
+filt = FILTER3(1);
+score += filt;
+if (filt && out)
+burn_frame(s, out, x, y);
+}
 }
 }
-}
 return score;
 }
 
@@ -214,18 +214,18 @@ static int filter_vrep(SignalstatsContext *s, const 
AVFrame *in, AVFrame *out, i
 int x, y, score = 0;
 
 for (y = VREP_START; y < h; y++) {
-const int y2lw = (y - VREP_START) * lw;
-const int ylw  =  y   * lw;
-int filt, totdiff = 0;
-
-for (x = 0; x < w; x++)
-totdiff += abs(p[y2lw + x] - p[ylw + x]);
-filt = totdiff < w;
+const int y2lw = (y - VREP_START) * lw;
+const int ylw  =  y   * lw;
+int filt, totdiff = 0;
 
-score += filt;
-if (filt && out)
 for (x = 0; x < w; x++)
-burn_frame(s, out, x, y);
+totdiff += abs(p[y2lw + x] - p[ylw + x]);
+filt = totdiff < w;
+
+score += filt;
+if (filt && out)
+for (x = 0; x < w; x++)
+burn_frame(s, out, x, y);
 }

[FFmpeg-cvslog] ffserver: dont leak child arguments

2014-11-26 Thread Lukasz Marek
ffmpeg | branch: master | Lukasz Marek  | Thu Nov 20 
00:28:03 2014 +0100| [3cb0bec6870cf0bb7879f7bfd4119ef39a02a464] | committer: 
Lukasz Marek

ffserver: dont leak child arguments

Signed-off-by: Lukasz Marek 

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

 ffserver.c|2 +-
 ffserver_config.c |   20 ++--
 ffserver_config.h |2 ++
 3 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/ffserver.c b/ffserver.c
index 3702fd6..012056d 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -3663,7 +3663,7 @@ static void handle_child_exit(int sig)
 
 if (uptime < 30)
 /* Turn off any more restarts */
-feed->child_argv = 0;
+ffserver_free_child_args(&feed->child_argv);
 }
 }
 }
diff --git a/ffserver_config.c b/ffserver_config.c
index f34dc5e..5f01e43 100644
--- a/ffserver_config.c
+++ b/ffserver_config.c
@@ -31,6 +31,8 @@
 #include "cmdutils.h"
 #include "ffserver_config.h"
 
+#define MAX_CHILD_ARGS 64
+
 static int ffserver_save_avoption(const char *opt, const char *arg, int type,
   FFServerConfig *config);
 static void vreport_config_error(const char *filename, int line_num, int 
log_level,
@@ -691,10 +693,10 @@ static int ffserver_parse_config_feed(FFServerConfig 
*config, const char *cmd, c
 if (!av_strcasecmp(cmd, "Launch")) {
 int i;
 
-feed->child_argv = av_mallocz(64 * sizeof(char *));
+feed->child_argv = av_mallocz_array(MAX_CHILD_ARGS, sizeof(char *));
 if (!feed->child_argv)
 return AVERROR(ENOMEM);
-for (i = 0; i < 62; i++) {
+for (i = 0; i < MAX_CHILD_ARGS - 2; i++) {
 ffserver_get_arg(arg, sizeof(arg), p);
 if (!arg[0])
 break;
@@ -1255,3 +1257,17 @@ int ffserver_parse_ffconfig(const char *filename, 
FFServerConfig *config)
 
 #undef ERROR
 #undef WARNING
+
+void ffserver_free_child_args(void *argsp)
+{
+int i;
+char **args;
+if (!argsp)
+return;
+args = *(char ***)argsp;
+if (!args)
+return;
+for (i = 0; i < MAX_CHILD_ARGS; i++)
+av_free(args[i]);
+av_freep(argsp);
+}
diff --git a/ffserver_config.h b/ffserver_config.h
index 4e1e0e0..bdeb3c9 100644
--- a/ffserver_config.h
+++ b/ffserver_config.h
@@ -128,4 +128,6 @@ void ffserver_parse_acl_row(FFServerStream *stream, 
FFServerStream* feed,
 
 int ffserver_parse_ffconfig(const char *filename, FFServerConfig *config);
 
+void ffserver_free_child_args(void *argsp);
+
 #endif /* FFSERVER_CONFIG_H */

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


[FFmpeg-cvslog] ffserver_config: cosmetic: simplify functions calls.

2014-11-26 Thread Lukasz Marek
ffmpeg | branch: master | Lukasz Marek  | Thu Nov 13 
18:45:17 2014 +0100| [e98aced69955d268ef61764edd70c59d44ada3a3] | committer: 
Lukasz Marek

ffserver_config: cosmetic: simplify functions calls.

ffserver_save_avoption() and ffserver_opt_preset() have
redundant arguments. They can be obtained basing on media type.
This simplifies uses and reduce chance for a mistake.

Signed-off-by: Lukasz Marek 

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

 ffserver_config.c |   91 ++---
 1 file changed, 45 insertions(+), 46 deletions(-)

diff --git a/ffserver_config.c b/ffserver_config.c
index 02c8431..6b80f02 100644
--- a/ffserver_config.c
+++ b/ffserver_config.c
@@ -31,8 +31,8 @@
 #include "cmdutils.h"
 #include "ffserver_config.h"
 
-static int ffserver_save_avoption(AVCodecContext *ctx, const char *opt, const 
char *arg,
-  AVDictionary **dict, int type, 
FFServerConfig *config, int line_num);
+static int ffserver_save_avoption(const char *opt, const char *arg, int type,
+  FFServerConfig *config, int line_num);
 static void vreport_config_error(const char *filename, int line_num, int 
log_level,
  int *errors, const char *fmt, va_list vl);
 static void report_config_error(const char *filename, int line_num, int 
log_level,
@@ -274,12 +274,25 @@ static int ffserver_set_codec(AVCodecContext *ctx, const 
char *codec_name, FFSer
 return 0;
 }
 
-static int ffserver_opt_preset(const char *arg, AVCodecContext *avctx, 
FFServerConfig *config, int line_num)
+static int ffserver_opt_preset(const char *arg, int type, FFServerConfig 
*config, int line_num)
 {
 FILE *f=NULL;
 char filename[1000], tmp[1000], tmp2[1000], line[1000];
 int ret = 0;
-AVCodec *codec = avcodec_find_encoder(avctx->codec_id);
+AVCodecContext *avctx;
+const AVCodec *codec;
+
+switch(type) {
+case AV_OPT_FLAG_AUDIO_PARAM:
+avctx = config->dummy_actx;
+break;
+case AV_OPT_FLAG_VIDEO_PARAM:
+avctx = config->dummy_vctx;
+break;
+default:
+av_assert0(0);
+}
+codec = avcodec_find_encoder(avctx->codec_id);
 
 if (!(f = get_preset_file(filename, sizeof(filename), arg, 0,
   codec ? codec->name : NULL))) {
@@ -306,29 +319,10 @@ static int ffserver_opt_preset(const char *arg, 
AVCodecContext *avctx, FFServerC
 av_log(NULL, AV_LOG_ERROR, "Subtitles preset found.\n");
 ret = AVERROR(EINVAL);
 break;
-} else {
-int type;
-AVDictionary **opts;
-
-switch(avctx->codec_type) {
-case AVMEDIA_TYPE_AUDIO:
-type = AV_OPT_FLAG_AUDIO_PARAM;
-opts = &config->audio_opts;
-break;
-case AVMEDIA_TYPE_VIDEO:
-type = AV_OPT_FLAG_VIDEO_PARAM;
-opts = &config->video_opts;
-break;
-default:
-ret = AVERROR(EINVAL);
-goto exit;
-}
-if (ffserver_save_avoption(avctx, tmp, tmp2, opts, type, config, 
line_num) < 0)
-break;
-}
+} else if (ffserver_save_avoption(tmp, tmp2, type, config, line_num) < 
0)
+break;
 }
 
-  exit:
 fclose(f);
 
 return ret;
@@ -430,8 +424,7 @@ static int ffserver_set_float_param(float *dest, const char 
*value, float factor
 return AVERROR(EINVAL);
 }
 
-static int ffserver_save_avoption(AVCodecContext *ctx, const char *opt, const 
char *arg, AVDictionary **dict,
-  int type, FFServerConfig *config, int 
line_num)
+static int ffserver_save_avoption(const char *opt, const char *arg, int type, 
FFServerConfig *config, int line_num)
 {
 static int hinted = 0;
 int ret = 0;
@@ -440,6 +433,26 @@ static int ffserver_save_avoption(AVCodecContext *ctx, 
const char *opt, const ch
 const char *option = NULL;
 const char *codec_name = NULL;
 char buff[1024];
+AVCodecContext *ctx;
+AVDictionary **dict;
+enum AVCodecID guessed_codec_id;
+
+switch (type) {
+case AV_OPT_FLAG_VIDEO_PARAM:
+ctx = config->dummy_vctx;
+dict = &config->video_opts;
+guessed_codec_id = config->guessed_video_codec_id != AV_CODEC_ID_NONE ?
+   config->guessed_video_codec_id : AV_CODEC_ID_H264;
+break;
+case AV_OPT_FLAG_AUDIO_PARAM:
+ctx = config->dummy_actx;
+dict = &config->audio_opts;
+guessed_codec_id = config->guessed_audio_codec_id != AV_CODEC_ID_NONE ?
+   config->guessed_audio_codec_id : AV_CODEC_ID_AAC;
+break;
+default:
+av_assert0(0);
+}
 
 if (strchr(opt, ':')) {
 //explicit private option
@@ -461,23 +474,11 @@ static int ffserver_save_

[FFmpeg-cvslog] ffserver_config: cosmetic: move line_num into FFServerConfig

2014-11-26 Thread Lukasz Marek
ffmpeg | branch: master | Lukasz Marek  | Mon Nov 17 
02:23:22 2014 +0100| [d57a6d20875f6e1423de0f4dab930c2cefaba9d7] | committer: 
Lukasz Marek

ffserver_config: cosmetic: move line_num into FFServerConfig

Moving line_num into FFServerConfig as parser state,
saves many passes of it aside of FFServerConfig pointer.

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

 ffserver_config.c |  114 ++---
 ffserver_config.h |1 +
 2 files changed, 58 insertions(+), 57 deletions(-)

diff --git a/ffserver_config.c b/ffserver_config.c
index 6b80f02..7266455 100644
--- a/ffserver_config.c
+++ b/ffserver_config.c
@@ -32,7 +32,7 @@
 #include "ffserver_config.h"
 
 static int ffserver_save_avoption(const char *opt, const char *arg, int type,
-  FFServerConfig *config, int line_num);
+  FFServerConfig *config);
 static void vreport_config_error(const char *filename, int line_num, int 
log_level,
  int *errors, const char *fmt, va_list vl);
 static void report_config_error(const char *filename, int line_num, int 
log_level,
@@ -253,12 +253,12 @@ static void add_codec(FFServerStream *stream, 
AVCodecContext *av)
 stream->streams[stream->nb_streams++] = st;
 }
 
-static int ffserver_set_codec(AVCodecContext *ctx, const char *codec_name, 
FFServerConfig *config, int line_num)
+static int ffserver_set_codec(AVCodecContext *ctx, const char *codec_name, 
FFServerConfig *config)
 {
 int ret;
 AVCodec *codec = avcodec_find_encoder_by_name(codec_name);
 if (!codec || codec->type != ctx->codec_type) {
-report_config_error(config->filename, line_num, AV_LOG_ERROR,
+report_config_error(config->filename, config->line_num, AV_LOG_ERROR,
 &config->errors, "Invalid codec name: %s\n", 
codec_name);
 return 0;
 }
@@ -268,13 +268,13 @@ static int ffserver_set_codec(AVCodecContext *ctx, const 
char *codec_name, FFSer
 ctx->codec = codec;
 }
 if (ctx->codec_id != codec->id)
-report_config_error(config->filename, line_num, AV_LOG_ERROR, 
&config->errors,
+report_config_error(config->filename, config->line_num, AV_LOG_ERROR, 
&config->errors,
 "Inconsistent configuration: trying to set %s 
codec option, but %s codec is used previously\n",
 codec_name, avcodec_get_name(ctx->codec_id));
 return 0;
 }
 
-static int ffserver_opt_preset(const char *arg, int type, FFServerConfig 
*config, int line_num)
+static int ffserver_opt_preset(const char *arg, int type, FFServerConfig 
*config)
 {
 FILE *f=NULL;
 char filename[1000], tmp[1000], tmp2[1000], line[1000];
@@ -313,13 +313,13 @@ static int ffserver_opt_preset(const char *arg, int type, 
FFServerConfig *config
 if ((!strcmp(tmp, "acodec") && avctx->codec_type == 
AVMEDIA_TYPE_AUDIO) ||
  !strcmp(tmp, "vcodec") && avctx->codec_type == AVMEDIA_TYPE_VIDEO)
 {
-if (ffserver_set_codec(avctx, tmp2, config, line_num) < 0)
+if (ffserver_set_codec(avctx, tmp2, config) < 0)
 break;
 } else if (!strcmp(tmp, "scodec")) {
 av_log(NULL, AV_LOG_ERROR, "Subtitles preset found.\n");
 ret = AVERROR(EINVAL);
 break;
-} else if (ffserver_save_avoption(tmp, tmp2, type, config, line_num) < 
0)
+} else if (ffserver_save_avoption(tmp, tmp2, type, config) < 0)
 break;
 }
 
@@ -364,7 +364,7 @@ static void report_config_error(const char *filename, int 
line_num, int log_leve
 }
 
 static int ffserver_set_int_param(int *dest, const char *value, int factor, 
int min, int max,
-  FFServerConfig *config, int line_num, const 
char *error_msg, ...)
+  FFServerConfig *config, const char 
*error_msg, ...)
 {
 int tmp;
 char *tailp;
@@ -388,7 +388,7 @@ static int ffserver_set_int_param(int *dest, const char 
*value, int factor, int
 if (config) {
 va_list vl;
 va_start(vl, error_msg);
-vreport_config_error(config->filename, line_num, AV_LOG_ERROR,
+vreport_config_error(config->filename, config->line_num, AV_LOG_ERROR,
 &config->errors, error_msg, vl);
 va_end(vl);
 }
@@ -396,7 +396,7 @@ static int ffserver_set_int_param(int *dest, const char 
*value, int factor, int
 }
 
 static int ffserver_set_float_param(float *dest, const char *value, float 
factor, float min, float max,
-FFServerConfig *config, int line_num, 
const char *error_msg, ...)
+FFServerConfig *config, const char 
*error_msg, ...)
 {
 double tmp;
 char *tailp;
@@ -417,14 +417,14 @@ static int ffserver_set_float_param(float *dest, const 
char *value, fl

[FFmpeg-cvslog] ffserver: dont leak pb_buffer

2014-11-26 Thread Lukasz Marek
ffmpeg | branch: master | Lukasz Marek  | Thu Nov 20 
18:59:58 2014 +0100| [3d0867917faa9b4cb8e9dd49e5773c60eb2b8fe6] | committer: 
Lukasz Marek

ffserver: dont leak pb_buffer

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

 ffserver.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/ffserver.c b/ffserver.c
index 012056d..8ef51a1 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -2254,6 +2254,7 @@ static int http_prepare_data(HTTPContext *c)
 c->state = HTTPSTATE_SEND_DATA_TRAILER;
 }
 
+av_freep(&c->pb_buffer);
 len = avio_close_dyn_buf(ctx->pb, &c->pb_buffer);
 c->cur_frame_bytes = len;
 c->buffer_ptr = c->pb_buffer;

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


[FFmpeg-cvslog] ffserver: export recommented encoder configuration

2014-11-26 Thread Lukasz Marek
ffmpeg | branch: master | Lukasz Marek  | Sun Nov 16 
21:51:42 2014 +0100| [ec6e035b8b1fcd7a1838ac12c887389a44af4d98] | committer: 
Lukasz Marek

ffserver: export recommented encoder configuration

Signed-off-by: Lukasz Marek 

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

 ffserver.c|6 +++--
 ffserver_config.c |   77 -
 2 files changed, 63 insertions(+), 20 deletions(-)

diff --git a/ffserver.c b/ffserver.c
index e24243d..3702fd6 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -3326,8 +3326,7 @@ static int add_av_stream(FFServerStream *feed, AVStream 
*st)
 
 av = st->codec;
 for(i=0;inb_streams;i++) {
-st = feed->streams[i];
-av1 = st->codec;
+av1 = feed->streams[i]->codec;
 if (av1->codec_id == av->codec_id &&
 av1->codec_type == av->codec_type &&
 av1->bit_rate == av->bit_rate) {
@@ -3355,6 +3354,9 @@ static int add_av_stream(FFServerStream *feed, AVStream 
*st)
 fst = add_av_stream1(feed, av, 0);
 if (!fst)
 return -1;
+if (av_stream_get_recommended_encoder_configuration(st))
+av_stream_set_recommended_encoder_configuration(fst,
+av_strdup(av_stream_get_recommended_encoder_configuration(st)));
 return feed->nb_streams - 1;
 }
 
diff --git a/ffserver_config.c b/ffserver_config.c
index 324aa26..f34dc5e 100644
--- a/ffserver_config.c
+++ b/ffserver_config.c
@@ -178,13 +178,15 @@ static void add_codec(FFServerStream *stream, 
AVCodecContext *av,
   FFServerConfig *config)
 {
 AVStream *st;
-AVDictionary **opts;
+AVDictionary **opts, *recommended = NULL;
+char *enc_config;
 
 if(stream->nb_streams >= FF_ARRAY_ELEMS(stream->streams))
 return;
 
 opts = av->codec_type == AVMEDIA_TYPE_AUDIO ?
&config->audio_opts : &config->video_opts;
+av_dict_copy(&recommended, *opts, 0);
 av_opt_set_dict2(av->priv_data, opts, AV_OPT_SEARCH_CHILDREN);
 av_opt_set_dict2(av, opts, AV_OPT_SEARCH_CHILDREN);
 if (av_dict_count(*opts))
@@ -196,63 +198,99 @@ static void add_codec(FFServerStream *stream, 
AVCodecContext *av,
 /* compute default parameters */
 switch(av->codec_type) {
 case AVMEDIA_TYPE_AUDIO:
-if (av->bit_rate == 0)
+if (av->bit_rate == 0) {
 av->bit_rate = 64000;
-if (av->sample_rate == 0)
+av_dict_set_int(&recommended, "ab", av->bit_rate, 0);
+}
+if (av->sample_rate == 0) {
 av->sample_rate = 22050;
-if (av->channels == 0)
+av_dict_set_int(&recommended, "ar", av->sample_rate, 0);
+}
+if (av->channels == 0) {
 av->channels = 1;
+av_dict_set_int(&recommended, "ac", av->channels, 0);
+}
 break;
 case AVMEDIA_TYPE_VIDEO:
-if (av->bit_rate == 0)
+if (av->bit_rate == 0) {
 av->bit_rate = 64000;
+av_dict_set_int(&recommended, "b", av->bit_rate, 0);
+}
 if (av->time_base.num == 0){
 av->time_base.den = 5;
 av->time_base.num = 1;
+av_dict_set(&recommended, "time_base", "1/5", 0);
 }
 if (av->width == 0 || av->height == 0) {
 av->width = 160;
 av->height = 128;
+av_dict_set(&recommended, "video_size", "160x128", 0);
 }
 /* Bitrate tolerance is less for streaming */
-if (av->bit_rate_tolerance == 0)
+if (av->bit_rate_tolerance == 0) {
 av->bit_rate_tolerance = FFMAX(av->bit_rate / 4,
   
(int64_t)av->bit_rate*av->time_base.num/av->time_base.den);
-if (av->qmin == 0)
+av_dict_set_int(&recommended, "bt", av->bit_rate_tolerance, 0);
+}
+if (av->qmin == 0) {
 av->qmin = 3;
-if (av->qmax == 0)
+av_dict_set_int(&recommended, "qmin", av->qmin, 0);
+}
+if (av->qmax == 0) {
 av->qmax = 31;
-if (av->max_qdiff == 0)
+av_dict_set_int(&recommended, "qmax", av->qmax, 0);
+}
+if (av->max_qdiff == 0) {
 av->max_qdiff = 3;
+av_dict_set_int(&recommended, "qdiff", av->max_qdiff, 0);
+}
+/*FIXME: 0.5 is a default for these two, it is a dead code */
 av->qcompress = 0.5;
+av_dict_set(&recommended, "qcomp", "0.5", 0);
 av->qblur = 0.5;
+av_dict_set(&recommended, "qblur", "0.5", 0);
 
-if (!av->nsse_weight)
+if (!av->nsse_weight) {
 av->nsse_weight = 8;
+av_dict_set_int(&recommended, "nssew", av->nsse_weight, 0);
+}
 
 av->frame_skip_cmp = FF_CMP_DCTMAX;
-if (!av->me_method)
+av_dict_set_int(&recommended, "skipcmp", FF_CMP_DCTMAX, 0);
+if (!av->me_method) {
 av->me_method = ME_EPZS;
+  

[FFmpeg-cvslog] ffserver_config: map ffserver options to AVOptions

2014-11-26 Thread Lukasz Marek
ffmpeg | branch: master | Lukasz Marek  | Thu Nov 13 
18:45:43 2014 +0100| [f61cb6453d22f3c09d4a57f7f07b35efdb66dcf9] | committer: 
Lukasz Marek

ffserver_config: map ffserver options to AVOptions

Signed-off-by: Lukasz Marek 

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

 ffserver_config.c |  238 -
 ffserver_config.h |2 -
 2 files changed, 70 insertions(+), 170 deletions(-)

diff --git a/ffserver_config.c b/ffserver_config.c
index 7266455..e9218ab 100644
--- a/ffserver_config.c
+++ b/ffserver_config.c
@@ -470,6 +470,9 @@ static int ffserver_save_avoption(const char *opt, const 
char *arg, int type, FF
 }
 
 o = av_opt_find(ctx, option, NULL, type | AV_OPT_FLAG_ENCODING_PARAM, 
AV_OPT_SEARCH_CHILDREN);
+if (!o && (!strcmp(option, "time_base")  || !strcmp(option, 
"pixel_format") ||
+   !strcmp(option, "video_size") || !strcmp(option, "codec_tag")))
+o = av_opt_find(ctx, option, NULL, 0, 0);
 if (!o) {
 report_config_error(config->filename, config->line_num, AV_LOG_ERROR,
 &config->errors, "Option not found: %s\n", opt);
@@ -497,6 +500,14 @@ static int ffserver_save_avoption(const char *opt, const 
char *arg, int type, FF
 return 0;
 }
 
+static int ffserver_save_avoption_int(const char *opt, int64_t arg,
+  int type, FFServerConfig *config)
+{
+char buf[22];
+snprintf(buf, sizeof(buf), "%"PRId64, arg);
+return ffserver_save_avoption(opt, buf, type, config);
+}
+
 #define ERROR(...)   report_config_error(config->filename, config->line_num, 
AV_LOG_ERROR,   &config->errors,   __VA_ARGS__)
 #define WARNING(...) report_config_error(config->filename, config->line_num, 
AV_LOG_WARNING, &config->warnings, __VA_ARGS__)
 
@@ -673,105 +684,10 @@ static int ffserver_parse_config_feed(FFServerConfig 
*config, const char *cmd, c
 return 0;
 }
 
-static void ffserver_apply_stream_config(AVCodecContext *enc, const 
AVDictionary *conf, AVDictionary **opts)
+static void ffserver_apply_stream_config(AVCodecContext *enc, AVDictionary 
**opts)
 {
-AVDictionaryEntry *e;
-
-/* Return values from ffserver_set_*_param are ignored.
-   Values are initially parsed and checked before inserting to
-   AVDictionary. */
-
-//video params
-if ((e = av_dict_get(conf, "VideoBitRateRangeMin", NULL, 0)))
-ffserver_set_int_param(&enc->rc_min_rate, e->value, 1000, INT_MIN,
-INT_MAX, NULL, 0, NULL);
-if ((e = av_dict_get(conf, "VideoBitRateRangeMax", NULL, 0)))
-ffserver_set_int_param(&enc->rc_max_rate, e->value, 1000, INT_MIN,
-INT_MAX, NULL, 0, NULL);
-if ((e = av_dict_get(conf, "Debug", NULL, 0)))
-ffserver_set_int_param(&enc->debug, e->value, 0, INT_MIN, INT_MAX,
-NULL, 0, NULL);
-if ((e = av_dict_get(conf, "Strict", NULL, 0)))
-ffserver_set_int_param(&enc->strict_std_compliance, e->value, 0,
-INT_MIN, INT_MAX, NULL, 0, NULL);
-if ((e = av_dict_get(conf, "VideoBufferSize", NULL, 0)))
-ffserver_set_int_param(&enc->rc_buffer_size, e->value, 8*1024,
-INT_MIN, INT_MAX, NULL, 0, NULL);
-if ((e = av_dict_get(conf, "VideoBitRateTolerance", NULL, 0)))
-ffserver_set_int_param(&enc->bit_rate_tolerance, e->value, 1000,
-INT_MIN, INT_MAX, NULL, 0, NULL);
-if ((e = av_dict_get(conf, "VideoBitRate", NULL, 0)))
-ffserver_set_int_param(&enc->bit_rate, e->value, 1000, INT_MIN,
-INT_MAX, NULL, 0, NULL);
-if ((e = av_dict_get(conf, "VideoSizeWidth", NULL, 0)))
-ffserver_set_int_param(&enc->width, e->value, 0, INT_MIN, INT_MAX,
-NULL, 0, NULL);
-if ((e = av_dict_get(conf, "VideoSizeHeight", NULL, 0)))
-ffserver_set_int_param(&enc->height, e->value, 0, INT_MIN, INT_MAX,
-NULL, 0, NULL);
-if ((e = av_dict_get(conf, "PixelFormat", NULL, 0))) {
-int val;
-ffserver_set_int_param(&val, e->value, 0, INT_MIN, INT_MAX, NULL, 0,
-NULL);
-enc->pix_fmt = val;
-}
-if ((e = av_dict_get(conf, "VideoGopSize", NULL, 0)))
-ffserver_set_int_param(&enc->gop_size, e->value, 0, INT_MIN, INT_MAX,
-NULL, 0, NULL);
-if ((e = av_dict_get(conf, "VideoFrameRateNum", NULL, 0)))
-ffserver_set_int_param(&enc->time_base.num, e->value, 0, INT_MIN,
-INT_MAX, NULL, 0, NULL);
-if ((e = av_dict_get(conf, "VideoFrameRateDen", NULL, 0)))
-ffserver_set_int_param(&enc->time_base.den, e->value, 0, INT_MIN,
-INT_MAX, NULL, 0, NULL);
-if ((e = av_dict_get(conf, "VideoQDiff", NULL, 0)))
-ffserver_set_int_param(&enc->max_qdiff, e->value, 0, INT_MIN, INT_MAX,
-NULL, 0, NULL);
-if ((e = av_dict_get(conf, "VideoQMax", NULL, 0)))
-f

[FFmpeg-cvslog] lavc/options: fix leaks in avcodec_free_context

2014-11-26 Thread Lukasz Marek
ffmpeg | branch: master | Lukasz Marek  | Sat Nov 22 
20:43:47 2014 +0100| [345cfd04d093d9fdec81ea3531e73b1f5c1b6a6c] | committer: 
Lukasz Marek

lavc/options: fix leaks in avcodec_free_context

Signed-off-by: Lukasz Marek 

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

 libavcodec/options.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/options.c b/libavcodec/options.c
index 44f3e90..7f9fb07 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -170,6 +170,9 @@ void avcodec_free_context(AVCodecContext **pavctx)
 
 av_freep(&avctx->extradata);
 av_freep(&avctx->subtitle_header);
+av_freep(&avctx->intra_matrix);
+av_freep(&avctx->inter_matrix);
+av_freep(&avctx->rc_override);
 
 av_freep(pavctx);
 }

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


[FFmpeg-cvslog] ffserver: allow skip setting defaults

2014-11-26 Thread Lukasz Marek
ffmpeg | branch: master | Lukasz Marek  | Sat Nov 15 
18:43:41 2014 +0100| [aaf6cc925f7f07a20956dbd0c8dc9927e84ac626] | committer: 
Lukasz Marek

ffserver: allow skip setting defaults

Signed-off-by: Lukasz Marek 

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

 doc/ffserver.texi |   11 +++
 ffserver.c|1 +
 ffserver_config.c |   35 +++
 ffserver_config.h |2 ++
 4 files changed, 49 insertions(+)

diff --git a/doc/ffserver.texi b/doc/ffserver.texi
index b7c5b6a..83b6520 100644
--- a/doc/ffserver.texi
+++ b/doc/ffserver.texi
@@ -408,6 +408,12 @@ ignored, and the log is written to standard output.
 Set no-daemon mode. This option is currently ignored since now
 @command{ffserver} will always work in no-daemon mode, and is
 deprecated.
+
+@item UseDefaults
+@item NoDefaults
+Control whether default codec options are used for the all streams or not.
+Each stream may overwrite this setting for its own. Default is 
@var{UseDefaults}.
+The lastest occurrence overrides previous if multiple definitions.
 @end table
 
 @section Feed section
@@ -571,6 +577,11 @@ deprecated in favor of @option{Metadata}.
 @item Metadata @var{key} @var{value}
 Set metadata value on the output stream.
 
+@item UseDefaults
+@item NoDefaults
+Control whether default codec options are used for the stream or not.
+Default is @var{UseDefaults} unless disabled globally.
+
 @item NoAudio
 @item NoVideo
 Suppress audio/video.
diff --git a/ffserver.c b/ffserver.c
index 933eb0e..e24243d 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -201,6 +201,7 @@ static FFServerConfig config = {
 .nb_max_http_connections = 2000,
 .nb_max_connections = 5,
 .max_bandwidth = 1000,
+.use_defaults = 1,
 };
 
 static void new_connection(int server_fd, int is_rtsp);
diff --git a/ffserver_config.c b/ffserver_config.c
index e1d8d8c..324aa26 100644
--- a/ffserver_config.c
+++ b/ffserver_config.c
@@ -191,6 +191,8 @@ static void add_codec(FFServerStream *stream, 
AVCodecContext *av,
 av_log(NULL, AV_LOG_WARNING,
"Something is wrong, %d options are not set!\n", 
av_dict_count(*opts));
 
+if (config->stream_use_defaults) {
+//TODO: reident
 /* compute default parameters */
 switch(av->codec_type) {
 case AVMEDIA_TYPE_AUDIO:
@@ -255,6 +257,25 @@ static void add_codec(FFServerStream *stream, 
AVCodecContext *av,
 default:
 abort();
 }
+} else {
+switch(av->codec_type) {
+case AVMEDIA_TYPE_AUDIO:
+if (av->bit_rate == 0)
+report_config_error(config->filename, config->line_num, 
AV_LOG_ERROR,
+&config->errors, "audio bit rate is not 
set\n");
+if (av->sample_rate == 0)
+report_config_error(config->filename, config->line_num, 
AV_LOG_ERROR,
+&config->errors, "audio sample rate is not 
set\n");
+break;
+case AVMEDIA_TYPE_VIDEO:
+if (av->width == 0 || av->height == 0)
+report_config_error(config->filename, config->line_num, 
AV_LOG_ERROR,
+&config->errors, "video size is not 
set\n");
+break;
+default:
+av_assert0(0);
+}
+}
 
 st = av_mallocz(sizeof(AVStream));
 if (!st)
@@ -583,6 +604,10 @@ static int ffserver_parse_config_global(FFServerConfig 
*config, const char *cmd,
 ffserver_get_arg(config->logfilename, sizeof(config->logfilename), 
p);
 } else if (!av_strcasecmp(cmd, "LoadModule")) {
 ERROR("Loadable modules are no longer supported\n");
+} else if (!av_strcasecmp(cmd, "NoDefaults")) {
+config->use_defaults = 0;
+} else if (!av_strcasecmp(cmd, "UseDefaults")) {
+config->use_defaults = 1;
 } else
 ERROR("Incorrect keyword: '%s'\n", cmd);
 return 0;
@@ -738,6 +763,7 @@ static int ffserver_parse_config_stream(FFServerConfig 
*config, const char *cmd,
 config->guessed_audio_codec_id = AV_CODEC_ID_NONE;
 config->guessed_video_codec_id = AV_CODEC_ID_NONE;
 }
+config->stream_use_defaults = config->use_defaults;
 *pstream = stream;
 return 0;
 }
@@ -1010,6 +1036,7 @@ static int ffserver_parse_config_stream(FFServerConfig 
*config, const char *cmd,
 } else if (!av_strcasecmp(cmd, "NoLoop")) {
 stream->loop = 0;
 } else if (!av_strcasecmp(cmd, "")) {
+config->stream_use_defaults &= 1;
 if (stream->feed && stream->fmt && strcmp(stream->fmt->name, "ffm")) {
 if (config->dummy_actx->codec_id == AV_CODEC_ID_NONE)
 config->dummy_actx->codec_id = config->guessed_audio_codec_id;
@@ -1032,6 +1059,14 @@ static int ffserver_parse_config_stream(FFServerConfig 
*config, const char *cmd,
 } else if (!av_strcasecmp(cmd, "File") || !av_strcasecmp(cmd, 
"

[FFmpeg-cvslog] ffserver_config: remove ffserver_apply_stream_config function

2014-11-26 Thread Lukasz Marek
ffmpeg | branch: master | Lukasz Marek  | Sun Nov 16 
01:33:19 2014 +0100| [6c2ed67c2f6f93fe153afba40b29a18d2cff0bd0] | committer: 
Lukasz Marek

ffserver_config: remove ffserver_apply_stream_config function

This function became very short and can be logically merged with add_codec().

Signed-off-by: Lukasz Marek 

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

 ffserver_config.c |   26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/ffserver_config.c b/ffserver_config.c
index e9218ab..e1d8d8c 100644
--- a/ffserver_config.c
+++ b/ffserver_config.c
@@ -174,13 +174,23 @@ void ffserver_parse_acl_row(FFServerStream *stream, 
FFServerStream* feed,
 }
 
 /* add a codec and set the default parameters */
-static void add_codec(FFServerStream *stream, AVCodecContext *av)
+static void add_codec(FFServerStream *stream, AVCodecContext *av,
+  FFServerConfig *config)
 {
 AVStream *st;
+AVDictionary **opts;
 
 if(stream->nb_streams >= FF_ARRAY_ELEMS(stream->streams))
 return;
 
+opts = av->codec_type == AVMEDIA_TYPE_AUDIO ?
+   &config->audio_opts : &config->video_opts;
+av_opt_set_dict2(av->priv_data, opts, AV_OPT_SEARCH_CHILDREN);
+av_opt_set_dict2(av, opts, AV_OPT_SEARCH_CHILDREN);
+if (av_dict_count(*opts))
+av_log(NULL, AV_LOG_WARNING,
+   "Something is wrong, %d options are not set!\n", 
av_dict_count(*opts));
+
 /* compute default parameters */
 switch(av->codec_type) {
 case AVMEDIA_TYPE_AUDIO:
@@ -684,14 +694,6 @@ static int ffserver_parse_config_feed(FFServerConfig 
*config, const char *cmd, c
 return 0;
 }
 
-static void ffserver_apply_stream_config(AVCodecContext *enc, AVDictionary 
**opts)
-{
-av_opt_set_dict2(enc->priv_data, opts, AV_OPT_SEARCH_CHILDREN);
-av_opt_set_dict2(enc, opts, AV_OPT_SEARCH_CHILDREN);
-if (av_dict_count(*opts))
-av_log(NULL, AV_LOG_ERROR, "Something went wrong, %d options not 
set!!!\n", av_dict_count(*opts));
-}
-
 static int ffserver_parse_config_stream(FFServerConfig *config, const char 
*cmd, const char **p,
 FFServerStream **pstream)
 {
@@ -1013,15 +1015,13 @@ static int ffserver_parse_config_stream(FFServerConfig 
*config, const char *cmd,
 config->dummy_actx->codec_id = config->guessed_audio_codec_id;
 if (!config->no_audio && config->dummy_actx->codec_id != 
AV_CODEC_ID_NONE) {
 AVCodecContext *audio_enc = 
avcodec_alloc_context3(avcodec_find_encoder(config->dummy_actx->codec_id));
-ffserver_apply_stream_config(audio_enc, &config->audio_opts);
-add_codec(stream, audio_enc);
+add_codec(stream, audio_enc, config);
 }
 if (config->dummy_vctx->codec_id == AV_CODEC_ID_NONE)
 config->dummy_vctx->codec_id = config->guessed_video_codec_id;
 if (!config->no_video && config->dummy_vctx->codec_id != 
AV_CODEC_ID_NONE) {
 AVCodecContext *video_enc = 
avcodec_alloc_context3(avcodec_find_encoder(config->dummy_vctx->codec_id));
-ffserver_apply_stream_config(video_enc, &config->video_opts);
-add_codec(stream, video_enc);
+add_codec(stream, video_enc, config);
 }
 }
 av_dict_free(&config->video_opts);

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


[FFmpeg-cvslog] avformat/apngdec: validate frame dimensions.

2014-11-26 Thread Benoit Fouet
ffmpeg | branch: master | Benoit Fouet  | Wed Nov 26 
10:12:18 2014 +0100| [e2b8b4caf6c0ae2b6a49520c3766c40924f1cb2d] | committer: 
Michael Niedermayer

avformat/apngdec: validate frame dimensions.

Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavformat/apngdec.c b/libavformat/apngdec.c
index 8aa70a0..276d765 100644
--- a/libavformat/apngdec.c
+++ b/libavformat/apngdec.c
@@ -301,7 +301,11 @@ static int decode_fctl_chunk(AVFormatContext *s, 
APNGDemuxContext *ctx, AVPacket
 height != s->streams[0]->codec->height ||
 x_offset != 0 ||
 y_offset != 0) {
-if (sequence_number == 0)
+if (sequence_number == 0 ||
+x_offset >= s->streams[0]->codec->width ||
+width > s->streams[0]->codec->width - x_offset ||
+y_offset >= s->streams[0]->codec->height ||
+height > s->streams[0]->codec->height - y_offset)
 return AVERROR_INVALIDDATA;
 ctx->is_key_frame = 0;
 } else {

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


[FFmpeg-cvslog] avcodec/hevc_ps: Check return code from pps_range_extensions()

2014-11-26 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu Nov 27 
02:31:46 2014 +0100| [9f9440bd8122cc8798139c9370db0873a24ae14b] | committer: 
Michael Niedermayer

avcodec/hevc_ps: Check return code from pps_range_extensions()

Fixes out of array read
Fixes: asan_heap-oob_177e222_885_cov_1532528832_MERGE_D_TI_3.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=9f9440bd8122cc8798139c9370db0873a24ae14b
---

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

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 4e1c561..0d6ede2 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -1375,7 +1375,8 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
 int pps_range_extensions_flag = get_bits1(gb);
 /* int pps_extension_7bits = */ get_bits(gb, 7);
 if (sps->ptl.general_ptl.profile_idc == FF_PROFILE_HEVC_REXT && 
pps_range_extensions_flag) {
-pps_range_extensions(s, pps, sps);
+if ((ret = pps_range_extensions(s, pps, sps)) < 0)
+goto err;
 }
 }
 

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