[FFmpeg-devel] [PATCH 3/4 v2] lavf/rawutils: New function ff_get_raw_palette()

2016-02-28 Thread Mats Peterson

Some simplification.

--
Mats Peterson
http://matsp888.no-ip.org/~mats/
>From 49e30ba82a006665c6ef3e2e4690597a3ae0c421 Mon Sep 17 00:00:00 2001
From: Mats Peterson 
Date: Mon, 29 Feb 2016 08:14:45 +0100
Subject: [PATCH 3/4 v2] lavf/rawutils: New function ff_get_raw_palette()

---
 libavformat/rawutils.c |   16 
 1 file changed, 16 insertions(+)

diff --git a/libavformat/rawutils.c b/libavformat/rawutils.c
index 26ebbb5..7b84984 100644
--- a/libavformat/rawutils.c
+++ b/libavformat/rawutils.c
@@ -65,3 +65,19 @@ fail:
 
 return ret;
 }
+
+int ff_get_raw_palette(AVFormatContext *s, AVPacket *pkt, int ret, const uint8_t **palette)
+{
+int size;
+
+*palette = av_packet_get_side_data(pkt, AV_PKT_DATA_PALETTE, );
+if (*palette && size != AVPALETTE_SIZE) {
+av_log(s, AV_LOG_ERROR, "Invalid palette side data\n");
+return AVERROR_INVALIDDATA;
+}
+
+if (!*palette && ret == CONTAINS_PAL)
+*palette = pkt->data + pkt->size - AVPALETTE_SIZE;
+
+return 0;
+}
-- 
1.7.10.4

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


[FFmpeg-devel] [PATCH 3/4] lavf/rawutils: New function ff_get_raw_palette()

2016-02-28 Thread Mats Peterson


--
Mats Peterson
http://matsp888.no-ip.org/~mats/
>From adaa0cecae9bc1bcf276826be5b7a61785bb5a9e Mon Sep 17 00:00:00 2001
From: Mats Peterson 
Date: Mon, 29 Feb 2016 07:36:34 +0100
Subject: [PATCH 3/4] lavf/rawutils: New function ff_get_raw_palette()

---
 libavformat/rawutils.c |   18 ++
 1 file changed, 18 insertions(+)

diff --git a/libavformat/rawutils.c b/libavformat/rawutils.c
index 26ebbb5..4af40ca 100644
--- a/libavformat/rawutils.c
+++ b/libavformat/rawutils.c
@@ -65,3 +65,21 @@ fail:
 
 return ret;
 }
+
+int ff_get_raw_palette(AVFormatContext *s, AVPacket *pkt, int ret, const uint8_t **palette)
+{
+uint8_t *tmp = NULL;
+int size;
+
+tmp = av_packet_get_side_data(pkt, AV_PKT_DATA_PALETTE, );
+if (tmp && size != AVPALETTE_SIZE) {
+av_log(s, AV_LOG_ERROR, "Invalid palette side data\n");
+return AVERROR_INVALIDDATA;
+}
+
+if (!tmp && ret == CONTAINS_PAL)
+tmp = pkt->data + pkt->size - AVPALETTE_SIZE;
+
+*palette = tmp;
+return 0;
+}
-- 
1.7.10.4

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


[FFmpeg-devel] [PATCH 4/4] lavf/internal.h: Add declaration for ff_get_raw_palette()

2016-02-28 Thread Mats Peterson


--
Mats Peterson
http://matsp888.no-ip.org/~mats/
>From 6cf8a6fb95d553774a4655e397e517d0d911c478 Mon Sep 17 00:00:00 2001
From: Mats Peterson 
Date: Mon, 29 Feb 2016 07:37:22 +0100
Subject: [PATCH 4/4] lavf/internal.h: Add declaration for ff_get_raw_palette()

---
 libavformat/internal.h |9 +
 1 file changed, 9 insertions(+)

