Re: [FFmpeg-devel] [PATCH] avformat/flvdec: don't propagate empty extradata

2018-08-24 Thread Paul B Mahol
On 8/24/18, James Almer  wrote:
> Fixes ticket #7379
>
> Signed-off-by: James Almer 
> ---
>  libavformat/flvdec.c | 6 ++
>  1 file changed, 6 insertions(+)
>

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


Re: [FFmpeg-devel] [PATCH V2] avcodec/h264_mp4toannexb_bsf: add No IDR frame situation

2018-08-24 Thread Fu, Linjie
-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of 
Michael Niedermayer
Sent: Friday, August 24, 2018 05:30
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] [PATCH V2] avcodec/h264_mp4toannexb_bsf: add No IDR 
frame situation

On Thu, Aug 16, 2018 at 03:07:50PM +0800, Linjie Fu wrote:
> Fix the live stream encoding problem using qsv when the first frame is 
> not an IDR frame.
> 
> Add the extradata information when the IDR frame is missing in the 
> first GOP.
> 
> Fix the bug reported in  ticket #6418.
> 
> [PATCH V2] Fix the coding style.
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/h264_mp4toannexb_bsf.c | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/libavcodec/h264_mp4toannexb_bsf.c 
> b/libavcodec/h264_mp4toannexb_bsf.c
> index 794c82e650..fbb9f1fe20 100644
> --- a/libavcodec/h264_mp4toannexb_bsf.c
> +++ b/libavcodec/h264_mp4toannexb_bsf.c
> @@ -33,6 +33,7 @@ typedef struct H264BSFContext {
>  int32_t  pps_offset;
>  uint8_t  length_size;
>  uint8_t  new_idr;
> +uint8_t  new_nal_slice;
>  uint8_t  idr_sps_seen;
>  uint8_t  idr_pps_seen;
>  int  extradata_parsed;
> @@ -243,6 +244,7 @@ static int h264_mp4toannexb_filter(AVBSFContext *ctx, 
> AVPacket *out)
> buf, nal_size, 1)) < 0)
>  goto fail;
>  s->new_idr = 0;
> +s->new_nal_slice = 1;
>  /* if only SPS has been seen, also insert PPS */
>  } else if (s->new_idr && unit_type == H264_NAL_IDR_SLICE && 
> s->idr_sps_seen && !s->idr_pps_seen) {
>  if (s->pps_offset == -1) { @@ -253,6 +255,12 @@ static 
> int h264_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out)
>  ctx->par_out->extradata + 
> s->pps_offset, ctx->par_out->extradata_size - s->pps_offset,
>  buf, nal_size, 1)) < 0)
>  goto fail;
> +} else if (s->new_idr && !s->new_nal_slice && H264_NAL_SLICE == 
> unit_type && !s->idr_sps_seen && !s->idr_pps_seen){
> +av_log(ctx, AV_LOG_WARNING, "first H264_NAL_SLICE when there is 
> no IDR.\n");
> +if ((ret = alloc_and_copy(out, ctx->par_out->extradata, 
> ctx->par_out->extradata_size, buf, nal_size, 1)) < 0)
> +goto fail;
> +s->new_nal_slice = 1;
> +s->new_idr = 0;

The commit message is insufficient
this adds the extradata if new_idr is set not just in the absence of IDR at the 
begin

also teh addded code is identical to the first if() just a different NAL is 
checked for, this code duplication is not a good idea in already complex code

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When you are offended at any man's fault, turn to yourself and study your own 
failings. Then you will forget your anger. -- Epictetus


Thanks for your review. 
I will adjust the code to reduce the duplication and make the commit message 
clearer.

I add " new_nal_slice " to indicate the newly coming H264_NAL_IDR_SLICE and 
H264_NAL_SLICE, because the new_idr is always "1" at the beginning of the 
filter regardless of the nal type of slice.  

This patch aims at the following issues:
1. the IDR frame is missing in the  first GOP of a stream (common in live 
stream, IDR.No.Inband.SPPS.mkv in ticket #6418)
2.  there is no IDR frame in the input stream.  (No.Inband.SPPS.No.IDR.mkv​ in 
ticket #6418)
In issue 1,  ffmpeg just drop all the frames in the first GOP without the patch 
then continue to decode the following frames. (qsv and libopenh264)
In issue 2,  ffmpeg could not decode any frames of the stream through 
h264_mp4toannexb_filter without the patch. (qsv and libopenh264)
After applying  this patch, all the frames could be decoded correctly  in both 
issues.  (qsv works well, libopenh264 has to check the slice_nal_type in the 
decode step in addition to the h264_mp4toannexb_filter, still can't decode.)

Thanks again.

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


Re: [FFmpeg-devel] [PATCH] lavf/mpegts: improve read error handling

2018-08-24 Thread Hendrik Leppkes
On Fri, Aug 24, 2018 at 5:01 AM myp...@gmail.com  wrote:
>
> On Fri, Aug 24, 2018 at 5:38 AM Rodger Combs  wrote:
> >
> > We previously could fail to check errors entirely, or misinterpret read
> errors
> > as normal EOFs.
> > ---
> >  libavformat/mpegts.c | 13 +++--
> >  1 file changed, 11 insertions(+), 2 deletions(-)
> >
> > diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> > index 37a6aa8bff..1350213d39 100644
> > --- a/libavformat/mpegts.c
> > +++ b/libavformat/mpegts.c
> > @@ -2475,6 +2475,8 @@ static int mpegts_resync(AVFormatContext *s, int
> seekback, const uint8_t *curren
> >
> >  for (i = 0; i < ts->resync_size; i++) {
> >  c = avio_r8(pb);
> > +if (pb->error)
> > +return pb->error;
> >  if (avio_feof(pb))
> >  return AVERROR_EOF;
> >  if (c == 0x47) {
> > @@ -2498,8 +2500,13 @@ static int read_packet(AVFormatContext *s, uint8_t
> *buf, int raw_packet_size,
> >
> >  for (;;) {
> >  len = ffio_read_indirect(pb, buf, TS_PACKET_SIZE, data);
> > -if (len != TS_PACKET_SIZE)
> > -return len < 0 ? len : AVERROR_EOF;
> > +if (len != TS_PACKET_SIZE) {
> > +if (len < 0)
> > +return len;
> > +if (pb->error)
> > +return pb->error;
> > +return AVERROR_EOF;
> > +}
> >  /* check packet sync byte */
> >  if ((*data)[0] != 0x47) {
> >  /* find a new packet start */
> > @@ -2670,6 +2677,8 @@ static int mpegts_read_header(AVFormatContext *s)
> >  /* read the first 8192 bytes to get packet size */
> >  pos = avio_tell(pb);
> >  len = avio_read(pb, buf, sizeof(buf));
> > +if (len < 0)
> > +return len;
> >  ts->raw_packet_size = get_packet_size(buf, len);
> >  if (ts->raw_packet_size <= 0) {
> >  av_log(s, AV_LOG_WARNING, "Could not detect TS packet size,
> defaulting to non-FEC/DVHS\n");
> > --
> As I understand, only after avio_xxx return < 0 to check pb->error, now we
> coding like:
>len = avio_xxx(pb);
>if (len < 0)
> return len;
> if (pb->error)
> return pb->error;
>
> It's stranger way for me, consider Unix API read(2), we just check the
> error after -1 is returned
> (
> http://man7.org/linux/man-pages/man2/read.2.html
> )
>
> we usually catch the error
> / error
> number like:
>

The reason for this is to be able to differentiate between EOF and
read errors. In case of a read error, partial data may still be
returned, and any short read is otherwise considered EOF before this
patch.
The alternative to this would be checking pb->eof_reached, which would
do the same thing,  just flip the logic on its head.

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


Re: [FFmpeg-devel] [PATCH 2/2] avformat/movenc: support Opus packets with more than 60ms of audio when writing the Sample Group Description Box

2018-08-24 Thread Carl Eugen Hoyos
2018-08-24 0:17 GMT+02:00, James Almer :
> Fixes assertion failures when trying to mux such streams.

Shouldn't this be 1/2?

And does this assert now for libavformat users that use
new libopus (but not libavcodec) or do I misunderstand?

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


Re: [FFmpeg-devel] swscale : add bitexact conv for grayf32 and gray16 to f32 conv

2018-08-24 Thread Martin Vignali
Updated patch in attach

001 and 002 : unchanged
003 : update from prev 003 : change in lut generation : move coeff calc
outside the loop, and avoid "i - min_loop" calc.
004 : update from prev 004 : change in lut generation : avoid "i -
min_loop" calc.

Martin


0002-swscale-unscale-add-bitexact-conversion-for-float-to.patch
Description: Binary data


0003-swscale-add-bit_exact-lut-creation-for-8bit-to-float.patch
Description: Binary data


0001-swscale-input-add-bit_exact-for-float-to-uint16-conv.patch
Description: Binary data


0004-swscale-swscale_unscaled-add-conversion-from-gray16-.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] avformat/movenc: support Opus packets with more than 60ms of audio when writing the Sample Group Description Box

2018-08-24 Thread Carl Eugen Hoyos
2018-08-24 17:31 GMT+02:00, James Almer :
> On 8/24/2018 7:19 AM, Carl Eugen Hoyos wrote:
>> 2018-08-24 0:17 GMT+02:00, James Almer :
>>> Fixes assertion failures when trying to mux such streams.
>>
>> Shouldn't this be 1/2?
>>
>> And does this assert now for libavformat users that use
>> new libopus (but not libavcodec) or do I misunderstand?
>
> This asserts for any stream with >= 80ms packets. It doesn't need to be
> a direct encode from the libopus wrapper, since it can also happen
> during be a remux.

Doesn't this indicate that the assert is wrong?
(That invalid input can trigger the assert)

Sorry if I misunderstand, Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/vf_interlace: fix numerical options

2018-08-24 Thread Paul B Mahol
On 8/23/18, Thomas Mundt  wrote:
> Currently numerical option values are misinterpreted in vf_interlace
> filter.
> Patch attached.
>
> Regards,
> Thomas
>

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


Re: [FFmpeg-devel] [PATCH 2/2] avformat/movenc: support Opus packets with more than 60ms of audio when writing the Sample Group Description Box

2018-08-24 Thread James Almer
On 8/24/2018 7:19 AM, Carl Eugen Hoyos wrote:
> 2018-08-24 0:17 GMT+02:00, James Almer :
>> Fixes assertion failures when trying to mux such streams.
> 
> Shouldn't this be 1/2?
> 
> And does this assert now for libavformat users that use
> new libopus (but not libavcodec) or do I misunderstand?

This asserts for any stream with >= 80ms packets. It doesn't need to be
a direct encode from the libopus wrapper, since it can also happen
during be a remux. So the order these two patches are committed doesn't
really matter.

But if you prefer, i can swap them before pushing.

> 
> Carl Eugen
> ___
> 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] [PATCH] avcodec/utils: document allocation requirement of extradata

2018-08-24 Thread James Almer
On 8/24/2018 2:59 PM, Timo Rothenpieler wrote:
> ---
>  libavcodec/avcodec.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 31e50d5a94..5ec7a2430b 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -1616,6 +1616,7 @@ typedef struct AVCodecContext {
>   * The allocated memory should be AV_INPUT_BUFFER_PADDING_SIZE bytes 
> larger
>   * than extradata_size to avoid problems if it is read with the 
> bitstream reader.
>   * The bytewise contents of extradata must not depend on the 
> architecture or CPU endianness.
> + * Must be allocated with av_malloc() in any case.

Use "Must be allocated with the av_malloc() family of functions"
instead. That's what's used in the doxy for other functions.

>   * - encoding: Set/allocated/freed by libavcodec.
>   * - decoding: Set/allocated/freed by user.
>   */
> 

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


[FFmpeg-devel] [PATCH] avcodec/utils: document allocation requirement of extradata

2018-08-24 Thread Timo Rothenpieler
---
 libavcodec/avcodec.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 31e50d5a94..2c5e78c88d 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1616,6 +1616,7 @@ typedef struct AVCodecContext {
  * The allocated memory should be AV_INPUT_BUFFER_PADDING_SIZE bytes larger
  * than extradata_size to avoid problems if it is read with the bitstream 
reader.
  * The bytewise contents of extradata must not depend on the architecture 
or CPU endianness.
+ * Must be allocated with the av_malloc() family of functions.
  * - encoding: Set/allocated/freed by libavcodec.
  * - decoding: Set/allocated/freed by user.
  */
-- 
2.17.0

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


[FFmpeg-devel] [PATCH] avcodec: add MatchWare Screen Capture Codec

2018-08-24 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/Makefile |   1 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/avcodec.h|   1 +
 libavcodec/codec_desc.c |   7 ++
 libavcodec/mwsc.c   | 174 
 libavformat/riff.c  |   1 +
 6 files changed, 185 insertions(+)
 create mode 100644 libavcodec/mwsc.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 9a309c348e..aee4f5431a 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -482,6 +482,7 @@ OBJS-$(CONFIG_MSZH_DECODER)+= lcldec.o
 OBJS-$(CONFIG_MTS2_DECODER)+= mss4.o
 OBJS-$(CONFIG_MVC1_DECODER)+= mvcdec.o
 OBJS-$(CONFIG_MVC2_DECODER)+= mvcdec.o
+OBJS-$(CONFIG_MWSC_DECODER)+= mwsc.o
 OBJS-$(CONFIG_MXPEG_DECODER)   += mxpegdec.o
 OBJS-$(CONFIG_NELLYMOSER_DECODER)  += nellymoserdec.o nellymoser.o
 OBJS-$(CONFIG_NELLYMOSER_ENCODER)  += nellymoserenc.o nellymoser.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index b1d1ef26c0..d41868c591 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -212,6 +212,7 @@ extern AVCodec ff_mszh_decoder;
 extern AVCodec ff_mts2_decoder;
 extern AVCodec ff_mvc1_decoder;
 extern AVCodec ff_mvc2_decoder;
+extern AVCodec ff_mwsc_decoder;
 extern AVCodec ff_mxpeg_decoder;
 extern AVCodec ff_nuv_decoder;
 extern AVCodec ff_paf_video_decoder;
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 2a4be2ca4f..b327284449 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -449,6 +449,7 @@ enum AVCodecID {
 AV_CODEC_ID_FITS,
 AV_CODEC_ID_IMM4,
 AV_CODEC_ID_PROSUMER,
+AV_CODEC_ID_MWSC,
 
 /* 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 e611183599..129d0f1aac 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1668,6 +1668,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("Brooktree ProSumer Video"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
 },
+{
+.id= AV_CODEC_ID_MWSC,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "mwsc",
+.long_name = NULL_IF_CONFIG_SMALL("MatchWare Screen Capture Codec"),
+.props = AV_CODEC_PROP_LOSSLESS,
+},
 
 /* various PCM "codecs" */
 {
diff --git a/libavcodec/mwsc.c b/libavcodec/mwsc.c
new file mode 100644
index 00..5ae8330500
--- /dev/null
+++ b/libavcodec/mwsc.c
@@ -0,0 +1,174 @@
+/*
+ * MatchWare Screen Capture Codec decoder
+ *
+ * Copyright (c) 2018 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 
+#include 
+#include 
+
+#include "avcodec.h"
+#include "bytestream.h"
+#include "internal.h"
+
+#include 
+
+typedef struct MWSCContext {
+unsigned  bpp;
+unsigned int  decomp_size;
+uint8_t  *decomp_buf;
+unsigned int  uncomp_size;
+uint8_t  *uncomp_buf;
+z_stream  zstream;
+} MWSCContext;
+
+static int rle_uncompress(AVCodecContext *avctx, GetByteContext *gb, 
PutByteContext *pb, int bpp)
+{
+int intra = 1;
+
+while (bytestream2_get_bytes_left(gb) > 0) {
+uint32_t fill = bytestream2_get_le24(gb);
+unsigned run = bytestream2_get_byte(gb);
+int j;
+
+if (run == 0) {
+run = bytestream2_get_le32(gb);
+for (j = 0; j < run; j++) {
+bytestream2_put_le24(pb, fill);
+}
+} else if (run == 255) {
+bytestream2_skip_p(pb, fill * 3);
+intra = 0;
+} else {
+for (j = 0; j < run; j++) {
+bytestream2_put_le24(pb, fill);
+}
+}
+}
+
+return intra;
+}
+
+static int decode_frame(AVCodecContext *avctx,
+void *data, int *got_frame,
+AVPacket *avpkt)
+{
+MWSCContext *s = avctx->priv_data;
+AVFrame *frame = data;
+uint8_t *buf = avpkt->data;
+int buf_size = avpkt->size;
+GetByteContext gb;
+PutByteContext pb;
+int ret, j;
+
+ret = 

Re: [FFmpeg-devel] [PATCH 2/2] avformat/movenc: support Opus packets with more than 60ms of audio when writing the Sample Group Description Box

2018-08-24 Thread Nicolas George
James Almer (2018-08-24):
> Invalid input (say, a packet reporting a frame size of the equivalent of
> 1ms) would assert before and after this patch. Do you consider an assert
> that triggers on invalid input to be wrong? I thought that was the
> entire point of one...

Assert failures cause an immediate exit and core dump. If a crafted
input can trigger a failure and crash the application, that is a serious
problem. Asserts are there to catch bugs.

> If you prefer i can remove the entire assert altogether. Or maybe
> replace it with a normal check that returns an error instead.

If you just remove the assert, then the invalid value is passed to the
rest of the code. You know better than me how it will react to it.

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 v2] avformat/movenc: implicitly enable negative CTS offsets for ismv

2018-08-24 Thread Jan Ekström
On Sun, Aug 5, 2018 at 6:31 AM Jan Ekström  wrote:
> Hi,
>
> Since this fixes b-frames in ISMV by not adding a double-delay (tfxd
> PTS + positive CTS offset), unless someone has any comments I will
> push this tonight (JST).
>
> Best regards,
> Jan

Pushed as 1931761f18cda3756a27087c366270c38160c754 .

Had it verified that FATE now fully passes (I didn't happen to have
the full FATE set around).

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


Re: [FFmpeg-devel] [PATCH] avcodec: add MatchWare Screen Capture Codec

2018-08-24 Thread Paul B Mahol
On 8/24/18, James Almer  wrote:
> On 8/24/2018 3:48 PM, Paul B Mahol wrote:
>> Signed-off-by: Paul B Mahol 
>> ---
>>  libavcodec/Makefile |   1 +
>>  libavcodec/allcodecs.c  |   1 +
>>  libavcodec/avcodec.h|   1 +
>>  libavcodec/codec_desc.c |   7 ++
>>  libavcodec/mwsc.c   | 174 
>>  libavformat/riff.c  |   1 +
>>  6 files changed, 185 insertions(+)
>>  create mode 100644 libavcodec/mwsc.c
>>

[...]

>> +
>> +s->decomp_size = 8 * avctx->height * ((avctx->width *
>> avctx->bits_per_coded_sample + 31) / 32);
>
> avctx->height and avctx->width are not checked for sane values. And even
> then, couldn't this overflow?
>

What you propose as solution? IIRC width/height are already checked at
higher level,
no need to check them again because we do not change them here.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] avformat/movenc: support Opus packets with more than 60ms of audio when writing the Sample Group Description Box

2018-08-24 Thread Hendrik Leppkes
On Fri, Aug 24, 2018 at 5:53 PM James Almer  wrote:
>
> On 8/24/2018 12:47 PM, Carl Eugen Hoyos wrote:
> > 2018-08-24 17:41 GMT+02:00, James Almer :
> >> On 8/24/2018 12:33 PM, Carl Eugen Hoyos wrote:
> >>> 2018-08-24 17:31 GMT+02:00, James Almer :
>  On 8/24/2018 7:19 AM, Carl Eugen Hoyos wrote:
> > 2018-08-24 0:17 GMT+02:00, James Almer :
> >> Fixes assertion failures when trying to mux such streams.
> >
> > Shouldn't this be 1/2?
> >
> > And does this assert now for libavformat users that use
> > new libopus (but not libavcodec) or do I misunderstand?
> 
>  This asserts for any stream with >= 80ms packets. It doesn't need to be
>  a direct encode from the libopus wrapper, since it can also happen
>  during be a remux.
> >>>
> >>> Doesn't this indicate that the assert is wrong?
> >>> (That invalid input can trigger the assert)
> >>
> >> Invalid input (say, a packet reporting a frame size of the equivalent of
> >> 1ms) would assert before and after this patch. Do you consider an assert
> >> that triggers on invalid input to be wrong?
> >
> > I wanted to write "definitely", I am a little puzzled now that you seem to
> > disagree.
> >
> > Yes, I think so: It probably depends on the definition of "invalid" but
> > I mean invalid data with valid api usage.
> >
> > Carl Eugen
>
> I am completely lost in this discussion since i don't understand your
> concern about this at all, so please tell me what you want me to do so
> we can move on: Do i commit the patch as is, do i remove the assert line
> altogether, or do i replace it with a normal check?

asserts should guard against errors made by developers, invalid
internal API use, verifying assumptions made about how an API is being
used, and things like that.
File data should never be checked with an assert, because you can then
abort the process with a crafted file.

So I would suggest to replace it with a normal if check.

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


Re: [FFmpeg-devel] [PATCH] lavf/mpegts: improve read error handling

2018-08-24 Thread Rodger Combs


> On Aug 24, 2018, at 03:44, Hendrik Leppkes  wrote:
> 
> On Fri, Aug 24, 2018 at 5:01 AM myp...@gmail.com  
> mailto:myp...@gmail.com>> wrote:
>> 
>> On Fri, Aug 24, 2018 at 5:38 AM Rodger Combs  wrote:
>>> 
>>> We previously could fail to check errors entirely, or misinterpret read
>> errors
>>> as normal EOFs.
>>> ---
>>> libavformat/mpegts.c | 13 +++--
>>> 1 file changed, 11 insertions(+), 2 deletions(-)
>>> 
>>> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
>>> index 37a6aa8bff..1350213d39 100644
>>> --- a/libavformat/mpegts.c
>>> +++ b/libavformat/mpegts.c
>>> @@ -2475,6 +2475,8 @@ static int mpegts_resync(AVFormatContext *s, int
>> seekback, const uint8_t *curren
>>> 
>>> for (i = 0; i < ts->resync_size; i++) {
>>> c = avio_r8(pb);
>>> +if (pb->error)
>>> +return pb->error;
>>> if (avio_feof(pb))
>>> return AVERROR_EOF;
>>> if (c == 0x47) {
>>> @@ -2498,8 +2500,13 @@ static int read_packet(AVFormatContext *s, uint8_t
>> *buf, int raw_packet_size,
>>> 
>>> for (;;) {
>>> len = ffio_read_indirect(pb, buf, TS_PACKET_SIZE, data);
>>> -if (len != TS_PACKET_SIZE)
>>> -return len < 0 ? len : AVERROR_EOF;
>>> +if (len != TS_PACKET_SIZE) {
>>> +if (len < 0)
>>> +return len;
>>> +if (pb->error)
>>> +return pb->error;
>>> +return AVERROR_EOF;
>>> +}
>>> /* check packet sync byte */
>>> if ((*data)[0] != 0x47) {
>>> /* find a new packet start */
>>> @@ -2670,6 +2677,8 @@ static int mpegts_read_header(AVFormatContext *s)
>>> /* read the first 8192 bytes to get packet size */
>>> pos = avio_tell(pb);
>>> len = avio_read(pb, buf, sizeof(buf));
>>> +if (len < 0)
>>> +return len;
>>> ts->raw_packet_size = get_packet_size(buf, len);
>>> if (ts->raw_packet_size <= 0) {
>>> av_log(s, AV_LOG_WARNING, "Could not detect TS packet size,
>> defaulting to non-FEC/DVHS\n");
>>> --
>> As I understand, only after avio_xxx return < 0 to check pb->error, now we
>> coding like:
>>   len = avio_xxx(pb);
>>   if (len < 0)
>>return len;
>>if (pb->error)
>>return pb->error;
>> 
>> It's stranger way for me, consider Unix API read(2), we just check the
>> error after -1 is returned
>> (
>> http://man7.org/linux/man-pages/man2/read.2.html
>> )
>> 
>> we usually catch the error
>> / error
>> number like:
>> 
> 
> The reason for this is to be able to differentiate between EOF and
> read errors. In case of a read error, partial data may still be
> returned, and any short read is otherwise considered EOF before this
> patch.
> The alternative to this would be checking pb->eof_reached, which would
> do the same thing,  just flip the logic on its head.

I'd actually sort of prefer that, since it'd let me call avio_feof() instead of 
doing a direct member access, but it turns out that eof_reached is set to 1 in 
error cases as well.

> 
> - Hendrik
> ___
> 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


[FFmpeg-devel] [PATCH] Support 64-bit integers for av_get_frame_filename2()

2018-08-24 Thread Devin Heitmueller
Create a new av_get_frame_filename3() API which is just like the
previous version but accepts a 64-bit integer for the "number"
argument.  This is useful in cases where you want to put the
original PTS into the filename (which can be larger than 32-bits).

Tested with:

./ffmpeg -copyts -vsync 0 -i foo.ts -frame_pts 1 -enc_time_base -1 foo_%d.png

Signed-off-by: Devin Heitmueller 
---
 libavformat/avformat.h | 2 ++
 libavformat/img2enc.c  | 2 +-
 libavformat/utils.c| 9 +++--
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index fdaffa5bf4..c358a9a71e 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2896,6 +2896,8 @@ void av_dump_format(AVFormatContext *ic,
  * @param flags AV_FRAME_FILENAME_FLAGS_*
  * @return 0 if OK, -1 on format error
  */
+int av_get_frame_filename3(char *buf, int buf_size,
+  const char *path, int64_t number, int flags);
 int av_get_frame_filename2(char *buf, int buf_size,
   const char *path, int number, int flags);
 
diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index a09cc8ec50..414eb827e2 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -101,7 +101,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
 return AVERROR(EINVAL);
 }
 } else if (img->frame_pts) {
-if (av_get_frame_filename2(filename, sizeof(filename), img->path, 
pkt->pts, AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) {
+if (av_get_frame_filename3(filename, sizeof(filename), img->path, 
pkt->pts, AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) {
 av_log(s, AV_LOG_ERROR, "Cannot write filename by pts of the 
frames.");
 return AVERROR(EINVAL);
 }
diff --git a/libavformat/utils.c b/libavformat/utils.c
index b0b5e164a6..d9d4d38a44 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4666,7 +4666,7 @@ uint64_t ff_get_formatted_ntp_time(uint64_t ntp_time_us)
 return ntp_ts;
 }
 
-int av_get_frame_filename2(char *buf, int buf_size, const char *path, int 
number, int flags)
+int av_get_frame_filename3(char *buf, int buf_size, const char *path, int64_t 
number, int flags)
 {
 const char *p;
 char *q, buf1[20], c;
@@ -4696,7 +4696,7 @@ int av_get_frame_filename2(char *buf, int buf_size, const 
char *path, int number
 percentd_found = 1;
 if (number < 0)
 nd += 1;
-snprintf(buf1, sizeof(buf1), "%0*d", nd, number);
+snprintf(buf1, sizeof(buf1), "%0*" PRId64, nd, number);
 len = strlen(buf1);
 if ((q - buf + len) > buf_size - 1)
 goto fail;
@@ -4721,6 +4721,11 @@ fail:
 return -1;
 }
 
+int av_get_frame_filename2(char *buf, int buf_size, const char *path, int 
number, int flags)
+{
+return av_get_frame_filename3(buf, buf_size, path, number, flags);
+}
+
 int av_get_frame_filename(char *buf, int buf_size, const char *path, int 
number)
 {
 return av_get_frame_filename2(buf, buf_size, path, number, 0);
-- 
2.13.2

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


Re: [FFmpeg-devel] [PATCH] avcodec: add MatchWare Screen Capture Codec

2018-08-24 Thread James Almer
On 8/24/2018 3:48 PM, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavcodec/Makefile |   1 +
>  libavcodec/allcodecs.c  |   1 +
>  libavcodec/avcodec.h|   1 +
>  libavcodec/codec_desc.c |   7 ++
>  libavcodec/mwsc.c   | 174 
>  libavformat/riff.c  |   1 +
>  6 files changed, 185 insertions(+)
>  create mode 100644 libavcodec/mwsc.c
> 
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 9a309c348e..aee4f5431a 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -482,6 +482,7 @@ OBJS-$(CONFIG_MSZH_DECODER)+= lcldec.o
>  OBJS-$(CONFIG_MTS2_DECODER)+= mss4.o
>  OBJS-$(CONFIG_MVC1_DECODER)+= mvcdec.o
>  OBJS-$(CONFIG_MVC2_DECODER)+= mvcdec.o
> +OBJS-$(CONFIG_MWSC_DECODER)+= mwsc.o
>  OBJS-$(CONFIG_MXPEG_DECODER)   += mxpegdec.o
>  OBJS-$(CONFIG_NELLYMOSER_DECODER)  += nellymoserdec.o nellymoser.o
>  OBJS-$(CONFIG_NELLYMOSER_ENCODER)  += nellymoserenc.o nellymoser.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index b1d1ef26c0..d41868c591 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -212,6 +212,7 @@ extern AVCodec ff_mszh_decoder;
>  extern AVCodec ff_mts2_decoder;
>  extern AVCodec ff_mvc1_decoder;
>  extern AVCodec ff_mvc2_decoder;
> +extern AVCodec ff_mwsc_decoder;
>  extern AVCodec ff_mxpeg_decoder;
>  extern AVCodec ff_nuv_decoder;
>  extern AVCodec ff_paf_video_decoder;
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 2a4be2ca4f..b327284449 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -449,6 +449,7 @@ enum AVCodecID {
>  AV_CODEC_ID_FITS,
>  AV_CODEC_ID_IMM4,
>  AV_CODEC_ID_PROSUMER,
> +AV_CODEC_ID_MWSC,
>  
>  /* 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 e611183599..129d0f1aac 100644
> --- a/libavcodec/codec_desc.c
> +++ b/libavcodec/codec_desc.c
> @@ -1668,6 +1668,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
>  .long_name = NULL_IF_CONFIG_SMALL("Brooktree ProSumer Video"),
>  .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
>  },
> +{
> +.id= AV_CODEC_ID_MWSC,
> +.type  = AVMEDIA_TYPE_VIDEO,
> +.name  = "mwsc",
> +.long_name = NULL_IF_CONFIG_SMALL("MatchWare Screen Capture Codec"),
> +.props = AV_CODEC_PROP_LOSSLESS,
> +},
>  
>  /* various PCM "codecs" */
>  {
> diff --git a/libavcodec/mwsc.c b/libavcodec/mwsc.c
> new file mode 100644
> index 00..5ae8330500
> --- /dev/null
> +++ b/libavcodec/mwsc.c
> @@ -0,0 +1,174 @@
> +/*
> + * MatchWare Screen Capture Codec decoder
> + *
> + * Copyright (c) 2018 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 
> +#include 
> +#include 
> +
> +#include "avcodec.h"
> +#include "bytestream.h"
> +#include "internal.h"
> +
> +#include 

Needs a zlib dependency in configure, then.

> +
> +typedef struct MWSCContext {
> +unsigned  bpp;
> +unsigned int  decomp_size;
> +uint8_t  *decomp_buf;
> +unsigned int  uncomp_size;
> +uint8_t  *uncomp_buf;
> +z_stream  zstream;
> +} MWSCContext;
> +
> +static int rle_uncompress(AVCodecContext *avctx, GetByteContext *gb, 
> PutByteContext *pb, int bpp)
> +{
> +int intra = 1;
> +
> +while (bytestream2_get_bytes_left(gb) > 0) {
> +uint32_t fill = bytestream2_get_le24(gb);
> +unsigned run = bytestream2_get_byte(gb);
> +int j;
> +
> +if (run == 0) {
> +run = bytestream2_get_le32(gb);
> +for (j = 0; j < run; j++) {
> +bytestream2_put_le24(pb, fill);
> +}
> +} else if (run == 255) {
> +bytestream2_skip_p(pb, fill * 3);
> +intra = 0;
> +} else {
> +for (j = 0; j < run; j++) {
> +bytestream2_put_le24(pb, fill);
> +}
> +}
> +}
> +
> +return intra;

Re: [FFmpeg-devel] [PATCH 2/2] avformat/movenc: support Opus packets with more than 60ms of audio when writing the Sample Group Description Box

2018-08-24 Thread James Almer
On 8/24/2018 12:33 PM, Carl Eugen Hoyos wrote:
> 2018-08-24 17:31 GMT+02:00, James Almer :
>> On 8/24/2018 7:19 AM, Carl Eugen Hoyos wrote:
>>> 2018-08-24 0:17 GMT+02:00, James Almer :
 Fixes assertion failures when trying to mux such streams.
>>>
>>> Shouldn't this be 1/2?
>>>
>>> And does this assert now for libavformat users that use
>>> new libopus (but not libavcodec) or do I misunderstand?
>>
>> This asserts for any stream with >= 80ms packets. It doesn't need to be
>> a direct encode from the libopus wrapper, since it can also happen
>> during be a remux.
> 
> Doesn't this indicate that the assert is wrong?
> (That invalid input can trigger the assert)

Invalid input (say, a packet reporting a frame size of the equivalent of
1ms) would assert before and after this patch. Do you consider an assert
that triggers on invalid input to be wrong? I thought that was the
entire point of one...

If you prefer i can remove the entire assert altogether. Or maybe
replace it with a normal check that returns an error instead. Otherwise
I'm not sure what's your concern.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] avformat/movenc: support Opus packets with more than 60ms of audio when writing the Sample Group Description Box

2018-08-24 Thread James Almer
On 8/24/2018 12:47 PM, Carl Eugen Hoyos wrote:
> 2018-08-24 17:41 GMT+02:00, James Almer :
>> On 8/24/2018 12:33 PM, Carl Eugen Hoyos wrote:
>>> 2018-08-24 17:31 GMT+02:00, James Almer :
 On 8/24/2018 7:19 AM, Carl Eugen Hoyos wrote:
> 2018-08-24 0:17 GMT+02:00, James Almer :
>> Fixes assertion failures when trying to mux such streams.
>
> Shouldn't this be 1/2?
>
> And does this assert now for libavformat users that use
> new libopus (but not libavcodec) or do I misunderstand?

 This asserts for any stream with >= 80ms packets. It doesn't need to be
 a direct encode from the libopus wrapper, since it can also happen
 during be a remux.
>>>
>>> Doesn't this indicate that the assert is wrong?
>>> (That invalid input can trigger the assert)
>>
>> Invalid input (say, a packet reporting a frame size of the equivalent of
>> 1ms) would assert before and after this patch. Do you consider an assert
>> that triggers on invalid input to be wrong?
> 
> I wanted to write "definitely", I am a little puzzled now that you seem to
> disagree.
> 
> Yes, I think so: It probably depends on the definition of "invalid" but
> I mean invalid data with valid api usage.
> 
> Carl Eugen

I am completely lost in this discussion since i don't understand your
concern about this at all, so please tell me what you want me to do so
we can move on: Do i commit the patch as is, do i remove the assert line
altogether, or do i replace it with a normal check?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] avformat/movenc: support Opus packets with more than 60ms of audio when writing the Sample Group Description Box

2018-08-24 Thread Carl Eugen Hoyos
2018-08-24 17:41 GMT+02:00, James Almer :
> On 8/24/2018 12:33 PM, Carl Eugen Hoyos wrote:
>> 2018-08-24 17:31 GMT+02:00, James Almer :
>>> On 8/24/2018 7:19 AM, Carl Eugen Hoyos wrote:
 2018-08-24 0:17 GMT+02:00, James Almer :
> Fixes assertion failures when trying to mux such streams.

 Shouldn't this be 1/2?

 And does this assert now for libavformat users that use
 new libopus (but not libavcodec) or do I misunderstand?
>>>
>>> This asserts for any stream with >= 80ms packets. It doesn't need to be
>>> a direct encode from the libopus wrapper, since it can also happen
>>> during be a remux.
>>
>> Doesn't this indicate that the assert is wrong?
>> (That invalid input can trigger the assert)
>
> Invalid input (say, a packet reporting a frame size of the equivalent of
> 1ms) would assert before and after this patch. Do you consider an assert
> that triggers on invalid input to be wrong?

I wanted to write "definitely", I am a little puzzled now that you seem to
disagree.

Yes, I think so: It probably depends on the definition of "invalid" but
I mean invalid data with valid api usage.

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


Re: [FFmpeg-devel] [PATCH 1/9] configure: [loongson] revert no-expensive-optimizations

2018-08-24 Thread Shiyou Yin
rom: ffmpeg-devel-boun...@ffmpeg.org [mailto:ffmpeg-devel-boun...@ffmpeg.org] 
On Behalf Of
>Michael Niedermayer
>Sent: Thursday, August 23, 2018 3:27 AM
>To: FFmpeg development discussions and patches
>Subject: Re: [FFmpeg-devel] [PATCH 1/9] configure: [loongson] revert 
>no-expensive-optimizations
>
>On Wed, Aug 22, 2018 at 06:11:15PM +0800, Shiyou Yin wrote:
>> >-Original Message-
>> >From: ffmpeg-devel-boun...@ffmpeg.org
>> >[mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Michael
>> >Niedermayer
>> >Sent: Wednesday, August 22, 2018 6:04 AM
>> >To: FFmpeg development discussions and patches
>> >Subject: Re: [FFmpeg-devel] [PATCH 1/9] configure: [loongson] revert
>> >no-expensive-optimizations
>> >
>> >On Tue, Aug 21, 2018 at 04:06:05PM +0800, Shiyou Yin wrote:
>> >> >-Original Message-
>> >> >From: ffmpeg-devel-boun...@ffmpeg.org
>> >> >[mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Shiyou Yin
>> >> >Sent: Thursday, July 12, 2018 8:44 PM
>> >> >To: ffmpeg-devel@ffmpeg.org
>> >> >Subject: [FFmpeg-devel] [PATCH 1/9] configure: [loongson] revert
>> >> >no-expensive-optimizations
>> >> >
>> >> >The bug in  gcc-4.9.x has been fixed in gcc master branch.
>> >> >Loongson released gcc-4.9.3-3.fc21.loongson with this patch.
>> >> >More bug info see:
>> >> >https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67736
>> >> >https://gcc.gnu.org/ml/gcc-patches/2012-05/msg00401.html
>> >> >
>> >> >Change-Id: I780125d4cdee71d40457aaee22126ba0547a2c8f
>> >> >Signed-off-by: Shiyou Yin 
>> >> >---
>> >> > configure | 6 +++---
>> >> > 1 file changed, 3 insertions(+), 3 deletions(-)
>> >> >
>> >> >diff --git a/configure b/configure index b1a4dcf..17a7ea9 100755
>> >> >--- a/configure
>> >> >+++ b/configure
>> >> >@@ -4789,13 +4789,13 @@ elif enabled mips; then
>> >> > disable mipsdspr2
>> >> > case $cpu in
>> >> > loongson3*)
>> >> >-cpuflags="-march=loongson3a -mhard-float
>> >-fno-expensive-optimizations"
>> >> >+cpuflags="-march=loongson3a -mhard-float"
>> >> > ;;
>> >> > loongson2e)
>> >> >-cpuflags="-march=loongson2e -mhard-float
>> >-fno-expensive-optimizations"
>> >> >+cpuflags="-march=loongson2e -mhard-float"
>> >> > ;;
>> >> > loongson2f)
>> >> >-cpuflags="-march=loongson2f -mhard-float
>> >-fno-expensive-optimizations"
>> >> >+cpuflags="-march=loongson2f -mhard-float"
>> >> > ;;
>> >> > esac
>> >> > ;;
>> >> >--
>> >> >2.1.0
>> >> >
>> >>
>> >> Hi Michael, could you please help to apply this patch. It has been tested 
>> >> on loongson
platform.
>> >
>> >shouldnt this test the compiler the user uses ? its version or something ?
>> >
>> Thank you very much for your review. Be strictly, it's needed to check
>> the compiler version which user uses.
>> Consider that this bug has been fixed about three years and the
>> compiler has been upgraded a lot of times in loongson yum repository.
>> At present, there are still only a few developers will build ffmpeg on
>> loongson platform. The risk of his change is controllable.
>> So, between the simplicity and absolute reliability of the code I chosed the 
>> simplicity this
time.
>> Should I still add version check here?
>
>I think there should maybe be a check for the minimum gcc version supported 
>then to ensure that no
too
>old version is used. If you do not want to add teh flag for specific versions 
>The effect of the bug
was IIRC
>not trivial to connect to the gcc version so it could leave a developer quite 
>lost and confused
what is
>causing it
>

Hi Michael, please help to review the following updates.


diff --git a/configure b/configure
index b9c9d0b..08cf48e 100755
--- a/configure
+++ b/configure
@@ -4796,15 +4796,24 @@ elif enabled mips; then
 disable mipsfpu
 disable mipsdsp
 disable mipsdspr2
+# When gcc version less than 5.3.0, add 
-fno-expensive-optimizations flag.
+if [ $cc == gcc ]; then
+gcc_version=$(gcc -dumpversion)
+if [ "$(echo "$gcc_version 5.3.0" | tr " " "\n" | sort -rV 
| head -n 1)" ==
"$gcc_version" ]; then
+expensive_optimization_flag=""
+else
+
expensive_optimization_flag="-fno-expensive-optimizations"
+fi
+fi
 case $cpu in
 loongson3*)
-cpuflags="-march=loongson3a -mhard-float 
-fno-expensive-optimizations"
+cpuflags="-march=loongson3a -mhard-float 
$expensive_optimization_flag"
 ;;
 loongson2e)
-cpuflags="-march=loongson2e 

Re: [FFmpeg-devel] [PATCH 1/9] configure: [loongson] revert no-expensive-optimizations

2018-08-24 Thread Michael Niedermayer
On Sat, Aug 25, 2018 at 12:19:40AM +0800, Shiyou Yin wrote:
> rom: ffmpeg-devel-boun...@ffmpeg.org [mailto:ffmpeg-devel-boun...@ffmpeg.org] 
> On Behalf Of
> >Michael Niedermayer
> >Sent: Thursday, August 23, 2018 3:27 AM
> >To: FFmpeg development discussions and patches
> >Subject: Re: [FFmpeg-devel] [PATCH 1/9] configure: [loongson] revert 
> >no-expensive-optimizations
> >
> >On Wed, Aug 22, 2018 at 06:11:15PM +0800, Shiyou Yin wrote:
> >> >-Original Message-
> >> >From: ffmpeg-devel-boun...@ffmpeg.org
> >> >[mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Michael
> >> >Niedermayer
> >> >Sent: Wednesday, August 22, 2018 6:04 AM
> >> >To: FFmpeg development discussions and patches
> >> >Subject: Re: [FFmpeg-devel] [PATCH 1/9] configure: [loongson] revert
> >> >no-expensive-optimizations
> >> >
> >> >On Tue, Aug 21, 2018 at 04:06:05PM +0800, Shiyou Yin wrote:
> >> >> >-Original Message-
> >> >> >From: ffmpeg-devel-boun...@ffmpeg.org
> >> >> >[mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Shiyou Yin
> >> >> >Sent: Thursday, July 12, 2018 8:44 PM
> >> >> >To: ffmpeg-devel@ffmpeg.org
> >> >> >Subject: [FFmpeg-devel] [PATCH 1/9] configure: [loongson] revert
> >> >> >no-expensive-optimizations
> >> >> >
> >> >> >The bug in  gcc-4.9.x has been fixed in gcc master branch.
> >> >> >Loongson released gcc-4.9.3-3.fc21.loongson with this patch.
> >> >> >More bug info see:
> >> >> >https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67736
> >> >> >https://gcc.gnu.org/ml/gcc-patches/2012-05/msg00401.html
> >> >> >
> >> >> >Change-Id: I780125d4cdee71d40457aaee22126ba0547a2c8f
> >> >> >Signed-off-by: Shiyou Yin 
> >> >> >---
> >> >> > configure | 6 +++---
> >> >> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >> >> >
> >> >> >diff --git a/configure b/configure index b1a4dcf..17a7ea9 100755
> >> >> >--- a/configure
> >> >> >+++ b/configure
> >> >> >@@ -4789,13 +4789,13 @@ elif enabled mips; then
> >> >> > disable mipsdspr2
> >> >> > case $cpu in
> >> >> > loongson3*)
> >> >> >-cpuflags="-march=loongson3a -mhard-float
> >> >-fno-expensive-optimizations"
> >> >> >+cpuflags="-march=loongson3a -mhard-float"
> >> >> > ;;
> >> >> > loongson2e)
> >> >> >-cpuflags="-march=loongson2e -mhard-float
> >> >-fno-expensive-optimizations"
> >> >> >+cpuflags="-march=loongson2e -mhard-float"
> >> >> > ;;
> >> >> > loongson2f)
> >> >> >-cpuflags="-march=loongson2f -mhard-float
> >> >-fno-expensive-optimizations"
> >> >> >+cpuflags="-march=loongson2f -mhard-float"
> >> >> > ;;
> >> >> > esac
> >> >> > ;;
> >> >> >--
> >> >> >2.1.0
> >> >> >
> >> >>
> >> >> Hi Michael, could you please help to apply this patch. It has been 
> >> >> tested on loongson
> platform.
> >> >
> >> >shouldnt this test the compiler the user uses ? its version or something ?
> >> >
> >> Thank you very much for your review. Be strictly, it's needed to check
> >> the compiler version which user uses.
> >> Consider that this bug has been fixed about three years and the
> >> compiler has been upgraded a lot of times in loongson yum repository.
> >> At present, there are still only a few developers will build ffmpeg on
> >> loongson platform. The risk of his change is controllable.
> >> So, between the simplicity and absolute reliability of the code I chosed 
> >> the simplicity this
> time.
> >> Should I still add version check here?
> >
> >I think there should maybe be a check for the minimum gcc version supported 
> >then to ensure that no
> too
> >old version is used. If you do not want to add teh flag for specific 
> >versions The effect of the bug
> was IIRC
> >not trivial to connect to the gcc version so it could leave a developer 
> >quite lost and confused
> what is
> >causing it
> >
> 
> Hi Michael, please help to review the following updates.
> 
> 
> diff --git a/configure b/configure
> index b9c9d0b..08cf48e 100755
> --- a/configure
> +++ b/configure
> @@ -4796,15 +4796,24 @@ elif enabled mips; then
>  disable mipsfpu
>  disable mipsdsp
>  disable mipsdspr2
> +# When gcc version less than 5.3.0, add 
> -fno-expensive-optimizations flag.
> +if [ $cc == gcc ]; then
> +gcc_version=$(gcc -dumpversion)
> +if [ "$(echo "$gcc_version 5.3.0" | tr " " "\n" | sort 
> -rV | head -n 1)" ==
> "$gcc_version" ]; then
> +expensive_optimization_flag=""
> +else
> +
> expensive_optimization_flag="-fno-expensive-optimizations"
> +fi
> +fi

This patch looks corrupted (by a newline)

[...]

-- 
Michael GnuPG 

Re: [FFmpeg-devel] [PATCH] Support 64-bit integers for av_get_frame_filename2()

2018-08-24 Thread James Almer
On 8/24/2018 3:56 PM, Devin Heitmueller wrote:
> Create a new av_get_frame_filename3() API which is just like the
> previous version but accepts a 64-bit integer for the "number"
> argument.  This is useful in cases where you want to put the
> original PTS into the filename (which can be larger than 32-bits).
> 
> Tested with:
> 
> ./ffmpeg -copyts -vsync 0 -i foo.ts -frame_pts 1 -enc_time_base -1 foo_%d.png
> 
> Signed-off-by: Devin Heitmueller 
> ---
>  libavformat/avformat.h | 2 ++
>  libavformat/img2enc.c  | 2 +-
>  libavformat/utils.c| 9 +++--
>  3 files changed, 10 insertions(+), 3 deletions(-)

Missing APIChanges entry and libavformat minor version bump.

> 
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index fdaffa5bf4..c358a9a71e 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -2896,6 +2896,8 @@ void av_dump_format(AVFormatContext *ic,
>   * @param flags AV_FRAME_FILENAME_FLAGS_*
>   * @return 0 if OK, -1 on format error
>   */
> +int av_get_frame_filename3(char *buf, int buf_size,
> +  const char *path, int64_t number, int flags);

Make buf_size of size_t type while at it.

>  int av_get_frame_filename2(char *buf, int buf_size,
>const char *path, int number, int flags);
>  
> diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
> index a09cc8ec50..414eb827e2 100644
> --- a/libavformat/img2enc.c
> +++ b/libavformat/img2enc.c
> @@ -101,7 +101,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
>  return AVERROR(EINVAL);
>  }
>  } else if (img->frame_pts) {
> -if (av_get_frame_filename2(filename, sizeof(filename), 
> img->path, pkt->pts, AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) {
> +if (av_get_frame_filename3(filename, sizeof(filename), 
> img->path, pkt->pts, AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0) {
>  av_log(s, AV_LOG_ERROR, "Cannot write filename by pts of the 
> frames.");
>  return AVERROR(EINVAL);
>  }
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index b0b5e164a6..d9d4d38a44 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -4666,7 +4666,7 @@ uint64_t ff_get_formatted_ntp_time(uint64_t ntp_time_us)
>  return ntp_ts;
>  }
>  
> -int av_get_frame_filename2(char *buf, int buf_size, const char *path, int 
> number, int flags)
> +int av_get_frame_filename3(char *buf, int buf_size, const char *path, 
> int64_t number, int flags)
>  {
>  const char *p;
>  char *q, buf1[20], c;
> @@ -4696,7 +4696,7 @@ int av_get_frame_filename2(char *buf, int buf_size, 
> const char *path, int number
>  percentd_found = 1;
>  if (number < 0)
>  nd += 1;
> -snprintf(buf1, sizeof(buf1), "%0*d", nd, number);
> +snprintf(buf1, sizeof(buf1), "%0*" PRId64, nd, number);

SCNd64.

>  len = strlen(buf1);
>  if ((q - buf + len) > buf_size - 1)
>  goto fail;
> @@ -4721,6 +4721,11 @@ fail:
>  return -1;
>  }
>  
> +int av_get_frame_filename2(char *buf, int buf_size, const char *path, int 
> number, int flags)
> +{
> +return av_get_frame_filename3(buf, buf_size, path, number, flags);
> +}
> +
>  int av_get_frame_filename(char *buf, int buf_size, const char *path, int 
> number)
>  {
>  return av_get_frame_filename2(buf, buf_size, path, number, 0);
> 

No opinion on the addition, so wait for someone else to review as well.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] avformat/movenc: support Opus packets with more than 60ms of audio when writing the Sample Group Description Box

2018-08-24 Thread Carl Eugen Hoyos
2018-08-24 17:53 GMT+02:00, James Almer :
> On 8/24/2018 12:47 PM, Carl Eugen Hoyos wrote:
>> 2018-08-24 17:41 GMT+02:00, James Almer :
>>> On 8/24/2018 12:33 PM, Carl Eugen Hoyos wrote:
 2018-08-24 17:31 GMT+02:00, James Almer :
> On 8/24/2018 7:19 AM, Carl Eugen Hoyos wrote:
>> 2018-08-24 0:17 GMT+02:00, James Almer :
>>> Fixes assertion failures when trying to mux such streams.
>>
>> Shouldn't this be 1/2?
>>
>> And does this assert now for libavformat users that use
>> new libopus (but not libavcodec) or do I misunderstand?
>
> This asserts for any stream with >= 80ms packets. It doesn't need to be
> a direct encode from the libopus wrapper, since it can also happen
> during be a remux.

 Doesn't this indicate that the assert is wrong?
 (That invalid input can trigger the assert)
>>>
>>> Invalid input (say, a packet reporting a frame size of the equivalent of
>>> 1ms) would assert before and after this patch. Do you consider an assert
>>> that triggers on invalid input to be wrong?
>>
>> I wanted to write "definitely", I am a little puzzled now that you seem to
>> disagree.
>>
>> Yes, I think so: It probably depends on the definition of "invalid" but
>> I mean invalid data with valid api usage.

> I am completely lost in this discussion since i don't understand your
> concern about this at all, so please tell me what you want me to do so
> we can move on: Do i commit the patch as is, do i remove the assert line
> altogether, or do i replace it with a normal check?

I believe the assert should be replaced with a normal check and
return (and/or error message) but I am not sure if I understand
the situation correctly since you seem to disagree.
(For me this appears as a trivial technical issue, a mistake in the
current code, that does not need substantial discussion.)

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


Re: [FFmpeg-devel] [PATCH] lavf/movenc: Fail when codec tag is invalid for format

2018-08-24 Thread John Stebbins
On 08/24/2018 11:15 AM, John Stebbins wrote:
> Fixes ticket #6897
> ---
>  libavformat/movenc.c | 20 +---
>  1 file changed, 9 insertions(+), 11 deletions(-)
>
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index 8ad7026741..fb001f9195 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -1596,23 +1596,21 @@ static int mov_find_codec_tag(AVFormatContext *s, 
> MOVTrack *track)
>  if (is_cover_image(track->st))
>  return ff_codec_get_tag(codec_cover_image_tags, 
> track->par->codec_id);
>  
> -if (track->mode == MODE_MP4 || track->mode == MODE_PSP)
> -tag = track->par->codec_tag;
> -else if (track->mode == MODE_ISM)
> -tag = track->par->codec_tag;
> -else if (track->mode == MODE_IPOD) {
> +if (track->mode == MODE_IPOD)
>  if (!av_match_ext(s->url, "m4a") &&
>  !av_match_ext(s->url, "m4v") &&
>  !av_match_ext(s->url, "m4b"))
>  av_log(s, AV_LOG_WARNING, "Warning, extension is not .m4a nor 
> .m4v "
> "Quicktime/Ipod might not play the file\n");
> -tag = track->par->codec_tag;
> -} else if (track->mode & MODE_3GP)
> -tag = track->par->codec_tag;
> -else if (track->mode == MODE_F4V)
> -tag = track->par->codec_tag;
> -else
> +
> +if (track->mode == MODE_MOV)
>  tag = mov_get_codec_tag(s, track);
> +else
> +if (av_codec_get_id(s->oformat->codec_tag,
> +track->par->codec_tag) == AV_CODEC_ID_NONE)
> +tag = 0;
> +else
> +tag = track->par->codec_tag;
>  
>  return tag;
>  }

On a second look, this really should also validate that the tag is valid for 
the given track->par->codec_id.  Let me
post a quick update...

-- 
John  GnuPG fingerprint: D0EC B3DB C372 D1F1 0B01  83F0 49F1 D7B2 60D4 D0F7




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


Re: [FFmpeg-devel] [PATCH] avcodec: add MatchWare Screen Capture Codec

2018-08-24 Thread James Almer
On 8/24/2018 4:48 PM, Paul B Mahol wrote:
> On 8/24/18, James Almer  wrote:
>> On 8/24/2018 3:48 PM, Paul B Mahol wrote:
>>> Signed-off-by: Paul B Mahol 
>>> ---
>>>  libavcodec/Makefile |   1 +
>>>  libavcodec/allcodecs.c  |   1 +
>>>  libavcodec/avcodec.h|   1 +
>>>  libavcodec/codec_desc.c |   7 ++
>>>  libavcodec/mwsc.c   | 174 
>>>  libavformat/riff.c  |   1 +
>>>  6 files changed, 185 insertions(+)
>>>  create mode 100644 libavcodec/mwsc.c
>>>
> 
> [...]
> 
>>> +
>>> +s->decomp_size = 8 * avctx->height * ((avctx->width *
>>> avctx->bits_per_coded_sample + 31) / 32);
>>
>> avctx->height and avctx->width are not checked for sane values. And even
>> then, couldn't this overflow?
>>
> 
> What you propose as solution? IIRC width/height are already checked at
> higher level,
> no need to check them again because we do not change them here.

At least check for overflow in this calculation. Use av_malloc_array(),
or check before setting s->decomp_size.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec: add Brooktree ProSumer Video decoder

2018-08-24 Thread Rostislav Pehlivanov
On Wed, 22 Aug 2018 at 17:01, Paul B Mahol  wrote:

> Signed-off-by: Paul B Mahol 
> ---
>  libavcodec/Makefile |   1 +
>  libavcodec/allcodecs.c  |   1 +
>  libavcodec/avcodec.h|   1 +
>  libavcodec/codec_desc.c |   7 +
>  libavcodec/prosumer.c   | 405 
>  libavformat/riff.c  |   1 +
>  6 files changed, 416 insertions(+)
>  create mode 100644 libavcodec/prosumer.c
>
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index f0c8226283..9a309c348e 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -515,6 +515,7 @@ OBJS-$(CONFIG_PRORES_DECODER)  += proresdec2.o
> proresdsp.o proresdata.o
>  OBJS-$(CONFIG_PRORES_ENCODER)  += proresenc_anatoliy.o
>  OBJS-$(CONFIG_PRORES_AW_ENCODER)   += proresenc_anatoliy.o
>  OBJS-$(CONFIG_PRORES_KS_ENCODER)   += proresenc_kostya.o proresdata.o
> +OBJS-$(CONFIG_PROSUMER_DECODER)+= prosumer.o
>  OBJS-$(CONFIG_PSD_DECODER) += psd.o
>  OBJS-$(CONFIG_PTX_DECODER) += ptx.o
>  OBJS-$(CONFIG_QCELP_DECODER)   += qcelpdec.o \
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index fd35fc1d0b..b1d1ef26c0 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -235,6 +235,7 @@ extern AVCodec ff_prores_encoder;
>  extern AVCodec ff_prores_decoder;
>  extern AVCodec ff_prores_aw_encoder;
>  extern AVCodec ff_prores_ks_encoder;
> +extern AVCodec ff_prosumer_decoder;
>  extern AVCodec ff_psd_decoder;
>  extern AVCodec ff_ptx_decoder;
>  extern AVCodec ff_qdraw_decoder;
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 31e50d5a94..2a4be2ca4f 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -448,6 +448,7 @@ enum AVCodecID {
>  AV_CODEC_ID_GDV,
>  AV_CODEC_ID_FITS,
>  AV_CODEC_ID_IMM4,
> +AV_CODEC_ID_PROSUMER,
>
>  /* 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 af66b35d2b..e611183599 100644
> --- a/libavcodec/codec_desc.c
> +++ b/libavcodec/codec_desc.c
> @@ -1661,6 +1661,13 @@ static const AVCodecDescriptor codec_descriptors[]
> = {
>  .long_name = NULL_IF_CONFIG_SMALL("Infinity IMM4"),
>  .props = AV_CODEC_PROP_LOSSY,
>  },
> +{
> +.id= AV_CODEC_ID_PROSUMER,
> +.type  = AVMEDIA_TYPE_VIDEO,
> +.name  = "prosumer",
> +.long_name = NULL_IF_CONFIG_SMALL("Brooktree ProSumer Video"),
> +.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
> +},
>
>  /* various PCM "codecs" */
>  {
> diff --git a/libavcodec/prosumer.c b/libavcodec/prosumer.c
> new file mode 100644
> index 00..7b9d5e7bdb
> --- /dev/null
> +++ b/libavcodec/prosumer.c
> @@ -0,0 +1,405 @@
> +/*
> + * Brooktree ProSumer Video decoder
> + * Copyright (c) 2018 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 
> +#include 
> +#include 
> +
> +#include "libavutil/imgutils.h"
> +#include "libavutil/internal.h"
> +#include "libavutil/intreadwrite.h"
> +#include "libavutil/mem.h"
> +
> +#include "avcodec.h"
> +#include "bytestream.h"
> +#include "internal.h"
> +
> +typedef struct ProSumerContext {
> +GetByteContext gb;
> +PutByteContext pb;
> +
> +unsigned stride;
> +unsigned size;
> +unsigned lut[0x1];
>

uint32_t, see below.



> +uint8_t *table_b;
> +uint8_t *decbuffer;
> +} ProSumerContext;
> +
> +#define PAIR(high, low) (((uint64_t)(high)< +
> +static int decompress(GetByteContext *gb, int size, PutByteContext *pb,
> const unsigned *lut)
> +{
> +int i, pos, idx, cnt, fill;
> +unsigned a, b, c;
>

uint32_t, see below.


+
> +bytestream2_skip(gb, 32);
> +cnt = 4;
> +a = bytestream2_get_le32(gb);
> +idx = a >> 20;
> +b = lut[2 * idx];
> +
> +while (1) {
>

This loop looks a bit lock-prone but since you check the bytestream reader
status everywhere should be fine.



> +if (((b & 0xFF00u) != 0x8000u) || (b & 0xFFu)) {
> +if ((b & 0xFF00u) != 0x8000u) {
> +

[FFmpeg-devel] [PATCH] avcodec/utils: document allocation requirement of extradata

2018-08-24 Thread Timo Rothenpieler
---
 libavcodec/avcodec.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 31e50d5a94..5ec7a2430b 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1616,6 +1616,7 @@ typedef struct AVCodecContext {
  * The allocated memory should be AV_INPUT_BUFFER_PADDING_SIZE bytes larger
  * than extradata_size to avoid problems if it is read with the bitstream 
reader.
  * The bytewise contents of extradata must not depend on the architecture 
or CPU endianness.
+ * Must be allocated with av_malloc() in any case.
  * - encoding: Set/allocated/freed by libavcodec.
  * - decoding: Set/allocated/freed by user.
  */
-- 
2.17.0

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


[FFmpeg-devel] [PATCH] lavf/movenc: Fail when codec tag is invalid for format

2018-08-24 Thread John Stebbins
Fixes ticket #6897
---
 libavformat/movenc.c | 20 +---
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 8ad7026741..4507666863 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1596,23 +1596,21 @@ static int mov_find_codec_tag(AVFormatContext *s, 
MOVTrack *track)
 if (is_cover_image(track->st))
 return ff_codec_get_tag(codec_cover_image_tags, track->par->codec_id);
 
-if (track->mode == MODE_MP4 || track->mode == MODE_PSP)
-tag = track->par->codec_tag;
-else if (track->mode == MODE_ISM)
-tag = track->par->codec_tag;
-else if (track->mode == MODE_IPOD) {
+if (track->mode == MODE_IPOD)
 if (!av_match_ext(s->url, "m4a") &&
 !av_match_ext(s->url, "m4v") &&
 !av_match_ext(s->url, "m4b"))
 av_log(s, AV_LOG_WARNING, "Warning, extension is not .m4a nor .m4v 
"
"Quicktime/Ipod might not play the file\n");
-tag = track->par->codec_tag;
-} else if (track->mode & MODE_3GP)
-tag = track->par->codec_tag;
-else if (track->mode == MODE_F4V)
-tag = track->par->codec_tag;
-else
+
+if (track->mode == MODE_MOV)
 tag = mov_get_codec_tag(s, track);
+else
+if (av_codec_get_id(s->oformat->codec_tag,
+track->par->codec_tag) != track->par->codec_id)
+tag = 0;
+else
+tag = track->par->codec_tag;
 
 return tag;
 }
-- 
2.17.1

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


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/libopusenc: support encoding packets of sizes bigger than 60ms

2018-08-24 Thread James Almer
On 8/23/2018 8:01 PM, Rostislav Pehlivanov wrote:
> On Thu, 23 Aug 2018 at 23:18, James Almer  wrote:
> 
>> Packets of sizes 80ms, 100ms and 120ms can be encoded since libopus 1.2
>>
>> Signed-off-by: James Almer 
>> ---
>>  libavcodec/libopusenc.c | 20 +++-
>>  1 file changed, 15 insertions(+), 5 deletions(-)
>>
>> diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c
>> index 4ae81b0bb2..7c025a66d7 100644
>> --- a/libavcodec/libopusenc.c
>> +++ b/libavcodec/libopusenc.c
>> @@ -271,12 +271,22 @@ static av_cold int
>> libopus_encode_init(AVCodecContext *avctx)
>>  case 960:
>>  case 1920:
>>  case 2880:
>> +#ifdef OPUS_FRAMESIZE_120_MS
>> +case 3840:
>> +case 4800:
>> +case 5760:
>> +#endif
>>  opus->opts.packet_size =
>>  avctx->frame_size  = frame_size * avctx->sample_rate / 48000;
>>  break;
>>  default:
>>  av_log(avctx, AV_LOG_ERROR, "Invalid frame duration: %g.\n"
>> -   "Frame duration must be exactly one of: 2.5, 5, 10, 20, 40
>> or 60.\n",
>> +   "Frame duration must be exactly one of: 2.5, 5, 10, 20, 40"
>> +#ifdef OPUS_FRAMESIZE_120_MS
>> +   ", 60, 80, 100 or 120.\n",
>> +#else
>> +   " or 60.\n",
>> +#endif
>> opus->opts.frame_duration);
>>  return AVERROR(EINVAL);
>>  }
>> @@ -463,10 +473,10 @@ static int libopus_encode(AVCodecContext *avctx,
>> AVPacket *avpkt,
>>  memset(audio, 0, opus->opts.packet_size * sample_size);
>>  }
>>
>> -/* Maximum packet size taken from opusenc in opus-tools. 60ms packets
>> - * consist of 3 frames in one packet. The maximum frame size is 1275
>> +/* Maximum packet size taken from opusenc in opus-tools. 120ms packets
>> + * consist of 6 frames in one packet. The maximum frame size is 1275
>>   * bytes along with the largest possible packet header of 7 bytes. */
>> -if ((ret = ff_alloc_packet2(avctx, avpkt, (1275 * 3 + 7) *
>> opus->stream_count, 0)) < 0)
>> +if ((ret = ff_alloc_packet2(avctx, avpkt, (1275 * 6 + 7) *
>> opus->stream_count, 0)) < 0)
>>  return ret;
>>
>>  if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT)
>> @@ -534,7 +544,7 @@ static const AVOption libopus_options[] = {
>>  { "voip",   "Favor improved speech intelligibility",   0,
>> AV_OPT_TYPE_CONST, { .i64 = OPUS_APPLICATION_VOIP },0, 0,
>> FLAGS, "application" },
>>  { "audio",  "Favor faithfulness to the input", 0,
>> AV_OPT_TYPE_CONST, { .i64 = OPUS_APPLICATION_AUDIO },   0, 0,
>> FLAGS, "application" },
>>  { "lowdelay",   "Restrict to only the lowest delay modes", 0,
>> AV_OPT_TYPE_CONST, { .i64 = OPUS_APPLICATION_RESTRICTED_LOWDELAY }, 0, 0,
>> FLAGS, "application" },
>> -{ "frame_duration", "Duration of a frame in milliseconds",
>> OFFSET(frame_duration), AV_OPT_TYPE_FLOAT, { .dbl = 20.0 }, 2.5, 60.0,
>> FLAGS },
>> +{ "frame_duration", "Duration of a frame in milliseconds",
>> OFFSET(frame_duration), AV_OPT_TYPE_FLOAT, { .dbl = 20.0 }, 2.5, 120.0,
>> FLAGS },
>>  { "packet_loss","Expected packet loss percentage",
>>  OFFSET(packet_loss),AV_OPT_TYPE_INT,   { .i64 = 0 },0,   100,
>> FLAGS },
>>  { "vbr","Variable bit rate mode",
>> OFFSET(vbr),AV_OPT_TYPE_INT,   { .i64 = 1 },0,   2,
>> FLAGS, "vbr" },
>>  { "off","Use constant bit rate", 0,
>> AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, FLAGS, "vbr" },
>> --
>> 2.18.0
>>
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> 
> LGTM

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


Re: [FFmpeg-devel] [PATCH 2/2] avformat/movenc: support Opus packets with more than 60ms of audio when writing the Sample Group Description Box

2018-08-24 Thread James Almer
On 8/24/2018 12:56 PM, Carl Eugen Hoyos wrote:
> 2018-08-24 17:53 GMT+02:00, James Almer :
>> On 8/24/2018 12:47 PM, Carl Eugen Hoyos wrote:
>>> 2018-08-24 17:41 GMT+02:00, James Almer :
 On 8/24/2018 12:33 PM, Carl Eugen Hoyos wrote:
> 2018-08-24 17:31 GMT+02:00, James Almer :
>> On 8/24/2018 7:19 AM, Carl Eugen Hoyos wrote:
>>> 2018-08-24 0:17 GMT+02:00, James Almer :
 Fixes assertion failures when trying to mux such streams.
>>>
>>> Shouldn't this be 1/2?
>>>
>>> And does this assert now for libavformat users that use
>>> new libopus (but not libavcodec) or do I misunderstand?
>>
>> This asserts for any stream with >= 80ms packets. It doesn't need to be
>> a direct encode from the libopus wrapper, since it can also happen
>> during be a remux.
>
> Doesn't this indicate that the assert is wrong?
> (That invalid input can trigger the assert)

 Invalid input (say, a packet reporting a frame size of the equivalent of
 1ms) would assert before and after this patch. Do you consider an assert
 that triggers on invalid input to be wrong?
>>>
>>> I wanted to write "definitely", I am a little puzzled now that you seem to
>>> disagree.
>>>
>>> Yes, I think so: It probably depends on the definition of "invalid" but
>>> I mean invalid data with valid api usage.
> 
>> I am completely lost in this discussion since i don't understand your
>> concern about this at all, so please tell me what you want me to do so
>> we can move on: Do i commit the patch as is, do i remove the assert line
>> altogether, or do i replace it with a normal check?
> 
> I believe the assert should be replaced with a normal check and
> return (and/or error message) but I am not sure if I understand
> the situation correctly since you seem to disagree.
> (For me this appears as a trivial technical issue, a mistake in the
> current code, that does not need substantial discussion.)

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


Re: [FFmpeg-devel] [PATCH] avformat/flvdec: don't propagate empty extradata

2018-08-24 Thread James Almer
On 8/24/2018 4:27 AM, Paul B Mahol wrote:
> On 8/24/18, James Almer  wrote:
>> Fixes ticket #7379
>>
>> Signed-off-by: James Almer 
>> ---
>>  libavformat/flvdec.c | 6 ++
>>  1 file changed, 6 insertions(+)
>>
> 
> Probably OK.

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


[FFmpeg-devel] [PATCH] lavf/movenc: Fail when codec tag is invalid for format

2018-08-24 Thread John Stebbins
Fixes ticket #6897
---
 libavformat/movenc.c | 20 +---
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 8ad7026741..fb001f9195 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1596,23 +1596,21 @@ static int mov_find_codec_tag(AVFormatContext *s, 
MOVTrack *track)
 if (is_cover_image(track->st))
 return ff_codec_get_tag(codec_cover_image_tags, track->par->codec_id);
 
-if (track->mode == MODE_MP4 || track->mode == MODE_PSP)
-tag = track->par->codec_tag;
-else if (track->mode == MODE_ISM)
-tag = track->par->codec_tag;
-else if (track->mode == MODE_IPOD) {
+if (track->mode == MODE_IPOD)
 if (!av_match_ext(s->url, "m4a") &&
 !av_match_ext(s->url, "m4v") &&
 !av_match_ext(s->url, "m4b"))
 av_log(s, AV_LOG_WARNING, "Warning, extension is not .m4a nor .m4v 
"
"Quicktime/Ipod might not play the file\n");
-tag = track->par->codec_tag;
-} else if (track->mode & MODE_3GP)
-tag = track->par->codec_tag;
-else if (track->mode == MODE_F4V)
-tag = track->par->codec_tag;
-else
+
+if (track->mode == MODE_MOV)
 tag = mov_get_codec_tag(s, track);
+else
+if (av_codec_get_id(s->oformat->codec_tag,
+track->par->codec_tag) == AV_CODEC_ID_NONE)
+tag = 0;
+else
+tag = track->par->codec_tag;
 
 return tag;
 }
-- 
2.17.1

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


Re: [FFmpeg-devel] [PATCH] avcodec: add MatchWare Screen Capture Codec

2018-08-24 Thread Rostislav Pehlivanov
On Fri, 24 Aug 2018 at 21:07, Paul B Mahol  wrote:

> Signed-off-by: Paul B Mahol 
> ---
>  configure   |   1 +
>  libavcodec/Makefile |   1 +
>  libavcodec/allcodecs.c  |   1 +
>  libavcodec/avcodec.h|   1 +
>  libavcodec/codec_desc.c |   7 ++
>  libavcodec/mwsc.c   | 182 
>  libavformat/riff.c  |   1 +
>  7 files changed, 194 insertions(+)
>  create mode 100644 libavcodec/mwsc.c
>
> diff --git a/configure b/configure
> index b9c9d0b307..0c1f6a79a7 100755
> --- a/configure
> +++ b/configure
> @@ -2679,6 +2679,7 @@ msmpeg4v3_decoder_select="h263_decoder"
>  msmpeg4v3_encoder_select="h263_encoder"
>  mss2_decoder_select="mpegvideo qpeldsp vc1_decoder"
>  mts2_decoder_select="mss34dsp"
> +mwsc_decoder_deps="zlib"
>  mxpeg_decoder_select="mjpeg_decoder"
>  nellymoser_decoder_select="mdct sinewin"
>  nellymoser_encoder_select="audio_frame_queue mdct sinewin"
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 9a309c348e..aee4f5431a 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -482,6 +482,7 @@ OBJS-$(CONFIG_MSZH_DECODER)+= lcldec.o
>  OBJS-$(CONFIG_MTS2_DECODER)+= mss4.o
>  OBJS-$(CONFIG_MVC1_DECODER)+= mvcdec.o
>  OBJS-$(CONFIG_MVC2_DECODER)+= mvcdec.o
> +OBJS-$(CONFIG_MWSC_DECODER)+= mwsc.o
>  OBJS-$(CONFIG_MXPEG_DECODER)   += mxpegdec.o
>  OBJS-$(CONFIG_NELLYMOSER_DECODER)  += nellymoserdec.o nellymoser.o
>  OBJS-$(CONFIG_NELLYMOSER_ENCODER)  += nellymoserenc.o nellymoser.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index b1d1ef26c0..d41868c591 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -212,6 +212,7 @@ extern AVCodec ff_mszh_decoder;
>  extern AVCodec ff_mts2_decoder;
>  extern AVCodec ff_mvc1_decoder;
>  extern AVCodec ff_mvc2_decoder;
> +extern AVCodec ff_mwsc_decoder;
>  extern AVCodec ff_mxpeg_decoder;
>  extern AVCodec ff_nuv_decoder;
>  extern AVCodec ff_paf_video_decoder;
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 2a4be2ca4f..b327284449 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -449,6 +449,7 @@ enum AVCodecID {
>  AV_CODEC_ID_FITS,
>  AV_CODEC_ID_IMM4,
>  AV_CODEC_ID_PROSUMER,
> +AV_CODEC_ID_MWSC,
>
>  /* 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 e611183599..129d0f1aac 100644
> --- a/libavcodec/codec_desc.c
> +++ b/libavcodec/codec_desc.c
> @@ -1668,6 +1668,13 @@ static const AVCodecDescriptor codec_descriptors[]
> = {
>  .long_name = NULL_IF_CONFIG_SMALL("Brooktree ProSumer Video"),
>  .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
>  },
> +{
> +.id= AV_CODEC_ID_MWSC,
> +.type  = AVMEDIA_TYPE_VIDEO,
> +.name  = "mwsc",
> +.long_name = NULL_IF_CONFIG_SMALL("MatchWare Screen Capture
> Codec"),
> +.props = AV_CODEC_PROP_LOSSLESS,
> +},
>
>  /* various PCM "codecs" */
>  {
> diff --git a/libavcodec/mwsc.c b/libavcodec/mwsc.c
> new file mode 100644
> index 00..632d1cc30c
> --- /dev/null
> +++ b/libavcodec/mwsc.c
> @@ -0,0 +1,182 @@
> +/*
> + * MatchWare Screen Capture Codec decoder
> + *
> + * Copyright (c) 2018 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 
> +#include 
> +#include 
> +
> +#include "avcodec.h"
> +#include "bytestream.h"
> +#include "internal.h"
> +
> +#include 
> +
> +typedef struct MWSCContext {
> +unsigned  bpp;
> +unsigned int  decomp_size;
> +uint8_t  *decomp_buf;
> +unsigned int  uncomp_size;
> +uint8_t  *uncomp_buf;
> +z_stream  zstream;
> +} MWSCContext;
> +
> +static int rle_uncompress(AVCodecContext *avctx, GetByteContext *gb,
> PutByteContext *pb, int bpp)
> +{
> +int intra = 1;
> +
> +while (bytestream2_get_bytes_left(gb) > 0) {
> +uint32_t fill = bytestream2_get_le24(gb);
> +unsigned run = bytestream2_get_byte(gb);
> +int j;
>


Re: [FFmpeg-devel] [PATCH 1/9] configure: [loongson] revert no-expensive-optimizations

2018-08-24 Thread Shiyou Yin
>> Hi Michael, please help to review the following updates.
>>
>>
>> diff --git a/configure b/configure
>> index b9c9d0b..08cf48e 100755
>> --- a/configure
>> +++ b/configure
>> @@ -4796,15 +4796,24 @@ elif enabled mips; then
>>  disable mipsfpu
>>  disable mipsdsp
>>  disable mipsdspr2
>> +# When gcc version less than 5.3.0, add 
>> -fno-expensive-optimizations flag.
>> +if [ $cc == gcc ]; then
>> +gcc_version=$(gcc -dumpversion)
>> +if [ "$(echo "$gcc_version 5.3.0" | tr " " "\n" |
>> + sort -rV | head -n 1)" ==
>> "$gcc_version" ]; then
>> +expensive_optimization_flag=""
>> +else
>> +
>> expensive_optimization_flag="-fno-expensive-optimizations"
>> +fi
>> +fi
>
>This patch looks corrupted (by a newline)
>
>[...]


Hi Michael, has repasted below, To avoid being corrupted again, I add an 
attachment.

diff --git a/configure b/configure
index b9c9d0b..08cf48e 100755
--- a/configure
+++ b/configure
@@ -4796,15 +4796,24 @@ elif enabled mips; then
 disable mipsfpu
 disable mipsdsp
 disable mipsdspr2
+# When gcc version less than 5.3.0, add 
-fno-expensive-optimizations flag.
+if [ $cc == gcc ]; then
+gcc_version=$(gcc -dumpversion)
+if [ "$(echo "$gcc_version 5.3.0" | tr " " "\n" | sort -rV 
| head -n 1)"
=="$gcc_version" ]; then
+expensive_optimization_flag=""
+else
+
expensive_optimization_flag="-fno-expensive-optimizations"
+fi
+fi
 case $cpu in
 loongson3*)
-cpuflags="-march=loongson3a -mhard-float 
-fno-expensive-optimizations"
+cpuflags="-march=loongson3a -mhard-float 
$expensive_optimization_flag"
 ;;
 loongson2e)
-cpuflags="-march=loongson2e -mhard-float 
-fno-expensive-optimizations"
+cpuflags="-march=loongson2e -mhard-float 
$expensive_optimization_flag"
 ;;
 loongson2f)
-cpuflags="-march=loongson2f -mhard-float 
-fno-expensive-optimizations"
+cpuflags="-march=loongson2f -mhard-float 
$expensive_optimization_flag"
 ;;
 esac
 ;;
--
2.1.0


0001-configure-loongson-revert-no-expensive-optimizations.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avcodec: add MatchWare Screen Capture Codec

2018-08-24 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 configure   |   1 +
 libavcodec/Makefile |   1 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/avcodec.h|   1 +
 libavcodec/codec_desc.c |   7 ++
 libavcodec/mwsc.c   | 182 
 libavformat/riff.c  |   1 +
 7 files changed, 194 insertions(+)
 create mode 100644 libavcodec/mwsc.c

diff --git a/configure b/configure
index b9c9d0b307..0c1f6a79a7 100755
--- a/configure
+++ b/configure
@@ -2679,6 +2679,7 @@ msmpeg4v3_decoder_select="h263_decoder"
 msmpeg4v3_encoder_select="h263_encoder"
 mss2_decoder_select="mpegvideo qpeldsp vc1_decoder"
 mts2_decoder_select="mss34dsp"
+mwsc_decoder_deps="zlib"
 mxpeg_decoder_select="mjpeg_decoder"
 nellymoser_decoder_select="mdct sinewin"
 nellymoser_encoder_select="audio_frame_queue mdct sinewin"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 9a309c348e..aee4f5431a 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -482,6 +482,7 @@ OBJS-$(CONFIG_MSZH_DECODER)+= lcldec.o
 OBJS-$(CONFIG_MTS2_DECODER)+= mss4.o
 OBJS-$(CONFIG_MVC1_DECODER)+= mvcdec.o
 OBJS-$(CONFIG_MVC2_DECODER)+= mvcdec.o
+OBJS-$(CONFIG_MWSC_DECODER)+= mwsc.o
 OBJS-$(CONFIG_MXPEG_DECODER)   += mxpegdec.o
 OBJS-$(CONFIG_NELLYMOSER_DECODER)  += nellymoserdec.o nellymoser.o
 OBJS-$(CONFIG_NELLYMOSER_ENCODER)  += nellymoserenc.o nellymoser.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index b1d1ef26c0..d41868c591 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -212,6 +212,7 @@ extern AVCodec ff_mszh_decoder;
 extern AVCodec ff_mts2_decoder;
 extern AVCodec ff_mvc1_decoder;
 extern AVCodec ff_mvc2_decoder;
+extern AVCodec ff_mwsc_decoder;
 extern AVCodec ff_mxpeg_decoder;
 extern AVCodec ff_nuv_decoder;
 extern AVCodec ff_paf_video_decoder;
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 2a4be2ca4f..b327284449 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -449,6 +449,7 @@ enum AVCodecID {
 AV_CODEC_ID_FITS,
 AV_CODEC_ID_IMM4,
 AV_CODEC_ID_PROSUMER,
+AV_CODEC_ID_MWSC,
 
 /* 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 e611183599..129d0f1aac 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1668,6 +1668,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("Brooktree ProSumer Video"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
 },
+{
+.id= AV_CODEC_ID_MWSC,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "mwsc",
+.long_name = NULL_IF_CONFIG_SMALL("MatchWare Screen Capture Codec"),
+.props = AV_CODEC_PROP_LOSSLESS,
+},
 
 /* various PCM "codecs" */
 {
diff --git a/libavcodec/mwsc.c b/libavcodec/mwsc.c
new file mode 100644
index 00..632d1cc30c
--- /dev/null
+++ b/libavcodec/mwsc.c
@@ -0,0 +1,182 @@
+/*
+ * MatchWare Screen Capture Codec decoder
+ *
+ * Copyright (c) 2018 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 
+#include 
+#include 
+
+#include "avcodec.h"
+#include "bytestream.h"
+#include "internal.h"
+
+#include 
+
+typedef struct MWSCContext {
+unsigned  bpp;
+unsigned int  decomp_size;
+uint8_t  *decomp_buf;
+unsigned int  uncomp_size;
+uint8_t  *uncomp_buf;
+z_stream  zstream;
+} MWSCContext;
+
+static int rle_uncompress(AVCodecContext *avctx, GetByteContext *gb, 
PutByteContext *pb, int bpp)
+{
+int intra = 1;
+
+while (bytestream2_get_bytes_left(gb) > 0) {
+uint32_t fill = bytestream2_get_le24(gb);
+unsigned run = bytestream2_get_byte(gb);
+int j;
+
+if (run == 0) {
+run = bytestream2_get_le32(gb);
+for (j = 0; j < run; j++) {
+bytestream2_put_le24(pb, fill);
+}
+} else if (run == 255) {
+bytestream2_skip_p(pb, fill * 3);
+intra = 0;
+} else {
+for (j = 

Re: [FFmpeg-devel] [PATCH] ffmpeg.c: add an option "detail_stats" to allow ffmpeg to output stats for each stream

2018-08-24 Thread Michael Niedermayer
On Thu, Aug 23, 2018 at 12:43:25PM -0700, Wang Cao wrote:
> From: Wang Cao 
> 
> Add an option "detail_stats" to ffmpeg to output stats for each video/audio 
> streams and each ouptut file ffmpeg output log in print_report. The format of 
> stats is unchanged.
> 
> Signed-off-by: Wang Cao 
> ---
>  doc/ffmpeg.texi  |  4 
>  fftools/ffmpeg.c | 53 +++-
>  fftools/ffmpeg.h |  1 +
>  fftools/ffmpeg_opt.c |  4 +++-
>  4 files changed, 45 insertions(+), 17 deletions(-)

breaks fate:
make fate-flv-add_keyframe_index -j12

Segmentation fault (core dumped)
make: *** [fate-flv-add_keyframe_index] Error 139

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

I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus


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


Re: [FFmpeg-devel] [PATCH] lavf/movenc: Fail when codec tag is invalid for format

2018-08-24 Thread Michael Niedermayer
On Fri, Aug 24, 2018 at 11:44:11AM -0700, John Stebbins wrote:
> Fixes ticket #6897
> ---
>  libavformat/movenc.c | 20 +---
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index 8ad7026741..4507666863 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -1596,23 +1596,21 @@ static int mov_find_codec_tag(AVFormatContext *s, 
> MOVTrack *track)
>  if (is_cover_image(track->st))
>  return ff_codec_get_tag(codec_cover_image_tags, 
> track->par->codec_id);
>  
> -if (track->mode == MODE_MP4 || track->mode == MODE_PSP)
> -tag = track->par->codec_tag;
> -else if (track->mode == MODE_ISM)
> -tag = track->par->codec_tag;
> -else if (track->mode == MODE_IPOD) {
> +if (track->mode == MODE_IPOD)
>  if (!av_match_ext(s->url, "m4a") &&
>  !av_match_ext(s->url, "m4v") &&
>  !av_match_ext(s->url, "m4b"))
>  av_log(s, AV_LOG_WARNING, "Warning, extension is not .m4a nor 
> .m4v "
> "Quicktime/Ipod might not play the file\n");
> -tag = track->par->codec_tag;
> -} else if (track->mode & MODE_3GP)
> -tag = track->par->codec_tag;
> -else if (track->mode == MODE_F4V)
> -tag = track->par->codec_tag;
> -else
> +
> +if (track->mode == MODE_MOV)
>  tag = mov_get_codec_tag(s, track);
> +else
> +if (av_codec_get_id(s->oformat->codec_tag,
> +track->par->codec_tag) != track->par->codec_id)
> +tag = 0;
> +else
> +tag = track->par->codec_tag;

This breaks mp2, a testcase would be:

./ffmpeg  -i sample.wtv -acodec copy -vn -y file.mp4

sample.wtv should be here:
https://trac.ffmpeg.org/raw-attachment/ticket/1004/sample.wtv

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 1
"Used only once"- "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."


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


Re: [FFmpeg-devel] [PATCH] avcodec: add Brooktree ProSumer Video decoder

2018-08-24 Thread Paul B Mahol
Will apply.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel