[FFmpeg-devel] [PATCH] Add FITS Muxer

2017-08-06 Thread Paras Chadha
Signed-off-by: Paras Chadha 
---
Added a new line in img2enc to add support for writing frames
into separate FITS files in a fashion similar to gif.
The following command can be used for that:
ffmpeg -i INPUT -c:v fits -f image2 "out%d.fits"

 libavformat/Makefile |   1 +
 libavformat/allformats.c |   2 +-
 libavformat/fitsenc.c| 183 +++
 libavformat/img2enc.c|   2 +
 4 files changed, 187 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/fitsenc.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 266b77a..faca4a0 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -165,6 +165,7 @@ OBJS-$(CONFIG_FIFO_MUXER)+= fifo.o
 OBJS-$(CONFIG_FILMSTRIP_DEMUXER) += filmstripdec.o
 OBJS-$(CONFIG_FILMSTRIP_MUXER)   += filmstripenc.o
 OBJS-$(CONFIG_FITS_DEMUXER)  += fitsdec.o
+OBJS-$(CONFIG_FITS_MUXER)+= fitsenc.o
 OBJS-$(CONFIG_FLAC_DEMUXER)  += flacdec.o rawdec.o \
 flac_picture.o   \
 oggparsevorbis.o \
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 3c12760..f3b2edb 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -121,7 +121,7 @@ static void register_all(void)
 REGISTER_MUXDEMUX(FFMETADATA,   ffmetadata);
 REGISTER_MUXER   (FIFO, fifo);
 REGISTER_MUXDEMUX(FILMSTRIP,filmstrip);
-REGISTER_DEMUXER (FITS, fits);
+REGISTER_MUXDEMUX(FITS, fits);
 REGISTER_MUXDEMUX(FLAC, flac);
 REGISTER_DEMUXER (FLIC, flic);
 REGISTER_MUXDEMUX(FLV,  flv);