diff --git a/libavformat/internal.h b/libavformat/internal.h
index bc6a6c2..1117635 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -573,4 +573,13 @@ int ff_parse_creation_time_metadata(AVFormatContext *s, int64_t *timestamp, int
  */
 int ff_reshuffle_raw_rgb(AVFormatContext *s, AVPacket **ppkt, AVCodecContext *enc, int expected_stride);
 
+/**
+ * Retrieves the palette from a packet, either from a side data packet
+ * or appended to the video data in the packet itself.
+ *
+ * @param pkt pointer to the packet before calling ff_reshuffle_raw_rgb()
+ * @param ret the return value from ff_reshuffle_raw_rgb()
+ */
+int ff_get_raw_palette(AVFormatContext *s, AVPacket *pkt, int ret, const uint8_t **palette);
+
 #endif /* AVFORMAT_INTERNAL_H */
-- 
1.7.10.4

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


[FFmpeg-devel] [PATCH 2/4] lavf/movenc: Add support for palette side data packets

2016-02-28 Thread Mats Peterson


--
Mats Peterson
http://matsp888.no-ip.org/~mats/
>From 7b903e8b0c35f72e2b2530a298719a617a3c1ec8 Mon Sep 17 00:00:00 2001
From: Mats Peterson 
Date: Mon, 29 Feb 2016 07:36:01 +0100
Subject: [PATCH 2/4] lavf/movenc: Add support for palette side data packets

---
 libavformat/movenc.c |   24 ++--
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 3295266..09ada1e 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1717,12 +1717,13 @@ static int mov_write_video_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *tr
 avio_wb16(pb, 0x18); /* Reserved */
 
 if (track->is_unaligned_qt_rgb && track->enc->pix_fmt == AV_PIX_FMT_PAL8) {
+int pal_size = 1 << track->enc->bits_per_coded_sample;
 int i;
 avio_wb16(pb, 0); /* Color table ID */
 avio_wb32(pb, 0); /* Color table seed */
 avio_wb16(pb, 0x8000);/* Color table flags */
-avio_wb16(pb, 255);   /* Color table size (zero-relative) */
-for (i = 0; i < 256; i++) {
+avio_wb16(pb, pal_size - 1);  /* Color table size (zero-relative) */
+for (i = 0; i < pal_size; i++) {
 uint32_t rgb = AV_RL32(>palette[i]);
 uint16_t r = (rgb >> 16) & 0xff;
 uint16_t g = (rgb >> 8)  & 0xff;
@@ -4763,19 +4764,22 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt)
 }
 }
 
-if (trk->is_unaligned_qt_rgb) {
-const uint8_t *data = pkt->data;
-int size = pkt->size;
+if (trk->is_unaligned_qt_rgb && pkt->size) {
 int64_t bpc = trk->enc->bits_per_coded_sample != 15 ? trk->enc->bits_per_coded_sample : 16;
 int expected_stride = ((trk->enc->width * bpc + 15) >> 4)*2;
+AVPacket *opkt = pkt;
 int ret = ff_reshuffle_raw_rgb(s, , trk->enc, expected_stride);
 if (ret < 0)
 return ret;
-if (ret == CONTAINS_PAL && !trk->pal_done) {
-int pal_size = 1 << trk->enc->bits_per_coded_sample;
-memset(trk->palette, 0, AVPALETTE_SIZE);
-memcpy(trk->palette, data + size - 4*pal_size, 4*pal_size);
-trk->pal_done++;
+if (!trk->pal_done) {
+const uint8_t *pal;
+int ret2 = ff_get_raw_palette(s, opkt, ret, );
+if (ret2 < 0)
+return ret2;
+if (pal) {
+memcpy(trk->palette, pal, AVPALETTE_SIZE);
+trk->pal_done++;
+}
 } else if (trk->enc->pix_fmt == AV_PIX_FMT_GRAY8 ||
trk->enc->pix_fmt == AV_PIX_FMT_MONOBLACK) {
 for (i = 0; i < pkt->size; i++)
-- 
1.7.10.4

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


[FFmpeg-devel] [PATCH 1/4] lavf/avienc: Add support for palette side data packets

2016-02-28 Thread Mats Peterson


--
Mats Peterson
http://matsp888.no-ip.org/~mats/
>From 61a4fd8283c184d132c81986b1b805b12d9c34d7 Mon Sep 17 00:00:00 2001
From: Mats Peterson 
Date: Mon, 29 Feb 2016 07:35:48 +0100
Subject: [PATCH 1/4] lavf/avienc: Add support for palette side data packets

---
 libavformat/avienc.c |   60 +++---
 1 file changed, 32 insertions(+), 28 deletions(-)

diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index ca505f4..547a9bf 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -362,7 +362,8 @@ static int avi_write_header(AVFormatContext *s)
 && enc->pix_fmt == AV_PIX_FMT_RGB555LE
 && enc->bits_per_coded_sample == 15)
 enc->bits_per_coded_sample = 16;
-avist->pal_offset = avio_tell(pb) + 40;
+if (pb->seekable)
+avist->pal_offset = avio_tell(pb) + 40;
 ff_put_bmp_header(pb, enc, ff_codec_bmp_tags, 0, 0);
 pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_avi,
   enc->bits_per_coded_sample);
@@ -652,8 +653,6 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
 {
 unsigned char tag[5];
 const int stream_index = pkt->stream_index;
-const uint8_t *data= pkt->data;
-int size   = pkt->size;
 AVIOContext *pb = s->pb;
 AVCodecContext *enc = s->streams[stream_index]->codec;
 AVIStream *avist= s->streams[stream_index]->priv_data;
@@ -668,39 +667,44 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
 if ((ret = write_skip_frames(s, stream_index, pkt->dts)) < 0)
 return ret;
 
-if (enc->codec_id == AV_CODEC_ID_RAWVIDEO && enc->codec_tag == 0) {
+if (enc->codec_id == AV_CODEC_ID_RAWVIDEO && enc->codec_tag == 0 && pkt->size) {
 int64_t bpc = enc->bits_per_coded_sample != 15 ? enc->bits_per_coded_sample : 16;
 int expected_stride = ((enc->width * bpc + 31) >> 5)*4;
-
+AVPacket *opkt = pkt;
+const uint8_t *pal;
+int ret2;
 ret = ff_reshuffle_raw_rgb(s, , enc, expected_stride);
 if (ret < 0)
 return ret;
-if (ret) {
-if (ret == CONTAINS_PAL) {
-int pc_tag, i;
-int pal_size = 1 << enc->bits_per_coded_sample;
-if (!avist->hdr_pal_done) {
-int64_t cur_offset = avio_tell(pb);
-avio_seek(pb, avist->pal_offset, SEEK_SET);
-for (i = 0; i < pal_size; i++) {
-uint32_t v = AV_RL32(data + size - 4*pal_size + 4*i);
-avio_wl32(pb, v & 0xff);
-}
-avio_seek(pb, cur_offset, SEEK_SET);
-avist->hdr_pal_done++;
-}
-avi_stream2fourcc(tag, stream_index, enc->codec_type);
-tag[2] = 'p'; tag[3] = 'c';
-pc_tag = ff_start_tag(pb, tag);
-avio_w8(pb, 0);
-avio_w8(pb, pal_size & 0xFF);
-avio_wl16(pb, 0); // reserved
+ret2 = ff_get_raw_palette(s, opkt, ret, );
+if (ret2 < 0)
+return ret2;
+if (pal) {
+int pal_size = 1 << enc->bits_per_coded_sample;
+int pc_tag, i;
+if (pb->seekable && !avist->hdr_pal_done) {
+int64_t cur_offset = avio_tell(pb);
+avio_seek(pb, avist->pal_offset, SEEK_SET);
 for (i = 0; i < pal_size; i++) {
-uint32_t v = AV_RL32(data + size - 4*pal_size + 4*i);
-avio_wb32(pb, v<<8);
+uint32_t v = AV_RL32(pal + 4*i);
+avio_wl32(pb, v & 0xff);
 }
-ff_end_tag(pb, pc_tag);
+avio_seek(pb, cur_offset, SEEK_SET);
+avist->hdr_pal_done++;
 }
+avi_stream2fourcc(tag, stream_index, enc->codec_type);
+tag[2] = 'p'; tag[3] = 'c';
+pc_tag = ff_start_tag(pb, tag);
+avio_w8(pb, 0);
+avio_w8(pb, pal_size & 0xFF);
+avio_wl16(pb, 0); // reserved
+for (i = 0; i < pal_size; i++) {
+uint32_t v = AV_RL32(pal + 4*i);
+avio_wb32(pb, v<<8);
+}
+ff_end_tag(pb, pc_tag);
+}
+if (ret) {
 ret = avi_write_packet_internal(s, pkt);
 av_packet_free();
 return ret;
-- 
1.7.10.4

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


[FFmpeg-devel] [PATCH] libavformat/segment.c: Continue using last provided segment size

2016-02-28 Thread Michael Ensly
For a project recently I had a need for a live stream to be split into
different size segments at startup to speed-up the time to get the first
few segments. The current behaviour of segment_times when the list ends is
to transcode the rest of the input as a single segment. For a single file,
this makes some sense, but for a live stream it hangs indefinitely and
would be better to stay using one of the segment times provided.

I used the patch below to switch to my desired behaviour, but a more
flexible alternative to allow both behaviours would be to use the
segment_time argument. Currently these two arguments are mutually
exclusive, so some documentation and errors would probably need changing to
accommodate that change. I'm happy to do that change and submit a new patch
that is a feature that is desired for ffmpeg.


diff --git a/libavformat/segment.c b/libavformat/segment.c
index 0c1f633..f7680d8 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -764,11 +764,11 @@ static int seg_write_packet(AVFormatContext *s,
AVPacket *pkt)
 return AVERROR(EINVAL);

 if (seg->times) {
-end_pts = seg->segment_count < seg->nb_times ?
-seg->times[seg->segment_count] : INT64_MAX;
+end_pts = seg->times[seg->segment_count < seg->nb_times ?
+seg->segment_count : seg->nb_times - 1];
 } else if (seg->frames) {
-start_frame = seg->segment_count < seg->nb_frames ?
-seg->frames[seg->segment_count] : INT_MAX;
+start_frame = seg->frames[seg->segment_count < seg->nb_frames ?
+seg->segment_count : seg->nb_frames - 1];
 } else {
 if (seg->use_clocktime) {
 int64_t avgt = av_gettime();
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v6 1/2] lavf/avienc: Add support for palette side data packets

2016-02-28 Thread Mats Peterson

On 02/28/2016 11:31 PM, Mats Peterson wrote:

On 02/28/2016 11:17 PM, Mats Peterson wrote:

On 02/28/2016 11:05 PM, Mats Peterson wrote:

Minor changes.



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




Michael, I'd like to repeat that on stream copy, in *most* cases (that
is as long as the extra size due to the stride of the original file is
not mistaken for a palette, and that can only happen if the extra size
is exactly 1024 bytes), the destination file will have the correct
stride thanks to ff_reshuffle_raw_rgb(). Thus, it won't be a perfectly
identical stream copy, but that would be rather useless anyway due to
the different stride requirements for AVI and QuickTime.

Example: ffmpeg -i 8bb_129.avi -vcodec copy 8bb_129.mov

Mats



There is no 8bb_129.avi out there. Should be 8bpp_129.avi.



Wait with this one, I have a new one with a shared ff_get_raw_palette() 
function coming.


Mats

--
Mats Peterson
http://matsp888.no-ip.org/~mats/
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] tests/api: Silence a few uninitialized variables warnings

2016-02-28 Thread Timothy Gu
---
 tests/api/api-flac-test.c | 2 +-
 tests/api/api-seek-test.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/api/api-flac-test.c b/tests/api/api-flac-test.c
index 7b48059..288bc2c 100644
--- a/tests/api/api-flac-test.c
+++ b/tests/api/api-flac-test.c
@@ -115,7 +115,7 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
 int result = 0;
 int got_output = 0;
 int i = 0;
-int in_frame_bytes, out_frame_bytes;
+int in_frame_bytes = 0, out_frame_bytes = 0;
 
 in_frame = av_frame_alloc();
 if (!in_frame) {
diff --git a/tests/api/api-seek-test.c b/tests/api/api-seek-test.c
index 135b972..5b655d8 100644
--- a/tests/api/api-seek-test.c
+++ b/tests/api/api-seek-test.c
@@ -179,7 +179,7 @@ static int seek_test(const char *input_filename, const char 
*start, const char *
 AVFormatContext *fmt_ctx = NULL;
 int video_stream;
 int result;
-int i, j;
+int i = 0, j = 0;
 long int start_ts, end_ts;
 
 size_of_array = 0;
-- 
1.9.1

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


[FFmpeg-devel] [PATCH] x86/vc1dsp: Split the file into MC and loopfilter

2016-02-28 Thread Timothy Gu
---
 libavcodec/x86/Makefile  |   3 +-
 libavcodec/x86/vc1dsp.asm| 585 ---
 libavcodec/x86/vc1dsp_loopfilter.asm | 317 +++
 libavcodec/x86/vc1dsp_mc.asm | 292 +
 4 files changed, 611 insertions(+), 586 deletions(-)
 delete mode 100644 libavcodec/x86/vc1dsp.asm
 create mode 100644 libavcodec/x86/vc1dsp_loopfilter.asm
 create mode 100644 libavcodec/x86/vc1dsp_mc.asm

diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile
index 629b0ee..839b5bc 100644
--- a/libavcodec/x86/Makefile
+++ b/libavcodec/x86/Makefile
@@ -120,7 +120,8 @@ YASM-OBJS-$(CONFIG_QPELDSP)+= x86/qpeldsp.o 
\
   x86/fpel.o\
   x86/qpel.o
 YASM-OBJS-$(CONFIG_RV34DSP)+= x86/rv34dsp.o
-YASM-OBJS-$(CONFIG_VC1DSP) += x86/vc1dsp.o
+YASM-OBJS-$(CONFIG_VC1DSP) += x86/vc1dsp_loopfilter.o   \
+  x86/vc1dsp_mc.o
 YASM-OBJS-$(CONFIG_IDCTDSP)+= x86/simple_idct10.o
 YASM-OBJS-$(CONFIG_VIDEODSP)   += x86/videodsp.o
 YASM-OBJS-$(CONFIG_VP3DSP) += x86/vp3dsp.o
diff --git a/libavcodec/x86/vc1dsp.asm b/libavcodec/x86/vc1dsp.asm
deleted file mode 100644
index eee42c2..000
--- a/libavcodec/x86/vc1dsp.asm
+++ /dev/null
@@ -1,585 +0,0 @@
-;**
-;* VC1 DSP optimizations
-;* Copyright (c) 2007 Christophe GISQUET 
-;* Copyright (c) 2009 David Conrad
-;*
-;* 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/x86/x86util.asm"
-
-cextern pw_4
-cextern pw_5
-cextern pw_9
-cextern pw_128
-
-section .text
-
-; dst_low, dst_high (src), zero
-; zero-extends one vector from 8 to 16 bits
-%macro UNPACK_8TO16 4
-mova  m%2, m%3
-punpckh%1 m%3, m%4
-punpckl%1 m%2, m%4
-%endmacro
-
-%macro STORE_4_WORDS 6
-%if cpuflag(sse4)
-pextrw %1, %5, %6+0
-pextrw %2, %5, %6+1
-pextrw %3, %5, %6+2
-pextrw %4, %5, %6+3
-%else
-movd  %6d, %5
-%if mmsize==16
-psrldq %5, 4
-%else
-psrlq  %5, 32
-%endif
-mov%1, %6w
-shr%6, 16
-mov%2, %6w
-movd  %6d, %5
-mov%3, %6w
-shr%6, 16
-mov%4, %6w
-%endif
-%endmacro
-
-; in:  p1 p0 q0 q1, clobbers p0
-; out: p1 = (2*(p1 - q1) - 5*(p0 - q0) + 4) >> 3
-%macro VC1_LOOP_FILTER_A0 4
-psubw  %1, %4
-psubw  %2, %3
-paddw  %1, %1
-pmullw %2, [pw_5]
-psubw  %1, %2
-paddw  %1, [pw_4]
-psraw  %1, 3
-%endmacro
-
-; in: p0 q0 a0 a1 a2
-; m0 m1 m7 m6 m5
-; %1: size
-; out: m0=p0' m1=q0'
-%macro VC1_FILTER 1
-PABSW   m4, m7
-PABSW   m3, m6
-PABSW   m2, m5
-movam6, m4
-pminsw  m3, m2
-pcmpgtw m6, m3  ; if (a2 < a0 || a1 < a0)
-psubw   m3, m4
-pmullw  m3, [pw_5]   ; 5*(a3 - a0)
-PABSW   m2, m3
-psraw   m2, 3   ; abs(d/8)
-pxorm7, m3  ; d_sign ^= a0_sign
-
-pxorm5, m5
-movdm3, r2d
-%if %1 > 4
-punpcklbw m3, m3
-%endif
-punpcklbw m3, m5
-pcmpgtw m3, m4  ; if (a0 < pq)
-pandm6, m3
-
-movam3, m0
-psubw   m3, m1
-PABSW   m4, m3
-psraw   m4, 1
-pxorm3, m7  ; d_sign ^ clip_sign
-psraw   m3, 15
-pminsw  m2, m4  ; min(d, clip)
-pcmpgtw m4, m5
-pandm6, m4  ; filt3 (C return value)
-
-; each set of 4 pixels is not filtered if the 3rd is not
-%if mmsize==16
-pshuflw m4, m6, 0xaa
-%if %1 > 4
-pshufhw m4, m4, 0xaa
-%endif
-%else
-pshufw  m4, m6, 0xaa
-%endif
-pandn   m3, m4
-pandm2, m6
-pandm3, m2  ; d final
-
-psraw   m7, 15
-pxorm3, m7
-psubw   m3, m7
-psubw   m0, m3
-paddw   m1, m3
-packuswb m0, m0
-packuswb m1, m1
-%endmacro
-
-; 1st param: size of filter
-; 2nd param: mov suffix equivalent to the filter size
-%macro VC1_V_LOOP_FILTER 2
-pxor  m5, m5
-mov%2 m6, [r4]
-mov%2 m4, [r4+r1]
-mov%2 m7, [r4+2*r1]
-mov%2 m0, [r4+r3]
-punpcklbw m6, m5
-punpcklbw m4, m5
-

[FFmpeg-devel] [PATCH]lavf/img2dec: Skip SOS when auto-detecting jpeg

2016-02-28 Thread Carl Eugen Hoyos
Hi!

I believe attached patch fixes a possible issue when auto-detecting jpeg.

Please review, Carl Eugen
diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 28a1fdb..94cce93 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -715,6 +715,7 @@ static int jpeg_probe(AVProbeData *p)
 state = 0xC0;
 break;
 case 0xDA:
+i += AV_RB16([i + 2]) + 1;
 if (state != 0xC0 && state != 0xDA)
 return 0;
 state = 0xDA;
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add chromascope filter

2016-02-28 Thread Paul B Mahol
Hi,

2nd version attached.
From 6d7f3221b8b7db32c35a64a98d6cb52bad247b88 Mon Sep 17 00:00:00 2001
From: Paul B Mahol 
Date: Mon, 1 Feb 2016 21:05:16 +0100
Subject: [PATCH] avfilter: add chromascope filter

Signed-off-by: Paul B Mahol 
---
 doc/filters.texi |   55 ++
 libavfilter/Makefile |1 +
 libavfilter/allfilters.c |1 +
 libavfilter/vf_chromascope.c | 1511 ++
 4 files changed, 1568 insertions(+)
 create mode 100644 libavfilter/vf_chromascope.c

diff --git a/doc/filters.texi b/doc/filters.texi
index 67c0da7..9c62b06 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -4553,6 +4553,61 @@ ffmpeg -f lavfi -i color=c=black:s=1280x720 -i video.mp4 -shortest -filter_compl
 @end example
 @end itemize
 
+@section chromascope
+
+Display CIE color diagram with pixels overlaid onto it.
+
+The filter acccepts the following options:
+
+@table @option
+@item system
+Set color system.
+
+@table @samp
+@item ntsc
+@item ebu
+@item smpte
+@item hdtv
+@item apple
+@item widergb
+@item cie1931
+@item rec709
+@item rec2020
+@end table
+
+@item cie
+Set CIE system.
+
+@table @samp
+@item xyy
+@item ucs
+@item luv
+@end table
+
+@item gamuts
+Set what gamuts to draw.
+
+See @code{system} option for avaiable values.
+
+@item size, s
+Set chromascope size, by default set to 512.
+
+@item intensity, i
+Set intensity used to map input pixel values to CIE diagram.
+
+@item contrast
+Set contrast used to draw tongue colors that are out of active color system gamut.
+
+@item corrgamma
+Correct gamma displayed on scope, by default enabled.
+
+@item showwhite
+Show white point on CIE diagram, by default disabled.
+
+@item gamma
+Set input gamma. Used only with XYZ input color space.
+@end table
+
 @section codecview
 
 Visualize information exported by some codecs.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 605ca29..1f12329 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -122,6 +122,7 @@ OBJS-$(CONFIG_BLEND_FILTER)  += vf_blend.o dualinput.o framesync
 OBJS-$(CONFIG_BOXBLUR_FILTER)+= vf_boxblur.o
 OBJS-$(CONFIG_BWDIF_FILTER)  += vf_bwdif.o
 OBJS-$(CONFIG_CHROMAKEY_FILTER)  += vf_chromakey.o
+OBJS-$(CONFIG_CHROMASCOPE_FILTER)+= vf_chromascope.o
 OBJS-$(CONFIG_CODECVIEW_FILTER)  += vf_codecview.o
 OBJS-$(CONFIG_COLORBALANCE_FILTER)   += vf_colorbalance.o
 OBJS-$(CONFIG_COLORCHANNELMIXER_FILTER)  += vf_colorchannelmixer.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index e44a9d5..c8978a5 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -143,6 +143,7 @@ void avfilter_register_all(void)
 REGISTER_FILTER(BOXBLUR,boxblur,vf);
 REGISTER_FILTER(BWDIF,  bwdif,  vf);
 REGISTER_FILTER(CHROMAKEY,  chromakey,  vf);
+REGISTER_FILTER(CHROMASCOPE,chromascope,vf);
 REGISTER_FILTER(CODECVIEW,  codecview,  vf);
 REGISTER_FILTER(COLORBALANCE,   colorbalance,   vf);
 REGISTER_FILTER(COLORCHANNELMIXER, colorchannelmixer, vf);
diff --git a/libavfilter/vf_chromascope.c b/libavfilter/vf_chromascope.c
new file mode 100644
index 000..a44e0c1
--- /dev/null
+++ b/libavfilter/vf_chromascope.c
@@ -0,0 +1,1511 @@
+/*
+ * Copyright (c) 2000 John Walker
+ * Copyright (c) 2016 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/avassert.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/opt.h"
+#include "libavutil/parseutils.h"
+#include "libavutil/pixdesc.h"
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+#include "video.h"
+
+enum CieSystem {
+XYY,
+UCS,
+LUV,
+NB_CIE
+};
+
+enum ColorsSystems {
+NTSCsystem,
+EBUsystem,
+SMPTEsystem,
+HDTVsystem,
+APPLEsystem,
+wRGBsystem,
+CIE1931system,
+Rec709system,
+Rec2020system,
+NB_CS
+};
+
+typedef struct ChromascopeContext {
+const AVClass *class;
+int color_system;
+unsigned gamuts;
+int size;
+int show_white;
+int correct_gamma;
+int cie;
+float intensity;
+float contrast;
+int 

Re: [FFmpeg-devel] [PATCH v6 1/2] lavf/avienc: Add support for palette side data packets

2016-02-28 Thread Mats Peterson

On 02/28/2016 11:17 PM, Mats Peterson wrote:

On 02/28/2016 11:05 PM, Mats Peterson wrote:

Minor changes.



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




Michael, I'd like to repeat that on stream copy, in *most* cases (that
is as long as the extra size due to the stride of the original file is
not mistaken for a palette, and that can only happen if the extra size
is exactly 1024 bytes), the destination file will have the correct
stride thanks to ff_reshuffle_raw_rgb(). Thus, it won't be a perfectly
identical stream copy, but that would be rather useless anyway due to
the different stride requirements for AVI and QuickTime.

Example: ffmpeg -i 8bb_129.avi -vcodec copy 8bb_129.mov

Mats



There is no 8bb_129.avi out there. Should be 8bpp_129.avi.

--
Mats Peterson
http://matsp888.no-ip.org/~mats/
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v6 1/2] lavf/avienc: Add support for palette side data packets

2016-02-28 Thread Mats Peterson

On 02/28/2016 11:05 PM, Mats Peterson wrote:

Minor changes.



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




Michael, I'd like to repeat that on stream copy, in *most* cases (that 
is as long as the extra size due to the stride of the original file is 
not mistaken for a palette, and that can only happen if the extra size 
is exactly 1024 bytes), the destination file will have the correct 
stride thanks to ff_reshuffle_raw_rgb(). Thus, it won't be a perfectly 
identical stream copy, but that would be rather useless anyway due to 
the different stride requirements for AVI and QuickTime.


Example: ffmpeg -i 8bb_129.avi -vcodec copy 8bb_129.mov

Mats

--
Mats Peterson
http://matsp888.no-ip.org/~mats/
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] avformat/mov: merge mov_read_custom functions

2016-02-28 Thread Marton Balint


On Sun, 28 Feb 2016, Michael Niedermayer wrote:


On Sat, Feb 20, 2016 at 02:11:49AM +0100, Marton Balint wrote:

This also fixes reading gapless metadata when the entries do not start with the
mean atom. Such samples can be found here:
https://hydrogenaud.io/index.php/topic,93310.0.html

Signed-off-by: Marton Balint 
---
 libavformat/mov.c | 50 --
 1 file changed, 12 insertions(+), 38 deletions(-)


probably ok



Thanks, I have applied the series.


also a fate test for this might make sense ... tell me if i should
upload something to fatesamples for that ...


If you download the .rar file from the URL above, and put 
102400samples_qt-lc-aac.m4a into the gapless folder, I can add it to the 
gapless test using the fixed aac decoder.


Regards,
Marton
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v6 2/2] lavf/movenc: Add support for palette side data packets

2016-02-28 Thread Mats Peterson

Minor changes.

--
Mats Peterson
http://matsp888.no-ip.org/~mats/
>From 89273db7f36475d80e0f054939b84746fa86c947 Mon Sep 17 00:00:00 2001
From: Mats Peterson 
Date: Sun, 28 Feb 2016 23:03:37 +0100
Subject: [PATCH v6 2/2] lavf/movenc: Add support for palette side data packets

---
 libavformat/movenc.c |   26 ++
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 3295266..44dddec 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1717,12 +1717,13 @@ static int mov_write_video_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *tr
 avio_wb16(pb, 0x18); /* Reserved */
 
 if (track->is_unaligned_qt_rgb && track->enc->pix_fmt == AV_PIX_FMT_PAL8) {
+int pal_size = 1 << track->enc->bits_per_coded_sample;
 int i;
 avio_wb16(pb, 0); /* Color table ID */
 avio_wb32(pb, 0); /* Color table seed */
 avio_wb16(pb, 0x8000);/* Color table flags */
-avio_wb16(pb, 255);   /* Color table size (zero-relative) */
-for (i = 0; i < 256; i++) {
+avio_wb16(pb, pal_size - 1);  /* Color table size (zero-relative) */
+for (i = 0; i < pal_size; i++) {
 uint32_t rgb = AV_RL32(>palette[i]);
 uint16_t r = (rgb >> 16) & 0xff;
 uint16_t g = (rgb >> 8)  & 0xff;
@@ -4763,19 +4764,28 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt)
 }
 }
 
-if (trk->is_unaligned_qt_rgb) {
+if (trk->is_unaligned_qt_rgb && pkt->size) {
 const uint8_t *data = pkt->data;
 int size = pkt->size;
 int64_t bpc = trk->enc->bits_per_coded_sample != 15 ? trk->enc->bits_per_coded_sample : 16;
 int expected_stride = ((trk->enc->width * bpc + 15) >> 4)*2;
+const uint8_t *pal = NULL;
+int sd_size;
 int ret = ff_reshuffle_raw_rgb(s, , trk->enc, expected_stride);
 if (ret < 0)
 return ret;
-if (ret == CONTAINS_PAL && !trk->pal_done) {
-int pal_size = 1 << trk->enc->bits_per_coded_sample;
-memset(trk->palette, 0, AVPALETTE_SIZE);
-memcpy(trk->palette, data + size - 4*pal_size, 4*pal_size);
-trk->pal_done++;
+if (!trk->pal_done) {
+pal = av_packet_get_side_data(pkt, AV_PKT_DATA_PALETTE, _size);
+if (pal && sd_size != AVPALETTE_SIZE) {
+av_log(s, AV_LOG_ERROR, "Invalid palette side data\n");
+return AVERROR_INVALIDDATA;
+}
+if (!pal && ret == CONTAINS_PAL)
+pal = data + size - AVPALETTE_SIZE;
+if (pal) {
+memcpy(trk->palette, pal, AVPALETTE_SIZE);
+trk->pal_done++;
+}
 } else if (trk->enc->pix_fmt == AV_PIX_FMT_GRAY8 ||
trk->enc->pix_fmt == AV_PIX_FMT_MONOBLACK) {
 for (i = 0; i < pkt->size; i++)
-- 
1.7.10.4

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


[FFmpeg-devel] [PATCH v6 1/2] lavf/avienc: Add support for palette side data packets

2016-02-28 Thread Mats Peterson

Minor changes.

--
Mats Peterson
http://matsp888.no-ip.org/~mats/
>From 4178618ce016a5d2569d6d7663b8c2d872ed5a42 Mon Sep 17 00:00:00 2001
From: Mats Peterson 
Date: Sun, 28 Feb 2016 23:03:23 +0100
Subject: [PATCH v6 1/2] lavf/avienc: Add support for palette side data packets

---
 libavformat/avienc.c |   61 +-
 1 file changed, 35 insertions(+), 26 deletions(-)

diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index ca505f4..6da5b50 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -362,7 +362,8 @@ static int avi_write_header(AVFormatContext *s)
 && enc->pix_fmt == AV_PIX_FMT_RGB555LE
 && enc->bits_per_coded_sample == 15)
 enc->bits_per_coded_sample = 16;
-avist->pal_offset = avio_tell(pb) + 40;
+if (pb->seekable)
+avist->pal_offset = avio_tell(pb) + 40;
 ff_put_bmp_header(pb, enc, ff_codec_bmp_tags, 0, 0);
 pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_avi,
   enc->bits_per_coded_sample);
@@ -668,39 +669,47 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
 if ((ret = write_skip_frames(s, stream_index, pkt->dts)) < 0)
 return ret;
 
-if (enc->codec_id == AV_CODEC_ID_RAWVIDEO && enc->codec_tag == 0) {
+if (enc->codec_id == AV_CODEC_ID_RAWVIDEO && enc->codec_tag == 0 && size) {
 int64_t bpc = enc->bits_per_coded_sample != 15 ? enc->bits_per_coded_sample : 16;
 int expected_stride = ((enc->width * bpc + 31) >> 5)*4;
-
+const uint8_t *pal = NULL;
+int sd_size;
 ret = ff_reshuffle_raw_rgb(s, , enc, expected_stride);
 if (ret < 0)
 return ret;
-if (ret) {
-if (ret == CONTAINS_PAL) {
-int pc_tag, i;
-int pal_size = 1 << enc->bits_per_coded_sample;
-if (!avist->hdr_pal_done) {
-int64_t cur_offset = avio_tell(pb);
-avio_seek(pb, avist->pal_offset, SEEK_SET);
-for (i = 0; i < pal_size; i++) {
-uint32_t v = AV_RL32(data + size - 4*pal_size + 4*i);
-avio_wl32(pb, v & 0xff);
-}
-avio_seek(pb, cur_offset, SEEK_SET);
-avist->hdr_pal_done++;
-}
-avi_stream2fourcc(tag, stream_index, enc->codec_type);
-tag[2] = 'p'; tag[3] = 'c';
-pc_tag = ff_start_tag(pb, tag);
-avio_w8(pb, 0);
-avio_w8(pb, pal_size & 0xFF);
-avio_wl16(pb, 0); // reserved
+pal = av_packet_get_side_data(pkt, AV_PKT_DATA_PALETTE, _size);
+if (pal && sd_size != AVPALETTE_SIZE) {
+av_log(s, AV_LOG_ERROR, "Invalid palette side data\n");
+return AVERROR_INVALIDDATA;
+}
+if (!pal && ret == CONTAINS_PAL)
+pal = data + size - AVPALETTE_SIZE;
+if (pal) {
+int pal_size = 1 << enc->bits_per_coded_sample;
+int pc_tag, i;
+if (pb->seekable && !avist->hdr_pal_done) {
+int64_t cur_offset = avio_tell(pb);
+avio_seek(pb, avist->pal_offset, SEEK_SET);
 for (i = 0; i < pal_size; i++) {
-uint32_t v = AV_RL32(data + size - 4*pal_size + 4*i);
-avio_wb32(pb, v<<8);
+uint32_t v = AV_RL32(pal + 4*i);
+avio_wl32(pb, v & 0xff);
 }
-ff_end_tag(pb, pc_tag);
+avio_seek(pb, cur_offset, SEEK_SET);
+avist->hdr_pal_done++;
 }
+avi_stream2fourcc(tag, stream_index, enc->codec_type);
+tag[2] = 'p'; tag[3] = 'c';
+pc_tag = ff_start_tag(pb, tag);
+avio_w8(pb, 0);
+avio_w8(pb, pal_size & 0xFF);
+avio_wl16(pb, 0); // reserved
+for (i = 0; i < pal_size; i++) {
+uint32_t v = AV_RL32(pal + 4*i);
+avio_wb32(pb, v<<8);
+}
+ff_end_tag(pb, pc_tag);
+}
+if (ret) {
 ret = avi_write_packet_internal(s, pkt);
 av_packet_free();
 return ret;
-- 
1.7.10.4

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


Re: [FFmpeg-devel] [PATCH v2] Enable dash output to work when the output isn't a local file

2016-02-28 Thread Michael Niedermayer
On Wed, Jan 06, 2016 at 09:57:41AM +0100, Raymond Hilseth wrote:
> Use avpriv_io_move instead of ff_rename to support more than only
> the file protocol.
> 
> Enabled the implementation of file_move in libavformat/file.c for
> systems not having unistd.h since it only requires the rename function
> from os_support.h.
> 
> Signed-off-by: Raymond Hilseth 

applied

thanks

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 3
"Rare item" - "Common item with rare defect or maybe just a lie"
"Professional" - "'Toy' made in china, not functional except as doorstop"
"Experts will know" - "The seller hopes you are not an expert"


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] Fwd: Fwd: libavformat/segment : add option to increment timecode

2016-02-28 Thread Martin Vignali
2016-02-23 20:08 GMT+01:00 Martin Vignali :

>
>
> 2016-02-23 19:41 GMT+01:00 Stefano Sabatini :
>
>> On date Friday 2016-02-19 14:04:12 +0100, Martin Vignali encoded:
>> > 2016-02-15 2:35 GMT+01:00 Stefano Sabatini :
>> [...]
>> > > > +err = av_timecode_init_from_string(, rate,
>> > > tcr->value, s);
>> > > > +if (err < 0) {
>> > > > +av_log(s, AV_LOG_WARNING, "Could not
>> increment
>> > > timecode, error occured during timecode creation.");
>> > > > +break;
>> > > > +}
>> > >
>> > > > +tc.start += (int)
>> > > av_q2d(av_mul_q(av_make_q(seg->time, 100 ), rate));/* increment
>> > > timecode */
>> > >
>> > > nit: 100_) => 100)
>> > >
>> > > Also, reading from the timecode.c code it looks like the increment
>> > > must be expressed in fps units.
>> > >
>> >
>> > Sorry don't understand what's wrong now. In my tests, the timecode
>> > incrementation is correct (but maybe i missed a special case)
>>
>> Not necessarily a problem, assuming the fps is consistent with the
>> rate.
>>
>
> Ok, so i think there is no problem, because timecode is created with the
> rate (av_timecode_init_from_string set the fps from rate.),
> and the increment is made with the rate.
> Both values are consistent.
>
>
>
>>
>> > > Finally, you are using the segment->time, which is different from the
>> > > effective segment duration. Could you set the metadata in segment_end,
>> > > where the exact duration is known?
>> > >
>> >
>> > Do you know how can i get the exact segment duration ?
>>
>> What about setting the metadata when you're *closing* the segment
>> (e.g. in segment_end())?
>>
>> This way you can know the exact duration.
>> --
>>
>>
> Ok for that, but in fact my question is more about the way to have a more
> precise duration than segment->time.
>
> Thanks,
>
> Martin
>
>

Hello,

New patch attached, with the timecode incrementation inside segment_end()
Use this time start_time and end_time (from SegmentListEntry) to calculate
the duration of the segment.


Best regards

Martin
From 6aab70f629ae8b951574c27d70f06e80334a9309 Mon Sep 17 00:00:00 2001
From: Martin Vignali 
Date: Sun, 28 Feb 2016 21:36:42 +0100
Subject: [PATCH] lavf/segment: add increment timecode option

for example you can split a file, keeping a continuous timecode between
each segment :

ffmpeg -i src.mov -timecode 10:00:00:00 -vcodec copy -f segment \
-segment_time 2 -reset_timestamps 1 -increment_tc 1 target_%03d.mov
---
 doc/muxers.texi   |  6 ++
 libavformat/segment.c | 32 
 2 files changed, 38 insertions(+)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 2e6bb4c..c2d26a8 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1017,6 +1017,12 @@ implementation for HLS segmentation.
 The segment muxer supports the following options:
 
 @table @option
+@item increment_tc @var{1|0}
+if set to @code{1}, increment timecode between each segment
+If this is selected, the input need to have
+a timecode in the first video stream. Default value is
+@code{0}.
+
 @item reference_stream @var{specifier}
 Set the reference stream, as specified by the string @var{specifier}.
 If @var{specifier} is set to @code{auto}, the reference is chosen
diff --git a/libavformat/segment.c b/libavformat/segment.c
index dd3b092..6335c89 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -41,6 +41,7 @@
 #include "libavutil/parseutils.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/time.h"
+#include "libavutil/timecode.h"
 #include "libavutil/time_internal.h"
 #include "libavutil/timestamp.h"
 
@@ -95,6 +96,7 @@ typedef struct SegmentContext {
 char *time_str;///< segment duration specification string
 int64_t time;  ///< segment duration
 int use_strftime;  ///< flag to expand filename with strftime
+int increment_tc;  ///< flag to increment timecode if found
 
 char *times_str;   ///< segment times specification string
 int64_t *times;///< list of segment interval specification
@@ -337,6 +339,12 @@ static int segment_end(AVFormatContext *s, int write_trailer, int is_last)
 SegmentContext *seg = s->priv_data;
 AVFormatContext *oc = seg->avf;
 int ret = 0;
+AVTimecode tc;
+AVRational rate;
+AVDictionaryEntry *tcr;
+char buf[AV_TIMECODE_STR_SIZE];
+int i;
+int err;
 
 av_write_frame(oc, NULL); /* Flush any buffered data (fragmented mp4) */
 if (write_trailer)
@@ -390,6 +398,29 @@ static int segment_end(AVFormatContext *s, int write_trailer, int is_last)
seg->avf->filename, seg->segment_count);
 seg->segment_count++;
 
+if (seg->increment_tc) {
+tcr = av_dict_get(s->metadata, "timecode", NULL, 0);
+if (tcr) {
+/* search the first video stream 

Re: [FFmpeg-devel] [PATCH 2/2] lavf/mov: downgrade sidx errors to non-fatal warnings; fixes trac #5216

2016-02-28 Thread Michael Niedermayer
On Mon, Feb 22, 2016 at 06:34:29PM -0600, Rodger Combs wrote:
> ---
>  libavformat/mov.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

LGTM

also same as previous, a  fate test is welcome if it can be done
with a small reference file

thanks

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Old school: Use the lowest level language in which you can solve the problem
conveniently.
New school: Use the highest level language in which the latest supercomputer
can solve the problem without the user falling asleep waiting.


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] lavf/mov: fix sidx with edit lists

2016-02-28 Thread Michael Niedermayer
On Mon, Feb 22, 2016 at 06:34:28PM -0600, Rodger Combs wrote:
> ---
>  libavformat/mov.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

LGTM
thx

btw, can this be tested in fate without too large reference files ?

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Democracy is the form of government in which you can choose your dictator


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] Support seek in encrypted MP4

2016-02-28 Thread Eran Kornblau
Bumping... same patch attached

Thanks

Eran


0001-mov-support-seek-in-encrypted-mp4.patch
Description: 0001-mov-support-seek-in-encrypted-mp4.patch
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] avformat/mov: merge mov_read_custom functions

2016-02-28 Thread Michael Niedermayer
On Sat, Feb 20, 2016 at 02:11:49AM +0100, Marton Balint wrote:
> This also fixes reading gapless metadata when the entries do not start with 
> the
> mean atom. Such samples can be found here:
> https://hydrogenaud.io/index.php/topic,93310.0.html
> 
> Signed-off-by: Marton Balint 
> ---
>  libavformat/mov.c | 50 --
>  1 file changed, 12 insertions(+), 38 deletions(-)

probably ok

also a fate test for this might make sense ... tell me if i should
upload something to fatesamples for that ...

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] Ignore invalid sprop-parameter-sets missing PPS

2016-02-28 Thread Andrew Shulgin
---
 libavformat/rtpdec_h264.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavformat/rtpdec_h264.c b/libavformat/rtpdec_h264.c
index b399be4..e707d03 100644
--- a/libavformat/rtpdec_h264.c
+++ b/libavformat/rtpdec_h264.c
@@ -166,6 +166,10 @@ static int sdp_parse_fmtp_config_h264(AVFormatContext *s,
 parse_profile_level_id(s, h264_data, value);
 } else if (!strcmp(attr, "sprop-parameter-sets")) {
 int ret;
+if (value[strlen(value) - 1] == ',') {
+av_log(s, AV_LOG_WARNING, "Missing PPS in sprop-parameter-sets, 
ignoring\n");
+return 0;
+}
 codec->extradata_size = 0;
 av_freep(>extradata);
 ret = ff_h264_parse_sprop_parameter_sets(s, >extradata,
-- 
2.4.10
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] LICENSE: Thorough editing

2016-02-28 Thread Timothy Gu
On Sat, Feb 13, 2016 at 05:41:10PM -0800, Timothy Gu wrote:
> The changes in "Incompatible libraries" section are strictly based on
> what our configure script says.
> ---
>  LICENSE.md | 64 
> +-
>  1 file changed, 38 insertions(+), 26 deletions(-)

Pushed.

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


Re: [FFmpeg-devel] [PATCH] x86/vf_blend: Add SSE2 optimization for divide

2016-02-28 Thread Timothy Gu
On Sun, Feb 14, 2016 at 03:45:11PM +0100, Henrik Gramner wrote:
> You could try doing 8 or 16 bytes per iteration instead of 4, it might
> be faster depending on how good your cpu is at OOE.

As discussed on IRC, no observable difference has been observed with such
changes, mainly because the bottleneck is in the division itself.

Therefore, patch applied without changes.

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


[FFmpeg-devel] [PATCH] avfilter/vf_bwdif: add x86 SIMD for 8bit

2016-02-28 Thread Thomas Mundt
The attached patch is my first SIMD code. It is more than 3x faster, so 
optimisations work.
But experienced programmers may find some more improvement.
I´m not really happy with the extra mov instructions needed in x86_32 for 
mrefs3 and prefs3 because of the register limitations.
I tried a lot, but this was the only way I made it work.
Since bwdif is based on yadif, I stole parts of the SIMD code from there. Also 
for learning how it works. Maybe I should add Michael and Daniel to the licence?
I will write SMID code for higher bitrates later, when this patch is approved.
Please comment.

0001-vf_bwdif-add-x86-SIMD-for-8bit.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/3] avformat: use ff_standardize_creation_time for formats writing all format string metadata

2016-02-28 Thread wm4
On Sun, 28 Feb 2016 14:28:20 +0100
Marton Balint  wrote:

> Signed-off-by: Marton Balint 
> ---
>  libavformat/apetag.c| 1 +
>  libavformat/cafenc.c| 1 +
>  libavformat/flvenc.c| 1 +
>  libavformat/id3v2enc.c  | 1 +
>  libavformat/lrcenc.c| 1 +
>  libavformat/nutenc.c| 1 +
>  libavformat/smjpegenc.c | 1 +
>  libavformat/wtvenc.c| 1 +
>  8 files changed, 8 insertions(+)
> 
> diff --git a/libavformat/apetag.c b/libavformat/apetag.c
> index 2ee277f..9d415b8 100644
> --- a/libavformat/apetag.c
> +++ b/libavformat/apetag.c
> @@ -193,6 +193,7 @@ int ff_ape_write_tag(AVFormatContext *s)
>   APE_TAG_FLAG_IS_HEADER);
>  ffio_fill(dyn_bc, 0, 8); // reserved
>  
> +ff_standardize_creation_time(s);
>  while ((e = av_dict_get(s->metadata, "", e, AV_DICT_IGNORE_SUFFIX))) {
>  int val_len;
>  
> diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c
> index 544bc4a..0b2f649 100644
> --- a/libavformat/cafenc.c
> +++ b/libavformat/cafenc.c
> @@ -175,6 +175,7 @@ static int caf_write_header(AVFormatContext *s)
>  avio_write(pb, enc->extradata, enc->extradata_size);
>  }
>  
> +ff_standardize_creation_time(s);
>  if (av_dict_count(s->metadata)) {
>  ffio_wfourcc(pb, "info"); //< Information chunk
>  while ((t = av_dict_get(s->metadata, "", t, AV_DICT_IGNORE_SUFFIX))) 
> {
> diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
> index 8fd5d29..ab71d41 100644
> --- a/libavformat/flvenc.c
> +++ b/libavformat/flvenc.c
> @@ -281,6 +281,7 @@ static void write_metadata(AVFormatContext *s, unsigned 
> int ts)
>  put_amf_double(pb, 0.0);
>  }
>  
> +ff_standardize_creation_time(s);
>  while ((tag = av_dict_get(s->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) 
> {
>  if(   !strcmp(tag->key, "width")
>  ||!strcmp(tag->key, "height")
> diff --git a/libavformat/id3v2enc.c b/libavformat/id3v2enc.c
> index 8b804c4..e4ccdf9 100644
> --- a/libavformat/id3v2enc.c
> +++ b/libavformat/id3v2enc.c
> @@ -242,6 +242,7 @@ int ff_id3v2_write_metadata(AVFormatContext *s, 
> ID3v2EncContext *id3)
>ID3v2_ENCODING_UTF8;
>  int i, ret;
>  
> +ff_standardize_creation_time(s);
>  if ((ret = write_metadata(s->pb, >metadata, id3, enc)) < 0)
>  return ret;
>  
> diff --git a/libavformat/lrcenc.c b/libavformat/lrcenc.c
> index b316ccd..74268cc 100644
> --- a/libavformat/lrcenc.c
> +++ b/libavformat/lrcenc.c
> @@ -52,6 +52,7 @@ static int lrc_write_header(AVFormatContext *s)
>  }
>  avpriv_set_pts_info(s->streams[0], 64, 1, 100);
>  
> +ff_standardize_creation_time(s);
>  ff_metadata_conv_ctx(s, ff_lrc_metadata_conv, NULL);
>  if(!(s->flags & AVFMT_FLAG_BITEXACT)) { // avoid breaking regression 
> tests
>  /* LRC provides a metadata slot for specifying encoder version
> diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
> index b6582ef..bf596ba 100644
> --- a/libavformat/nutenc.c
> +++ b/libavformat/nutenc.c
> @@ -489,6 +489,7 @@ static int write_globalinfo(NUTContext *nut, AVIOContext 
> *bc)
>  if (ret < 0)
>  return ret;
>  
> +ff_standardize_creation_time(s);
>  while ((t = av_dict_get(s->metadata, "", t, AV_DICT_IGNORE_SUFFIX)))
>  count += add_info(dyn_bc, t->key, t->value);
>  
> diff --git a/libavformat/smjpegenc.c b/libavformat/smjpegenc.c
> index 430a497..4553c86 100644
> --- a/libavformat/smjpegenc.c
> +++ b/libavformat/smjpegenc.c
> @@ -46,6 +46,7 @@ static int smjpeg_write_header(AVFormatContext *s)
>  avio_wb32(pb, 0);
>  avio_wb32(pb, 0);
>  
> +ff_standardize_creation_time(s);
>  while ((t = av_dict_get(s->metadata, "", t, AV_DICT_IGNORE_SUFFIX))) {
>  avio_wl32(pb, SMJPEG_TXT);
>  avio_wb32(pb, strlen(t->key) + strlen(t->value) + 3);
> diff --git a/libavformat/wtvenc.c b/libavformat/wtvenc.c
> index 0894b7f..908448f 100644
> --- a/libavformat/wtvenc.c
> +++ b/libavformat/wtvenc.c
> @@ -672,6 +672,7 @@ static void write_table_entries_attrib(AVFormatContext *s)
>  AVIOContext *pb = s->pb;
>  AVDictionaryEntry *tag = 0;
>  
> +ff_standardize_creation_time(s);
>  //FIXME: translate special tags (e.g. WM/Bitrate) to binary 
> representation
>  ff_metadata_conv(>metadata, ff_asf_metadata_conv, NULL);
>  while ((tag = av_dict_get(s->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))

Patches 1 and 2 LGTM.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavfi: add rangescope filter

2016-02-28 Thread Paul B Mahol
Hi,

patch attached.
From 71b621fb53b3d86a049f20f09fb2fbafd6354ccc Mon Sep 17 00:00:00 2001
From: Paul B Mahol 
Date: Sun, 28 Feb 2016 10:39:19 +0100
Subject: [PATCH] avfilter: add rangescope filter

Signed-off-by: Paul B Mahol 
---
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   1 +
 libavfilter/vf_rangescope.c | 296 
 3 files changed, 298 insertions(+)
 create mode 100644 libavfilter/vf_rangescope.c

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 605ca29..a876fa4 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -219,6 +219,7 @@ OBJS-$(CONFIG_PSNR_FILTER)   += vf_psnr.o dualinput.o framesync.
 OBJS-$(CONFIG_PULLUP_FILTER) += vf_pullup.o
 OBJS-$(CONFIG_QP_FILTER) += vf_qp.o
 OBJS-$(CONFIG_RANDOM_FILTER) += vf_random.o
+OBJS-$(CONFIG_RANGESCOPE_FILTER) += vf_rangescope.o
 OBJS-$(CONFIG_REALTIME_FILTER)   += f_realtime.o
 OBJS-$(CONFIG_REMOVEGRAIN_FILTER)+= vf_removegrain.o
 OBJS-$(CONFIG_REMOVELOGO_FILTER) += bbox.o lswsutils.o lavfutils.o vf_removelogo.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index e44a9d5..e65cdf3 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -239,6 +239,7 @@ void avfilter_register_all(void)
 REGISTER_FILTER(PULLUP, pullup, vf);
 REGISTER_FILTER(QP, qp, vf);
 REGISTER_FILTER(RANDOM, random, vf);
+REGISTER_FILTER(RANGESCOPE, rangescope, vf);
 REGISTER_FILTER(REALTIME,   realtime,   vf);
 REGISTER_FILTER(REMOVEGRAIN,removegrain,vf);
 REGISTER_FILTER(REMOVELOGO, removelogo, vf);
diff --git a/libavfilter/vf_rangescope.c b/libavfilter/vf_rangescope.c
new file mode 100644
index 000..118c43b
--- /dev/null
+++ b/libavfilter/vf_rangescope.c
@@ -0,0 +1,296 @@
+/*
+ * Copyright (c) 2016 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/avassert.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/opt.h"
+#include "libavutil/parseutils.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/xga_font_data.h"
+#include "avfilter.h"
+#include "drawutils.h"
+#include "formats.h"
+#include "internal.h"
+#include "video.h"
+
+typedef struct Range {
+int min;
+int max;
+int imin;
+int imax;
+} Range;
+
+typedef struct RangescopeContext {
+const AVClass *class;
+int ow, oh;
+int axis;
+
+int planewidth[4];
+int planeheight[4];
+int nb_planes;
+int depth;
+FFDrawContext draw;
+FFDrawColor color[4];
+FFDrawColor black;
+FFDrawColor green;
+FFDrawColor hcolor;
+uint8_t map[4];
+uint8_t highlight[4];
+
+Range range[4];
+int max;
+void (*get_ranges)(AVFilterContext *ctx, AVFrame *in);
+} RangescopeContext;
+
+#define OFFSET(x) offsetof(RangescopeContext, x)
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
+
+static const AVOption rangescope_options[] = {
+{ "size", "set output size", OFFSET(ow),   AV_OPT_TYPE_IMAGE_SIZE, {.str="vga"}, 0, 0, FLAGS },
+{ "s","set output size", OFFSET(ow),   AV_OPT_TYPE_IMAGE_SIZE, {.str="vga"}, 0, 0, FLAGS },
+{ "axis", "draw axis", OFFSET(axis),   AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
+{ "a","draw axis", OFFSET(axis),   AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
+{ "c","set highlight color", OFFSET(highlight), AV_OPT_TYPE_COLOR, {.str="yellow"}, 0, 0, FLAGS },
+{ NULL }
+};
+
+AVFILTER_DEFINE_CLASS(rangescope);
+
+static const enum AVPixelFormat pix_fmts[] = {
+AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP,
+AV_PIX_FMT_GBRAP12,  AV_PIX_FMT_GBRAP16,
+AV_PIX_FMT_GBRP9,AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14,
+AV_PIX_FMT_GBRP16,
+AV_PIX_FMT_YUV422P,  AV_PIX_FMT_YUV420P,
+AV_PIX_FMT_YUV444P,  AV_PIX_FMT_YUV440P,
+AV_PIX_FMT_YUV411P,  AV_PIX_FMT_YUV410P,
+AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ411P, AV_PIX_FMT_YUVJ420P,
+AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P,
+AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA420P,

Re: [FFmpeg-devel] [PATCH 1/2] avformat/mov: merge mov_read_custom functions

2016-02-28 Thread Marton Balint


On Sat, 20 Feb 2016, Marton Balint wrote:


This also fixes reading gapless metadata when the entries do not start with the
mean atom. Such samples can be found here:
https://hydrogenaud.io/index.php/topic,93310.0.html

Signed-off-by: Marton Balint 
---
libavformat/mov.c | 50 --
1 file changed, 12 insertions(+), 38 deletions(-)


Ping?

Regards,
Marton
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Fixed missing rawutils.o reference (required by movenc.c; link s fails if not referenced otherwise)

2016-02-28 Thread Michael Niedermayer
On Sun, Feb 28, 2016 at 01:36:03PM +0200, Roman Ryltsov wrote:
> I hope this is sent to proper mail list and formatted as expected too.
> 
> 
> The patch fixes a small problem building configuration with just a few
> things enabled. MOV muxer uses ff_reshuffle_raw_rgb from rawutils.c and
> the latter is not properly referenced for linking.
> 
> ---
> 
>  libavformat/Makefile | 2 +-
> 
>  1 file changed, 1 insertion(+), 1 deletion(-)

applied

thanks

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Asymptotically faster algorithms should always be preferred if you have
asymptotical amounts of data


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 3/3] ffmpeg: remove hardcoded 'now' creation_time support

2016-02-28 Thread Marton Balint
Every date parsing routine now uses av_parse_time which handles 'now' and
provides greater precision as well. This change also enables the segmenter
muxer to set the proper 'now' creation time at the beginning of each segment.

Signed-off-by: Marton Balint 
---
 ffmpeg_opt.c | 13 -
 1 file changed, 13 deletions(-)

diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index edbc4a0..00d91c8 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -40,7 +40,6 @@
 #include "libavutil/parseutils.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/pixfmt.h"
-#include "libavutil/time_internal.h"
 
 #define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass"
 
@@ -2430,7 +2429,6 @@ loop_end:
 char type, *val;
 const char *stream_spec;
 int index = 0, j, ret = 0;
-char now_time[256];
 
 val = strchr(o->metadata[i].u.str, '=');
 if (!val) {
@@ -2440,17 +2438,6 @@ loop_end:
 }
 *val++ = 0;
 
-if (!strcmp(o->metadata[i].u.str, "creation_time") &&
-!strcmp(val, "now")) {
-time_t now = time(0);
-struct tm *ptm, tmbuf;
-ptm = localtime_r(, );
-if (ptm) {
-if (strftime(now_time, sizeof(now_time), "%Y-%m-%d %H:%M:%S", 
ptm))
-val = now_time;
-}
-}
-
 parse_meta_type(o->metadata[i].specifier, , , _spec);
 if (type == 's') {
 for (j = 0; j < oc->nb_streams; j++) {
-- 
2.6.2

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


[FFmpeg-devel] [PATCH 1/3] avformat/utils: add a function to standardize creation time

2016-02-28 Thread Marton Balint
This can be used for formats which write all format metadata as string to
files, therefore non-standard creation times such as 'now' will be parsed.

The standardized creation time is UTC ISO 8601 with microsecond precision.

Signed-off-by: Marton Balint 
---
 libavformat/internal.h |  8 
 libavformat/utils.c| 22 ++
 libavformat/version.h  |  2 +-
 3 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/libavformat/internal.h b/libavformat/internal.h
index bc6a6c2..e8601db 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -560,6 +560,14 @@ void ff_format_io_close(AVFormatContext *s, AVIOContext 
**pb);
  */
 int ff_parse_creation_time_metadata(AVFormatContext *s, int64_t *timestamp, 
int return_seconds);
 
+/**
+ * Standardize creation_time metadata in AVFormatContext to an ISO-8601
+ * timestamp string.
+ *
+ * @param s AVFormatContext
+ * @return <0 on error
+ */
+int ff_standardize_creation_time(AVFormatContext *s);
 
 #define CONTAINS_PAL 2
 /**
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 78255c3..ecb4f38 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -33,6 +33,7 @@
 #include "libavutil/parseutils.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/time.h"
+#include "libavutil/time_internal.h"
 #include "libavutil/timestamp.h"
 
 #include "libavcodec/bytestream.h"
@@ -4758,3 +4759,24 @@ int ff_parse_creation_time_metadata(AVFormatContext *s, 
int64_t *timestamp, int
 }
 return 0;
 }
+
+int ff_standardize_creation_time(AVFormatContext *s)
+{
+int64_t timestamp;
+int ret = ff_parse_creation_time_metadata(s, , 0);
+if (ret == 1) {
+time_t seconds = timestamp / 100;
+struct tm *ptm, tmbuf;
+ptm = gmtime_r(, );
+if (ptm) {
+char buf[32];
+if (!strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S", ptm))
+return AVERROR_EXTERNAL;
+av_strlcatf(buf, sizeof(buf), ".%06dZ", (int)(timestamp % 
100));
+av_dict_set(>metadata, "creation_time", buf, 0);
+} else {
+return AVERROR_EXTERNAL;
+}
+}
+return ret;
+}
diff --git a/libavformat/version.h b/libavformat/version.h
index 82a8892..9f4ede7 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -31,7 +31,7 @@
 
 #define LIBAVFORMAT_VERSION_MAJOR  57
 #define LIBAVFORMAT_VERSION_MINOR  26
-#define LIBAVFORMAT_VERSION_MICRO 100
+#define LIBAVFORMAT_VERSION_MICRO 101
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
-- 
2.6.2

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


[FFmpeg-devel] [PATCH 2/3] avformat: use ff_standardize_creation_time for formats writing all format string metadata

2016-02-28 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavformat/apetag.c| 1 +
 libavformat/cafenc.c| 1 +
 libavformat/flvenc.c| 1 +
 libavformat/id3v2enc.c  | 1 +
 libavformat/lrcenc.c| 1 +
 libavformat/nutenc.c| 1 +
 libavformat/smjpegenc.c | 1 +
 libavformat/wtvenc.c| 1 +
 8 files changed, 8 insertions(+)

diff --git a/libavformat/apetag.c b/libavformat/apetag.c
index 2ee277f..9d415b8 100644
--- a/libavformat/apetag.c
+++ b/libavformat/apetag.c
@@ -193,6 +193,7 @@ int ff_ape_write_tag(AVFormatContext *s)
  APE_TAG_FLAG_IS_HEADER);
 ffio_fill(dyn_bc, 0, 8); // reserved
 
+ff_standardize_creation_time(s);
 while ((e = av_dict_get(s->metadata, "", e, AV_DICT_IGNORE_SUFFIX))) {
 int val_len;
 
diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c
index 544bc4a..0b2f649 100644
--- a/libavformat/cafenc.c
+++ b/libavformat/cafenc.c
@@ -175,6 +175,7 @@ static int caf_write_header(AVFormatContext *s)
 avio_write(pb, enc->extradata, enc->extradata_size);
 }
 
+ff_standardize_creation_time(s);
 if (av_dict_count(s->metadata)) {
 ffio_wfourcc(pb, "info"); //< Information chunk
 while ((t = av_dict_get(s->metadata, "", t, AV_DICT_IGNORE_SUFFIX))) {
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index 8fd5d29..ab71d41 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -281,6 +281,7 @@ static void write_metadata(AVFormatContext *s, unsigned int 
ts)
 put_amf_double(pb, 0.0);
 }
 
+ff_standardize_creation_time(s);
 while ((tag = av_dict_get(s->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
 if(   !strcmp(tag->key, "width")
 ||!strcmp(tag->key, "height")
diff --git a/libavformat/id3v2enc.c b/libavformat/id3v2enc.c
index 8b804c4..e4ccdf9 100644
--- a/libavformat/id3v2enc.c
+++ b/libavformat/id3v2enc.c
@@ -242,6 +242,7 @@ int ff_id3v2_write_metadata(AVFormatContext *s, 
ID3v2EncContext *id3)
   ID3v2_ENCODING_UTF8;
 int i, ret;
 
+ff_standardize_creation_time(s);
 if ((ret = write_metadata(s->pb, >metadata, id3, enc)) < 0)
 return ret;
 
diff --git a/libavformat/lrcenc.c b/libavformat/lrcenc.c
index b316ccd..74268cc 100644
--- a/libavformat/lrcenc.c
+++ b/libavformat/lrcenc.c
@@ -52,6 +52,7 @@ static int lrc_write_header(AVFormatContext *s)
 }
 avpriv_set_pts_info(s->streams[0], 64, 1, 100);
 
+ff_standardize_creation_time(s);
 ff_metadata_conv_ctx(s, ff_lrc_metadata_conv, NULL);
 if(!(s->flags & AVFMT_FLAG_BITEXACT)) { // avoid breaking regression tests
 /* LRC provides a metadata slot for specifying encoder version
diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
index b6582ef..bf596ba 100644
--- a/libavformat/nutenc.c
+++ b/libavformat/nutenc.c
@@ -489,6 +489,7 @@ static int write_globalinfo(NUTContext *nut, AVIOContext 
*bc)
 if (ret < 0)
 return ret;
 
+ff_standardize_creation_time(s);
 while ((t = av_dict_get(s->metadata, "", t, AV_DICT_IGNORE_SUFFIX)))
 count += add_info(dyn_bc, t->key, t->value);
 
diff --git a/libavformat/smjpegenc.c b/libavformat/smjpegenc.c
index 430a497..4553c86 100644
--- a/libavformat/smjpegenc.c
+++ b/libavformat/smjpegenc.c
@@ -46,6 +46,7 @@ static int smjpeg_write_header(AVFormatContext *s)
 avio_wb32(pb, 0);
 avio_wb32(pb, 0);
 
+ff_standardize_creation_time(s);
 while ((t = av_dict_get(s->metadata, "", t, AV_DICT_IGNORE_SUFFIX))) {
 avio_wl32(pb, SMJPEG_TXT);
 avio_wb32(pb, strlen(t->key) + strlen(t->value) + 3);
diff --git a/libavformat/wtvenc.c b/libavformat/wtvenc.c
index 0894b7f..908448f 100644
--- a/libavformat/wtvenc.c
+++ b/libavformat/wtvenc.c
@@ -672,6 +672,7 @@ static void write_table_entries_attrib(AVFormatContext *s)
 AVIOContext *pb = s->pb;
 AVDictionaryEntry *tag = 0;
 
+ff_standardize_creation_time(s);
 //FIXME: translate special tags (e.g. WM/Bitrate) to binary representation
 ff_metadata_conv(>metadata, ff_asf_metadata_conv, NULL);
 while ((tag = av_dict_get(s->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
-- 
2.6.2

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


[FFmpeg-devel] [PATCH v5 2/2] lavf/movenc: Add support for palette side data packets

2016-02-28 Thread Mats Peterson

Remove unnecessary cast to uint8_t for av_packet_get_side_data().

--
Mats Peterson
http://matsp888.no-ip.org/~mats/
>From 867cf8dc4eb627f219069a0ee5f5e95e9ad5384d Mon Sep 17 00:00:00 2001
From: Mats Peterson 
Date: Sun, 28 Feb 2016 13:19:59 +0100
Subject: [PATCH v5 2/2] lavf/movenc: Add support for palette side data packets

---
 libavformat/movenc.c |   21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 3295266..22ab01e 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -4763,19 +4763,28 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt)
 }
 }
 
-if (trk->is_unaligned_qt_rgb) {
+if (trk->is_unaligned_qt_rgb && pkt->size) {
 const uint8_t *data = pkt->data;
 int size = pkt->size;
 int64_t bpc = trk->enc->bits_per_coded_sample != 15 ? trk->enc->bits_per_coded_sample : 16;
 int expected_stride = ((trk->enc->width * bpc + 15) >> 4)*2;
+const uint8_t *pal = NULL;
+int sd_size;
 int ret = ff_reshuffle_raw_rgb(s, , trk->enc, expected_stride);
 if (ret < 0)
 return ret;
-if (ret == CONTAINS_PAL && !trk->pal_done) {
-int pal_size = 1 << trk->enc->bits_per_coded_sample;
-memset(trk->palette, 0, AVPALETTE_SIZE);
-memcpy(trk->palette, data + size - 4*pal_size, 4*pal_size);
-trk->pal_done++;
+if (!trk->pal_done) {
+pal = av_packet_get_side_data(pkt, AV_PKT_DATA_PALETTE, _size);
+if (pal && sd_size != AVPALETTE_SIZE) {
+av_log(s, AV_LOG_ERROR, "Invalid palette side data\n");
+return AVERROR_INVALIDDATA;
+}
+if (!pal && ret == CONTAINS_PAL)
+pal = data + size - AVPALETTE_SIZE;
+if (pal) {
+memcpy(trk->palette, pal, AVPALETTE_SIZE);
+trk->pal_done++;
+}
 } else if (trk->enc->pix_fmt == AV_PIX_FMT_GRAY8 ||
trk->enc->pix_fmt == AV_PIX_FMT_MONOBLACK) {
 for (i = 0; i < pkt->size; i++)
-- 
1.7.10.4

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


[FFmpeg-devel] [PATCH v5 1/2] lavf/avienc: Add support for palette side data packets

2016-02-28 Thread Mats Peterson

Remove unnecessary cast to uint8_t for av_packet_get_side_data().
>From 50f56cd66ac52e8eea2210fc4ed2189d3311a9f4 Mon Sep 17 00:00:00 2001
From: Mats Peterson 
Date: Sun, 28 Feb 2016 13:19:43 +0100
Subject: [PATCH v5 1/2] lavf/avienc: Add support for palette side data packets

---
 libavformat/avienc.c |   61 +-
 1 file changed, 35 insertions(+), 26 deletions(-)

diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index ca505f4..aa73701 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -362,7 +362,8 @@ static int avi_write_header(AVFormatContext *s)
 && enc->pix_fmt == AV_PIX_FMT_RGB555LE
 && enc->bits_per_coded_sample == 15)
 enc->bits_per_coded_sample = 16;
-avist->pal_offset = avio_tell(pb) + 40;
+if (pb->seekable)
+avist->pal_offset = avio_tell(pb) + 40;
 ff_put_bmp_header(pb, enc, ff_codec_bmp_tags, 0, 0);
 pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_avi,
   enc->bits_per_coded_sample);
@@ -668,39 +669,47 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
 if ((ret = write_skip_frames(s, stream_index, pkt->dts)) < 0)
 return ret;
 
-if (enc->codec_id == AV_CODEC_ID_RAWVIDEO && enc->codec_tag == 0) {
+if (enc->codec_id == AV_CODEC_ID_RAWVIDEO && enc->codec_tag == 0 && size) {
 int64_t bpc = enc->bits_per_coded_sample != 15 ? enc->bits_per_coded_sample : 16;
 int expected_stride = ((enc->width * bpc + 31) >> 5)*4;
-
+const uint8_t *pal = NULL;
+int pal_size = 1 << enc->bits_per_coded_sample;
+int sd_size, i;
 ret = ff_reshuffle_raw_rgb(s, , enc, expected_stride);
 if (ret < 0)
 return ret;
-if (ret) {
-if (ret == CONTAINS_PAL) {
-int pc_tag, i;
-int pal_size = 1 << enc->bits_per_coded_sample;
-if (!avist->hdr_pal_done) {
-int64_t cur_offset = avio_tell(pb);
-avio_seek(pb, avist->pal_offset, SEEK_SET);
-for (i = 0; i < pal_size; i++) {
-uint32_t v = AV_RL32(data + size - 4*pal_size + 4*i);
-avio_wl32(pb, v & 0xff);
-}
-avio_seek(pb, cur_offset, SEEK_SET);
-avist->hdr_pal_done++;
-}
-avi_stream2fourcc(tag, stream_index, enc->codec_type);
-tag[2] = 'p'; tag[3] = 'c';
-pc_tag = ff_start_tag(pb, tag);
-avio_w8(pb, 0);
-avio_w8(pb, pal_size & 0xFF);
-avio_wl16(pb, 0); // reserved
+pal = av_packet_get_side_data(pkt, AV_PKT_DATA_PALETTE, _size);
+if (pal && sd_size != AVPALETTE_SIZE) {
+av_log(s, AV_LOG_ERROR, "Invalid palette side data\n");
+return AVERROR_INVALIDDATA;
+}
+if (!pal && ret == CONTAINS_PAL)
+pal = data + size - AVPALETTE_SIZE;
+if (pal) {
+int pc_tag;
+if (pb->seekable && !avist->hdr_pal_done) {
+int64_t cur_offset = avio_tell(pb);
+avio_seek(pb, avist->pal_offset, SEEK_SET);
 for (i = 0; i < pal_size; i++) {
-uint32_t v = AV_RL32(data + size - 4*pal_size + 4*i);
-avio_wb32(pb, v<<8);
+uint32_t v = AV_RL32(pal + 4*i);
+avio_wl32(pb, v & 0xff);
 }
-ff_end_tag(pb, pc_tag);
+avio_seek(pb, cur_offset, SEEK_SET);
+avist->hdr_pal_done++;
 }
+avi_stream2fourcc(tag, stream_index, enc->codec_type);
+tag[2] = 'p'; tag[3] = 'c';
+pc_tag = ff_start_tag(pb, tag);
+avio_w8(pb, 0);
+avio_w8(pb, pal_size & 0xFF);
+avio_wl16(pb, 0); // reserved
+for (i = 0; i < pal_size; i++) {
+uint32_t v = AV_RL32(pal + 4*i);
+avio_wb32(pb, v<<8);
+}
+ff_end_tag(pb, pc_tag);
+}
+if (ret) {
 ret = avi_write_packet_internal(s, pkt);
 av_packet_free();
 return ret;
-- 
1.7.10.4

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


Re: [FFmpeg-devel] [PATCH v4 1/2 v2] lavf/avienc: Add support for palette side data packets

2016-02-28 Thread Mats Peterson

On 02/28/2016 01:11 PM, Reimar Döffinger wrote:

On Sun, Feb 28, 2016 at 12:53:18PM +0100, Mats Peterson wrote:

-avist->pal_offset = avio_tell(pb) + 40;
+if (pb->seekable)
+avist->pal_offset = avio_tell(pb) + 40;


I don't mind, but the check seems unnecessary here?


Well, avio_tell() (at least ftell()) will fail on an unseekable stream. 
I just checked with a small snippet. It doesn't hurt to have it, anyway.



Hm, why the cast? That seems to be the return type of that function
already...
I believe I at least have no further comments.
___


Yes, I suppose it's unnecessary. I actually thought of removing it 
before, so I will do it now.



> I believe I at least have no further comments.
> ___

OK. Thanks.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v3 1/2] lavf/avienc: Add support for palette side data packets

2016-02-28 Thread Mats Peterson

On 02/28/2016 01:05 PM, Reimar Döffinger wrote:

On Sun, Feb 28, 2016 at 12:26:15PM +0100, Mats Peterson wrote:

Also it might be helpful for you to have a look at tests/fate/demux.mak
and tests/fate/video.mak and use copy-paste to write some basic tests
for all the things you implement, so it doesn't get broken the moment
you look the other way...


Yes, but I'm completely new at writing FATE tests, and it seems very complex
to me, so I'll take a rain check on that one. Hopefully Michael will be able
to add some good tests for the palette stuff, when he's got the time for it.


That's why I said copy-paste.
Either way there's little complex about it, they all just run a
ffmpeg command (same as you do when developing tests,
so you must know a few good ones) and then takes some form
of hash/checksum of the result and stores that as reference.
Sure some of the details are non-obvious (like where the
input test files are stored) but what is in the mak
files consists of some magic you generally don't need to
understand and a FFmpeg command-line.
With "make V=1 fate-testname" you see exactly what is being run.
I may be wrong, but I think waiting for Michael to have "time over"
so to say isn't a very successful strategy.
___


Perhaps not :) Anyway, that's a later issue.

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


Re: [FFmpeg-devel] [PATCH v3 1/2] lavf/avienc: Add support for palette side data packets

2016-02-28 Thread Reimar Döffinger
On Sun, Feb 28, 2016 at 12:26:15PM +0100, Mats Peterson wrote:
> >Also it might be helpful for you to have a look at tests/fate/demux.mak
> >and tests/fate/video.mak and use copy-paste to write some basic tests
> >for all the things you implement, so it doesn't get broken the moment
> >you look the other way...
> 
> Yes, but I'm completely new at writing FATE tests, and it seems very complex
> to me, so I'll take a rain check on that one. Hopefully Michael will be able
> to add some good tests for the palette stuff, when he's got the time for it.

That's why I said copy-paste.
Either way there's little complex about it, they all just run a
ffmpeg command (same as you do when developing tests,
so you must know a few good ones) and then takes some form
of hash/checksum of the result and stores that as reference.
Sure some of the details are non-obvious (like where the
input test files are stored) but what is in the mak
files consists of some magic you generally don't need to
understand and a FFmpeg command-line.
With "make V=1 fate-testname" you see exactly what is being run.
I may be wrong, but I think waiting for Michael to have "time over"
so to say isn't a very successful strategy.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v3 1/2] lavf/avienc: Add support for palette side data packets

2016-02-28 Thread Mats Peterson

On 02/28/2016 12:59 PM, Reimar Döffinger wrote:

On Sun, Feb 28, 2016 at 12:33:16PM +0100, Mats Peterson wrote:

On 02/28/2016 12:26 PM, Mats Peterson wrote:

On 02/28/2016 12:16 PM, Reimar Döffinger wrote:
Well, the documentation says that avio_seek() is a variant of the
fseek() function. I would rather say it's a variant of lseek(), since it
returns the new position, not just 0 or -1. In any case, this is what
the lseek() man page says:

"On error, the value (off_t) -1 is returned and  errno  is  set  to
indicate the error."

So it's not really undefined.



Even if the return value is not undefined on error from an avio_seek(),
would you prefer using pb->seekable instead of invoking an avio_seek()
function that will fail? Is it more elegant to you?


I never said the return value was undefined, I said its
behaviour (i.e. what it did to your stream) is undefined.
E.g. it might have seeked back by the size of cached data
instead of to the place you wanted.
That's why checking pb->seekable is the only way fairly
sure to not produce incorrect results.
___


Alright. Sorry. Fixed in v4 1/2 v2 that I just posted. Have a look at it.

Mats

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


Re: [FFmpeg-devel] [PATCH v3 1/2] lavf/avienc: Add support for palette side data packets

2016-02-28 Thread Reimar Döffinger
On Sun, Feb 28, 2016 at 12:33:16PM +0100, Mats Peterson wrote:
> On 02/28/2016 12:26 PM, Mats Peterson wrote:
> >On 02/28/2016 12:16 PM, Reimar Döffinger wrote:
> >Well, the documentation says that avio_seek() is a variant of the
> >fseek() function. I would rather say it's a variant of lseek(), since it
> >returns the new position, not just 0 or -1. In any case, this is what
> >the lseek() man page says:
> >
> >"On error, the value (off_t) -1 is returned and  errno  is  set  to
> >indicate the error."
> >
> >So it's not really undefined.
> >
> 
> Even if the return value is not undefined on error from an avio_seek(),
> would you prefer using pb->seekable instead of invoking an avio_seek()
> function that will fail? Is it more elegant to you?

I never said the return value was undefined, I said its
behaviour (i.e. what it did to your stream) is undefined.
E.g. it might have seeked back by the size of cached data
instead of to the place you wanted.
That's why checking pb->seekable is the only way fairly
sure to not produce incorrect results.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v4 1/2 v2] lavf/avienc: Add support for palette side data packets

2016-02-28 Thread Mats Peterson

Check pb->seekable before using avio_tell() or avio_seek().

--
Mats Peterson
http://matsp888.no-ip.org/~mats/
>From 425b2d52ad640cc8785baad50cacf846d7dcb7aa Mon Sep 17 00:00:00 2001
From: Mats Peterson 
Date: Sun, 28 Feb 2016 12:51:10 +0100
Subject: [PATCH v4 1/2 v2] lavf/avienc: Add support for palette side data packets

---
 libavformat/avienc.c |   61 +-
 1 file changed, 35 insertions(+), 26 deletions(-)

diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index ca505f4..f5de865 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -362,7 +362,8 @@ static int avi_write_header(AVFormatContext *s)
 && enc->pix_fmt == AV_PIX_FMT_RGB555LE
 && enc->bits_per_coded_sample == 15)
 enc->bits_per_coded_sample = 16;
-avist->pal_offset = avio_tell(pb) + 40;
+if (pb->seekable)
+avist->pal_offset = avio_tell(pb) + 40;
 ff_put_bmp_header(pb, enc, ff_codec_bmp_tags, 0, 0);
 pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_avi,
   enc->bits_per_coded_sample);
@@ -668,39 +669,47 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
 if ((ret = write_skip_frames(s, stream_index, pkt->dts)) < 0)
 return ret;
 
-if (enc->codec_id == AV_CODEC_ID_RAWVIDEO && enc->codec_tag == 0) {
+if (enc->codec_id == AV_CODEC_ID_RAWVIDEO && enc->codec_tag == 0 && size) {
 int64_t bpc = enc->bits_per_coded_sample != 15 ? enc->bits_per_coded_sample : 16;
 int expected_stride = ((enc->width * bpc + 31) >> 5)*4;
-
+const uint8_t *pal = NULL;
+int pal_size = 1 << enc->bits_per_coded_sample;
+int sd_size, i;
 ret = ff_reshuffle_raw_rgb(s, , enc, expected_stride);
 if (ret < 0)
 return ret;
-if (ret) {
-if (ret == CONTAINS_PAL) {
-int pc_tag, i;
-int pal_size = 1 << enc->bits_per_coded_sample;
-if (!avist->hdr_pal_done) {
-int64_t cur_offset = avio_tell(pb);
-avio_seek(pb, avist->pal_offset, SEEK_SET);
-for (i = 0; i < pal_size; i++) {
-uint32_t v = AV_RL32(data + size - 4*pal_size + 4*i);
-avio_wl32(pb, v & 0xff);
-}
-avio_seek(pb, cur_offset, SEEK_SET);
-avist->hdr_pal_done++;
-}
-avi_stream2fourcc(tag, stream_index, enc->codec_type);
-tag[2] = 'p'; tag[3] = 'c';
-pc_tag = ff_start_tag(pb, tag);
-avio_w8(pb, 0);
-avio_w8(pb, pal_size & 0xFF);
-avio_wl16(pb, 0); // reserved
+pal = (uint8_t *)av_packet_get_side_data(pkt, AV_PKT_DATA_PALETTE, _size);
+if (pal && sd_size != AVPALETTE_SIZE) {
+av_log(s, AV_LOG_ERROR, "Invalid palette side data\n");
+return AVERROR_INVALIDDATA;
+}
+if (!pal && ret == CONTAINS_PAL)
+pal = data + size - AVPALETTE_SIZE;
+if (pal) {
+int pc_tag;
+if (pb->seekable && !avist->hdr_pal_done) {
+int64_t cur_offset = avio_tell(pb);
+avio_seek(pb, avist->pal_offset, SEEK_SET);
 for (i = 0; i < pal_size; i++) {
-uint32_t v = AV_RL32(data + size - 4*pal_size + 4*i);
-avio_wb32(pb, v<<8);
+uint32_t v = AV_RL32(pal + 4*i);
+avio_wl32(pb, v & 0xff);
 }
-ff_end_tag(pb, pc_tag);
+avio_seek(pb, cur_offset, SEEK_SET);
+avist->hdr_pal_done++;
 }
+avi_stream2fourcc(tag, stream_index, enc->codec_type);
+tag[2] = 'p'; tag[3] = 'c';
+pc_tag = ff_start_tag(pb, tag);
+avio_w8(pb, 0);
+avio_w8(pb, pal_size & 0xFF);
+avio_wl16(pb, 0); // reserved
+for (i = 0; i < pal_size; i++) {
+uint32_t v = AV_RL32(pal + 4*i);
+avio_wb32(pb, v<<8);
+}
+ff_end_tag(pb, pc_tag);
+}
+if (ret) {
 ret = avi_write_packet_internal(s, pkt);
 av_packet_free();
 return ret;
-- 
1.7.10.4

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


[FFmpeg-devel] [PATCH 2/2] fate: add libavcodec utils test

2016-02-28 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 tests/fate/libavcodec.mak |5 +
 1 file changed, 5 insertions(+)

diff --git a/tests/fate/libavcodec.mak b/tests/fate/libavcodec.mak
index 22c0839..5aba2ee 100644
--- a/tests/fate/libavcodec.mak
+++ b/tests/fate/libavcodec.mak
@@ -38,6 +38,11 @@ FATE_LIBAVCODEC-$(CONFIG_JPEG2000_ENCODER) += fate-j2k-dwt
 fate-j2k-dwt: libavcodec/jpeg2000dwt-test$(EXESUF)
 fate-j2k-dwt: CMD = run libavcodec/jpeg2000dwt-test
 
+FATE_LIBAVCODEC-yes += fate-libavcodec-utils
+fate-libavcodec-utils: libavcodec/utils-test$(EXESUF)
+fate-libavcodec-utils: CMD = run libavcodec/utils-test
+fate-libavcodec-utils: CMP = null
+fate-libavcodec-utils: REF = /dev/null
 
 FATE-$(CONFIG_AVCODEC) += $(FATE_LIBAVCODEC-yes)
 fate-libavcodec: $(FATE_LIBAVCODEC-yes)
-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH 1/2] avcodec: Add utils test

2016-02-28 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavcodec/Makefile |1 +
 libavcodec/utils.c  |   20 
 2 files changed, 21 insertions(+)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 5389725..667e257 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -952,6 +952,7 @@ TESTPROGS = imgconvert  
\
 jpeg2000dwt \
 mathops\
 options \
+utils   \
 avfft   \
 
 TESTPROGS-$(CONFIG_CABAC) += cabac
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 5791ffa..d354878 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -3653,3 +3653,23 @@ AVCPBProperties *ff_add_cpb_side_data(AVCodecContext 
*avctx)
 
 return props;
 }
+
+#ifdef TEST
+int main(void){
+avcodec_register_all();
+AVCodec *codec = NULL;
+int ret = 0;
+
+while (codec = av_codec_next(codec)) {
+if (av_codec_is_encoder(codec)) {
+if (codec->type == AVMEDIA_TYPE_AUDIO) {
+if (!codec->sample_fmts) {
+av_log(NULL, AV_LOG_FATAL, "Encoder %s is missing the 
sample_fmts field\n", codec->name);
+ret = 1;
+}
+}
+}
+}
+return ret;
+}
+#endif /* TEST */
-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH] Fixed missing rawutils.o reference (required by movenc.c; link s fails if not referenced otherwise)

2016-02-28 Thread Roman Ryltsov
I hope this is sent to proper mail list and formatted as expected too.


The patch fixes a small problem building configuration with just a few
things enabled. MOV muxer uses ff_reshuffle_raw_rgb from rawutils.c and
the latter is not properly referenced for linking.

---

 libavformat/Makefile | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)

 

diff --git a/libavformat/Makefile b/libavformat/Makefile

index 3b32907..6ae4327 100644

--- a/libavformat/Makefile

+++ b/libavformat/Makefile

@@ -268,7 +268,7 @@ OBJS-$(CONFIG_MMF_DEMUXER)   += mmf.o

 OBJS-$(CONFIG_MMF_MUXER) += mmf.o rawenc.o

 OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o mov_chan.o replaygain.o

 OBJS-$(CONFIG_MOV_MUXER) += movenc.o avc.o hevc.o \

-movenchint.o mov_chan.o
rtp.o movenccenc.o

+movenchint.o mov_chan.o
rtp.o movenccenc.o rawutils.o

 OBJS-$(CONFIG_MP2_MUXER) += mp3enc.o rawenc.o id3v2enc.o

 OBJS-$(CONFIG_MP3_DEMUXER)   += mp3dec.o replaygain.o

 OBJS-$(CONFIG_MP3_MUXER) += mp3enc.o rawenc.o id3v2enc.o

-- 

1.9.5.msysgit.1

 

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


Re: [FFmpeg-devel] [PATCH v3 1/2] lavf/avienc: Add support for palette side data packets

2016-02-28 Thread Mats Peterson

On 02/28/2016 12:26 PM, Mats Peterson wrote:

On 02/28/2016 12:16 PM, Reimar Döffinger wrote:

And Reimar, the AVI muxer libavformat/avienc.c uses *lots* of
avio_seek()
all over the place, so it won't work well on stdout regardless of my
patch.
I have checked for avio_seek() returning >= 0 in my part of the code
in any
case, but it won't make much of a difference.


I think the effect of a failed avio_seek is kind of undefined, so
checking the result is not really right as by then it's already broken.



Well, the documentation says that avio_seek() is a variant of the
fseek() function. I would rather say it's a variant of lseek(), since it
returns the new position, not just 0 or -1. In any case, this is what
the lseek() man page says:

"On error, the value (off_t) -1 is returned and  errno  is  set  to
indicate the error."

So it's not really undefined.



Even if the return value is not undefined on error from an avio_seek(), 
would you prefer using pb->seekable instead of invoking an avio_seek() 
function that will fail? Is it more elegant to you?


Mats

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


Re: [FFmpeg-devel] [PATCH v3 1/2] lavf/avienc: Add support for palette side data packets

2016-02-28 Thread Mats Peterson

On 02/28/2016 12:16 PM, Reimar Döffinger wrote:

And Reimar, the AVI muxer libavformat/avienc.c uses *lots* of avio_seek()
all over the place, so it won't work well on stdout regardless of my patch.
I have checked for avio_seek() returning >= 0 in my part of the code in any
case, but it won't make much of a difference.


I think the effect of a failed avio_seek is kind of undefined, so
checking the result is not really right as by then it's already broken.



Well, the documentation says that avio_seek() is a variant of the 
fseek() function. I would rather say it's a variant of lseek(), since it 
returns the new position, not just 0 or -1. In any case, this is what 
the lseek() man page says:


"On error, the value (off_t) -1 is returned and  errno  is  set  to 
indicate the error."


So it's not really undefined.

I also disagree with your analysis, all other avio_seek I could find

are under if (pb->seekable), even if it is sometimes quite non-obvious.


Yes, I've noticed that.


Also it might be helpful for you to have a look at tests/fate/demux.mak
and tests/fate/video.mak and use copy-paste to write some basic tests
for all the things you implement, so it doesn't get broken the moment
you look the other way...


Yes, but I'm completely new at writing FATE tests, and it seems very 
complex to me, so I'll take a rain check on that one. Hopefully Michael 
will be able to add some good tests for the palette stuff, when he's got 
the time for it.


Mats

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


Re: [FFmpeg-devel] [PATCH v3 1/2] lavf/avienc: Add support for palette side data packets

2016-02-28 Thread Reimar Döffinger
On Sun, Feb 28, 2016 at 06:11:27AM +0100, Mats Peterson wrote:
> On 02/28/2016 05:38 AM, Mats Peterson wrote:
> >On 02/28/2016 05:27 AM, Mats Peterson wrote:
> >>Use "palette side data" instead of "palette extradata" in error message.
> >>
> >>
> >>
> >>___
> >>ffmpeg-devel mailing list
> >>ffmpeg-devel@ffmpeg.org
> >>http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >>
> >
> >
> >Michael, I would like to add that ff_reshuffle_raw_rgb() that you wrote
> >has the benefit of taking care of the correct stride when using stream
> >copy as well. Thus, it won't be an "identical" stream copy, but it will
> >be a valid one for the output file format in question.
> >
> >Mats
> >
> 
> And Reimar, the AVI muxer libavformat/avienc.c uses *lots* of avio_seek()
> all over the place, so it won't work well on stdout regardless of my patch.
> I have checked for avio_seek() returning >= 0 in my part of the code in any
> case, but it won't make much of a difference.

I think the effect of a failed avio_seek is kind of undefined, so
checking the result is not really right as by then it's already broken.
I also disagree with your analysis, all other avio_seek I could find
are under if (pb->seekable), even if it is sometimes quite non-obvious.
Also it might be helpful for you to have a look at tests/fate/demux.mak
and tests/fate/video.mak and use copy-paste to write some basic tests
for all the things you implement, so it doesn't get broken the moment
you look the other way...
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] lavf/avienc: Add support for palette side data packets

2016-02-28 Thread Mats Peterson

On 02/28/2016 11:31 AM, Mats Peterson wrote:


Speaking of something else, with these patches it should be possible for
MPlayer to deliver the palette in a side data packet to the FFmpeg AVI
and QuickTime muxers. I suppose that's part of the reason why you want
palette side data handling to be implemented in the muxers, Reimar.



Plus the fact that it's needed when doing stream copy, with FFmpeg's 
current way of using palette side data packets on the demuxer side.


Mats

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


Re: [FFmpeg-devel] [PATCH 1/2] lavf/avienc: Add support for palette side data packets

2016-02-28 Thread Mats Peterson

On 02/28/2016 11:31 AM, Mats Peterson wrote:

On 02/28/2016 11:25 AM, Mats Peterson wrote:

On 02/28/2016 11:24 AM, Reimar Döffinger wrote:

Why is the packet data in AVI packets sometimes zero bytes when using
stream copy, Michael? There certainly must be some reason for it?


AVI is fixed frame rate. If you have for example variable frame rate
input empty packets will be used to get the right timing.
I'm not sure that is truly the cause in your case, but it is at least
one possible reason.
___


Yeah, that sounds like a possible reason alright. It only happens for
AVI, not Quicktime, so...

Mats

___



Speaking of something else, with these patches it should be possible for
MPlayer to deliver the palette in a side data packet to the FFmpeg AVI
and QuickTime muxers. I suppose that's part of the reason why you want
palette side data handling to be implemented in the muxers, Reimar.

Mats



or MEncoder, rather.


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


Re: [FFmpeg-devel] Endianness of palette

2016-02-28 Thread Mats Peterson

On 02/28/2016 11:31 AM, Reimar Döffinger wrote:

On 28.02.2016, at 11:19, Mats Peterson  wrote:

 From libavutil/pixfmt.h:

* @note
* AV_PIX_FMT_RGB32 is handled in an endian-specific manner. An RGBA
* color is put together as:
*  (A << 24) | (R << 16) | (G << 8) | B
* This is stored as BGRA on little-endian CPU architectures and ARGB on
* big-endian CPUs.


This is not quite true, and you said yourself that the palette isn't stored in 
a host-specific order, Michael, since one has to use AV_RL32() to get the 
palette entries correctly on a big-endian machine. Itt is stored BGRA, in that 
order, in memory, as far as I understand.


1) pixfmt.h applies to AVFrame not AVPacket really, it can be a bit confusing 
for raw formats that way though


Ah, OK. In any case I have noticed that you have to use AV_RL32() on a 
big-endian machine to get the palette entries from the *packets* (sided 
data or appended) in the right order.


Mats

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


Re: [FFmpeg-devel] [PATCH 1/2] lavf/avienc: Add support for palette side data packets

2016-02-28 Thread Mats Peterson

On 02/28/2016 11:25 AM, Mats Peterson wrote:

On 02/28/2016 11:24 AM, Reimar Döffinger wrote:

Why is the packet data in AVI packets sometimes zero bytes when using
stream copy, Michael? There certainly must be some reason for it?


AVI is fixed frame rate. If you have for example variable frame rate
input empty packets will be used to get the right timing.
I'm not sure that is truly the cause in your case, but it is at least
one possible reason.
___


Yeah, that sounds like a possible reason alright. It only happens for
AVI, not Quicktime, so...

Mats

___



Speaking of something else, with these patches it should be possible for 
MPlayer to deliver the palette in a side data packet to the FFmpeg AVI 
and QuickTime muxers. I suppose that's part of the reason why you want 
palette side data handling to be implemented in the muxers, Reimar.


Mats

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


Re: [FFmpeg-devel] New filter: remap?

2016-02-28 Thread F.Sluiter
Yes, i am currently interested in pixels only. Effects I am after are
related to lens corrections.
Op 26 feb. 2016 12:42 schreef "Paul B Mahol" :

> On 2/26/16, Thilo Borgmann  wrote:
> > Am 25.02.16 um 22:24 schrieb F.Sluiter:
> >> If it doesn exist I would like to develop a new filter and would like to
> >> check if nobody is already working on it or that it exists under a
> >> different name.
> >>
> >> I have been researching the following usecase:
> >>
> >> Similar tot the displace filter, I would need a filter to remap pixels
> >> (the
> >> difference being that displace displaces the pixels relative to where it
> >> was, remap would specify where the target pixel originates from):
> >>
> >> Description: Remap pixels as indicated by second and third input stream.
> >>
> >> It takes three input streams and outputs one stream, the first input is
> >> the
> >> source, and second and third input are targetmaps. The second and third
> >> input specifies the x.y coordinate where the pixel in the target stream
> >> originates from. Note that once generated, remap files can be reused
> over
> >> and over again. Source and target do not have to have the same size.
> >> The effect I am trying to achieve is hard to compute with the relative
> >> "displace", and a lot more straightforward with "remap".
> >
> > Why not extend the displace filter to act relative/absolute based on a
> > parameter?
>
> Displace works on pixels components, I guess OP wants to work only with
> pixels.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] Endianness of palette

2016-02-28 Thread Reimar Döffinger
On 28.02.2016, at 11:19, Mats Peterson  wrote:
> From libavutil/pixfmt.h:
> 
> * @note
> * AV_PIX_FMT_RGB32 is handled in an endian-specific manner. An RGBA
> * color is put together as:
> *  (A << 24) | (R << 16) | (G << 8) | B
> * This is stored as BGRA on little-endian CPU architectures and ARGB on
> * big-endian CPUs.
> 
> 
> This is not quite true, and you said yourself that the palette isn't stored 
> in a host-specific order, Michael, since one has to use AV_RL32() to get the 
> palette entries correctly on a big-endian machine. Itt is stored BGRA, in 
> that order, in memory, as far as I understand.

1) pixfmt.h applies to AVFrame not AVPacket really, it can be a bit confusing 
for raw formats that way though
2) this part just says that RGB32 is short for "bigendian ? ARGB : BRGA", it is 
not really its own format, so I miss a bit of context why it is relevant for 
palette.

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


Re: [FFmpeg-devel] [PATCH 1/2] lavf/avienc: Add support for palette side data packets

2016-02-28 Thread Reimar Döffinger


On 28.02.2016, at 03:10, Mats Peterson  wrote:

> On 02/28/2016 03:00 AM, Mats Peterson wrote:
>> 
>> 
>> 
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> 
> 
> Why is the packet data in AVI packets sometimes zero bytes when using stream 
> copy, Michael? There certainly must be some reason for it?

AVI is fixed frame rate. If you have for example variable frame rate input 
empty packets will be used to get the right timing.
I'm not sure that is truly the cause in your case, but it is at least one 
possible reason.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] Endianness of palette

2016-02-28 Thread Mats Peterson

From libavutil/pixfmt.h:

* @note
 * AV_PIX_FMT_RGB32 is handled in an endian-specific manner. An RGBA
 * color is put together as:
 *  (A << 24) | (R << 16) | (G << 8) | B
 * This is stored as BGRA on little-endian CPU architectures and ARGB on
 * big-endian CPUs.


This is not quite true, and you said yourself that the palette isn't 
stored in a host-specific order, Michael, since one has to use AV_RL32() 
to get the palette entries correctly on a big-endian machine. Itt is 
stored BGRA, in that order, in memory, as far as I understand.


Mats

--
Mats Peterson
http://matsp888.no-ip.org/~mats/
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v4 2/2] lavf/movenc: Add support for palette side data packets

2016-02-28 Thread Mats Peterson

Use "sd_size" instead of "pkt_pal_size".

--
Mats Peterson
http://matsp888.no-ip.org/~mats/
>From 7a94429c9d09785309deeccecfce23c468c09e84 Mon Sep 17 00:00:00 2001
From: Mats Peterson 
Date: Sun, 28 Feb 2016 10:55:39 +0100
Subject: [PATCH v4 2/2] lavf/movenc: Add support for palette side data packets

---
 libavformat/movenc.c |   21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index e0223b2..e068e46 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -4760,19 +4760,28 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt)
 }
 }
 
-if (trk->is_unaligned_qt_rgb) {
+if (trk->is_unaligned_qt_rgb && pkt->size) {
 const uint8_t *data = pkt->data;
 int size = pkt->size;
 int64_t bpc = trk->enc->bits_per_coded_sample != 15 ? trk->enc->bits_per_coded_sample : 16;
 int expected_stride = ((trk->enc->width * bpc + 15) >> 4)*2;
+const uint8_t *pal = NULL;
+int sd_size;
 int ret = ff_reshuffle_raw_rgb(s, , trk->enc, expected_stride);
 if (ret < 0)
 return ret;
-if (ret == CONTAINS_PAL && !trk->pal_done) {
-int pal_size = 1 << trk->enc->bits_per_coded_sample;
-memset(trk->palette, 0, AVPALETTE_SIZE);
-memcpy(trk->palette, data + size - 4*pal_size, 4*pal_size);
-trk->pal_done++;
+if (!trk->pal_done) {
+pal = (uint8_t *)av_packet_get_side_data(pkt, AV_PKT_DATA_PALETTE, _size);
+if (pal && sd_size != AVPALETTE_SIZE) {
+av_log(s, AV_LOG_ERROR, "Invalid palette side data\n");
+return AVERROR_INVALIDDATA;
+}
+if (!pal && ret == CONTAINS_PAL)
+pal = data + size - AVPALETTE_SIZE;
+if (pal) {
+memcpy(trk->palette, pal, AVPALETTE_SIZE);
+trk->pal_done++;
+}
 } else if (trk->enc->pix_fmt == AV_PIX_FMT_GRAY8 ||
trk->enc->pix_fmt == AV_PIX_FMT_MONOBLACK) {
 for (i = 0; i < pkt->size; i++)
-- 
1.7.10.4

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


[FFmpeg-devel] [PATCH v4 1/2] lavf/avienc: Add support for palette side data packets

2016-02-28 Thread Mats Peterson

Use "sd_size" instead of "pkt_pal_size".

--
Mats Peterson
http://matsp888.no-ip.org/~mats/
>From ff9a16add48793aa121122c64269cdfdbe6e6c7f Mon Sep 17 00:00:00 2001
From: Mats Peterson 
Date: Sun, 28 Feb 2016 10:55:25 +0100
Subject: [PATCH v4 1/2] lavf/avienc: Add support for palette side data packets

---
 libavformat/avienc.c |   53 +-
 1 file changed, 31 insertions(+), 22 deletions(-)

diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index ca505f4..2171674 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -668,39 +668,48 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
 if ((ret = write_skip_frames(s, stream_index, pkt->dts)) < 0)
 return ret;
 
-if (enc->codec_id == AV_CODEC_ID_RAWVIDEO && enc->codec_tag == 0) {
+if (enc->codec_id == AV_CODEC_ID_RAWVIDEO && enc->codec_tag == 0 && size) {
 int64_t bpc = enc->bits_per_coded_sample != 15 ? enc->bits_per_coded_sample : 16;
 int expected_stride = ((enc->width * bpc + 31) >> 5)*4;
-
+const uint8_t *pal = NULL;
+int pal_size = 1 << enc->bits_per_coded_sample;
+int sd_size, i;
 ret = ff_reshuffle_raw_rgb(s, , enc, expected_stride);
 if (ret < 0)
 return ret;
-if (ret) {
-if (ret == CONTAINS_PAL) {
-int pc_tag, i;
-int pal_size = 1 << enc->bits_per_coded_sample;
-if (!avist->hdr_pal_done) {
-int64_t cur_offset = avio_tell(pb);
-avio_seek(pb, avist->pal_offset, SEEK_SET);
+pal = (uint8_t *)av_packet_get_side_data(pkt, AV_PKT_DATA_PALETTE, _size);
+if (pal && sd_size != AVPALETTE_SIZE) {
+av_log(s, AV_LOG_ERROR, "Invalid palette side data\n");
+return AVERROR_INVALIDDATA;
+}
+if (!pal && ret == CONTAINS_PAL)
+pal = data + size - AVPALETTE_SIZE;
+if (pal) {
+int pc_tag;
+if (!avist->hdr_pal_done) {
+int64_t cur_offset = avio_tell(pb);
+if (avio_seek(pb, avist->pal_offset, SEEK_SET) >= 0) {
 for (i = 0; i < pal_size; i++) {
-uint32_t v = AV_RL32(data + size - 4*pal_size + 4*i);
+uint32_t v = AV_RL32(pal + 4*i);
 avio_wl32(pb, v & 0xff);
 }
 avio_seek(pb, cur_offset, SEEK_SET);
-avist->hdr_pal_done++;
-}
-avi_stream2fourcc(tag, stream_index, enc->codec_type);
-tag[2] = 'p'; tag[3] = 'c';
-pc_tag = ff_start_tag(pb, tag);
-avio_w8(pb, 0);
-avio_w8(pb, pal_size & 0xFF);
-avio_wl16(pb, 0); // reserved
-for (i = 0; i < pal_size; i++) {
-uint32_t v = AV_RL32(data + size - 4*pal_size + 4*i);
-avio_wb32(pb, v<<8);
 }
-ff_end_tag(pb, pc_tag);
+avist->hdr_pal_done++;
 }
+avi_stream2fourcc(tag, stream_index, enc->codec_type);
+tag[2] = 'p'; tag[3] = 'c';
+pc_tag = ff_start_tag(pb, tag);
+avio_w8(pb, 0);
+avio_w8(pb, pal_size & 0xFF);
+avio_wl16(pb, 0); // reserved
+for (i = 0; i < pal_size; i++) {
+uint32_t v = AV_RL32(pal + 4*i);
+avio_wb32(pb, v<<8);
+}
+ff_end_tag(pb, pc_tag);
+}
+if (ret) {
 ret = avi_write_packet_internal(s, pkt);
 av_packet_free();
 return ret;
-- 
1.7.10.4

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


[FFmpeg-devel] [PATCH] avfilter/avf_showcqt: optimize draw routines

2016-02-28 Thread Muhammad Faiz
optimize draw_bar_yuv (slightly faster)
optimize draw_axis (about 2x faster)

Signed-off-by: Muhammad Faiz 
---
 libavfilter/avf_showcqt.c | 212 +-
 1 file changed, 115 insertions(+), 97 deletions(-)

diff --git a/libavfilter/avf_showcqt.c b/libavfilter/avf_showcqt.c
index 023924f..6515ad6 100644
--- a/libavfilter/avf_showcqt.c
+++ b/libavfilter/avf_showcqt.c
@@ -710,6 +710,30 @@ static void draw_bar_rgb(AVFrame *out, const float *h, 
const float *rcp_h,
 }
 }
 
+#define DRAW_BAR_WITH_CHROMA(x) \
+do { \
+if (h[x] <= ht) { \
+*lpy++ = 16; \
+*lpu++ = 128; \
+*lpv++ = 128; \
+} else { \
+mul = (h[x] - ht) * rcp_h[x]; \
+*lpy++ = lrintf(mul * c[x].yuv.y + 16.0f); \
+*lpu++ = lrintf(mul * c[x].yuv.u + 128.0f); \
+*lpv++ = lrintf(mul * c[x].yuv.v + 128.0f); \
+} \
+} while (0)
+
+#define DRAW_BAR_WITHOUT_CHROMA(x) \
+do { \
+if (h[x] <= ht) { \
+*lpy++ = 16; \
+} else { \
+mul = (h[x] - ht) * rcp_h[x]; \
+*lpy++ = lrintf(mul * c[x].yuv.y + 16.0f); \
+} \
+} while (0)
+
 static void draw_bar_yuv(AVFrame *out, const float *h, const float *rcp_h,
  const ColorFloat *c, int bar_h)
 {
@@ -726,36 +750,15 @@ static void draw_bar_yuv(AVFrame *out, const float *h, 
const float *rcp_h,
 lpy = vy + y * lsy;
 lpu = vu + yh * lsu;
 lpv = vv + yh * lsv;
-for (x = 0; x < w; x += 2) {
-if (h[x] <= ht) {
-*lpy++ = 16;
-*lpu++ = 128;
-*lpv++ = 128;
-} else {
-mul = (h[x] - ht) * rcp_h[x];
-*lpy++ = lrintf(mul * c[x].yuv.y + 16.0f);
-*lpu++ = lrintf(mul * c[x].yuv.u + 128.0f);
-*lpv++ = lrintf(mul * c[x].yuv.v + 128.0f);
+if (fmt == AV_PIX_FMT_YUV444P) {
+for (x = 0; x < w; x += 2) {
+DRAW_BAR_WITH_CHROMA(x);
+DRAW_BAR_WITH_CHROMA(x+1);
 }
-/* u and v are skipped on yuv422p and yuv420p */
-if (fmt == AV_PIX_FMT_YUV444P) {
-if (h[x+1] <= ht) {
-*lpy++ = 16;
-*lpu++ = 128;
-*lpv++ = 128;
-} else {
-mul = (h[x+1] - ht) * rcp_h[x+1];
-*lpy++ = lrintf(mul * c[x+1].yuv.y + 16.0f);
-*lpu++ = lrintf(mul * c[x+1].yuv.u + 128.0f);
-*lpv++ = lrintf(mul * c[x+1].yuv.v + 128.0f);
-}
-} else {
-if (h[x+1] <= ht) {
-*lpy++ = 16;
-} else {
-mul = (h[x+1] - ht) * rcp_h[x+1];
-*lpy++ = lrintf(mul * c[x+1].yuv.y + 16.0f);
-}
+} else {
+for (x = 0; x < w; x += 2) {
+DRAW_BAR_WITH_CHROMA(x);
+DRAW_BAR_WITHOUT_CHROMA(x+1);
 }
 }
 
@@ -763,46 +766,20 @@ static void draw_bar_yuv(AVFrame *out, const float *h, 
const float *rcp_h,
 lpy = vy + (y+1) * lsy;
 lpu = vu + (y+1) * lsu;
 lpv = vv + (y+1) * lsv;
-for (x = 0; x < w; x += 2) {
-/* u and v are skipped on yuv420p */
-if (fmt != AV_PIX_FMT_YUV420P) {
-if (h[x] <= ht) {
-*lpy++ = 16;
-*lpu++ = 128;
-*lpv++ = 128;
-} else {
-mul = (h[x] - ht) * rcp_h[x];
-*lpy++ = lrintf(mul * c[x].yuv.y + 16.0f);
-*lpu++ = lrintf(mul * c[x].yuv.u + 128.0f);
-*lpv++ = lrintf(mul * c[x].yuv.v + 128.0f);
-}
-} else {
-if (h[x] <= ht) {
-*lpy++ = 16;
-} else {
-mul = (h[x] - ht) * rcp_h[x];
-*lpy++ = lrintf(mul * c[x].yuv.y + 16.0f);
-}
+if (fmt == AV_PIX_FMT_YUV444P) {
+for (x = 0; x < w; x += 2) {
+DRAW_BAR_WITH_CHROMA(x);
+DRAW_BAR_WITH_CHROMA(x+1);
 }
-/* u and v are skipped on yuv422p and yuv420p */
-if (out->format == AV_PIX_FMT_YUV444P) {
-if (h[x+1] <= ht) {
-*lpy++ = 16;
-*lpu++ = 128;
-*lpv++ = 128;
-} else {
-mul = (h[x+1] - ht) * rcp_h[x+1];
-*lpy++ = lrintf(mul * c[x+1].yuv.y + 16.0f);
-*lpu++ = lrintf(mul * c[x+1].yuv.u + 128.0f);
-*lpv++ = lrintf(mul * c[x+1].yuv.v + 128.0f);
-}
-} else {
-if (h[x+1] <= ht) {
-*lpy++ = 16;
-} else {
-mul = (h[x+1] - ht) * rcp_h[x+1];
-   

Re: [FFmpeg-devel] [PATCH 2/2] avcodec/utils: Warn if a encoder is missing the pix_fmts or sample_fmts list

2016-02-28 Thread Hendrik Leppkes
On Sun, Feb 28, 2016 at 2:14 AM, Michael Niedermayer
 wrote:
> On Sun, Feb 28, 2016 at 01:26:16AM +0100, Hendrik Leppkes wrote:
>> On Sun, Feb 28, 2016 at 12:17 AM, Michael Niedermayer
>>  wrote:
>> > This would require listing supported formats for rawvideo and 
>> > wrapped_avframe
>> >
>> > Signed-off-by: Michael Niedermayer 
>> > ---
>> >  libavcodec/utils.c |5 +
>> >  1 file changed, 5 insertions(+)
>> >
>> > diff --git a/libavcodec/utils.c b/libavcodec/utils.c
>> > index 2690d0d..267c973 100644
>> > --- a/libavcodec/utils.c
>> > +++ b/libavcodec/utils.c
>> > @@ -188,6 +188,11 @@ av_cold void avcodec_register(AVCodec *codec)
>> >
>> >  if (codec->init_static_data)
>> >  codec->init_static_data(codec);
>> > +
>> > +if (av_codec_is_encoder(codec) && codec->type == AVMEDIA_TYPE_VIDEO 
>> > && !codec->pix_fmts)
>> > +av_log(NULL, AV_LOG_WARNING, "Encoder %s is missing the pix_fmts 
>> > field\n", codec->name);
>> > +if (av_codec_is_encoder(codec) && codec->type == AVMEDIA_TYPE_AUDIO  
>> > && !codec->sample_fmts)
>> > +av_log(NULL, AV_LOG_WARNING, "Encoder %s is missing the 
>> > sample_fmts field\n", codec->name);
>> >  }
>>
>> It seems kinda silly to write code to check if other code is correct.
>
> i dont think i understand because what you say would mean that
> fate and all self tests are a bad idea if i dont misunderstand
>
>

A dedicated test suite is different to random checks in random
functions. FATE wouldn't even detect such cases, since its just log.

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