diff --git a/libavformat/fitsenc.c b/libavformat/fitsenc.c
new file mode 100644
index 000..0dcdcdf
--- /dev/null
+++ b/libavformat/fitsenc.c
@@ -0,0 +1,183 @@
+/*
+ * FITS muxer
+ * Copyright (c) 2017 Paras Chadha
+ *
+ * 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
+ */
+
+/**
+ * @file
+ * FITS muxer.
+ */
+
+#include "internal.h"
+
+typedef struct FITSContext {
+int first_image;
+} FITSContext;
+
+static int fits_write_header(AVFormatContext *s)
+{
+FITSContext *fitsctx = s->priv_data;
+fitsctx->first_image = 1;
+return 0;
+}
+
+/**
+ * Write one header line comprising of keyword and value(int)
+ * @param s AVFormat Context
+ * @param keyword pointer to the char array in which keyword is stored
+ * @param value the value corresponding to the keyword
+ * @param lines_written to keep track of lines written so far
+ * @return 0
+ */
+static int write_keyword_value(AVFormatContext *s, const char *keyword, int 
value, int *lines_written)
+{
+int len, ret;
+uint8_t header[80];
+
+len = strlen(keyword);
+memset(header, ' ', sizeof(header));
+memcpy(header, keyword, len);
+
+header[8] = '=';
+header[9] = ' ';
+
+ret = snprintf(header + 10, 70, "%d", value);
+header[ret + 10] = ' ';
+
+avio_write(s->pb, header, sizeof(header));
+*lines_written += 1;
+return 0;
+}
+
+static int write_image_header(AVFormatContext *s)
+{
+AVStream *st = s->streams[0];
+AVCodecParameters *encctx = st->codecpar;
+FITSContext *fitsctx = s->priv_data;
+uint8_t buffer[80];
+int bitpix, naxis, naxis3 = 1, bzero = 0, rgb = 0, lines_written = 0, 
lines_left;
+
+switch (encctx->format) {
+case AV_PIX_FMT_GRAY8:
+bitpix = 8;
+naxis = 2;
+break;
+case AV_PIX_FMT_GRAY16BE:
+bitpix = 16;
+naxis = 2;
+bzero = 32768;
+break;
+case AV_PIX_FMT_GBRP:
+case AV_PIX_FMT_GBRAP:
+bitpix = 8;
+naxis = 3;
+rgb = 1;
+if (encctx->format == AV_PIX_FMT_GBRP) {
+naxis3 = 3;
+} else {
+naxis3 = 4;
+}
+break;
+case AV_PIX_FMT_GBRP16BE:
+case AV_PIX_FMT_GBRAP16BE:
+bitpix = 16;
+naxis = 3;
+rgb = 1;
+if (encctx->format == AV_PIX_FMT_GBRP16BE) {
+naxis3 = 3;
+} else {
+naxis3 = 4;
+}
+b

[FFmpeg-devel] [PATCH] Add FITS Encoder

2017-08-06 Thread Paras Chadha
Signed-off-by: Paras Chadha 
---
Moved header writing code to muxer
Made the changes suggested

 Changelog  |   1 +
 doc/general.texi   |   2 +-
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   2 +-
 libavcodec/fitsenc.c   | 130 +
 5 files changed, 134 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/fitsenc.c

diff --git a/Changelog b/Changelog
index 61414f8..4b7b41b 100644
--- a/Changelog
+++ b/Changelog
@@ -33,6 +33,7 @@ version :
 - tlut2 video filter
 - floodfill video filter
 - FITS demuxer and decoder
+- FITS muxer and encoder

 version 3.3:
 - CrystalHD decoder moved to new decode API
diff --git a/doc/general.texi b/doc/general.texi
index 01402cb..1ea7984 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -592,7 +592,7 @@ following image formats are supported:
 @tab Digital Picture Exchange
 @item EXR  @tab   @tab X
 @tab OpenEXR
-@item FITS @tab   @tab X
+@item FITS @tab X @tab X
 @tab Flexible Image Transport System
 @item JPEG @tab X @tab X
 @tab Progressive JPEG is not supported.
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 42eec07..590410c 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -292,6 +292,7 @@ OBJS-$(CONFIG_FFV1_ENCODER)+= ffv1enc.o ffv1.o
 OBJS-$(CONFIG_FFWAVESYNTH_DECODER) += ffwavesynth.o
 OBJS-$(CONFIG_FIC_DECODER) += fic.o
 OBJS-$(CONFIG_FITS_DECODER)+= fitsdec.o fits.o
+OBJS-$(CONFIG_FITS_ENCODER)+= fitsenc.o
 OBJS-$(CONFIG_FLAC_DECODER)+= flacdec.o flacdata.o flac.o
 OBJS-$(CONFIG_FLAC_ENCODER)+= flacenc.o flacdata.o flac.o 
vorbis_data.o
 OBJS-$(CONFIG_FLASHSV_DECODER) += flashsv.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 8678ac2..7fe66f4 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -192,7 +192,7 @@ static void register_all(void)
 REGISTER_ENCDEC (FFV1,  ffv1);
 REGISTER_ENCDEC (FFVHUFF,   ffvhuff);
 REGISTER_DECODER(FIC,   fic);
-REGISTER_DECODER(FITS,  fits);
+REGISTER_ENCDEC (FITS,  fits);
 REGISTER_ENCDEC (FLASHSV,   flashsv);
 REGISTER_ENCDEC (FLASHSV2,  flashsv2);
 REGISTER_DECODER(FLIC,  flic);
diff --git a/libavcodec/fitsenc.c b/libavcodec/fitsenc.c
new file mode 100644
index 000..f67f3ad
--- /dev/null
+++ b/libavcodec/fitsenc.c
@@ -0,0 +1,130 @@
+/*
+ * FITS image encoder
+ * Copyright (c) 2017 Paras Chadha
+ *
+ * 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
+ */
+
+/**
+ * @file
+ * FITS image encoder
+ *
+ * Specification: https://fits.gsfc.nasa.gov/fits_standard.html Version 3.0
+ *
+ * RGBA images are encoded as planes in RGBA order. So, NAXIS3 is 3 or 4 for 
them.
+ * Also CTYPE3 = 'RGB ' is added to the header to distinguish them from 3d 
images.
+ */
+
+#include "libavutil/intreadwrite.h"
+#include "avcodec.h"
+#include "bytestream.h"
+#include "internal.h"
+
+static int fits_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
+const AVFrame *pict, int *got_packet)
+{
+AVFrame * const p = (AVFrame *)pict;
+uint8_t *bytestream, *bytestream_start, *ptr;
+const uint16_t flip = (1 << 15);
+uint64_t data_size = 0, padded_data_size = 0;
+int ret, bitpix, naxis3 = 1, i, j, k, bytes_left;
+int map[] = {2, 0, 1, 3}; // mapping from GBRA -> RGBA as RGBA is to be 
stored in FITS file..
+
+switch (avctx->pix_fmt) {
+case AV_PIX_FMT_GRAY8:
+case AV_PIX_FMT_GRAY16BE:
+map[0] = 0; // grayscale images should be directly mapped
+if (avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
+bitpix = 8;
+} else {
+bitpix = 16;
+}
+break;
+case AV_PIX_FMT_GBRP:
+case AV_PIX_FMT_GBRAP:
+bitpix = 8;
+if (avctx->pix_fmt == AV_PIX_FMT_GBRP) {
+naxis3 = 3;
+} else {
+naxis3 = 4;
+}
+break;
+case AV_PIX_FMT_GBRP16BE:
+case AV_PIX_FMT_GBRAP16BE:
+bitpix = 16;
+if (avctx->pix_f

Re: [FFmpeg-devel] [PATCH V2] doc/examples: Add a qsv encoder example

2017-08-06 Thread Steven Liu
2017-08-07 10:45 GMT+08:00 Li, Zhong :
>> -Original Message-
>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
>> Of Steven Liu
>> Sent: Wednesday, August 2, 2017 2:01 PM
>> To: FFmpeg development discussions and patches
>> 
>> Subject: Re: [FFmpeg-devel] [PATCH V2] doc/examples: Add a qsv encoder
>> example
>>
>> 2017-08-03 1:27 GMT+08:00 Zhong Li :
>> > It is an evolution from the exmaple "encode_video.c" to support qsv
>> encoder.
>> >
>> > V1->V2: Split to a separated qsv encoding example, instead of a patch
>> > based on encode_video.c
>> >
>> > Signed-off-by: Zhong Li 
>> > ---
>> >  configure |   2 +
>> >  doc/Makefile  |   1 +
>> >  doc/examples/qsvenc.c | 211
>> > ++
>> >  3 files changed, 214 insertions(+)
>> >  create mode 100644 doc/examples/qsvenc.c
>> >
>> > diff --git a/configure b/configure
>> > index 66c7b94..676cd85 100755
>> > --- a/configure
>> > +++ b/configure
>> > @@ -1472,6 +1472,7 @@ EXAMPLE_LIST="
>> >  metadata_example
>> >  muxing_example
>> >  qsvdec_example
>> > +qsvenc_example
>> >  remuxing_example
>> >  resampling_audio_example
>> >  scaling_video_example
>> > @@ -3213,6 +3214,7 @@ hw_decode_example_deps="avcodec avformat
>> avutil"
>> >  metadata_example_deps="avformat avutil"
>> >  muxing_example_deps="avcodec avformat avutil swscale"
>> >  qsvdec_example_deps="avcodec avutil libmfx h264_qsv_decoder"
>> > +qsvenc_example_deps="avcodec avutil libmfx"
>> >  remuxing_example_deps="avcodec avformat avutil"
>> >  resampling_audio_example_deps="avutil swresample"
>> >  scaling_video_example_deps="avutil swscale"
>> > diff --git a/doc/Makefile b/doc/Makefile index b670f0b..ed41763 100644
>> > --- a/doc/Makefile
>> > +++ b/doc/Makefile
>> > @@ -52,6 +52,7 @@ DOC_EXAMPLES-$(CONFIG_HW_DECODE_EXAMPLE)
>> += hw_decode
>> >  DOC_EXAMPLES-$(CONFIG_METADATA_EXAMPLE)  +=
>> metadata
>> >  DOC_EXAMPLES-$(CONFIG_MUXING_EXAMPLE)+=
>> muxing
>> >  DOC_EXAMPLES-$(CONFIG_QSVDEC_EXAMPLE)+= qsvdec
>> > +DOC_EXAMPLES-$(CONFIG_QSVENC_EXAMPLE)+= qsvenc
>> >  DOC_EXAMPLES-$(CONFIG_REMUXING_EXAMPLE)  +=
>> remuxing
>> >  DOC_EXAMPLES-$(CONFIG_RESAMPLING_AUDIO_EXAMPLE)  +=
>> resampling_audio
>> >  DOC_EXAMPLES-$(CONFIG_SCALING_VIDEO_EXAMPLE) +=
>> scaling_video
>> > diff --git a/doc/examples/qsvenc.c b/doc/examples/qsvenc.c new file
>> > mode 100644 index 000..3b94cc8
>> > --- /dev/null
>> > +++ b/doc/examples/qsvenc.c
>> > @@ -0,0 +1,211 @@
>> > +/*
>> > + * Copyright (c) 2017 Fabrice Bellard, Zhong Li
>> > + *
>> > + * Permission is hereby granted, free of charge, to any person
>> > +obtaining a copy
>> > + * of this software and associated documentation files (the
>> > +"Software"), to deal
>> > + * in the Software without restriction, including without limitation
>> > +the rights
>> > + * to use, copy, modify, merge, publish, distribute, sublicense,
>> > +and/or sell
>> > + * copies of the Software, and to permit persons to whom the Software
>> > +is
>> > + * furnished to do so, subject to the following conditions:
>> > + *
>> > + * The above copyright notice and this permission notice shall be
>> > +included in
>> > + * all copies or substantial portions of the Software.
>> > + *
>> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
>> KIND,
>> > +EXPRESS OR
>> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
>> > +MERCHANTABILITY,
>> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
>> EVENT
>> > +SHALL
>> > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
>> DAMAGES
>> > +OR OTHER
>> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
>> OTHERWISE,
>> > +ARISING FROM,
>> > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
>> OTHER
>> > +DEALINGS IN
>> > + * THE SOFTWARE.
>> > + */
>> > +
>> > +/**
>> > + * @file
>> > + * Intel QSV-accelerated encoding example
>> > + *
>> > + * @example qsvenc.c
>> > + */
>> > +
>> > +#include 
>> > +#include 
>> > +#include 
>> > +
>> > +#include 
>> > +
>> > +#include 
>> > +#include 
>> > +#include "libavutil/buffer.h"
>> > +#include "libavutil/hwcontext.h"
>> > +
>> > +static void encode(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket
>> *pkt,
>> > +   FILE *outfile)
>> > +{
>> > +int ret;
>> > +
>> > +/* send the frame to the encoder */
>> > +if (frame)
>> > +printf("Send frame %3"PRId64"\n", frame->pts);
>> > +
>> > +ret = avcodec_send_frame(enc_ctx, frame);
>> > +if (ret < 0) {
>> > +fprintf(stderr, "Error sending a frame for encoding\n");
>> > +exit(1);
>> > +}
>> > +
>> > +while (ret >= 0) {
>> > +ret = avcodec_receive_packet(enc_ctx, pkt);
>> > +if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
>> > +return;
>> > +else if (ret < 0) {
>> > +fprintf(stderr, "Error during encoding\n")

Re: [FFmpeg-devel] [PATCH V2] doc/examples: Add a qsv encoder example

2017-08-06 Thread Li, Zhong
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Steven Liu
> Sent: Wednesday, August 2, 2017 2:01 PM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH V2] doc/examples: Add a qsv encoder
> example
> 
> 2017-08-03 1:27 GMT+08:00 Zhong Li :
> > It is an evolution from the exmaple "encode_video.c" to support qsv
> encoder.
> >
> > V1->V2: Split to a separated qsv encoding example, instead of a patch
> > based on encode_video.c
> >
> > Signed-off-by: Zhong Li 
> > ---
> >  configure |   2 +
> >  doc/Makefile  |   1 +
> >  doc/examples/qsvenc.c | 211
> > ++
> >  3 files changed, 214 insertions(+)
> >  create mode 100644 doc/examples/qsvenc.c
> >
> > diff --git a/configure b/configure
> > index 66c7b94..676cd85 100755
> > --- a/configure
> > +++ b/configure
> > @@ -1472,6 +1472,7 @@ EXAMPLE_LIST="
> >  metadata_example
> >  muxing_example
> >  qsvdec_example
> > +qsvenc_example
> >  remuxing_example
> >  resampling_audio_example
> >  scaling_video_example
> > @@ -3213,6 +3214,7 @@ hw_decode_example_deps="avcodec avformat
> avutil"
> >  metadata_example_deps="avformat avutil"
> >  muxing_example_deps="avcodec avformat avutil swscale"
> >  qsvdec_example_deps="avcodec avutil libmfx h264_qsv_decoder"
> > +qsvenc_example_deps="avcodec avutil libmfx"
> >  remuxing_example_deps="avcodec avformat avutil"
> >  resampling_audio_example_deps="avutil swresample"
> >  scaling_video_example_deps="avutil swscale"
> > diff --git a/doc/Makefile b/doc/Makefile index b670f0b..ed41763 100644
> > --- a/doc/Makefile
> > +++ b/doc/Makefile
> > @@ -52,6 +52,7 @@ DOC_EXAMPLES-$(CONFIG_HW_DECODE_EXAMPLE)
> += hw_decode
> >  DOC_EXAMPLES-$(CONFIG_METADATA_EXAMPLE)  +=
> metadata
> >  DOC_EXAMPLES-$(CONFIG_MUXING_EXAMPLE)+=
> muxing
> >  DOC_EXAMPLES-$(CONFIG_QSVDEC_EXAMPLE)+= qsvdec
> > +DOC_EXAMPLES-$(CONFIG_QSVENC_EXAMPLE)+= qsvenc
> >  DOC_EXAMPLES-$(CONFIG_REMUXING_EXAMPLE)  +=
> remuxing
> >  DOC_EXAMPLES-$(CONFIG_RESAMPLING_AUDIO_EXAMPLE)  +=
> resampling_audio
> >  DOC_EXAMPLES-$(CONFIG_SCALING_VIDEO_EXAMPLE) +=
> scaling_video
> > diff --git a/doc/examples/qsvenc.c b/doc/examples/qsvenc.c new file
> > mode 100644 index 000..3b94cc8
> > --- /dev/null
> > +++ b/doc/examples/qsvenc.c
> > @@ -0,0 +1,211 @@
> > +/*
> > + * Copyright (c) 2017 Fabrice Bellard, Zhong Li
> > + *
> > + * Permission is hereby granted, free of charge, to any person
> > +obtaining a copy
> > + * of this software and associated documentation files (the
> > +"Software"), to deal
> > + * in the Software without restriction, including without limitation
> > +the rights
> > + * to use, copy, modify, merge, publish, distribute, sublicense,
> > +and/or sell
> > + * copies of the Software, and to permit persons to whom the Software
> > +is
> > + * furnished to do so, subject to the following conditions:
> > + *
> > + * The above copyright notice and this permission notice shall be
> > +included in
> > + * all copies or substantial portions of the Software.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
> KIND,
> > +EXPRESS OR
> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> > +MERCHANTABILITY,
> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
> EVENT
> > +SHALL
> > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
> DAMAGES
> > +OR OTHER
> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
> OTHERWISE,
> > +ARISING FROM,
> > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> OTHER
> > +DEALINGS IN
> > + * THE SOFTWARE.
> > + */
> > +
> > +/**
> > + * @file
> > + * Intel QSV-accelerated encoding example
> > + *
> > + * @example qsvenc.c
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +
> > +#include 
> > +#include 
> > +#include "libavutil/buffer.h"
> > +#include "libavutil/hwcontext.h"
> > +
> > +static void encode(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket
> *pkt,
> > +   FILE *outfile)
> > +{
> > +int ret;
> > +
> > +/* send the frame to the encoder */
> > +if (frame)
> > +printf("Send frame %3"PRId64"\n", frame->pts);
> > +
> > +ret = avcodec_send_frame(enc_ctx, frame);
> > +if (ret < 0) {
> > +fprintf(stderr, "Error sending a frame for encoding\n");
> > +exit(1);
> > +}
> > +
> > +while (ret >= 0) {
> > +ret = avcodec_receive_packet(enc_ctx, pkt);
> > +if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
> > +return;
> > +else if (ret < 0) {
> > +fprintf(stderr, "Error during encoding\n");
> > +exit(1);
> > +}
> > +
> > +printf("Write packet %3"PRId64" (size=%5d)\n", pkt->pts,
> pkt->size);
> > +fwrite(pkt->data, 1, pkt->size, outfile

Re: [FFmpeg-devel] [PATCH] doc/filters: document the unstability of the shorthand options notation.

2017-08-06 Thread Michael Niedermayer
On Sun, Aug 06, 2017 at 10:37:35AM +0200, Nicolas George wrote:
> L'octidi 18 thermidor, an CCXXV, James Almer a écrit :
> > What do you mean? What i suggested would be done each time an option is
> > removed or added anywhere but at the end, both of which afaik are
> > uncommon cases.
> > It's not something that requires a rewrite of the current codebase.
> 
> I mean that since I consider the break bearable (somebody upgrades a
> piece of software, they MUST test the scripts that depend on it, and
> fixing the issue once and for all is easy), I am not willing to spend my
> time implementing (and testing, for this kind of thing that takes time)
> the deprecation-warning-and-backward-compatibility dance.

Lets take a step back and look at this

There are some rarely used options in multi input filters like
overlay which break.
Noone even noticed except me

And you propose to declare the most used syntax from every filter
unstable.

This just doesnt add up, its like shooting the patient in the head as
a treatment for a cold

Please correct me if iam wrong, but isnt all that is needed to just
not remove the options from the AVOption array from the tiny number
of filters affected?
Or declare the tiny number of moved/changed options as removed/not
supported in shorthand notation.

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Everything should be made as simple as possible, but not simpler.
-- Albert Einstein


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


[FFmpeg-devel] [PATCH] [PATCH] avdevice/avfoundation: add scaleFactor attribute for avfoundation

2017-08-06 Thread sharpbai
From: sharpbai 

feature: add scaleFactor attribute for avfoundation
added by: siyuan.w...@duobei.com
added by: yiren...@duobei.com
---
 doc/indevs.texi| 22 ++
 libavdevice/avfoundation.m |  6 ++
 2 files changed, 28 insertions(+)

diff --git a/doc/indevs.texi b/doc/indevs.texi
index 09e3321..1ba71d7 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -139,6 +139,13 @@ Capture the mouse pointer. Default is 0.
 @item -capture_mouse_clicks
 Capture the screen mouse clicks. Default is 0.
 
+@item -scale_factor
+Scale factor for capture the screen. Set this property to scale the buffers
+by a given factor. For example capturing a retina screen which resolution 
2880x1800 
+with a scale_factor of 0.5 (or 0.05) produces video buffers at 1440x900 (or 
144x90).
+This is useful for reducing captured file size and increasing performance 
+in capturing screen. Default is 1.0 (no scaling).
+
 @end table
 
 @subsection Examples
@@ -169,6 +176,21 @@ Record video from the system default video device using 
the pixel format bgr0 an
 $ ffmpeg -f avfoundation -pixel_format bgr0 -i "default:none" out.avi
 @end example
 
+@item
+Capture video from the first screen using the pixel format bgr0 and scaling in 
half size into out.avi.
+First command use the avfoundation device command to enumerate all the 
available input devices including
+screens ready to be captured:
+@example
+$ ffmpeg -f avfoundation -list_devices true -i ""
+@end example
+Once you've figured out the device index corresponding to the screen to be 
captured use, run the second
+command with the correct screen device index to execute screen capture. For 
example on my mac the index
+of "Screen Capture 0" is "1", I should replace @code{-i 
""} with @code{-i "1"} in the second command.
+@example
+$ ffmpeg -f avfoundation -pixel_format bgr0 -scale_factor 0.5 -i 
"" out.avi
+@end example
+
+
 @end itemize
 
 @section bktr
diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index e2ddf47..1196cf3 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -96,6 +96,7 @@ typedef struct
 
 int capture_cursor;
 int capture_mouse_clicks;
+float   scale_factor;
 
 int list_devices;
 int video_device_index;
@@ -735,6 +736,10 @@ static int avf_read_header(AVFormatContext *s)
 capture_screen_input.minFrameDuration = 
CMTimeMake(ctx->framerate.den, ctx->framerate.num);
 }
 
+if (ctx->scale_factor > 0.0) {
+capture_screen_input.scaleFactor = ctx->scale_factor;
+}
+
 #if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
 if (ctx->capture_cursor) {
 capture_screen_input.capturesCursor = YES;
@@ -1025,6 +1030,7 @@ static const AVOption options[] = {
 { "video_size", "set video size", offsetof(AVFContext, width), 
AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, AV_OPT_FLAG_DECODING_PARAM },
 { "capture_cursor", "capture the screen cursor", offsetof(AVFContext, 
capture_cursor), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM },
 { "capture_mouse_clicks", "capture the screen mouse clicks", 
offsetof(AVFContext, capture_mouse_clicks), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, 
AV_OPT_FLAG_DECODING_PARAM },
+{ "scale_factor", "scale screen factor range", offsetof(AVFContext, 
scale_factor), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, 1.0, 
AV_OPT_FLAG_DECODING_PARAM },
 
 { NULL },
 };
-- 
2.2.1

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


[FFmpeg-devel] [PATCH 2/2] avcodec/dvenc: Change quantizer dead zone default to 7

2017-08-06 Thread Michael Niedermayer
This improves the quality and reduces the "blocking" in flat areas

Signed-off-by: Michael Niedermayer 
---
 libavcodec/dvenc.c  |  2 +-
 tests/ref/lavf/dv_fmt   | 12 ++--
 tests/ref/vsynth/vsynth1-dv |  4 ++--
 tests/ref/vsynth/vsynth1-dv-411 |  6 +++---
 tests/ref/vsynth/vsynth1-dv-50  |  6 +++---
 tests/ref/vsynth/vsynth2-dv |  6 +++---
 tests/ref/vsynth/vsynth2-dv-411 |  6 +++---
 tests/ref/vsynth/vsynth2-dv-50  |  6 +++---
 tests/ref/vsynth/vsynth_lena-dv |  6 +++---
 tests/ref/vsynth/vsynth_lena-dv-411 |  6 +++---
 tests/ref/vsynth/vsynth_lena-dv-50  |  6 +++---
 11 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index 8474498ee6..ce2fc75daa 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -756,7 +756,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 #define OFFSET(x) offsetof(DVVideoContext, x)
 static const AVOption dv_options[] = {
-{ "quant_deadzone","Quantizer dead zone",
OFFSET(quant_deadzone),   AV_OPT_TYPE_INT, { .i64 = 15 }, 0, 1024, VE },
+{ "quant_deadzone","Quantizer dead zone",
OFFSET(quant_deadzone),   AV_OPT_TYPE_INT, { .i64 = 7 }, 0, 1024, VE },
 { NULL },
 };
 
diff --git a/tests/ref/lavf/dv_fmt b/tests/ref/lavf/dv_fmt
index dac43b68a1..0263202c8e 100644
--- a/tests/ref/lavf/dv_fmt
+++ b/tests/ref/lavf/dv_fmt
@@ -1,9 +1,9 @@
-5a622e1ae4fd16bec59cd514380d7882 *./tests/data/lavf/lavf.dv
+7830f9c6716ceb6011f865f1e521b951 *./tests/data/lavf/lavf.dv
 360 ./tests/data/lavf/lavf.dv
-./tests/data/lavf/lavf.dv CRC=0x0a6edbd8
-155e8fd4ea1196edd56ae9ff09edcf85 *./tests/data/lavf/lavf.dv
+./tests/data/lavf/lavf.dv CRC=0xd428d3ee
+5569626370c7c72d40de2c4559e32856 *./tests/data/lavf/lavf.dv
 348 ./tests/data/lavf/lavf.dv
-./tests/data/lavf/lavf.dv CRC=0x3e5583fa
-87d3b20f656235671383a7eaa2f66330 *./tests/data/lavf/lavf.dv
+./tests/data/lavf/lavf.dv CRC=0xa0088163
+2fb332aab8f2ba9c33b1b2368194392a *./tests/data/lavf/lavf.dv
 360 ./tests/data/lavf/lavf.dv
-./tests/data/lavf/lavf.dv CRC=0xf3e6873c
+./tests/data/lavf/lavf.dv CRC=0xbdaf7f52
diff --git a/tests/ref/vsynth/vsynth1-dv b/tests/ref/vsynth/vsynth1-dv
index 6237b078c5..ea357b7723 100644
--- a/tests/ref/vsynth/vsynth1-dv
+++ b/tests/ref/vsynth/vsynth1-dv
@@ -1,4 +1,4 @@
-4d572f758b55a1756adf9f54132f3b9e *tests/data/fate/vsynth1-dv.dv
+4246668d61439617101d051d7a995108 *tests/data/fate/vsynth1-dv.dv
 720 tests/data/fate/vsynth1-dv.dv
-1cda5a62c3a2f17cc7d5b4cddccf2524 *tests/data/fate/vsynth1-dv.out.rawvideo
+d52e7a9eac459ade9561d0b89bba58e7 *tests/data/fate/vsynth1-dv.out.rawvideo
 stddev:6.90 PSNR: 31.34 MAXDIFF:   76 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth1-dv-411 b/tests/ref/vsynth/vsynth1-dv-411
index 48e01a1403..ec88d67ece 100644
--- a/tests/ref/vsynth/vsynth1-dv-411
+++ b/tests/ref/vsynth/vsynth1-dv-411
@@ -1,4 +1,4 @@
-f179899efba432c6f01149c36c709092 *tests/data/fate/vsynth1-dv-411.dv
+df067afe65f1712d9e8efa7117aab6ea *tests/data/fate/vsynth1-dv-411.dv
 720 tests/data/fate/vsynth1-dv-411.dv
-48904744fabbbc3421a762f615ef6456 *tests/data/fate/vsynth1-dv-411.out.rawvideo
-stddev:9.44 PSNR: 28.62 MAXDIFF:   84 bytes:  7603200/  7603200
+ed493bad827dc903188fce8d3b597fcb *tests/data/fate/vsynth1-dv-411.out.rawvideo
+stddev:9.45 PSNR: 28.62 MAXDIFF:   84 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth1-dv-50 b/tests/ref/vsynth/vsynth1-dv-50
index d5da88d78c..4a2ff00110 100644
--- a/tests/ref/vsynth/vsynth1-dv-50
+++ b/tests/ref/vsynth/vsynth1-dv-50
@@ -1,4 +1,4 @@
-a193c5f92bf6e74c604e759d5f4f0f94 *tests/data/fate/vsynth1-dv-50.dv
+adb1df1a65cecab225677003a5de9f28 *tests/data/fate/vsynth1-dv-50.dv
 1440 tests/data/fate/vsynth1-dv-50.dv
-41c4df5f2d876fcd5245643b9ded6711 *tests/data/fate/vsynth1-dv-50.out.rawvideo
-stddev:1.72 PSNR: 43.38 MAXDIFF:   29 bytes:  7603200/  7603200
+4ab1f5b7aad15fab9e3c1ea5b96da39b *tests/data/fate/vsynth1-dv-50.out.rawvideo
+stddev:1.72 PSNR: 43.37 MAXDIFF:   29 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth2-dv b/tests/ref/vsynth/vsynth2-dv
index bb0602a70f..3127b56288 100644
--- a/tests/ref/vsynth/vsynth2-dv
+++ b/tests/ref/vsynth/vsynth2-dv
@@ -1,4 +1,4 @@
-9002a5769a7744a4b8d24b01787abc3b *tests/data/fate/vsynth2-dv.dv
+6a059698f1f619312dd91504697cca98 *tests/data/fate/vsynth2-dv.dv
 720 tests/data/fate/vsynth2-dv.dv
-22a62dc9108c4a8b1a3c708e5d383748 *tests/data/fate/vsynth2-dv.out.rawvideo
-stddev:1.99 PSNR: 42.12 MAXDIFF:   38 bytes:  7603200/  7603200
+528fd407b6d19f5fe3b3446a3080d148 *tests/data/fate/vsynth2-dv.out.rawvideo
+stddev:1.99 PSNR: 42.13 MAXDIFF:   38 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth2-dv-411 b/tests/ref/vsynth/vsynth2-dv-411
index bdda6367bc..3cee4de303 100644
--- a/tests/ref/vsynth/vsynth2-dv-411
+++ b/tests/ref/vsynth/vsynth2-dv-

[FFmpeg-devel] [PATCH 1/2] avcodec/dvenc: Support adjusting the quantizer deadzone

2017-08-06 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavcodec/dv.h|  3 +++
 libavcodec/dvenc.c | 24 +++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/libavcodec/dv.h b/libavcodec/dv.h
index 6350a16dff..0e97bb200e 100644
--- a/libavcodec/dv.h
+++ b/libavcodec/dv.h
@@ -38,6 +38,7 @@ typedef struct DVwork_chunk {
 } DVwork_chunk;
 
 typedef struct DVVideoContext {
+AVClass *avclass;
 const AVDVProfile *sys;
 const AVFrame   *frame;
 AVCodecContext  *avctx;
@@ -51,6 +52,8 @@ typedef struct DVVideoContext {
 me_cmp_func ildct_cmp;
 DVwork_chunk work_chunks[4 * 12 * 27];
 uint32_t idct_factor[2 * 4 * 16 * 64];
+
+int quant_deadzone;
 } DVVideoContext;
 
 enum dv_section_type {
diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index e3de18a510..8474498ee6 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -17,6 +17,8 @@
  * 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
+ *
+ * quant_deadzone code and fixes sponsored by NOA GmbH
  */
 
 /**
@@ -28,6 +30,7 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/internal.h"
+#include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 
 #include "avcodec.h"
@@ -265,6 +268,8 @@ static av_always_inline int dv_init_enc_block(EncBlockInfo 
*bi, uint8_t *data,
 #endif
 int max  = classes[0];
 int prev = 0;
+const unsigned deadzone = s->quant_deadzone;
+const unsigned threshold = 2 * deadzone;
 
 av_assert2int) blk) & 15) == 0);
 
@@ -297,13 +302,15 @@ static av_always_inline int 
dv_init_enc_block(EncBlockInfo *bi, uint8_t *data,
 for (i = mb_area_start[area]; i < mb_area_start[area + 1]; i++) {
 int level = blk[zigzag_scan[i]];
 
-if (level + 15 > 30U) {
+if (level + deadzone > threshold) {
 bi->sign[i] = (level >> 31) & 1;
 /* Weight it and shift down into range, adding for rounding.
  * The extra division by a factor of 2^4 reverses the 8x
  * expansion of the DCT AND the 2x doubling of the weights. */
 level = (FFABS(level) * weight[i] + (1 << (dv_weight_bits 
+ 3))) >>
 (dv_weight_bits + 4);
+if (!level)
+continue;
 bi->mb[i] = level;
 if (level > max)
 max = level;
@@ -746,6 +753,20 @@ FF_ENABLE_DEPRECATION_WARNINGS
 return 0;
 }
 
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+#define OFFSET(x) offsetof(DVVideoContext, x)
+static const AVOption dv_options[] = {
+{ "quant_deadzone","Quantizer dead zone",
OFFSET(quant_deadzone),   AV_OPT_TYPE_INT, { .i64 = 15 }, 0, 1024, VE },
+{ NULL },
+};
+
+static const AVClass dvvideo_encode_class = {
+.class_name = "dvvideo encoder",
+.item_name  = av_default_item_name,
+.option = dv_options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
 AVCodec ff_dvvideo_encoder = {
 .name   = "dvvideo",
 .long_name  = NULL_IF_CONFIG_SMALL("DV (Digital Video)"),
@@ -759,4 +780,5 @@ AVCodec ff_dvvideo_encoder = {
 AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV422P,
 AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE
 },
+.priv_class = &dvvideo_encode_class,
 };
-- 
2.13.0

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


Re: [FFmpeg-devel] [PATCH] zscale: Fix memory leak

2017-08-06 Thread Paul B Mahol
On 8/6/17, Jkldjfset  wrote:
> Empty Message

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


[FFmpeg-devel] [PATCH 3/3] ffplay: add support for more SDL pixel formats when rendering video

2017-08-06 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 ffplay.c | 114 +--
 1 file changed, 82 insertions(+), 32 deletions(-)

diff --git a/ffplay.c b/ffplay.c
index 8174caf4a6..7a9b76a93d 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -362,6 +362,32 @@ static AVPacket flush_pkt;
 static SDL_Window *window;
 static SDL_Renderer *renderer;
 
+static const struct TextureFormatEntry {
+enum AVPixelFormat format;
+int texture_fmt;
+} sdl_texture_format_map[] = {
+{ AV_PIX_FMT_RGB8,   SDL_PIXELFORMAT_RGB332 },
+{ AV_PIX_FMT_RGB444, SDL_PIXELFORMAT_RGB444 },
+{ AV_PIX_FMT_RGB555, SDL_PIXELFORMAT_RGB555 },
+{ AV_PIX_FMT_BGR555, SDL_PIXELFORMAT_BGR555 },
+{ AV_PIX_FMT_RGB565, SDL_PIXELFORMAT_RGB565 },
+{ AV_PIX_FMT_BGR565, SDL_PIXELFORMAT_BGR565 },
+{ AV_PIX_FMT_RGB24,  SDL_PIXELFORMAT_RGB24 },
+{ AV_PIX_FMT_BGR24,  SDL_PIXELFORMAT_BGR24 },
+{ AV_PIX_FMT_0RGB32, SDL_PIXELFORMAT_RGB888 },
+{ AV_PIX_FMT_0BGR32, SDL_PIXELFORMAT_BGR888 },
+{ AV_PIX_FMT_NE(RGB0, 0BGR), SDL_PIXELFORMAT_RGBX },
+{ AV_PIX_FMT_NE(BGR0, 0RGB), SDL_PIXELFORMAT_BGRX },
+{ AV_PIX_FMT_RGB32,  SDL_PIXELFORMAT_ARGB },
+{ AV_PIX_FMT_RGB32_1,SDL_PIXELFORMAT_RGBA },
+{ AV_PIX_FMT_BGR32,  SDL_PIXELFORMAT_ABGR },
+{ AV_PIX_FMT_BGR32_1,SDL_PIXELFORMAT_BGRA },
+{ AV_PIX_FMT_YUV420P,SDL_PIXELFORMAT_IYUV },
+{ AV_PIX_FMT_YUYV422,SDL_PIXELFORMAT_YUY2 },
+{ AV_PIX_FMT_UYVY422,SDL_PIXELFORMAT_UYVY },
+{ AV_PIX_FMT_NONE,   SDL_PIXELFORMAT_UNKNOWN },
+};
+
 #if CONFIG_AVFILTER
 static int opt_add_vfilter(void *optctx, const char *opt, const char *arg)
 {
@@ -820,6 +846,7 @@ static int realloc_texture(SDL_Texture **texture, Uint32 
new_format, int new_wid
 memset(pixels, 0, pitch * new_height);
 SDL_UnlockTexture(*texture);
 }
+av_log(NULL, AV_LOG_VERBOSE, "Created %dx%d texture with %s.\n", 
new_width, new_height, SDL_GetPixelFormatName(new_format));
 }
 return 0;
 }
@@ -855,31 +882,33 @@ static void calculate_display_rect(SDL_Rect *rect,
 rect->h = FFMAX(height, 1);
 }
 
-static int upload_texture(SDL_Texture *tex, AVFrame *frame, struct SwsContext 
**img_convert_ctx) {
+static void get_sdl_pix_fmt_and_blendmode(int format, Uint32 *sdl_pix_fmt, 
SDL_BlendMode *sdl_blendmode)
+{
+int i;
+*sdl_blendmode = SDL_BLENDMODE_NONE;
+*sdl_pix_fmt = SDL_PIXELFORMAT_UNKNOWN;
+if (format == AV_PIX_FMT_RGB32   ||
+format == AV_PIX_FMT_RGB32_1 ||
+format == AV_PIX_FMT_BGR32   ||
+format == AV_PIX_FMT_BGR32_1)
+*sdl_blendmode = SDL_BLENDMODE_BLEND;
+for (i = 0; i < FF_ARRAY_ELEMS(sdl_texture_format_map) - 1; i++) {
+if (format == sdl_texture_format_map[i].format) {
+*sdl_pix_fmt = sdl_texture_format_map[i].texture_fmt;
+return;
+}
+}
+}
+
+static int upload_texture(SDL_Texture **tex, AVFrame *frame, struct SwsContext 
**img_convert_ctx) {
 int ret = 0;
-switch (frame->format) {
-case AV_PIX_FMT_YUV420P:
-if (frame->linesize[0] > 0 && frame->linesize[1] > 0 && 
frame->linesize[2] > 0) {
-ret = SDL_UpdateYUVTexture(tex, NULL, frame->data[0], 
frame->linesize[0],
-  frame->data[1], 
frame->linesize[1],
-  frame->data[2], 
frame->linesize[2]);
-} else if (frame->linesize[0] < 0 && frame->linesize[1] < 0 && 
frame->linesize[2] < 0) {
-ret = SDL_UpdateYUVTexture(tex, NULL, frame->data[0] + 
frame->linesize[0] * (frame->height- 1), 
-frame->linesize[0],
-  frame->data[1] + 
frame->linesize[1] * (AV_CEIL_RSHIFT(frame->height, 1) - 1), 
-frame->linesize[1],
-  frame->data[2] + 
frame->linesize[2] * (AV_CEIL_RSHIFT(frame->height, 1) - 1), 
-frame->linesize[2]);
-} else {
-av_log(NULL, AV_LOG_ERROR, "Mixed negative and positive 
linesizes are not supported.\n");
-return -1;
-}
-break;
-case AV_PIX_FMT_BGRA:
-if (frame->linesize[0] < 0) {
-ret = SDL_UpdateTexture(tex, NULL, frame->data[0] + 
frame->linesize[0] * (frame->height - 1), -frame->linesize[0]);
-} else {
-ret = SDL_UpdateTexture(tex, NULL, frame->data[0], 
frame->linesize[0]);
-}
-break;
-default:
+Uint32 sdl_pix_fmt;
+SDL_BlendMode sdl_blendmode;
+get_sdl_pix_fmt_and_blendmode(frame->format, &sdl_pix_fmt, &sdl_blendmode);
+if (realloc_texture(tex, sdl_pix_fmt == SDL_PIXELFORMAT_UNKNOWN ? 
SDL_PIXELFORMAT_ARGB : sdl_pix_fmt,

[FFmpeg-devel] [PATCH 2/3] ffplay: add support for displaying rgb images with alpha

2017-08-06 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 ffplay.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ffplay.c b/ffplay.c
index ee3d1628e8..8174caf4a6 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -957,7 +957,8 @@ static void video_image_display(VideoState *is)
 
 if (!vp->uploaded) {
 int sdl_pix_fmt = vp->frame->format == AV_PIX_FMT_YUV420P ? 
SDL_PIXELFORMAT_YV12 : SDL_PIXELFORMAT_ARGB;
-if (realloc_texture(&is->vid_texture, sdl_pix_fmt, vp->frame->width, 
vp->frame->height, SDL_BLENDMODE_NONE, 0) < 0)
+SDL_BlendMode sdl_blendmode = vp->frame->format == AV_PIX_FMT_YUV420P 
? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND;
+if (realloc_texture(&is->vid_texture, sdl_pix_fmt, vp->frame->width, 
vp->frame->height, sdl_blendmode, 0) < 0)
 return;
 if (upload_texture(is->vid_texture, vp->frame, &is->img_convert_ctx) < 
0)
 return;
-- 
2.13.1

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


[FFmpeg-devel] [PATCH 1/3] ffplay: add support for rendering yuv images with negative line size

2017-08-06 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 ffplay.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/ffplay.c b/ffplay.c
index 7cc5ab1644..ee3d1628e8 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -859,13 +859,18 @@ static int upload_texture(SDL_Texture *tex, AVFrame 
*frame, struct SwsContext **
 int ret = 0;
 switch (frame->format) {
 case AV_PIX_FMT_YUV420P:
-if (frame->linesize[0] < 0 || frame->linesize[1] < 0 || 
frame->linesize[2] < 0) {
-av_log(NULL, AV_LOG_ERROR, "Negative linesize is not supported 
for YUV.\n");
+if (frame->linesize[0] > 0 && frame->linesize[1] > 0 && 
frame->linesize[2] > 0) {
+ret = SDL_UpdateYUVTexture(tex, NULL, frame->data[0], 
frame->linesize[0],
+  frame->data[1], 
frame->linesize[1],
+  frame->data[2], 
frame->linesize[2]);
+} else if (frame->linesize[0] < 0 && frame->linesize[1] < 0 && 
frame->linesize[2] < 0) {
+ret = SDL_UpdateYUVTexture(tex, NULL, frame->data[0] + 
frame->linesize[0] * (frame->height- 1), 
-frame->linesize[0],
+  frame->data[1] + 
frame->linesize[1] * (AV_CEIL_RSHIFT(frame->height, 1) - 1), 
-frame->linesize[1],
+  frame->data[2] + 
frame->linesize[2] * (AV_CEIL_RSHIFT(frame->height, 1) - 1), 
-frame->linesize[2]);
+} else {
+av_log(NULL, AV_LOG_ERROR, "Mixed negative and positive 
linesizes are not supported.\n");
 return -1;
 }
-ret = SDL_UpdateYUVTexture(tex, NULL, frame->data[0], 
frame->linesize[0],
-  frame->data[1], 
frame->linesize[1],
-  frame->data[2], 
frame->linesize[2]);
 break;
 case AV_PIX_FMT_BGRA:
 if (frame->linesize[0] < 0) {
-- 
2.13.1

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


[FFmpeg-devel] [PATCH 2/2]v7 Opus Pyramid Vector Quantization Search in x86 SIMD asm

2017-08-06 Thread Ivan Kalvachev
This patch requires "Add macros used in opus_pvq_search to x86util.asm"
as 4 of the macros are moved there.

1. Cosmetics is completely redone.

2. I've left the align code as it is.
I found a really old nasm-2.07 version (from 19 Jan 2010) and made a test build.
I got nasm-2.09.04 (from Jan 11 2011) too, just to be sure.
They all passed without issues.

The x264 x86inc.asm also uses smartalign without
checking version number.

Also I had to do a bit more extensive benchmarks,
because it's hard to tell which version is better
(with or without align).
So far it looks like the align might be faster
with 2-6 cycles at best.

So until somebody finds some concrete issue
I'd like to keep the code as it is.

(maybe try avx2 without align:)


I hope I haven't forgotten to do something.
And I do hope I haven't messed up something new.

Best Regards.
From ac21f1bbaa155090851e8b2b52d2302a0c17d6ab Mon Sep 17 00:00:00 2001
From: Ivan Kalvachev 
Date: Thu, 8 Jun 2017 22:24:33 +0300
Subject: [PATCH 2/6] SIMD opus pvq_search implementation

Explanation on the workings and methods used by the
Pyramid Vector Quantization Search function
could be found in the following Work-In-Progress mail threads:
http://ffmpeg.org/pipermail/ffmpeg-devel/2017-June/212146.html
http://ffmpeg.org/pipermail/ffmpeg-devel/2017-June/212816.html
http://ffmpeg.org/pipermail/ffmpeg-devel/2017-July/213030.html
http://ffmpeg.org/pipermail/ffmpeg-devel/2017-July/213436.html

Signed-off-by: Ivan Kalvachev 
---
 libavcodec/opus_pvq.c  |   3 +
 libavcodec/opus_pvq.h  |   5 +-
 libavcodec/x86/Makefile|   3 +
 libavcodec/x86/opus_dsp_init.c |  45 +
 libavcodec/x86/opus_pvq_search.asm | 395 +
 5 files changed, 449 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/x86/opus_dsp_init.c
 create mode 100644 libavcodec/x86/opus_pvq_search.asm

diff --git a/libavcodec/opus_pvq.c b/libavcodec/opus_pvq.c
index 2ac66a0ede..2fb276099b 100644
--- a/libavcodec/opus_pvq.c
+++ b/libavcodec/opus_pvq.c
@@ -947,6 +947,9 @@ int av_cold ff_celt_pvq_init(CeltPVQ **pvq)
 s->encode_band= pvq_encode_band;
 s->band_cost  = pvq_band_cost;
 
+if (ARCH_X86)
+ff_opus_dsp_init_x86(s);
+
 *pvq = s;
 
 return 0;
diff --git a/libavcodec/opus_pvq.h b/libavcodec/opus_pvq.h
index 6691494838..9246337360 100644
--- a/libavcodec/opus_pvq.h
+++ b/libavcodec/opus_pvq.h
@@ -33,8 +33,8 @@
float *lowband_scratch, int fill)
 
 struct CeltPVQ {
-DECLARE_ALIGNED(32, int,   qcoeff  )[176];
-DECLARE_ALIGNED(32, float, hadamard_tmp)[176];
+DECLARE_ALIGNED(32, int,   qcoeff  )[256];
+DECLARE_ALIGNED(32, float, hadamard_tmp)[256];
 
 float (*pvq_search)(float *X, int *y, int K, int N);
 
@@ -45,6 +45,7 @@ struct CeltPVQ {
 };
 
 int  ff_celt_pvq_init  (struct CeltPVQ **pvq);
+void ff_opus_dsp_init_x86(struct CeltPVQ *s);
 void ff_celt_pvq_uninit(struct CeltPVQ **pvq);
 
 #endif /* AVCODEC_OPUS_PVQ_H */
diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile
index 0dbc46504e..e36644c72a 100644
--- a/libavcodec/x86/Makefile
+++ b/libavcodec/x86/Makefile
@@ -52,6 +52,8 @@ OBJS-$(CONFIG_APNG_DECODER)+= x86/pngdsp_init.o
 OBJS-$(CONFIG_CAVS_DECODER)+= x86/cavsdsp.o
 OBJS-$(CONFIG_DCA_DECODER) += x86/dcadsp_init.o x86/synth_filter_init.o
 OBJS-$(CONFIG_DNXHD_ENCODER)   += x86/dnxhdenc_init.o
+OBJS-$(CONFIG_OPUS_DECODER)+= x86/opus_dsp_init.o
+OBJS-$(CONFIG_OPUS_ENCODER)+= x86/opus_dsp_init.o
 OBJS-$(CONFIG_HEVC_DECODER)+= x86/hevcdsp_init.o
 OBJS-$(CONFIG_JPEG2000_DECODER)+= x86/jpeg2000dsp_init.o
 OBJS-$(CONFIG_MLP_DECODER) += x86/mlpdsp_init.o
@@ -123,6 +125,7 @@ X86ASM-OBJS-$(CONFIG_MDCT15)   += x86/mdct15.o
 X86ASM-OBJS-$(CONFIG_ME_CMP)   += x86/me_cmp.o
 X86ASM-OBJS-$(CONFIG_MPEGAUDIODSP) += x86/imdct36.o
 X86ASM-OBJS-$(CONFIG_MPEGVIDEOENC) += x86/mpegvideoencdsp.o
+X86ASM-OBJS-$(CONFIG_OPUS_ENCODER) += x86/opus_pvq_search.o
 X86ASM-OBJS-$(CONFIG_PIXBLOCKDSP)  += x86/pixblockdsp.o
 X86ASM-OBJS-$(CONFIG_QPELDSP)  += x86/qpeldsp.o \
   x86/fpel.o\
diff --git a/libavcodec/x86/opus_dsp_init.c b/libavcodec/x86/opus_dsp_init.c
new file mode 100644
index 00..c51f786ee8
--- /dev/null
+++ b/libavcodec/x86/opus_dsp_init.c
@@ -0,0 +1,45 @@
+/*
+ * Opus encoder assembly optimizations
+ * Copyright (C) 2017 Ivan Kalvachev 
+ *
+ * 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

Re: [FFmpeg-devel] [PATCH 7/7] lavfi/vf_stack: move to activate design.

2017-08-06 Thread Nicolas George
Le nonidi 19 thermidor, an CCXXV, Gyan a écrit :
> Is ticket #6566 also related?

No, since the changes to overlay are not yet committed and since "Buffer
queue overflow" is precisely the thing that will go away when they will
be.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH 7/7] lavfi/vf_stack: move to activate design.

2017-08-06 Thread John Warburton
On Sun, Aug 6, 2017 at 4:39 PM, Gyan  wrote:
> Is ticket #6566 also related?

This test case on ticket #6566 indeed freezes during the overlay on my
patched FFmpeg with the alteration to libav/vf_stack.c taken out. I
have not been able to test it in another way yet.

Kind regards,
JW
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 7/7] lavfi/vf_stack: move to activate design.

2017-08-06 Thread Gyan
Is ticket #6566 also related?

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


Re: [FFmpeg-devel] [PATCH 7/7] lavfi/vf_stack: move to activate design.

2017-08-06 Thread Nicolas George
Le nonidi 19 thermidor, an CCXXV, John Warburton a écrit :
> Gentlemen, I am sorry to report that this particular patch to
> lavfi/vf_stack.c breaks FFmpeg on-screen output when a vertical stack
> (vstack) follows a horizontal stack (hstack). Below, please find a
> chain to -filter_complex, cut down from a much more complex chain,
> that reproduces the problem.
> 
> FFmpeg here is compiled for Windows using mingw-w64 tool chain on Bash
> for Windows. I usually make this up nearly every day without incident.
> 
> At commit 4e0e9ce2dc67a94c98d40a46e91fe5aa53ad0376 ("lavfi/framesync2:
> implement "activate" design"), the following script downloads an audio
> stream, and successfully produces three visual representations using
> FFmpeg filters, output to the 'SDL' device. 'opengl' also works.
> 
> In this script, the avectorscope and showfreqs filters are
> horizontally stacked; then this combination is stacked vertically with
> an output from the ebur128 filter.
> 
> ffmpeg -v debug -i 'http://s3.yesstreaming.net:7001/;stream/'
> -filter_complex "[a0]asplit=3[a][b][c];
> [a]avectorscope=size=512x512[z]; [b]showfreqs[y]; [z][y]hstack[n];
> [c]ebur128=video=1[d][e]; [d]scale=1536:512[g]; [n][g]vstack;
> [e]anullsink" -f SDL Test
> 
> But once the patch to lavfi_vf_stack is applied, at commit
> 0dd8320e16bcdbe6b928e99489cf47abd16d3255, the same script results in a
> blank, white display window using the SDL device, and a blank black
> window using opengl. The text output from the ebur128 filter stops
> after one line. Merely applying a single hstack or vstack works: but
> the two together fail after this point:
> 
> https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/0dd8320e16bcdbe6b928e99489cf47abd16d3255
> ("lavfi/vf_stack: move to "activate" design")
> 
> Furthermore, compiling from today's git master but reversing ONLY the
> above patch to vf_stack.c also results in a working FFmpeg when given
> the above test case.

I can reproduce the issue here. Thanks for the report.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH 7/7] lavfi/vf_stack: move to activate design.

2017-08-06 Thread John Warburton
On Mon, Jul 17, 2017 at 3:19 PM, Nicolas George  wrote:
>
> Signed-off-by: Nicolas George 
> ---
>  libavfilter/Makefile   |  4 ++--
>  libavfilter/vf_stack.c | 32 +---
>  2 files changed, 15 insertions(+), 21 deletions(-)
>
>
> Works as expected. Including shortest.
> And no longer subject to bufferqueue overflows.

Gentlemen, I am sorry to report that this particular patch to
lavfi/vf_stack.c breaks FFmpeg on-screen output when a vertical stack
(vstack) follows a horizontal stack (hstack). Below, please find a
chain to -filter_complex, cut down from a much more complex chain,
that reproduces the problem.

FFmpeg here is compiled for Windows using mingw-w64 tool chain on Bash
for Windows. I usually make this up nearly every day without incident.

At commit 4e0e9ce2dc67a94c98d40a46e91fe5aa53ad0376 ("lavfi/framesync2:
implement "activate" design"), the following script downloads an audio
stream, and successfully produces three visual representations using
FFmpeg filters, output to the 'SDL' device. 'opengl' also works.

In this script, the avectorscope and showfreqs filters are
horizontally stacked; then this combination is stacked vertically with
an output from the ebur128 filter.

ffmpeg -v debug -i 'http://s3.yesstreaming.net:7001/;stream/'
-filter_complex "[a0]asplit=3[a][b][c];
[a]avectorscope=size=512x512[z]; [b]showfreqs[y]; [z][y]hstack[n];
[c]ebur128=video=1[d][e]; [d]scale=1536:512[g]; [n][g]vstack;
[e]anullsink" -f SDL Test

But once the patch to lavfi_vf_stack is applied, at commit
0dd8320e16bcdbe6b928e99489cf47abd16d3255, the same script results in a
blank, white display window using the SDL device, and a blank black
window using opengl. The text output from the ebur128 filter stops
after one line. Merely applying a single hstack or vstack works: but
the two together fail after this point:

https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/0dd8320e16bcdbe6b928e99489cf47abd16d3255
("lavfi/vf_stack: move to "activate" design")

Furthermore, compiling from today's git master but reversing ONLY the
above patch to vf_stack.c also results in a working FFmpeg when given
the above test case.

Both debug outputs from the parser are identical:

[Parsed_asplit_0 @ 022917a3eb60] Setting 'outputs' to value '3'
[Parsed_avectorscope_1 @ 022917a3e9c0] Setting 'size' to value '512x512'
[Parsed_ebur128_4 @ 022917a3ec20] Setting 'video' to value '1'
[Parsed_ebur128_4 @ 022917a3ec20] EBU +9 scale
[Parsed_scale_5 @ 022917a3e820] Setting 'w' to value '1536'
[Parsed_scale_5 @ 022917a3e820] Setting 'h' to value '512'
[Parsed_scale_5 @ 022917a3e820] w:1536 h:512 flags:'bilinear' interl:0
[graph_0_in_0_0 @ 022917a3f2a0] Setting 'time_base' to value '1/44100'
[graph_0_in_0_0 @ 022917a3f2a0] Setting 'sample_rate' to value '44100'
[graph_0_in_0_0 @ 022917a3f2a0] Setting 'sample_fmt' to value 's16p'
[graph_0_in_0_0 @ 022917a3f2a0] Setting 'channel_layout' to value '0x3'
[graph_0_in_0_0 @ 022917a3f2a0] tb:1/44100 samplefmt:s16p
samplerate:44100 chlayout:0x3
[Parsed_avectorscope_1 @ 022917a3e9c0] auto-inserting filter
'auto_resampler_0' between the filter 'Parsed_asplit_0' and the filter
'Parsed_avectorscope_1'
[Parsed_showfreqs_2 @ 022917a3e740] auto-inserting filter
'auto_resampler_1' between the filter 'Parsed_asplit_0' and the filter
'Parsed_showfreqs_2'
[Parsed_ebur128_4 @ 022917a3ec20] auto-inserting filter
'auto_resampler_2' between the filter 'Parsed_asplit_0' and the filter
'Parsed_ebur128_4'
[AVFilterGraph @ 022917a3d540] query_formats: 10 queried, 12
merged, 9 already done, 0 delayed
[auto_resampler_0 @ 022917a3e8e0] picking s16 out of 2 ref:s16p
[auto_resampler_2 @ 022917a3f440] [SWR @ 022917f34f80] Using
fltp internally between filters
[auto_resampler_2 @ 022917a3f440] ch:2 chl:stereo fmt:s16p
r:44100Hz -> ch:2 chl:stereo fmt:dbl r:48000Hz
[auto_resampler_0 @ 022917a3e8e0] [SWR @ 022917a894c0] Using
s16p internally between filters
[auto_resampler_0 @ 022917a3e8e0] ch:2 chl:stereo fmt:s16p
r:44100Hz -> ch:2 chl:stereo fmt:s16 r:44100Hz
[auto_resampler_1 @ 022917a3ea80] [SWR @ 022917f1ffc0] Using
s16p internally between filters
[auto_resampler_1 @ 022917a3ea80] ch:2 chl:stereo fmt:s16p
r:44100Hz -> ch:2 chl:stereo fmt:fltp r:44100Hz
[Parsed_hstack_3 @ 022917a3f1e0] [framesync @ 022917a2e608]
Selected 1/44100 time base
[Parsed_hstack_3 @ 022917a3f1e0] [framesync @ 022917a2e608] Sync level 1
[swscaler @ 022918081100] Forcing full internal H chroma due to
input having non subsampled chroma
[Parsed_scale_5 @ 022917a3e820] w:640 h:480 fmt:rgb24 sar:1/1 ->
w:1536 h:512 fmt:rgba sar:4/9 flags:0x2
[Parsed_vstack_6 @ 022917a3ed00] [framesync @ 0229177dd5c8]
Selected 1/100 time base
[Parsed_vstack_6 @ 022917a3ed00] [framesync @ 0229177dd5c8] Sync level 1
[sdl,sdl2 @ 022917a4df40] w:1536 h:1024 fmt:rgba -> w:1536 h:1024

I hope this information might 

[FFmpeg-devel] [PATCH] Add FITS Decoder

2017-08-06 Thread Paras Chadha
Signed-off-by: Paras Chadha 
---
Made the changes suggested.
Added a new file fits.c with common code

 Changelog   |   1 +
 doc/general.texi|   2 +
 libavcodec/Makefile |   2 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/avcodec.h|   1 +
 libavcodec/codec_desc.c |   7 ++
 libavcodec/fits.c   | 203 +++
 libavcodec/fits.h   |  79 
 libavcodec/fitsdec.c| 318 
 libavcodec/version.h|   2 +-
 10 files changed, 615 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/fits.c
 create mode 100644 libavcodec/fits.h
 create mode 100644 libavcodec/fitsdec.c

diff --git a/Changelog b/Changelog
index c797d68..61414f8 100644
--- a/Changelog
+++ b/Changelog
@@ -32,6 +32,7 @@ version :
 - unpremultiply video filter
 - tlut2 video filter
 - floodfill video filter
+- FITS demuxer and decoder

 version 3.3:
 - CrystalHD decoder moved to new decode API
diff --git a/doc/general.texi b/doc/general.texi
index 036c8c2..01402cb 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -592,6 +592,8 @@ following image formats are supported:
 @tab Digital Picture Exchange
 @item EXR  @tab   @tab X
 @tab OpenEXR
+@item FITS @tab   @tab X
+@tab Flexible Image Transport System
 @item JPEG @tab X @tab X
 @tab Progressive JPEG is not supported.
 @item JPEG 2000@tab X @tab X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index b0c39ac..42eec07 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -291,6 +291,7 @@ OBJS-$(CONFIG_FFV1_DECODER)+= ffv1dec.o ffv1.o
 OBJS-$(CONFIG_FFV1_ENCODER)+= ffv1enc.o ffv1.o
 OBJS-$(CONFIG_FFWAVESYNTH_DECODER) += ffwavesynth.o
 OBJS-$(CONFIG_FIC_DECODER) += fic.o
+OBJS-$(CONFIG_FITS_DECODER)+= fitsdec.o fits.o
 OBJS-$(CONFIG_FLAC_DECODER)+= flacdec.o flacdata.o flac.o
 OBJS-$(CONFIG_FLAC_ENCODER)+= flacenc.o flacdata.o flac.o 
vorbis_data.o
 OBJS-$(CONFIG_FLASHSV_DECODER) += flashsv.o
@@ -846,6 +847,7 @@ OBJS-$(CONFIG_ISO_MEDIA)   += mpeg4audio.o 
mpegaudiodata.o
 OBJS-$(CONFIG_ADTS_MUXER)  += mpeg4audio.o
 OBJS-$(CONFIG_CAF_DEMUXER) += ac3tab.o
 OBJS-$(CONFIG_DNXHD_DEMUXER)   += dnxhddata.o
+OBJS-$(CONFIG_FITS_DEMUXER)+= fits.o
 OBJS-$(CONFIG_FLV_DEMUXER) += mpeg4audio.o
 OBJS-$(CONFIG_LATM_MUXER)  += mpeg4audio.o
 OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER)+= mpeg4audio.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 4712592..8678ac2 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -192,6 +192,7 @@ static void register_all(void)
 REGISTER_ENCDEC (FFV1,  ffv1);
 REGISTER_ENCDEC (FFVHUFF,   ffvhuff);
 REGISTER_DECODER(FIC,   fic);
+REGISTER_DECODER(FITS,  fits);
 REGISTER_ENCDEC (FLASHSV,   flashsv);
 REGISTER_ENCDEC (FLASHSV2,  flashsv2);
 REGISTER_DECODER(FLIC,  flic);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index c594993..b28002f 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -447,6 +447,7 @@ enum AVCodecID {
 AV_CODEC_ID_SRGC,
 AV_CODEC_ID_SVG,
 AV_CODEC_ID_GDV,
+AV_CODEC_ID_FITS,

 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
start of audio codecs
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 6f43b68..2fea680 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1464,6 +1464,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
  AV_CODEC_PROP_LOSSLESS,
 },
 {
+.id= AV_CODEC_ID_FITS,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "fits",
+.long_name = NULL_IF_CONFIG_SMALL("FITS image"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+},
+{
 .id= AV_CODEC_ID_GIF,
 .type  = AVMEDIA_TYPE_VIDEO,
 .name  = "gif",
diff --git a/libavcodec/fits.c b/libavcodec/fits.c
new file mode 100644
index 000..fc6fd03
--- /dev/null
+++ b/libavcodec/fits.c
@@ -0,0 +1,203 @@
+/*
+ * FITS implementation of common functions
+ * Copyright (c) 2017 Paras Chadha
+ *
+ * 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 

Re: [FFmpeg-devel] [PATCH] Add FITS Demuxer

2017-08-06 Thread Paras Chadha
On Sun, Aug 6, 2017 at 5:27 PM, Nicolas George  wrote:

> Le duodi 12 thermidor, an CCXXV, Paras Chadha a écrit :
> > But i am returning the size from this function. If i make them unsigned,
> > how will i return errors which are negative integers.
> > One thing i can do is pass data_size as pointer to the function. Should i
> > do that ?
>
> No need: you can make the variables unsigned and still return them as
> signed. The error codes never go into the variables.
>

In order to simplify the loop in read_packet, i have passed pointer to size
as an argument.
Also renamed the function to is_image.


>
> > > Use the correct bound, long is wrong.
> > okay, i was actually confused regarding the correct bound. So should i
> use
> > INT_MAX as it is the default value max_alloc_size. Since i am adding 2879
> > at the end, so correct limiting value would be INT_MAX - 2879. Am i
> correct
> > or should i use something else ?
>
> You have to use the constant that corresponds to the types in the
> computation. If it is int, then INT_MAX, int64_t wants INT64_MAX and
> size_t wants SIZE_MAX.
>

okay


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


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


[FFmpeg-devel] [PATCH] Add FITS Demuxer

2017-08-06 Thread Paras Chadha
Signed-off-by: Paras Chadha 
---
Made changes suggested.
Refactored Code

 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/fitsdec.c| 231 +++
 libavformat/version.h|   2 +-
 4 files changed, 234 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/fitsdec.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index b0ef82c..266b77a 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -164,6 +164,7 @@ OBJS-$(CONFIG_FFMETADATA_MUXER)  += ffmetaenc.o
 OBJS-$(CONFIG_FIFO_MUXER)+= fifo.o
 OBJS-$(CONFIG_FILMSTRIP_DEMUXER) += filmstripdec.o
 OBJS-$(CONFIG_FILMSTRIP_MUXER)   += filmstripenc.o
+OBJS-$(CONFIG_FITS_DEMUXER)  += fitsdec.o
 OBJS-$(CONFIG_FLAC_DEMUXER)  += flacdec.o rawdec.o \
 flac_picture.o   \
 oggparsevorbis.o \
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 1ebc142..3c12760 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -121,6 +121,7 @@ static void register_all(void)
 REGISTER_MUXDEMUX(FFMETADATA,   ffmetadata);
 REGISTER_MUXER   (FIFO, fifo);
 REGISTER_MUXDEMUX(FILMSTRIP,filmstrip);
+REGISTER_DEMUXER (FITS, fits);
 REGISTER_MUXDEMUX(FLAC, flac);
 REGISTER_DEMUXER (FLIC, flic);
 REGISTER_MUXDEMUX(FLV,  flv);
diff --git a/libavformat/fitsdec.c b/libavformat/fitsdec.c
new file mode 100644
index 000..4b288b3
--- /dev/null
+++ b/libavformat/fitsdec.c
@@ -0,0 +1,231 @@
+/*
+ * FITS demuxer
+ * Copyright (c) 2017 Paras Chadha
+ *
+ * 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
+ */
+
+/**
+ * @file
+ * FITS demuxer.
+ */
+
+#include "libavutil/intreadwrite.h"
+#include "internal.h"
+#include "libavutil/opt.h"
+#include "libavcodec/fits.h"
+#include "libavutil/bprint.h"
+
+#define FITS_BLOCK_SIZE 2880
+
+typedef struct FITSContext {
+const AVClass *class;
+AVRational framerate;
+int first_image;
+int64_t pts;
+} FITSContext;
+
+static int fits_probe(AVProbeData *p)
+{
+const uint8_t *b = p->buf;
+if (!memcmp(b, "SIMPLE  =T", 30))
+return AVPROBE_SCORE_MAX - 1;
+return 0;
+}
+
+static int fits_read_header(AVFormatContext *s)
+{
+AVStream *st;
+FITSContext * fits = s->priv_data;
+
+st = avformat_new_stream(s, NULL);
+if (!st)
+return AVERROR(ENOMEM);
+
+st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+st->codecpar->codec_id = AV_CODEC_ID_FITS;
+
+avpriv_set_pts_info(st, 64, fits->framerate.den, fits->framerate.num);
+fits->pts = 0;
+fits->first_image = 1;
+return 0;
+}
+
+/**
+ * Parses header and checks that the current HDU contains image or not
+ * It also stores the header in the avbuf and stores the size of data part in 
data_size
+ * @param s pointer to AVFormat Context
+ * @param fits pointer to FITSContext
+ * @param header pointer to FITSHeader
+ * @param avbuf pointer to AVBPrint to store the header
+ * @param data_size to store the size of data part
+ * @return 1 if image found, 0 if any other extension and AVERROR_INVALIDDATA 
otherwise
+ */
+static int64_t is_image(AVFormatContext *s, FITSContext *fits, FITSHeader 
*header,
+ AVBPrint *avbuf, uint64_t *data_size)
+{
+int i, ret, image = 0;
+char buf[FITS_BLOCK_SIZE] = { 0 };
+int64_t buf_size = 0, size = 0, t;
+
+do {
+ret = avio_read(s->pb, buf, FITS_BLOCK_SIZE);
+if (ret < 0) {
+return ret;
+} else if (ret < FITS_BLOCK_SIZE) {
+return AVERROR_INVALIDDATA;
+}
+
+av_bprint_append_data(avbuf, buf, FITS_BLOCK_SIZE);
+ret = 0;
+buf_size = 0;
+while(!ret && buf_size < FITS_BLOCK_SIZE) {
+ret = avpriv_fits_header_parse_line(s, header, buf + buf_size, 
NULL);
+buf_size += 80;
+}
+} while (!ret);
+if (ret < 0)
+return ret;
+
+image = fits->first_image || header->image_extension;
+fits->first_image = 0;
+
+if (header->groups) {
+image = 0;
+ 

[FFmpeg-devel] [PATCH] avcodec/mpeg4videodec: Clear mcsel before decoding an image

2017-08-06 Thread Michael Niedermayer
Fixes: runtime error: signed integer overflow: 2146467840 + 1032192 cannot be 
represented in type 'int'
Fixes: 2826/clusterfuzz-testcase-minimized-5901511613743104

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/mpeg4videodec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 89c4b367f7..8f85e9362d 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -2290,6 +2290,7 @@ static int decode_vop_header(Mpeg4DecContext *ctx, 
GetBitContext *gb)
 int time_incr, time_increment;
 int64_t pts;
 
+s->mcsel   = 0;
 s->pict_type = get_bits(gb, 2) + AV_PICTURE_TYPE_I;/* pict type: I 
= 0 , P = 1 */
 if (s->pict_type == AV_PICTURE_TYPE_B && s->low_delay &&
 ctx->vol_control_parameters == 0 && !(s->avctx->flags & 
AV_CODEC_FLAG_LOW_DELAY)) {
-- 
2.13.0

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


[FFmpeg-devel] [PATCH 1/2]v2 Add macros used in opus_pvq_search to x86util.asm

2017-08-06 Thread Ivan Kalvachev
On 8/6/17, Henrik Gramner  wrote:
> On Sat, Aug 5, 2017 at 9:10 PM, Ivan Kalvachev  wrote:
>> +%macro VBROADCASTSS 2 ; dst xmm/ymm, src m32/xmm
>> +%if cpuflag(avx2)
>> +vbroadcastss  %1, %2; ymm, xmm
>> +%elif cpuflag(avx)
>> +%ifnum sizeof%2 ; avx1 register
>> +vpermilps  xmm%1, xmm%2, q  ; xmm, xmm, imm || ymm, ymm,
>> imm
>
> Nit: Use shufps instead of vpermilps, it's one byte shorter but
> otherwise identical in this case.
>
> c5 e8 c6 ca 00vshufps xmm1,xmm2,xmm2,0x0
> c4 e3 79 04 ca 00 vpermilps xmm1,xmm2,0x0

It's also 1 latency cycle less on some old AMD cpu's.

Done.


>> +%macro BLENDVPS 3 ; dst/src_a, src_b, mask
>> +%if cpuflag(avx)
>> +blendvps  %1, %1, %2, %3
>> +%elif cpuflag(sse4)
>> +%if notcpuflag(avx)
>> +%ifnidn %3,xmm0
>> +%error sse41 blendvps uses xmm0 as default 3d operand, you
>> used %3
>> +%endif
>> +%endif
>
> notcpuflag(avx) is redundant (it's always true since AVX uses the first
> branch).

Done.

This is a remnant from the time I had label to turn on and off
different implementations.


Best Regards

 ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
From a43da9061c08dcf4cb6ecd7c8eaad074cdb551d1 Mon Sep 17 00:00:00 2001
From: Ivan Kalvachev 
Date: Sat, 5 Aug 2017 20:18:50 +0300
Subject: [PATCH 1/6] Add macros to x86util.asm .

Improved version of VBROADCASTSS that works like the avx2 instruction.
Emulation of vpbroadcastd.
Horizontal sum HSUMPS that places the result in all elements.
Emulation of blendvps and pblendvb.

Signed-off-by: Ivan Kalvachev 
---
 libavutil/x86/x86util.asm | 106 ++
 1 file changed, 98 insertions(+), 8 deletions(-)

diff --git a/libavutil/x86/x86util.asm b/libavutil/x86/x86util.asm
index cc7d272cad..e1220dfc1a 100644
--- a/libavutil/x86/x86util.asm
+++ b/libavutil/x86/x86util.asm
@@ -832,14 +832,25 @@
 pmaxsd  %1, %2
 %endmacro
 
-%macro VBROADCASTSS 2 ; dst xmm/ymm, src m32
-%if cpuflag(avx)
-vbroadcastss %1, %2
-%else ; sse
-%ifnidn %1, %2
-movss%1, %2
-%endif
-shufps   %1, %1, 0
+%macro VBROADCASTSS 2 ; dst xmm/ymm, src m32/xmm
+%if cpuflag(avx2)
+vbroadcastss  %1, %2
+%elif cpuflag(avx)
+%ifnum sizeof%2 ; avx1 register
+shufps  xmm%1, xmm%2, xmm%2, q
+%if sizeof%1 >= 32  ; mmsize>=32
+vinsertf128  %1, %1, xmm%1, 1
+%endif
+%else   ; avx1 memory
+vbroadcastss  %1, %2
+%endif
+%else
+%ifnum sizeof%2 ; sse register
+shufps  %1, %2, %2, q
+%else   ; sse memory
+movss   %1, %2
+shufps  %1, %1, 0
+%endif
 %endif
 %endmacro
 
@@ -854,6 +865,21 @@
 %endif
 %endmacro
 
+%macro VPBROADCASTD 2 ; dst xmm/ymm, src m32/xmm
+%if cpuflag(avx2)
+vpbroadcastd  %1, %2
+%elif cpuflag(avx) && sizeof%1 >= 32
+%error vpbroadcastd not possible with ymm on avx1. try vbroadcastss
+%else
+%ifnum sizeof%2 ; sse2 register
+pshufd  %1, %2, q
+%else   ; sse memory
+movd%1, %2
+pshufd  %1, %1, 0
+%endif
+%endif
+%endmacro
+
 %macro SHUFFLE_MASK_W 8
 %rep 8
 %if %1>=0x80
@@ -918,3 +944,67 @@
 movhlps%1, %2; may cause an int/float domain transition and has a dependency on dst
 %endif
 %endmacro
+
+; Horizontal Sum of Packed Single precision floats
+; The resulting sum is in all elements.
+%macro HSUMPS 2 ; dst/src, tmp
+%if cpuflag(avx)
+%if sizeof%1>=32  ; avx
+vperm2f128  %2, %1, %1, (0)*16+(1)
+addps   %1, %2
+%endif
+shufps  %2, %1, %1, q1032
+addps   %1, %2
+shufps  %2, %1, %1, q0321
+addps   %1, %2
+%else  ; this form is a bit faster than the short avx-like emulation.
+movaps  %2, %1
+shufps  %1, %1, q1032
+addps   %1, %2
+movaps  %2, %1
+shufps  %1, %1, q0321
+addps   %1, %2
+; all %1 members should be equal for as long as float a+b==b+a
+%endif
+%endmacro
+
+; Emulate blendvps if not available
+;
+; src_b is destroyed when using emulation with logical operands
+; SSE41 blendv instruction is hard coded to use xmm0 as mask
+%macro BLENDVPS 3 ; dst/src_a, src_b, mask
+%if cpuflag(avx)
+blendvps  %1, %1, %2, %3
+%elif cpuflag(sse4)
+%ifnidn %3,xmm0
+%error sse41 blendvps uses xmm0 as default 3d operand, you used %3
+%endif
+blendvps  %1, %2, %3
+%else
+xorps  %2, %1
+andps  %2, %3
+xorps  %1, %2
+%endif
+%endmacro
+
+; Emulate pblendvb if not available
+;
+; src_b is destroyed when using emulation with logical operands
+; SSE41 blendv instruction is hard coded to use xmm0 as mask
+%macro PBLENDVB 3 ; dst/src_a, src_b, mask
+%if cpuflag(avx)
+%if cpuflag(avx) && notcpuflag(avx2) && sizeof%1 >= 32
+%error

Re: [FFmpeg-devel] [PATCH] Add FITS Decoder

2017-08-06 Thread Nicolas George
Le duodi 12 thermidor, an CCXXV, Paras Chadha a écrit :
> > > +if (strncmp(keyword, "BITPIX", 6)) {
> > > +av_log(avcl, AV_LOG_ERROR, "expected BITPIX keyword,
> > found %s = %s\n", keyword, value);
> > > +return AVERROR_INVALIDDATA;
> > > +}
> > > +
> >
> > > +if (sscanf(value, "%d", &header->bitpix) != 1) {
> > > +av_log(avcl, AV_LOG_ERROR, "invalid value of BITPIX
> > keyword, %s = %s\n", keyword, value);
> > > +return AVERROR_INVALIDDATA;
> > > +}

> Do you mean i should add checking of keyword and value in single if using
> && ?

No, I meant that you could have a function or a macro that parses the
value as an integer, prints the error and returns, all in one step.
Possibly the keyword in the same step, depending on how many you have.

> Yes, i know about this. This version is the correct one to use. Actually,
> for the image, ascii table extensions these keywords should be present
> after NAXISN only and in that order only. But in binary table and groups
> structure there may be other keywords after NAXISN and before PCOUNT,
> GCOUNT. Here it will enter PCOUNT state only when image extension is there.
> Otherwise these keywords will be parsed in the REST state.

You do not need to validate the order of the fields in the demuxer: you
can just parse everything in REST. If it comes in the correct order, it
works, if it comes in the incorrect order, it works too and that is not
a problem.

> Since a common function is made, i have to include them here too for ascii,
> binary table extensions etc. That is why they are checked only when image
> extension is not there.

There is no need to parse them twice: just store the value in an
integer, and once it is finished check that integer only if needed.

> ok, so should i use SIZE_MAX = INT_MAX - 2879 ?

See my other mail: it depends on the type in the computation.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH] Add FITS Demuxer

2017-08-06 Thread Nicolas George
Le duodi 12 thermidor, an CCXXV, Paras Chadha a écrit :
> But i am returning the size from this function. If i make them unsigned,
> how will i return errors which are negative integers.
> One thing i can do is pass data_size as pointer to the function. Should i
> do that ?

No need: you can make the variables unsigned and still return them as
signed. The error codes never go into the variables.

> > Use the correct bound, long is wrong.
> okay, i was actually confused regarding the correct bound. So should i use
> INT_MAX as it is the default value max_alloc_size. Since i am adding 2879
> at the end, so correct limiting value would be INT_MAX - 2879. Am i correct
> or should i use something else ?

You have to use the constant that corresponds to the types in the
computation. If it is int, then INT_MAX, int64_t wants INT64_MAX and
size_t wants SIZE_MAX.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH]v6 Opus Pyramid Vector Quantization Search in x86 SIMD asm

2017-08-06 Thread Henrik Gramner
On Sat, Aug 5, 2017 at 12:58 AM, Ivan Kalvachev  wrote:
> 8 packed, 8 scalar.
>
> Unless I miss something (and as I've said before,
> I'm not confident enough to mess with that code.)
>
> (AVX does extend to 32 variants, but they are not
> SSE compatible, so no need to emulate them.)

Oh, right. I quickly glanced at the docs and saw 32 pseudo-ops for
each instruction for a total of 128 when adding pd, ps, sd, ss, but
the fact that only the first 8 is relevant here reduces it to 32 which
is a lot more manageable.

> movaps m1, [WRT_PIC_BASE + const_2 + r2 ]
>
> Looks better. (Also not tested. Will do, later.)

I intentionally used the WRT define at the end because that's most
similar to the built in wrt syntax used when accessing symbols through
the PLT or GOT, e.g.

mov eax, [external_symbol wrt ..got]

> Yeh $$ is the start of the current section, and that's is going to be
> ".text"  not "rodata".

Obviously, yes. You need a reference that results in a compile-time
constant PC-offset (which .rodata isn't) to create PC-relative
relocation records to external symbols.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add macros used in opus_pvq_search to x86util.asm

2017-08-06 Thread Henrik Gramner
On Sat, Aug 5, 2017 at 9:10 PM, Ivan Kalvachev  wrote:
> +%macro VBROADCASTSS 2 ; dst xmm/ymm, src m32/xmm
> +%if cpuflag(avx2)
> +vbroadcastss  %1, %2; ymm, xmm
> +%elif cpuflag(avx)
> +%ifnum sizeof%2 ; avx1 register
> +vpermilps  xmm%1, xmm%2, q  ; xmm, xmm, imm || ymm, ymm, imm

Nit: Use shufps instead of vpermilps, it's one byte shorter but
otherwise identical in this case.

c5 e8 c6 ca 00vshufps xmm1,xmm2,xmm2,0x0
c4 e3 79 04 ca 00 vpermilps xmm1,xmm2,0x0

> +%macro BLENDVPS 3 ; dst/src_a, src_b, mask
> +%if cpuflag(avx)
> +blendvps  %1, %1, %2, %3
> +%elif cpuflag(sse4)
> +%if notcpuflag(avx)
> +%ifnidn %3,xmm0
> +%error sse41 blendvps uses xmm0 as default 3d operand, you used 
> %3
> +%endif
> +%endif

notcpuflag(avx) is redundant (it's always true since AVX uses the first branch).
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] doc/filters: document the unstability of the shorthand options notation.

2017-08-06 Thread Nicolas George
L'octidi 18 thermidor, an CCXXV, James Almer a écrit :
> What do you mean? What i suggested would be done each time an option is
> removed or added anywhere but at the end, both of which afaik are
> uncommon cases.
> It's not something that requires a rewrite of the current codebase.

I mean that since I consider the break bearable (somebody upgrades a
piece of software, they MUST test the scripts that depend on it, and
fixing the issue once and for all is easy), I am not willing to spend my
time implementing (and testing, for this kind of thing that takes time)
the deprecation-warning-and-backward-compatibility dance.

Therefore, I think anybody opposing that change has three choices:
propose a solution (possibly a patch) that does not require extra work,
present or future, from the lavfi maintainers; own up that they are
blocking progress in the lavfi cleanup; or yield.

Note: to help the transition, I am perfectly willing to write a
ChangeLog entry, that does not take much time:

- The order of options in filters is no longer considered stable. If
  long-term stability is necessary (i.e. for scripts), use named options
  (e.g. overlay=50:100 -> overlay=x=50:y=100).

We have caused much more severe breakage in the past (especially
considering that only minor options change, and they were usually set by
name anyway), and ones that were much harder to fix.

Regards,

-- 
  Nicolas George


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


[FFmpeg-devel] [PATCH] ffprobe: fix use of uninitialized variable

2017-08-06 Thread Zhao Zhili
---
 ffprobe.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ffprobe.c b/ffprobe.c
index f22c4f57ad..ac9ff051fa 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -3328,6 +3328,7 @@ static int parse_read_interval(const char
*interval_spec,
 }
 interval->end = lli;
 } else {
+interval->duration_frames = 0;
 ret = av_parse_time(&us, p, 1);
 if (ret < 0) {
 av_log(NULL, AV_LOG_ERROR, "Invalid interval end/duration
specification '%s'\n", p);
@@ -3337,6 +3338,7 @@ static int parse_read_interval(const char
*interval_spec,
 }
 } else {
 interval->has_end = 0;
+interval->duration_frames = 0;
 }

 end:
@@ -3357,7 +3359,7 @@ static int parse_read_intervals(const char
*intervals_spec)
 n++;
 n++;

-read_intervals = av_malloc_array(n, sizeof(*read_intervals));
+read_intervals = av_mallocz_array(n, sizeof(*read_intervals));
 if (!read_intervals) {
 ret = AVERROR(ENOMEM);
 goto end;
-- 
2.13.2


0001-ffprobe-fix-use-of-uninitialized-variable.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v3] libaf/hlsenc: allow dynamic encryption key rotation

2017-08-06 Thread Steven Liu
2017-08-05 18:14 GMT+08:00 DeHackEd :
> Makes behaviour of 805ce25b1d2f optional, re-enables
> HLS key rotation feature
>
> Signed-off-by: DHE 
> ---
>  doc/muxers.texi  | 7 ++-
>  libavformat/hlsenc.c | 4 +++-
>  2 files changed, 9 insertions(+), 2 deletions(-)
>
> v1->v2: Actually works this time
>
> v2->v3: Documentation fix, parameter reference was incorrect
>
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index 94472ce..2bec5f8 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -551,7 +551,7 @@ format. The optional third line specifies the 
> initialization vector (IV) as a
>  hexadecimal string to be used instead of the segment sequence number 
> (default)
>  for encryption. Changes to @var{key_info_file} will result in segment
>  encryption with the new key/IV and an entry in the playlist for the new key
> -URI/IV.
> +URI/IV if @code{hls_flags periodic_rekey} is enabled.
>
>  Key info file format:
>  @example
> @@ -665,6 +665,11 @@ first segment's information.
>  @item omit_endlist
>  Do not append the @code{EXT-X-ENDLIST} tag at the end of the playlist.
>
> +@item periodic_rekey
> +The file specified by @code{hls_key_info_file} will be checked periodically 
> and
> +detect updates to the encryption info. Be sure to replace this file 
> atomically,
> +including the file containing the AES encryption key.
> +
>  @item split_by_time
>  Allow segments to start on frames other than keyframes. This improves
>  behavior on some players when the time between keyframes is inconsistent,
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 5cf8c89..74a3249 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -85,6 +85,7 @@ typedef enum HLSFlags {
>  HLS_SECOND_LEVEL_SEGMENT_DURATION = (1 << 9), // include segment 
> duration (microsec) in segment filenames when use_localtime  e.g.: %%09t
>  HLS_SECOND_LEVEL_SEGMENT_SIZE = (1 << 10), // include segment size 
> (bytes) in segment filenames when use_localtime  e.g.: %%014s
>  HLS_TEMP_FILE = (1 << 11),
> +HLS_PERIODIC_REKEY = (1 << 12),
>  } HLSFlags;
>
>  typedef enum {
> @@ -1236,7 +1237,7 @@ static int hls_start(AVFormatContext *s)
>" will use -hls_key_info_file priority\n");
>  }
>
> -if (c->number <= 1) {
> +if (c->number <= 1 || (c->flags & HLS_PERIODIC_REKEY)) {
>  if (c->key_info_file) {
>  if ((err = hls_encryption_start(s)) < 0)
>  goto fail;
> @@ -1804,6 +1805,7 @@ static const AVOption options[] = {
>  {"second_level_segment_index", "include segment index in segment 
> filenames when use_localtime", 0, AV_OPT_TYPE_CONST, {.i64 = 
> HLS_SECOND_LEVEL_SEGMENT_INDEX }, 0, UINT_MAX,   E, "flags"},
>  {"second_level_segment_duration", "include segment duration in segment 
> filenames when use_localtime", 0, AV_OPT_TYPE_CONST, {.i64 = 
> HLS_SECOND_LEVEL_SEGMENT_DURATION }, 0, UINT_MAX,   E, "flags"},
>  {"second_level_segment_size", "include segment size in segment filenames 
> when use_localtime", 0, AV_OPT_TYPE_CONST, {.i64 = 
> HLS_SECOND_LEVEL_SEGMENT_SIZE }, 0, UINT_MAX,   E, "flags"},
> +{"periodic_rekey", "reload keyinfo file periodically for re-keying", 0, 
> AV_OPT_TYPE_CONST, {.i64 = HLS_PERIODIC_REKEY }, 0, UINT_MAX,   E, "flags"},
>  {"use_localtime", "set filename expansion with strftime at segment 
> creation", OFFSET(use_localtime), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
>  {"use_localtime_mkdir", "create last directory component in 
> strftime-generated filename", OFFSET(use_localtime_mkdir), AV_OPT_TYPE_BOOL, 
> {.i64 = 0 }, 0, 1, E },
>  {"hls_playlist_type", "set the HLS playlist type", OFFSET(pl_type), 
> AV_OPT_TYPE_INT, {.i64 = PLAYLIST_TYPE_NONE }, 0, PLAYLIST_TYPE_NB-1, E, 
> "pl_type" },
> --
> 1.8.4.1
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Applied!


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