Re: [FFmpeg-devel] [PATCH v4 0/9] Enhancement for libopenh264 encoder

2020-04-25 Thread Fu, Linjie
Hi,

> From: Fu, Linjie 
> Sent: Wednesday, April 15, 2020 12:54
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [PATCH v4 0/9] Enhancement for libopenh264 encoder
> 
> Docs would be provided later.
> 
> Linjie Fu (9):
>   lavc/libopenh264enc: Add default qmin/qmax support
>   lavc/libopenh264enc: add default gop size and bit rate
>   lavc/libopenh264enc: add bit rate control select support
>   lavc/libopenh264enc: prompt slice number changing inside libopenh264
>   lavc/libopenh264enc: set slice_mode option to deprecated
> [v4]: move FF_API_OPENH264_SLICE_MODE to libavcodec/version.h
>   lavc/libopenh264enc: separate svc_encode_init() into several functions
>   lavc/libopenh264enc: add profile high option support
>   lavc/libopenh264enc: allow specifying the profile through
> AVCodecContext
>   lavc/libopenh264enc: Add coder option to replace cabac
> [v4]: move FF_API_OPENH264_CABAC to libavcodec/version.h
> 
>  libavcodec/libopenh264enc.c | 365 ++--
> 
>  libavcodec/version.h|   6 +
>  2 files changed, 259 insertions(+), 112 deletions(-)
> 
> --
> 2.7.4
Ping for this set.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2 6/6] avformat/audiointerleave: only keep the retime functionality of the audio interleaver

2020-04-25 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> Marton Balint:
>> And rename it to retimeinterleave, use the pcm_rechunk bitstream filter for
>> rechunking.
>>
>> By seperating the two functions we hopefully get cleaner code.
>>
>> Signed-off-by: Marton Balint 
>> ---
>>  configure  |  2 +
>>  libavformat/Makefile   |  4 +-
>>  libavformat/gxfenc.c   | 29 
>>  libavformat/mux.c  |  1 -
>>  libavformat/mxfenc.c   | 32 ++
>>  libavformat/retimeinterleave.c | 51 
>> ++
>>  .../{audiointerleave.h => retimeinterleave.h}  | 31 ++---
>>  libavformat/utils.c|  1 -
>>  8 files changed, 111 insertions(+), 40 deletions(-)
>>  create mode 100644 libavformat/retimeinterleave.c
>>  rename libavformat/{audiointerleave.h => retimeinterleave.h} (57%)
> 
> Why don't you delete audiointerleave.c? (I would have expected to see
> more deletions than insertions.)
> 
>>
>> diff --git a/configure b/configure
>> index 4f285f0074..f5a84c31bd 100755
>> --- a/configure
>> +++ b/configure
>> @@ -2722,6 +2722,7 @@ fraps_decoder_select="bswapdsp huffman"
>>  g2m_decoder_deps="zlib"
>>  g2m_decoder_select="blockdsp idctdsp jpegtables"
>>  g729_decoder_select="audiodsp"
>> +gxf_encoder_select="pcm_rechunk_bsf"
>>  h261_decoder_select="mpegvideo"
>>  h261_encoder_select="mpegvideoenc"
>>  h263_decoder_select="h263_parser h263dsp mpegvideo qpeldsp"
>> @@ -2794,6 +2795,7 @@ mv30_decoder_select="aandcttables blockdsp"
>>  mvha_decoder_deps="zlib"
>>  mvha_decoder_select="llviddsp"
>>  mwsc_decoder_deps="zlib"
>> +mxf_encoder_select="pcm_rechunk_bsf"
>>  mxpeg_decoder_select="mjpeg_decoder"
>>  nellymoser_decoder_select="mdct sinewin"
>>  nellymoser_encoder_select="audio_frame_queue mdct sinewin"
>> diff --git a/libavformat/Makefile b/libavformat/Makefile
>> index d4bed3c113..56ca55fbd5 100644
>> --- a/libavformat/Makefile
>> +++ b/libavformat/Makefile
>> @@ -205,7 +205,7 @@ OBJS-$(CONFIG_GIF_DEMUXER)   += gifdec.o
>>  OBJS-$(CONFIG_GSM_DEMUXER)   += gsmdec.o
>>  OBJS-$(CONFIG_GSM_MUXER) += rawenc.o
>>  OBJS-$(CONFIG_GXF_DEMUXER)   += gxf.o
>> -OBJS-$(CONFIG_GXF_MUXER) += gxfenc.o audiointerleave.o
>> +OBJS-$(CONFIG_GXF_MUXER) += gxfenc.o retimeinterleave.o
>>  OBJS-$(CONFIG_G722_DEMUXER)  += g722.o rawdec.o
>>  OBJS-$(CONFIG_G722_MUXER)+= rawenc.o
>>  OBJS-$(CONFIG_G723_1_DEMUXER)+= g723_1.o
>> @@ -347,7 +347,7 @@ OBJS-$(CONFIG_MUSX_DEMUXER)  += musx.o
>>  OBJS-$(CONFIG_MV_DEMUXER)+= mvdec.o
>>  OBJS-$(CONFIG_MVI_DEMUXER)   += mvi.o
>>  OBJS-$(CONFIG_MXF_DEMUXER)   += mxfdec.o mxf.o
>> -OBJS-$(CONFIG_MXF_MUXER) += mxfenc.o mxf.o 
>> audiointerleave.o avc.o
>> +OBJS-$(CONFIG_MXF_MUXER) += mxfenc.o mxf.o 
>> retimeinterleave.o avc.o
>>  OBJS-$(CONFIG_MXG_DEMUXER)   += mxg.o
>>  OBJS-$(CONFIG_NC_DEMUXER)+= ncdec.o
>>  OBJS-$(CONFIG_NISTSPHERE_DEMUXER)+= nistspheredec.o pcm.o
>> diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c
>> index e7536a6a7e..e95ae99cba 100644
>> --- a/libavformat/gxfenc.c
>> +++ b/libavformat/gxfenc.c
>> @@ -27,7 +27,7 @@
>>  #include "avformat.h"
>>  #include "internal.h"
>>  #include "gxf.h"
>> -#include "audiointerleave.h"
>> +#include "retimeinterleave.h"
>>  
>>  #define GXF_AUDIO_PACKET_SIZE 65536
>>  
>> @@ -44,7 +44,7 @@ typedef struct GXFTimecode{
>>  } GXFTimecode;
>>  
>>  typedef struct GXFStreamContext {
>> -AudioInterleaveContext aic;
>> +RetimeInterleaveContext aic;
>>  uint32_t track_type;
>>  uint32_t sample_size;
>>  uint32_t sample_rate;
>> @@ -813,14 +813,12 @@ static int gxf_write_header(AVFormatContext *s)
>>  return -1;
>>  }
>>  }
>> +ff_retime_interleave_init(&sc->aic, st->time_base);
>>  /* FIXME first 10 audio tracks are 0 to 9 next 22 are A to V */
>>  sc->media_info = media_info<<8 | ('0'+tracks[media_info]++);
>>  sc->order = s->nb_streams - st->index;
>>  }
>>  
>> -if (ff_audio_interleave_init(s, GXF_samples_per_frame, (AVRational){ 1, 
>> 48000 }) < 0)
>> -return -1;
>> -
>>  if (tcr && vsc)
>>  gxf_init_timecode(s, &gxf->tc, tcr->value, vsc->fields);
>>  
>> @@ -877,8 +875,6 @@ static void gxf_deinit(AVFormatContext *s)
>>  {
>>  GXFContext *gxf = s->priv_data;
>>  
>> -ff_audio_interleave_close(s);
>> -
>>  av_freep(&gxf->flt_entries);
>>  av_freep(&gxf->map_offsets);
>>  }
>> @@ -1016,8 +1012,22 @@ static int gxf_interleave_packet(AVFormatContext *s, 
>> AVPacket *out, AVPacket *pk
>>  {
>>  if (pkt && s->streams[pkt->stream_index]->codecpar->codec_type == 
>> AVMEDIA_TYPE_V

Re: [FFmpeg-devel] [PATCH v2 4/6] avformat/mux: add proper support for full N:M bitstream filtering

2020-04-25 Thread Andreas Rheinhardt
Marton Balint:
> Previously only 1:1 bitstream filters were supported, the end of the stream 
> was
> not signalled to the bitstream filters and time base changes were ignored.
> 
> Signed-off-by: Marton Balint 
> ---
>  libavformat/mux.c | 91 
> ++-
>  1 file changed, 57 insertions(+), 34 deletions(-)
> 
> diff --git a/libavformat/mux.c b/libavformat/mux.c
> index 4118d221e0..c2b6d4461e 100644
> --- a/libavformat/mux.c
> +++ b/libavformat/mux.c
> @@ -822,14 +822,13 @@ static int prepare_input_packet(AVFormatContext *s, 
> AVPacket *pkt)
>  return 0;
>  }
>  
> -static int do_packet_auto_bsf(AVFormatContext *s, AVPacket *pkt) {
> -AVStream *st = s->streams[pkt->stream_index];
> +static int need_auto_bsf(AVFormatContext *s, AVStream *st, AVPacket *pkt) {

{ belongs in a line of its own.

>  int ret;
>  
>  if (!(s->flags & AVFMT_FLAG_AUTO_BSF))
> -return 1;
> +return 0;
>  
> -if (s->oformat->check_bitstream) {
> +if (pkt && s->oformat->check_bitstream) {
>  if (!st->internal->bitstream_checked) {
>  if ((ret = s->oformat->check_bitstream(s, pkt)) < 0)
>  return ret;
> @@ -838,31 +837,7 @@ static int do_packet_auto_bsf(AVFormatContext *s, 
> AVPacket *pkt) {
>  }
>  }
>  
> -if (st->internal->bsfc) {
> -AVBSFContext *ctx = st->internal->bsfc;
> -// TODO: when any bitstream filter requires flushing at EOF, we'll 
> need to
> -// flush each stream's BSF chain on write_trailer.
> -if ((ret = av_bsf_send_packet(ctx, pkt)) < 0) {
> -av_log(ctx, AV_LOG_ERROR,
> -"Failed to send packet to filter %s for stream %d\n",
> -ctx->filter->name, pkt->stream_index);
> -return ret;
> -}
> -// TODO: when any automatically-added bitstream filter is generating 
> multiple
> -// output packets for a single input one, we'll need to call this in 
> a loop
> -// and write each output packet.
> -if ((ret = av_bsf_receive_packet(ctx, pkt)) < 0) {
> -if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
> -return 0;
> -av_log(ctx, AV_LOG_ERROR,
> -"Failed to receive packet from filter %s for stream 
> %d\n",
> -ctx->filter->name, pkt->stream_index);
> -if (s->error_recognition & AV_EF_EXPLODE)
> -return ret;
> -return 0;
> -}
> -}
> -return 1;
> +return !!st->internal->bsfc;
>  }
>  
>  static int interleaved_write_packet(AVFormatContext *s, AVPacket *pkt, int 
> flush);
> @@ -889,17 +864,56 @@ static int write_packet_common(AVFormatContext *s, 
> AVStream *st, AVPacket *pkt,
>  }
>  }
>  
> +static int write_packets_from_bsfs(AVFormatContext *s, AVStream *st, 
> AVPacket *pkt, int interleaved)
> +{
> +AVBSFContext *bsfc = st->internal->bsfc;
> +AVPacket opkt = {0};

The doc of av_bsf_receive_packet() states that this packet "should be
"clean" (i.e. freshly allocated with av_packet_alloc() or unreffed with
av_packet_unref())". Simply zeroing it does not fulfill this requirement.
I suggest an alternative approach: We only need a spare packet for
av_bsf_receive_packet() if we don't already have a packet; and this
happens if and only if this function is called from av_write_trailer().
So this spare packet should reside in av_write_trailer() and be properly
initialized there (so that it can be used to signal EOF to the bsf); pkt
should be the only packet in this function. This avoids unnecessary
initializations.

> +int ret;
> +
> +if ((ret = av_bsf_send_packet(bsfc, pkt)) < 0) {
> +av_log(s, AV_LOG_ERROR,
> +"Failed to send packet to filter %s for stream %d\n",
> +bsfc->filter->name, st->index);
> +return ret;
> +}
> +
> +do {
> +ret = av_bsf_receive_packet(bsfc, &opkt);
> +if (ret < 0) {
> +if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
> +ret = 0;

You can just return 0 here and remove the next check.

> +if (ret < 0) {
> +av_log(s, AV_LOG_ERROR, "Error applying bitstream filters to 
> an output "
> +   "packet for stream #%d: %s\n", st->index, 
> av_err2str(ret));
> +if (!(s->error_recognition & AV_EF_EXPLODE) && ret != 
> AVERROR(ENOMEM))
> +continue;
> +}
> +return ret;
> +}
> +av_packet_rescale_ts(&opkt, bsfc->time_base_out, st->time_base);
> +ret = write_packet_common(s, st, &opkt, interleaved);
> +if (!interleaved) // write_packet_common already unrefed opkt for 
> interleaved

Unfortunately not. It does this only if interleaved_write_packet() has
been reached. If not, opkt leaks.

If you followed the above recommendation, then the memleak for the
interleaved cod

[FFmpeg-devel] [PATCH 1/2] lavfi/vaapi: check avaliable before set color properties

2020-04-25 Thread Fei Wang
If the color proerties is UNSPECIFIED(enum value is 2), do not pass
the invalid value to driver.

Signed-off-by: Fei Wang 
---
 libavfilter/vaapi_vpp.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavfilter/vaapi_vpp.c b/libavfilter/vaapi_vpp.c
index b5b245c..6ffc09d 100644
--- a/libavfilter/vaapi_vpp.c
+++ b/libavfilter/vaapi_vpp.c
@@ -493,18 +493,18 @@ static int vaapi_vpp_colour_properties(AVFilterContext 
*avctx,
 .chroma_sample_location   = input_props.va_chroma_sample_location,
 .color_range  = input_props.va_color_range,
 #if VA_CHECK_VERSION(1, 3, 0)
-.colour_primaries = input_props.color_primaries,
-.transfer_characteristics = input_props.color_trc,
-.matrix_coefficients  = input_props.colorspace,
+.colour_primaries = (input_props.color_primaries == 
AVCOL_PRI_UNSPECIFIED ? 0 : input_props.color_primaries),
+.transfer_characteristics = (input_props.color_trc == 
AVCOL_TRC_UNSPECIFIED ? 0 : input_props.color_trc),
+.matrix_coefficients  = (input_props.colorspace == 
AVCOL_SPC_UNSPECIFIED ? 0 : input_props.colorspace),
 #endif
 };
 params->output_color_properties = (VAProcColorProperties) {
 .chroma_sample_location   = output_props.va_chroma_sample_location,
 .color_range  = output_props.va_color_range,
 #if VA_CHECK_VERSION(1, 3, 0)
-.colour_primaries = output_props.color_primaries,
-.transfer_characteristics = output_props.color_trc,
-.matrix_coefficients  = output_props.colorspace,
+.colour_primaries = (input_props.color_primaries == 
AVCOL_PRI_UNSPECIFIED ? 0 : input_props.color_primaries),
+.transfer_characteristics = (input_props.color_trc == 
AVCOL_TRC_UNSPECIFIED ? 0 : input_props.color_trc),
+.matrix_coefficients  = (input_props.colorspace == 
AVCOL_SPC_UNSPECIFIED ? 0 : input_props.colorspace),
 #endif
 };
 #endif
-- 
2.7.4

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/2] lavfi/vaapi: add more factors when using VAProcColorStandardExplicit

2020-04-25 Thread Fei Wang
Use VAProcColorStandardExplicit only if the color properties all
specificed.

Signed-off-by: Fei Wang 
---
 libavfilter/vaapi_vpp.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/libavfilter/vaapi_vpp.c b/libavfilter/vaapi_vpp.c
index 6ffc09d..e1d3373 100644
--- a/libavfilter/vaapi_vpp.c
+++ b/libavfilter/vaapi_vpp.c
@@ -278,10 +278,14 @@ static void 
vaapi_vpp_fill_colour_standard(VAAPIColourProperties *props,
 // use them and avoid doing any mapping.  (The driver may not support
 // some particular code point, but it still has enough information to
 // make a better fallback choice than we do in that case.)
-for (i = 0; i < nb_vacs; i++) {
-if (vacs[i] == VAProcColorStandardExplicit) {
-props->va_color_standard = VAProcColorStandardExplicit;
-return;
+if ((props->colorspace != AVCOL_SPC_UNSPECIFIED) &&
+(props->color_trc != AVCOL_TRC_UNSPECIFIED) &&
+(props->color_primaries != AVCOL_PRI_UNSPECIFIED)) {
+for (i = 0; i < nb_vacs; i++) {
+if (vacs[i] == VAProcColorStandardExplicit) {
+props->va_color_standard = VAProcColorStandardExplicit;
+return;
+}
 }
 }
 #endif
-- 
2.7.4

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v3 1/3] swscale: make yuv2interleavedX more asm-friendly

2020-04-25 Thread Nelson Gomez
From: Nelson Gomez 

Extracting information from SwsContext in assembly is difficult, and
rearranging SwsContext just for asm access didn't look good. These
functions only need a couple of fields from it anyway, so just make
them parameters in their own right.

Signed-off-by: Nelson Gomez 
---
 libswscale/output.c   | 12 +---
 libswscale/swscale_internal.h |  5 +++--
 libswscale/vscale.c   |  2 +-
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/libswscale/output.c b/libswscale/output.c
index 68f43ffba3..2e5d6076ab 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -180,7 +180,7 @@ yuv2planeX_16_c_template(const int16_t *filter, int 
filterSize,
 }
 }
 
-static void yuv2p016cX_c(SwsContext *c, const int16_t *chrFilter, int 
chrFilterSize,
+static void yuv2p016cX_c(enum AVPixelFormat dstFormat, const uint8_t 
*chrDither, const int16_t *chrFilter, int chrFilterSize,
  const int16_t **chrUSrc, const int16_t **chrVSrc,
  uint8_t *dest8, int chrDstW)
 {
@@ -188,7 +188,7 @@ static void yuv2p016cX_c(SwsContext *c, const int16_t 
*chrFilter, int chrFilterS
 const int32_t **uSrc = (const int32_t **)chrUSrc;
 const int32_t **vSrc = (const int32_t **)chrVSrc;
 int shift = 15;
-int big_endian = c->dstFormat == AV_PIX_FMT_P016BE;
+int big_endian = dstFormat == AV_PIX_FMT_P016BE;
 int i, j;
 
 for (i = 0; i < chrDstW; i++) {
@@ -402,12 +402,10 @@ static void yuv2plane1_8_c(const int16_t *src, uint8_t 
*dest, int dstW,
 }
 }
 
-static void yuv2nv12cX_c(SwsContext *c, const int16_t *chrFilter, int 
chrFilterSize,
+static void yuv2nv12cX_c(enum AVPixelFormat dstFormat, const uint8_t 
*chrDither, const int16_t *chrFilter, int chrFilterSize,
 const int16_t **chrUSrc, const int16_t **chrVSrc,
 uint8_t *dest, int chrDstW)
 {
-enum AVPixelFormat dstFormat = c->dstFormat;
-const uint8_t *chrDither = c->chrDither8;
 int i;
 
 if (dstFormat == AV_PIX_FMT_NV12 ||
@@ -477,13 +475,13 @@ static void yuv2p010lX_c(const int16_t *filter, int 
filterSize,
 }
 }
 
-static void yuv2p010cX_c(SwsContext *c, const int16_t *chrFilter, int 
chrFilterSize,
+static void yuv2p010cX_c(enum AVPixelFormat dstFormat, const uint8_t 
*chrDither, const int16_t *chrFilter, int chrFilterSize,
  const int16_t **chrUSrc, const int16_t **chrVSrc,
  uint8_t *dest8, int chrDstW)
 {
 uint16_t *dest = (uint16_t*)dest8;
 int shift = 17;
-int big_endian = c->dstFormat == AV_PIX_FMT_P010BE;
+int big_endian = dstFormat == AV_PIX_FMT_P010BE;
 int i, j;
 
 for (i = 0; i < chrDstW; i++) {
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 9dda53eead..42fd87e887 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -119,7 +119,8 @@ typedef void (*yuv2planarX_fn)(const int16_t *filter, int 
filterSize,
  * Write one line of horizontally scaled chroma to interleaved output
  * with multi-point vertical scaling between input pixels.
  *
- * @param c SWS scaling context
+ * @param dstFormat destination pixel format
+ * @param chrDither ordered dither array of type uint8_t and size 8
  * @param chrFilter vertical chroma scaling coefficients, 12 bits [0,4096]
  * @param chrUSrc   scaled chroma (U) source data, 15 bits for 8-10-bit
  *  output, 19 bits for 16-bit output (in int32_t)
@@ -130,7 +131,7 @@ typedef void (*yuv2planarX_fn)(const int16_t *filter, int 
filterSize,
  *  output, this is in uint16_t
  * @param dstW  width of chroma planes
  */
-typedef void (*yuv2interleavedX_fn)(struct SwsContext *c,
+typedef void (*yuv2interleavedX_fn)(enum AVPixelFormat dstFormat, const 
uint8_t *chrDither,
 const int16_t *chrFilter,
 int chrFilterSize,
 const int16_t **chrUSrc,
diff --git a/libswscale/vscale.c b/libswscale/vscale.c
index 72352dedb3..cac85921da 100644
--- a/libswscale/vscale.c
+++ b/libswscale/vscale.c
@@ -85,7 +85,7 @@ static int chr_planar_vscale(SwsContext *c, 
SwsFilterDescriptor *desc, int slice
 uint16_t *filter = inst->filter[0] + (inst->isMMX ? 0 : chrSliceY * 
inst->filter_size);
 
 if (c->yuv2nv12cX) {
-((yuv2interleavedX_fn)inst->pfn)(c, filter, inst->filter_size, 
(const int16_t**)src1, (const int16_t**)src2, dst1[0], dstW);
+((yuv2interleavedX_fn)inst->pfn)(c->dstFormat, c->chrDither8, 
filter, inst->filter_size, (const int16_t**)src1, (const int16_t**)src2, 
dst1[0], dstW);
 } else if (inst->filter_size == 1) {
 ((yuv2planar1_fn)inst->pfn)((const int16_t*)src1[0], dst1[0], 
dstW, c->chrDither8, 0);
 ((yuv2planar1_fn)inst->pfn)((const int16_t*)src2[0], dst2[0], 
dstW, c->chrDither

[FFmpeg-devel] [PATCH v3 3/3] swscale: cosmetic fixes

2020-04-25 Thread Nelson Gomez
From: Nelson Gomez 

Signed-off-by: Nelson Gomez 
---
 libswscale/output.c   | 13 -
 libswscale/swscale_internal.h |  3 ++-
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/libswscale/output.c b/libswscale/output.c
index 2e5d6076ab..bddfaf16af 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -180,7 +180,8 @@ yuv2planeX_16_c_template(const int16_t *filter, int 
filterSize,
 }
 }
 
-static void yuv2p016cX_c(enum AVPixelFormat dstFormat, const uint8_t 
*chrDither, const int16_t *chrFilter, int chrFilterSize,
+static void yuv2p016cX_c(enum AVPixelFormat dstFormat, const uint8_t 
*chrDither,
+ const int16_t *chrFilter, int chrFilterSize,
  const int16_t **chrUSrc, const int16_t **chrVSrc,
  uint8_t *dest8, int chrDstW)
 {
@@ -402,9 +403,10 @@ static void yuv2plane1_8_c(const int16_t *src, uint8_t 
*dest, int dstW,
 }
 }
 
-static void yuv2nv12cX_c(enum AVPixelFormat dstFormat, const uint8_t 
*chrDither, const int16_t *chrFilter, int chrFilterSize,
-const int16_t **chrUSrc, const int16_t **chrVSrc,
-uint8_t *dest, int chrDstW)
+static void yuv2nv12cX_c(enum AVPixelFormat dstFormat, const uint8_t 
*chrDither,
+ const int16_t *chrFilter, int chrFilterSize,
+ const int16_t **chrUSrc, const int16_t **chrVSrc,
+ uint8_t *dest, int chrDstW)
 {
 int i;
 
@@ -475,7 +477,8 @@ static void yuv2p010lX_c(const int16_t *filter, int 
filterSize,
 }
 }
 
-static void yuv2p010cX_c(enum AVPixelFormat dstFormat, const uint8_t 
*chrDither, const int16_t *chrFilter, int chrFilterSize,
+static void yuv2p010cX_c(enum AVPixelFormat dstFormat, const uint8_t 
*chrDither,
+ const int16_t *chrFilter, int chrFilterSize,
  const int16_t **chrUSrc, const int16_t **chrVSrc,
  uint8_t *dest8, int chrDstW)
 {
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 42fd87e887..d87a9ad741 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -131,7 +131,8 @@ typedef void (*yuv2planarX_fn)(const int16_t *filter, int 
filterSize,
  *  output, this is in uint16_t
  * @param dstW  width of chroma planes
  */
-typedef void (*yuv2interleavedX_fn)(enum AVPixelFormat dstFormat, const 
uint8_t *chrDither,
+typedef void (*yuv2interleavedX_fn)(enum AVPixelFormat dstFormat,
+const uint8_t *chrDither,
 const int16_t *chrFilter,
 int chrFilterSize,
 const int16_t **chrUSrc,
-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v3 0/3] swscale: add AVX2 version of yuv2nv12cX

2020-04-25 Thread Nelson Gomez
From: Nelson Gomez 

v3:
  - Fixed x86_32 compilation

v2: [2]
  - Addressing comments James left on iter. 1
  - Cleaned up how dither gets read to avoid using stack space

v1: [1]

[1] http://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/261313.html
[2] http://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/261346.html

This patchset aims to optimize yuv2nv12cX_c for Intel/AMD chips by adding an
AVX2 implementation of it. To support this change, the typedef declaration for
yuv2interleavedX_fn has been changed to pass two additional parameters for
chrDither8 and dstFormat rather than passing a pointer to the entire SwsContext.
Output is bit-identical to the software implementation.

Patchset validated on an Intel Xeon W-2133, Core i7-8650U, and an AMD Ryzen
1700. Passes fate tests; this patch is exercised by
fate-filter-pixdesc-nv{12,21,24,42}.

Benchmarks measured on the W-2133. Flags used are:

  -benchmark -i /dev/shm/benchmark.mp4 -pix_fmt nv42 -f null -

Benchmark material is a yuv420p file:

  http://linux.microsoft.com/~negomez/ffmpeg/yuv420p-benchmark.mp4

Results:

  * Single-threaded conversion: +95% fps

-cpuflags -avx2 -threads 1:

frame= 9959 fps=114 q=-0.0 Lsize=N/A time=00:05:32.29 bitrate=N/A 
speed=3.79x
bench: utime=87.648s stime=0.060s rtime=87.709s
bench: maxrss=35020kB

-cpuflags all -threads 1:

frame= 9959 fps=222 q=-0.0 Lsize=N/A time=00:05:32.29 bitrate=N/A 
speed=7.39x
bench: utime=44.900s stime=0.040s rtime=44.941s
bench: maxrss=33048kB


  * Multi-threaded conversion: +197% fps

-cpuflags -avx2:

frame= 9959 fps=159 q=-0.0 Lsize=N/A time=00:05:32.29 bitrate=N/A speed=5.3x
bench: utime=90.381s stime=0.430s rtime=62.663s
bench: maxrss=77420kB

-cpuflags all:

frame= 9959 fps=473 q=-0.0 Lsize=N/A time=00:05:32.29 bitrate=N/A 
speed=15.8x
bench: utime=48.625s stime=0.459s rtime=21.058s
bench: maxrss=78500kB

Nelson Gomez (3):
  swscale: make yuv2interleavedX more asm-friendly
  swscale/x86/output: add AVX2 version of yuv2nv12cX
  swscale: cosmetic fixes

 libswscale/output.c   |  19 ++---
 libswscale/swscale_internal.h |   6 +-
 libswscale/vscale.c   |   2 +-
 libswscale/x86/output.asm | 126 +-
 libswscale/x86/swscale.c  |  28 
 5 files changed, 168 insertions(+), 13 deletions(-)

-- 
2.25.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v3 2/3] swscale/x86/output: add AVX2 version of yuv2nv12cX

2020-04-25 Thread Nelson Gomez
From: Nelson Gomez 

256 bits is just wide enough to fit all the operands needed to vectorize
the software implementation, but AVX2 is needed to for a couple of
instructions like cross-lane permutation.

Output is bit-for-bit identical to C.

Signed-off-by: Nelson Gomez 
---
 libswscale/x86/output.asm | 126 +-
 libswscale/x86/swscale.c  |  28 +
 2 files changed, 153 insertions(+), 1 deletion(-)

diff --git a/libswscale/x86/output.asm b/libswscale/x86/output.asm
index db3e9934f8..7f82665e1b 100644
--- a/libswscale/x86/output.asm
+++ b/libswscale/x86/output.asm
@@ -2,6 +2,7 @@
 ;* x86-optimized vertical line scaling functions
 ;* Copyright (c) 2011 Ronald S. Bultje 
 ;*Kieran Kunhya 
+;*   (c) 2020 Nelson Gomez 
 ;*
 ;* This file is part of FFmpeg.
 ;*
@@ -22,7 +23,7 @@
 
 %include "libavutil/x86/x86util.asm"
 
-SECTION_RODATA
+SECTION_RODATA 32
 
 minshort:  times 8 dw 0x8000
 yuv2yuvX_16_start:  times 4 dd 0x4000 - 0x4000
@@ -34,9 +35,20 @@ pd_4:  times 4 dd 4
 pd_4min0x4:times 4 dd 4 - (0x4)
 pw_16: times 8 dw 16
 pw_32: times 8 dw 32
+pd_255:times 8 dd 255
 pw_512:times 8 dw 512
 pw_1024:   times 8 dw 1024
 
+yuv2nv12_shuffle_mask: times 2 db 0,  4,  8, 12, \
+ -1, -1, -1, -1, \
+ -1, -1, -1, -1, \
+ -1, -1, -1, -1
+yuv2nv21_shuffle_mask: times 2 db 4,  0, 12,  8, \
+ -1, -1, -1, -1, \
+ -1, -1, -1, -1, \
+ -1, -1, -1, -1
+yuv2nv12_permute_mask: dd 0, 4, 1, 2, 3, 5, 6, 7
+
 SECTION .text
 
 ;-
@@ -423,3 +435,115 @@ yuv2plane1_fn  9, 5, 3
 yuv2plane1_fn 10, 5, 3
 yuv2plane1_fn 16, 5, 3
 %endif
+
+%undef movsx
+
+;-
+; AVX2 yuv2nv12cX implementation
+;
+; void ff_yuv2nv12cX_avx2(enum AVPixelFormat format, const uint8_t *dither,
+; const int16_t *filter, int filterSize,
+; const int16_t **u, const int16_t **v,
+; uint8_t *dst, int dstWidth)
+;
+; void ff_yuv2nv21cX_avx2(enum AVPixelFormat format, const uint8_t *dither,
+; const int16_t *filter, int filterSize,
+; const int16_t **u, const int16_t **v,
+; uint8_t *dst, int dstWidth)
+;-
+
+%if ARCH_X86_64
+%macro yuv2nv12cX_fn 1
+cglobal %1cX, 8, 11, 13, tmp1, dither, filter, filterSize, u, v, dst, dstWidth
+
+mov tmp1q, qword [ditherq]
+movq xm0, tmp1q
+ror tmp1q, 24
+movq xm1, tmp1q
+
+pmovzxbd m0, xm0
+pslld m0, m0, 12; ditherLo
+pmovzxbd m1, xm1
+pslld m1, m1, 12; ditherHi
+
+pxor m9, m9 ; uint8_min dwords
+mova m10, [pd_255]  ; uint8_max dwords
+mova m11, [%1_shuffle_mask] ; shuffle_mask
+mova m12, [yuv2nv12_permute_mask]   ; permute mask
+
+DEFINE_ARGS tmp1, tmp2, filter, filterSize, u, v, dst, dstWidth
+
+xor r8q, r8q
+
+nv12_outer_%1:
+mova m2, m0 ; resultLo
+mova m3, m1 ; resultHi
+xor r9q, r9q
+
+nv12_inner_%1:
+movsx r10d, word [filterq + (2 * r9q)]
+movd xm4, r10d
+vpbroadcastd m4, xm4; filter
+
+mov tmp1q, [uq + (gprsize * r9q)]
+mova xm7, oword [tmp1q + 2 * r8q]
+
+mov tmp2q, [vq + (gprsize * r9q)]
+mova xm8, oword [tmp2q + 2 * r8q]
+
+punpcklwd xm5, xm7, xm8
+pmovsxwd m5, xm5; multiplicandsLo
+punpckhwd xm6, xm7, xm8
+pmovsxwd m6, xm6; multiplicandsHi
+
+pmulld m7, m5, m4   ; mulResultLo
+pmulld m8, m6, m4   ; mulResultHi
+paddd m2, m2, m7; resultLo += mulResultLo
+paddd m3, m3, m8; resultHi += mulResultHi
+
+inc r9d
+cmp r9d, filterSized
+jl nv12_inner_%1
+; end of inner loop
+
+psrad m2, m2, 19
+psrad m3, m3, 19
+
+; Vectorized av_clip_uint8
+pmaxsd m2, m2, m9
+pmaxsd m3, m3, m9
+pminsd m2, m2, m10
+pminsd m3, m3, m10
+
+; At this point we have clamped uint8s arranged in this order:
+; m2: u1  0  0  0  v1  0  0  0  [...]
+; m3: u5  0  0  0  v5  0  0  0  [...]
+;
+; First, we shuffle the bytes to make the bytes semi-contiguous.
+; AVX-2 doesn't have cross-lane shuffling, so we'll end up with:
+; m2: u1  v1  u2  v2  0  0  0  0  0  0  0  0  u3  v3  u4  v4
+; m3: u5  v5  u6  v6  0  0  0  0  0  0  0  0  u7  v7  u8  v8
+pshufb m

Re: [FFmpeg-devel] [PATCH v2 6/6] avformat/audiointerleave: only keep the retime functionality of the audio interleaver

2020-04-25 Thread Andreas Rheinhardt
Marton Balint:
> And rename it to retimeinterleave, use the pcm_rechunk bitstream filter for
> rechunking.
> 
> By seperating the two functions we hopefully get cleaner code.
> 
> Signed-off-by: Marton Balint 
> ---
>  configure  |  2 +
>  libavformat/Makefile   |  4 +-
>  libavformat/gxfenc.c   | 29 
>  libavformat/mux.c  |  1 -
>  libavformat/mxfenc.c   | 32 ++
>  libavformat/retimeinterleave.c | 51 
> ++
>  .../{audiointerleave.h => retimeinterleave.h}  | 31 ++---
>  libavformat/utils.c|  1 -
>  8 files changed, 111 insertions(+), 40 deletions(-)
>  create mode 100644 libavformat/retimeinterleave.c
>  rename libavformat/{audiointerleave.h => retimeinterleave.h} (57%)

Why don't you delete audiointerleave.c? (I would have expected to see
more deletions than insertions.)

> 
> diff --git a/configure b/configure
> index 4f285f0074..f5a84c31bd 100755
> --- a/configure
> +++ b/configure
> @@ -2722,6 +2722,7 @@ fraps_decoder_select="bswapdsp huffman"
>  g2m_decoder_deps="zlib"
>  g2m_decoder_select="blockdsp idctdsp jpegtables"
>  g729_decoder_select="audiodsp"
> +gxf_encoder_select="pcm_rechunk_bsf"
>  h261_decoder_select="mpegvideo"
>  h261_encoder_select="mpegvideoenc"
>  h263_decoder_select="h263_parser h263dsp mpegvideo qpeldsp"
> @@ -2794,6 +2795,7 @@ mv30_decoder_select="aandcttables blockdsp"
>  mvha_decoder_deps="zlib"
>  mvha_decoder_select="llviddsp"
>  mwsc_decoder_deps="zlib"
> +mxf_encoder_select="pcm_rechunk_bsf"
>  mxpeg_decoder_select="mjpeg_decoder"
>  nellymoser_decoder_select="mdct sinewin"
>  nellymoser_encoder_select="audio_frame_queue mdct sinewin"
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index d4bed3c113..56ca55fbd5 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -205,7 +205,7 @@ OBJS-$(CONFIG_GIF_DEMUXER)   += gifdec.o
>  OBJS-$(CONFIG_GSM_DEMUXER)   += gsmdec.o
>  OBJS-$(CONFIG_GSM_MUXER) += rawenc.o
>  OBJS-$(CONFIG_GXF_DEMUXER)   += gxf.o
> -OBJS-$(CONFIG_GXF_MUXER) += gxfenc.o audiointerleave.o
> +OBJS-$(CONFIG_GXF_MUXER) += gxfenc.o retimeinterleave.o
>  OBJS-$(CONFIG_G722_DEMUXER)  += g722.o rawdec.o
>  OBJS-$(CONFIG_G722_MUXER)+= rawenc.o
>  OBJS-$(CONFIG_G723_1_DEMUXER)+= g723_1.o
> @@ -347,7 +347,7 @@ OBJS-$(CONFIG_MUSX_DEMUXER)  += musx.o
>  OBJS-$(CONFIG_MV_DEMUXER)+= mvdec.o
>  OBJS-$(CONFIG_MVI_DEMUXER)   += mvi.o
>  OBJS-$(CONFIG_MXF_DEMUXER)   += mxfdec.o mxf.o
> -OBJS-$(CONFIG_MXF_MUXER) += mxfenc.o mxf.o audiointerleave.o 
> avc.o
> +OBJS-$(CONFIG_MXF_MUXER) += mxfenc.o mxf.o 
> retimeinterleave.o avc.o
>  OBJS-$(CONFIG_MXG_DEMUXER)   += mxg.o
>  OBJS-$(CONFIG_NC_DEMUXER)+= ncdec.o
>  OBJS-$(CONFIG_NISTSPHERE_DEMUXER)+= nistspheredec.o pcm.o
> diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c
> index e7536a6a7e..e95ae99cba 100644
> --- a/libavformat/gxfenc.c
> +++ b/libavformat/gxfenc.c
> @@ -27,7 +27,7 @@
>  #include "avformat.h"
>  #include "internal.h"
>  #include "gxf.h"
> -#include "audiointerleave.h"
> +#include "retimeinterleave.h"
>  
>  #define GXF_AUDIO_PACKET_SIZE 65536
>  
> @@ -44,7 +44,7 @@ typedef struct GXFTimecode{
>  } GXFTimecode;
>  
>  typedef struct GXFStreamContext {
> -AudioInterleaveContext aic;
> +RetimeInterleaveContext aic;
>  uint32_t track_type;
>  uint32_t sample_size;
>  uint32_t sample_rate;
> @@ -813,14 +813,12 @@ static int gxf_write_header(AVFormatContext *s)
>  return -1;
>  }
>  }
> +ff_retime_interleave_init(&sc->aic, st->time_base);
>  /* FIXME first 10 audio tracks are 0 to 9 next 22 are A to V */
>  sc->media_info = media_info<<8 | ('0'+tracks[media_info]++);
>  sc->order = s->nb_streams - st->index;
>  }
>  
> -if (ff_audio_interleave_init(s, GXF_samples_per_frame, (AVRational){ 1, 
> 48000 }) < 0)
> -return -1;
> -
>  if (tcr && vsc)
>  gxf_init_timecode(s, &gxf->tc, tcr->value, vsc->fields);
>  
> @@ -877,8 +875,6 @@ static void gxf_deinit(AVFormatContext *s)
>  {
>  GXFContext *gxf = s->priv_data;
>  
> -ff_audio_interleave_close(s);
> -
>  av_freep(&gxf->flt_entries);
>  av_freep(&gxf->map_offsets);
>  }
> @@ -1016,8 +1012,22 @@ static int gxf_interleave_packet(AVFormatContext *s, 
> AVPacket *out, AVPacket *pk
>  {
>  if (pkt && s->streams[pkt->stream_index]->codecpar->codec_type == 
> AVMEDIA_TYPE_VIDEO)
>  pkt->duration = 2; // enforce 2 fields
> -return ff_audio_rechunk_interleave(s, out, pkt, flush,
> -   

Re: [FFmpeg-devel] [PATCH v2 2/6] avformat/mux: factorize interleaved write_packet

2020-04-25 Thread Andreas Rheinhardt
Marton Balint:
> Signed-off-by: Marton Balint 
> ---
>  libavformat/mux.c | 52 +---
>  1 file changed, 21 insertions(+), 31 deletions(-)
> 
> diff --git a/libavformat/mux.c b/libavformat/mux.c
> index 5209c84f40..90faf51768 100644
> --- a/libavformat/mux.c
> +++ b/libavformat/mux.c
> @@ -1195,6 +1195,25 @@ static int interleave_packet(AVFormatContext *s, 
> AVPacket *out, AVPacket *in, in
>  return ff_interleave_packet_per_dts(s, out, in, flush);
>  }
>  
> +static int interleaved_write_packet(AVFormatContext *s, AVPacket *pkt, int 
> flush)
> +{
> +for (;; ) {
> +AVPacket opkt;
> +int ret = interleave_packet(s, &opkt, pkt, flush);
> +if (ret <= 0)
> +return ret;
> +
> +pkt = NULL;
> +
> +ret = write_packet(s, &opkt);
> +
> +av_packet_unref(&opkt);
> +
> +if (ret < 0)
> +return ret;
> +}
> +}
> +
>  int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
>  {
>  int ret, flush = 0;
> @@ -1229,22 +1248,8 @@ int av_interleaved_write_frame(AVFormatContext *s, 
> AVPacket *pkt)
>  av_log(s, AV_LOG_TRACE, "av_interleaved_write_frame FLUSH\n");
>  flush = 1;
>  }
> +return interleaved_write_packet(s, pkt, flush);
>  
> -for (;; ) {
> -AVPacket opkt;
> -int ret = interleave_packet(s, &opkt, pkt, flush);
> -if (ret <= 0)
> -return ret;
> -
> -pkt = NULL;
> -
> -ret = write_packet(s, &opkt);
> -
> -av_packet_unref(&opkt);
> -
> -if (ret < 0)
> -return ret;
> -}
>  fail:
>  av_packet_unref(pkt);
>  return ret;
> @@ -1254,23 +1259,8 @@ int av_write_trailer(AVFormatContext *s)
>  {
>  int ret, i;
>  
> -for (;; ) {
> -AVPacket pkt;
> -ret = interleave_packet(s, &pkt, NULL, 1);
> -if (ret < 0)
> -goto fail;
> -if (!ret)
> -break;
> -
> -ret = write_packet(s, &pkt);
> -
> -av_packet_unref(&pkt);
> +ret = interleaved_write_packet(s, NULL, 1);
>  
> -if (ret < 0)
> -goto fail;
> -}
> -
> -fail:
>  if (s->oformat->write_trailer) {
>  if (!(s->oformat->flags & AVFMT_NOFILE) && s->pb)
>  avio_write_marker(s->pb, AV_NOPTS_VALUE, 
> AVIO_DATA_MARKER_TRAILER);
> 
Looks good on its own; yet I wonder about the placement of
interleaved_write_packet(). The current one requires a forward
declaration in the next patch.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v10 2/2] avformat: add demuxer for Pro Pinball Series' Soundbanks

2020-04-25 Thread Zane van Iperen
On Sun, 26 Apr 2020 00:07:52 +0200
"Michael Niedermayer"  wrote:

> On Sat, Apr 25, 2020 at 01:10:53PM +, Zane van Iperen wrote:
> > On Sat, 25 Apr 2020 13:15:25 +0200
> > "Michael Niedermayer"  wrote:
> >  
> > > > +static int pp_bnk_probe(const AVProbeData *p)
> > > > +{
> > > > +uint32_t sample_rate = AV_RL32(p->buf +  4);
> > > > +uint32_t track_count = AV_RL32(p->buf + 12);
> > > > +uint32_t flags   = AV_RL32(p->buf + 16);
> > > > +
> > > > +if (track_count == 0 || sample_rate == 0)
> > > > +return 0;  
> > >
> > > the header code checks these also for INT_MAX
> > >
> > >  
> >
> > See below I check both track_count and sample_rate for sane upper
> > limits. Is it worth adding an INT_MAX check too?  
> 
> why not ? its rejected by the header reading code
> 

Done.
> 
> >
> >
> > /* These limits are based on analysing the game files. */
> > if (track_count > 113)
> > return 10;
> >
> > if ((sample_rate !=  5512) && (sample_rate != 11025) &&
> > (sample_rate != 22050) && (sample_rate != 44100))
> > return 10;
> >
> >
> >  
> > > > +
> > > > +/* Sometimes we have the first track header, so check that
> > > > too. */
> > > > +if (p->buf_size >= 32 && AV_RL32(p->buf + 28) !=
> > > > sample_rate)
> > > > +return 0;  
> > >
> > > are files with 32 or less bytes valid ?
> > > If not its probably better to not recognize such small pieces
> > >  
> >
> > A file needs at least one track and the first track header is
> > immediately after the file header, so I guess the minimum valid size
> > would be 40 (assuming an empty track).
> >
> > Would removing the "p->buf_size >= 32" check be alright?  
> 
> yes, that should be ok due to AVPROBE_PADDING_SIZE
> 

Done.

> also iam not sure it makes sense or if it goes to far but the probe
> code could check all tracks which are within the buffer
> all these low 10 scores are a bit ugly, some more solid "yes iam sure
> this is / is not" instead of such really low scores.
> 
> low scores which get returned based on few weak checks have the
> problem of more often producing errors in detection. Random non
> multimedia files being detected as something they are not or if 2
> demuxers have such a low score detection then its more likely the
> wrong one will be choosen
> 

I agree it's ugly. Checking all the tracks seems rather messy imo, and
would only work for the smaller files anyway.

One thing that might be possible (but is still ugly) is to check for
file extension as well. These files are only ever be seen with
a ".{5,11,22,44}c" extension. If it matches, the score could be bumped
a bit higher.

A more-forceful option is to change the "return 10" checks to "return
0". Although technically valid files, there are none that exist in
the wild with these cases. I'd prefer this solution and can just leave a
comment if it needs to be changed in the future.

Zane

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/decode: use a single list bsf for codec decode bsfs

2020-04-25 Thread James Almer
On 4/25/2020 7:11 PM, Marton Balint wrote:
> Signed-off-by: Marton Balint 
> ---
>  libavcodec/cuviddec.c |   2 +-
>  libavcodec/decode.c   | 162 
> +++---
>  libavcodec/internal.h |   3 +-
>  3 files changed, 22 insertions(+), 145 deletions(-)
> 
> diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
> index 50dc8956c3..13a7db10cd 100644
> --- a/libavcodec/cuviddec.c
> +++ b/libavcodec/cuviddec.c
> @@ -946,7 +946,7 @@ static av_cold int cuvid_decode_init(AVCodecContext 
> *avctx)
>  }
>  
>  if (avctx->codec->bsfs) {
> -const AVCodecParameters *par = 
> avctx->internal->filter.bsfs[avctx->internal->filter.nb_bsfs - 1]->par_out;
> +const AVCodecParameters *par = avctx->internal->filter.bsf->par_out;
>  ctx->cuparse_ext.format.seqhdr_data_length = par->extradata_size;
>  memcpy(ctx->cuparse_ext.raw_seqhdr_data,
> par->extradata,
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index d4bdb9b1c0..167eaa6bb6 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -205,100 +205,28 @@ int ff_decode_bsfs_init(AVCodecContext *avctx)
>  {
>  AVCodecInternal *avci = avctx->internal;
>  DecodeFilterContext *s = &avci->filter;
> -const char *bsfs_str;
>  int ret;
>  
> -if (s->nb_bsfs)
> +if (s->bsf)
>  return 0;
>  
> -bsfs_str = avctx->codec->bsfs ? avctx->codec->bsfs : "null";

If i'm reading this right, if the string passed to
av_bsf_list_parse_str() results in no bsf being inserted to the list,
ff_list_bsf acts the same as if it was the null bsf, right?

> -while (bsfs_str && *bsfs_str) {
> -AVBSFContext **tmp;
> -const AVBitStreamFilter *filter;
> -char *bsf, *bsf_options_str, *bsf_name;
> -
> -bsf = av_get_token(&bsfs_str, ",");
> -if (!bsf) {
> -ret = AVERROR(ENOMEM);
> -goto fail;
> -}
> -bsf_name = av_strtok(bsf, "=", &bsf_options_str);
> -if (!bsf_name) {
> -av_freep(&bsf);
> -ret = AVERROR(ENOMEM);
> -goto fail;
> -}
> -
> -filter = av_bsf_get_by_name(bsf_name);
> -if (!filter) {
> -av_log(avctx, AV_LOG_ERROR, "A non-existing bitstream filter %s "
> -   "requested by a decoder. This is a bug, please report 
> it.\n",
> -   bsf_name);
> -av_freep(&bsf);
> -ret = AVERROR_BUG;
> -goto fail;
> -}
> -
> -tmp = av_realloc_array(s->bsfs, s->nb_bsfs + 1, sizeof(*s->bsfs));
> -if (!tmp) {
> -av_freep(&bsf);
> -ret = AVERROR(ENOMEM);
> -goto fail;
> -}
> -s->bsfs = tmp;
> -
> -ret = av_bsf_alloc(filter, &s->bsfs[s->nb_bsfs]);
> -if (ret < 0) {
> -av_freep(&bsf);
> -goto fail;
> -}
> -s->nb_bsfs++;
> -
> -if (s->nb_bsfs == 1) {
> -/* We do not currently have an API for passing the input 
> timebase into decoders,
> - * but no filters used here should actually need it.
> - * So we make up some plausible-looking number (the MPEG 90kHz 
> timebase) */
> -s->bsfs[s->nb_bsfs - 1]->time_base_in = (AVRational){ 1, 9 };
> -ret = avcodec_parameters_from_context(s->bsfs[s->nb_bsfs - 
> 1]->par_in,
> -  avctx);
> -} else {
> -s->bsfs[s->nb_bsfs - 1]->time_base_in = s->bsfs[s->nb_bsfs - 
> 2]->time_base_out;
> -ret = avcodec_parameters_copy(s->bsfs[s->nb_bsfs - 1]->par_in,
> -  s->bsfs[s->nb_bsfs - 2]->par_out);
> -}
> -if (ret < 0) {
> -av_freep(&bsf);
> -goto fail;
> -}
> -
> -if (bsf_options_str && filter->priv_class) {
> -const AVOption *opt = av_opt_next(s->bsfs[s->nb_bsfs - 
> 1]->priv_data, NULL);
> -const char * shorthand[2] = {NULL};
> -
> -if (opt)
> -shorthand[0] = opt->name;
> -
> -ret = av_opt_set_from_string(s->bsfs[s->nb_bsfs - 1]->priv_data, 
> bsf_options_str, shorthand, "=", ":");
> -if (ret < 0) {
> -if (ret != AVERROR(ENOMEM)) {
> -av_log(avctx, AV_LOG_ERROR, "Invalid options for 
> bitstream filter %s "
> -   "requested by the decoder. This is a bug, please 
> report it.\n",
> -   bsf_name);
> -ret = AVERROR_BUG;
> -}
> -av_freep(&bsf);
> -goto fail;
> -}
> -}
> -av_freep(&bsf);
> +ret = av_bsf_list_parse_str(avctx->codec->bsfs, &s->bsf);
> +if (ret < 0) {
> +av_log(avctx, AV_LOG_ERROR, "Error parsing decoder bitstream filters 
> '%s': %s\n", avctx->codec->bsfs, av_err2str(ret));

Re: [FFmpeg-devel] [PATCH]lavc/jpeg2000dec: Scale 4-7bit output to 8 bits

2020-04-25 Thread Carl Eugen Hoyos
Am So., 26. Apr. 2020 um 01:00 Uhr schrieb Michael Niedermayer
:
>
> On Sat, Apr 25, 2020 at 07:26:08PM +0200, Carl Eugen Hoyos wrote:
> > Hi!
> >
> > Attached patch makes the output of the reference sample p0_03.j2k
> > bit-exact with opj_decompress and kdu_render and more similar to
> > jasper's output.
> >
> > Please comment, Carl Eugen
>
> can these per pixel computations be avoided by adjusting
> f_stepsize / i_stepsize ?

Sorry, I cannot answer this but I realize that the patch probably
only makes sense for the lossless transformation.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH]lavc/jpeg2000dec: Scale 4-7bit output to 8 bits

2020-04-25 Thread Michael Niedermayer
On Sat, Apr 25, 2020 at 07:26:08PM +0200, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch makes the output of the reference sample p0_03.j2k
> bit-exact with opj_decompress and kdu_render and more similar to
> jasper's output.
> 
> Please comment, Carl Eugen

can these per pixel computations be avoided by adjusting
f_stepsize / i_stepsize ?

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v3 5/6] avcodec/pcm_rechunk_bsf: add bitstream filter to rechunk pcm audio

2020-04-25 Thread Andreas Rheinhardt
Marton Balint:
> Signed-off-by: Marton Balint 
> ---
>  Changelog  |   1 +
>  doc/bitstream_filters.texi |  30 ++
>  libavcodec/Makefile|   1 +
>  libavcodec/bitstream_filters.c |   1 +
>  libavcodec/pcm_rechunk_bsf.c   | 206 
> +
>  libavcodec/version.h   |   2 +-
>  6 files changed, 240 insertions(+), 1 deletion(-)
>  create mode 100644 libavcodec/pcm_rechunk_bsf.c
> 
> diff --git a/Changelog b/Changelog
> index d9fcd8bb0a..6b0c911279 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -59,6 +59,7 @@ version :
>  - mv30 decoder
>  - Expanded styling support for 3GPP Timed Text Subtitles (movtext)
>  - WebP parser
> +- pcm_rechunk bitstream filter
>  
>  
>  version 4.2:
> diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
> index 8fe5b3ad75..70c276feed 100644
> --- a/doc/bitstream_filters.texi
> +++ b/doc/bitstream_filters.texi
> @@ -548,6 +548,36 @@ ffmpeg -i INPUT -c copy -bsf noise[=1] output.mkv
>  @section null
>  This bitstream filter passes the packets through unchanged.
>  
> +@section pcm_rechunk
> +
> +Repacketize PCM audio to a fixed number of samples per packet or a fixed 
> packet
> +rate per second. This is similar to the @ref{asetnsamples,,asetnsamples audio
> +filter,ffmpeg-filters} but works on audio packets instead of audio frames.
> +
> +@table @option
> +@item nb_out_samples, n
> +Set the number of samples per each output audio packet. The number is 
> intended
> +as the number of samples @emph{per each channel}. Default value is 1024.
> +
> +@item pad, p
> +If set to 1, the filter will pad the last audio packet with silence, so that 
> it
> +will contain the same number of samples (or roughly the same number of 
> samples,
> +see @option{frame_rate}) as the previous ones. Default value is 1.
> +
> +@item frame_rate, r
> +This option makes the filter output a fixed numer of packets per second 
> instead
> +of a fixed number of samples per packet. If the audio sample rate is not
> +divisible by the frame rate then the number of samples will not be constant 
> but
> +will vary slightly so that each packet will start as close as to the frame

"as close to the frame boundary as possible" or "as close as possible to
the frame boundary"

> +boundary as possible. Using this option has precedence over 
> @option{nb_out_samples}.
> +@end table
> +
> +You can generate the well known 1602-1601-1602-1601-1602 pattern of 48kHz 
> audio
> +for NTSC frame rate using the @option{frame_rate} option.
> +@example
> +ffmpeg -f lavfi -i sine=r=48000:d=1 -c pcm_s16le -bsf 
> pcm_rechunk=r=3/1001 -f framecrc -
> +@end example
> +
>  @section prores_metadata
>  
>  Modify color property metadata embedded in prores stream.
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 88944d9a3a..35968bdaf7 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -1115,6 +1115,7 @@ OBJS-$(CONFIG_MP3_HEADER_DECOMPRESS_BSF)  += 
> mp3_header_decompress_bsf.o \
>  OBJS-$(CONFIG_MPEG2_METADATA_BSF) += mpeg2_metadata_bsf.o
>  OBJS-$(CONFIG_NOISE_BSF)  += noise_bsf.o
>  OBJS-$(CONFIG_NULL_BSF)   += null_bsf.o
> +OBJS-$(CONFIG_PCM_RECHUNK_BSF)+= pcm_rechunk_bsf.o
>  OBJS-$(CONFIG_PRORES_METADATA_BSF)+= prores_metadata_bsf.o
>  OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF)   += remove_extradata_bsf.o
>  OBJS-$(CONFIG_TEXT2MOVSUB_BSF)+= movsub_bsf.o
> diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
> index 6b5ffe4d70..9e701191f8 100644
> --- a/libavcodec/bitstream_filters.c
> +++ b/libavcodec/bitstream_filters.c
> @@ -49,6 +49,7 @@ extern const AVBitStreamFilter ff_mpeg4_unpack_bframes_bsf;
>  extern const AVBitStreamFilter ff_mov2textsub_bsf;
>  extern const AVBitStreamFilter ff_noise_bsf;
>  extern const AVBitStreamFilter ff_null_bsf;
> +extern const AVBitStreamFilter ff_pcm_rechunk_bsf;
>  extern const AVBitStreamFilter ff_prores_metadata_bsf;
>  extern const AVBitStreamFilter ff_remove_extradata_bsf;
>  extern const AVBitStreamFilter ff_text2movsub_bsf;
> diff --git a/libavcodec/pcm_rechunk_bsf.c b/libavcodec/pcm_rechunk_bsf.c
> new file mode 100644
> index 00..2a038fd79b
> --- /dev/null
> +++ b/libavcodec/pcm_rechunk_bsf.c
> @@ -0,0 +1,206 @@
> +/*
> + * Copyright (c) 2020 Marton Balint
> + *
> + * 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 co

[FFmpeg-devel] [PATCH] avcodec/decode: use a single list bsf for codec decode bsfs

2020-04-25 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavcodec/cuviddec.c |   2 +-
 libavcodec/decode.c   | 162 +++---
 libavcodec/internal.h |   3 +-
 3 files changed, 22 insertions(+), 145 deletions(-)

diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index 50dc8956c3..13a7db10cd 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -946,7 +946,7 @@ static av_cold int cuvid_decode_init(AVCodecContext *avctx)
 }
 
 if (avctx->codec->bsfs) {
-const AVCodecParameters *par = 
avctx->internal->filter.bsfs[avctx->internal->filter.nb_bsfs - 1]->par_out;
+const AVCodecParameters *par = avctx->internal->filter.bsf->par_out;
 ctx->cuparse_ext.format.seqhdr_data_length = par->extradata_size;
 memcpy(ctx->cuparse_ext.raw_seqhdr_data,
par->extradata,
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index d4bdb9b1c0..167eaa6bb6 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -205,100 +205,28 @@ int ff_decode_bsfs_init(AVCodecContext *avctx)
 {
 AVCodecInternal *avci = avctx->internal;
 DecodeFilterContext *s = &avci->filter;
-const char *bsfs_str;
 int ret;
 
-if (s->nb_bsfs)
+if (s->bsf)
 return 0;
 
-bsfs_str = avctx->codec->bsfs ? avctx->codec->bsfs : "null";
-while (bsfs_str && *bsfs_str) {
-AVBSFContext **tmp;
-const AVBitStreamFilter *filter;
-char *bsf, *bsf_options_str, *bsf_name;
-
-bsf = av_get_token(&bsfs_str, ",");
-if (!bsf) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
-bsf_name = av_strtok(bsf, "=", &bsf_options_str);
-if (!bsf_name) {
-av_freep(&bsf);
-ret = AVERROR(ENOMEM);
-goto fail;
-}
-
-filter = av_bsf_get_by_name(bsf_name);
-if (!filter) {
-av_log(avctx, AV_LOG_ERROR, "A non-existing bitstream filter %s "
-   "requested by a decoder. This is a bug, please report 
it.\n",
-   bsf_name);
-av_freep(&bsf);
-ret = AVERROR_BUG;
-goto fail;
-}
-
-tmp = av_realloc_array(s->bsfs, s->nb_bsfs + 1, sizeof(*s->bsfs));
-if (!tmp) {
-av_freep(&bsf);
-ret = AVERROR(ENOMEM);
-goto fail;
-}
-s->bsfs = tmp;
-
-ret = av_bsf_alloc(filter, &s->bsfs[s->nb_bsfs]);
-if (ret < 0) {
-av_freep(&bsf);
-goto fail;
-}
-s->nb_bsfs++;
-
-if (s->nb_bsfs == 1) {
-/* We do not currently have an API for passing the input timebase 
into decoders,
- * but no filters used here should actually need it.
- * So we make up some plausible-looking number (the MPEG 90kHz 
timebase) */
-s->bsfs[s->nb_bsfs - 1]->time_base_in = (AVRational){ 1, 9 };
-ret = avcodec_parameters_from_context(s->bsfs[s->nb_bsfs - 
1]->par_in,
-  avctx);
-} else {
-s->bsfs[s->nb_bsfs - 1]->time_base_in = s->bsfs[s->nb_bsfs - 
2]->time_base_out;
-ret = avcodec_parameters_copy(s->bsfs[s->nb_bsfs - 1]->par_in,
-  s->bsfs[s->nb_bsfs - 2]->par_out);
-}
-if (ret < 0) {
-av_freep(&bsf);
-goto fail;
-}
-
-if (bsf_options_str && filter->priv_class) {
-const AVOption *opt = av_opt_next(s->bsfs[s->nb_bsfs - 
1]->priv_data, NULL);
-const char * shorthand[2] = {NULL};
-
-if (opt)
-shorthand[0] = opt->name;
-
-ret = av_opt_set_from_string(s->bsfs[s->nb_bsfs - 1]->priv_data, 
bsf_options_str, shorthand, "=", ":");
-if (ret < 0) {
-if (ret != AVERROR(ENOMEM)) {
-av_log(avctx, AV_LOG_ERROR, "Invalid options for bitstream 
filter %s "
-   "requested by the decoder. This is a bug, please 
report it.\n",
-   bsf_name);
-ret = AVERROR_BUG;
-}
-av_freep(&bsf);
-goto fail;
-}
-}
-av_freep(&bsf);
+ret = av_bsf_list_parse_str(avctx->codec->bsfs, &s->bsf);
+if (ret < 0) {
+av_log(avctx, AV_LOG_ERROR, "Error parsing decoder bitstream filters 
'%s': %s\n", avctx->codec->bsfs, av_err2str(ret));
+goto fail;
+}
 
-ret = av_bsf_init(s->bsfs[s->nb_bsfs - 1]);
-if (ret < 0)
-goto fail;
+/* We do not currently have an API for passing the input timebase into 
decoders,
+ * but no filters used here should actually need it.
+ * So we make up some plausible-looking number (the MPEG 90kHz timebase) */
+s->bsf->time_base_in = (AVRational){ 1, 9 };
+ret = avcodec_parameters_from_context(s->bsf->par_in, avctx);
+if (ret < 

Re: [FFmpeg-devel] [PATCH v10 2/2] avformat: add demuxer for Pro Pinball Series' Soundbanks

2020-04-25 Thread Michael Niedermayer
On Sat, Apr 25, 2020 at 01:10:53PM +, Zane van Iperen wrote:
> On Sat, 25 Apr 2020 13:15:25 +0200
> "Michael Niedermayer"  wrote:
> 
> > > +static int pp_bnk_probe(const AVProbeData *p)
> > > +{
> > > +uint32_t sample_rate = AV_RL32(p->buf +  4);
> > > +uint32_t track_count = AV_RL32(p->buf + 12);
> > > +uint32_t flags   = AV_RL32(p->buf + 16);
> > > +
> > > +if (track_count == 0 || sample_rate == 0)
> > > +return 0;  
> > 
> > the header code checks these also for INT_MAX
> > 
> > 
> 
> See below I check both track_count and sample_rate for sane upper
> limits. Is it worth adding an INT_MAX check too?

why not ? its rejected by the header reading code


> 
> 
> /* These limits are based on analysing the game files. */
> if (track_count > 113)
> return 10;
> 
> if ((sample_rate !=  5512) && (sample_rate != 11025) &&
> (sample_rate != 22050) && (sample_rate != 44100))
> return 10;
> 
> 
> 
> > > +
> > > +/* Sometimes we have the first track header, so check that
> > > too. */
> > > +if (p->buf_size >= 32 && AV_RL32(p->buf + 28) != sample_rate)
> > > +return 0;  
> > 
> > are files with 32 or less bytes valid ?
> > If not its probably better to not recognize such small pieces
> > 
> 
> A file needs at least one track and the first track header is
> immediately after the file header, so I guess the minimum valid size
> would be 40 (assuming an empty track).
> 
> Would removing the "p->buf_size >= 32" check be alright?

yes, that should be ok due to AVPROBE_PADDING_SIZE

also iam not sure it makes sense or if it goes to far but the probe
code could check all tracks which are within the buffer
all these low 10 scores are a bit ugly, some more solid "yes iam sure
this is / is not" instead of such really low scores.

low scores which get returned based on few weak checks have the problem
of more often producing errors in detection. Random non multimedia files being
detected as something they are not or if 2 demuxers have such a low score
detection then its more likely the wrong one will be choosen


thx

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

If you fake or manipulate statistics in a paper in physics you will never
get a job again.
If you fake or manipulate statistics in a paper in medicin you will get
a job for life at the pharma industry.


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 0/2] fix for seeking in HLS with TS/FMP4 media

2020-04-25 Thread Carl Eugen Hoyos
Am Fr., 24. Apr. 2020 um 17:21 Uhr schrieb vectronic
:
>
> I am resubmitting a patch which fixes the following two tickets:
>
> https://trac.ffmpeg.org/ticket/7359
> https://trac.ffmpeg.org/ticket/7485

Are you Nick Ryan / did you write the attached patches?

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/dirac_vlc: Fix integer overflow in ff_dirac_golomb_read_32bit()

2020-04-25 Thread Michael Niedermayer
On Sat, Apr 25, 2020 at 12:29:15AM +0200, Lynne wrote:
> Apr 24, 2020, 23:04 by mich...@niedermayer.cc:
> 
> > Fixes: left shift of 1073741824 by 1 places cannot be represented in type 
> > 'int32_t' (aka 'int')
> > Fixes: 
> > 21245/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DIRAC_fuzzer-5683334274613248
> >
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/dirac_vlc.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/dirac_vlc.c b/libavcodec/dirac_vlc.c
> > index fbe28017bc..6d53078fc0 100644
> > --- a/libavcodec/dirac_vlc.c
> > +++ b/libavcodec/dirac_vlc.c
> > @@ -1115,7 +1115,7 @@ int ff_dirac_golomb_read_32bit(const uint8_t *buf, 
> > int bytes,
> >  {
> >  LUTState lut = ff_dirac_golomb_lut[*buf++];
> >  int32_t *dst = (int32_t *)_dst, *last = dst + coeffs;
> > -int32_t val = 0;
> > +uint32_t val = 0;
> >  
> >  for (int i = 1; i < bytes; i++)
> >  PROCESS_VALS;
> > -- 
> > 2.17.1
> >
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-requ...@ffmpeg.org>  with subject "unsubscribe".
> >
> 
> LGTM.
> You should change the same variable in ff_dirac_golomb_read_16bit to a 
> uint16_t too, to be safe.

will apply with that change

thx

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

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/3] avcodec/bsf: support shorthand options for av_bsf_list_parse_str

2020-04-25 Thread James Almer
On 4/25/2020 3:55 PM, Marton Balint wrote:
> Or maybe we should just drop supporting shorthand options instead?

That would be a breaking change (commands like -bsf:v noise=123 would
stop working), vs extending existing API in a way that i assume does not
break currently valid strings, so this approach is better.

> 
> Signed-off-by: Marton Balint 
> ---
>  libavcodec/bsf.c | 53 ++---
>  1 file changed, 26 insertions(+), 27 deletions(-)
> 
> diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
> index d3a9db57f7..85b63a5c9a 100644
> --- a/libavcodec/bsf.c
> +++ b/libavcodec/bsf.c
> @@ -431,7 +431,7 @@ int av_bsf_list_append(AVBSFList *lst, AVBSFContext *bsf)
>  return av_dynarray_add_nofree(&lst->bsfs, &lst->nb_bsfs, bsf);
>  }
>  
> -int av_bsf_list_append2(AVBSFList *lst, const char *bsf_name, AVDictionary 
> ** options)
> +static int bsf_list_append_internal(AVBSFList *lst, const char *bsf_name, 
> const char *options, AVDictionary ** options_dict)
>  {
>  int ret;
>  const AVBitStreamFilter *filter;
> @@ -445,8 +445,20 @@ int av_bsf_list_append2(AVBSFList *lst, const char 
> *bsf_name, AVDictionary ** op
>  if (ret < 0)
>  return ret;
>  
> -if (options) {
> -ret = av_opt_set_dict2(bsf, options, AV_OPT_SEARCH_CHILDREN);
> +if (options && filter->priv_class) {
> +const AVOption *opt = av_opt_next(bsf->priv_data, NULL);
> +const char * shorthand[2] = {NULL};
> +
> +if (opt)
> +shorthand[0] = opt->name;
> +
> +ret = av_opt_set_from_string(bsf->priv_data, options, shorthand, 
> "=", ":");
> +if (ret < 0)
> +goto end;
> +}
> +
> +if (options_dict) {
> +ret = av_opt_set_dict2(bsf, options_dict, AV_OPT_SEARCH_CHILDREN);
>  if (ret < 0)
>  goto end;
>  }
> @@ -460,6 +472,11 @@ end:
>  return ret;
>  }
>  
> +int av_bsf_list_append2(AVBSFList *lst, const char *bsf_name, AVDictionary 
> ** options)
> +{
> +return bsf_list_append_internal(lst, bsf_name, NULL, options);
> +}
> +
>  int av_bsf_list_finalize(AVBSFList **lst, AVBSFContext **bsf)
>  {
>  int ret = 0;
> @@ -486,33 +503,15 @@ end:
>  return ret;
>  }
>  
> -static int bsf_parse_single(const char *str, AVBSFList *bsf_lst)
> +static int bsf_parse_single(char *str, AVBSFList *bsf_lst)
>  {
> -char *bsf_name, *bsf_options_str, *buf;
> -AVDictionary *bsf_options = NULL;
> -int ret = 0;
> +char *bsf_name, *bsf_options_str;
>  
> -if (!(buf = av_strdup(str)))
> -return AVERROR(ENOMEM);
> -
> -bsf_name = av_strtok(buf, "=", &bsf_options_str);
> -if (!bsf_name) {
> -ret = AVERROR(EINVAL);
> -goto end;
> -}
> -
> -if (bsf_options_str) {
> -ret = av_dict_parse_string(&bsf_options, bsf_options_str, "=", ":", 
> 0);
> -if (ret < 0)
> -goto end;
> -}
> -
> -ret = av_bsf_list_append2(bsf_lst, bsf_name, &bsf_options);
> +bsf_name = av_strtok(str, "=", &bsf_options_str);
> +if (!bsf_name)
> +return AVERROR(EINVAL);
>  
> -end:
> -av_dict_free(&bsf_options);
> -av_free(buf);
> -return ret;
> +return bsf_list_append_internal(bsf_lst, bsf_name, bsf_options_str, 
> NULL);
>  }
>  
>  int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf_lst)
> 

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/3] avcodec/bsf: support shorthand options for av_bsf_list_parse_str

2020-04-25 Thread Marton Balint
Or maybe we should just drop supporting shorthand options instead?

Signed-off-by: Marton Balint 
---
 libavcodec/bsf.c | 53 ++---
 1 file changed, 26 insertions(+), 27 deletions(-)

diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
index d3a9db57f7..85b63a5c9a 100644
--- a/libavcodec/bsf.c
+++ b/libavcodec/bsf.c
@@ -431,7 +431,7 @@ int av_bsf_list_append(AVBSFList *lst, AVBSFContext *bsf)
 return av_dynarray_add_nofree(&lst->bsfs, &lst->nb_bsfs, bsf);
 }
 
-int av_bsf_list_append2(AVBSFList *lst, const char *bsf_name, AVDictionary ** 
options)
+static int bsf_list_append_internal(AVBSFList *lst, const char *bsf_name, 
const char *options, AVDictionary ** options_dict)
 {
 int ret;
 const AVBitStreamFilter *filter;
@@ -445,8 +445,20 @@ int av_bsf_list_append2(AVBSFList *lst, const char 
*bsf_name, AVDictionary ** op
 if (ret < 0)
 return ret;
 
-if (options) {
-ret = av_opt_set_dict2(bsf, options, AV_OPT_SEARCH_CHILDREN);
+if (options && filter->priv_class) {
+const AVOption *opt = av_opt_next(bsf->priv_data, NULL);
+const char * shorthand[2] = {NULL};
+
+if (opt)
+shorthand[0] = opt->name;
+
+ret = av_opt_set_from_string(bsf->priv_data, options, shorthand, "=", 
":");
+if (ret < 0)
+goto end;
+}
+
+if (options_dict) {
+ret = av_opt_set_dict2(bsf, options_dict, AV_OPT_SEARCH_CHILDREN);
 if (ret < 0)
 goto end;
 }
@@ -460,6 +472,11 @@ end:
 return ret;
 }
 
+int av_bsf_list_append2(AVBSFList *lst, const char *bsf_name, AVDictionary ** 
options)
+{
+return bsf_list_append_internal(lst, bsf_name, NULL, options);
+}
+
 int av_bsf_list_finalize(AVBSFList **lst, AVBSFContext **bsf)
 {
 int ret = 0;
@@ -486,33 +503,15 @@ end:
 return ret;
 }
 
-static int bsf_parse_single(const char *str, AVBSFList *bsf_lst)
+static int bsf_parse_single(char *str, AVBSFList *bsf_lst)
 {
-char *bsf_name, *bsf_options_str, *buf;
-AVDictionary *bsf_options = NULL;
-int ret = 0;
+char *bsf_name, *bsf_options_str;
 
-if (!(buf = av_strdup(str)))
-return AVERROR(ENOMEM);
-
-bsf_name = av_strtok(buf, "=", &bsf_options_str);
-if (!bsf_name) {
-ret = AVERROR(EINVAL);
-goto end;
-}
-
-if (bsf_options_str) {
-ret = av_dict_parse_string(&bsf_options, bsf_options_str, "=", ":", 0);
-if (ret < 0)
-goto end;
-}
-
-ret = av_bsf_list_append2(bsf_lst, bsf_name, &bsf_options);
+bsf_name = av_strtok(str, "=", &bsf_options_str);
+if (!bsf_name)
+return AVERROR(EINVAL);
 
-end:
-av_dict_free(&bsf_options);
-av_free(buf);
-return ret;
+return bsf_list_append_internal(bsf_lst, bsf_name, bsf_options_str, NULL);
 }
 
 int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf_lst)
-- 
2.16.4

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 3/3] fftools/ffmpeg_opt: use av_bsf_list_parse_str for parsing bsf lists

2020-04-25 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 fftools/ffmpeg_opt.c | 57 +++-
 1 file changed, 3 insertions(+), 54 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index b52aa28626..dc42fb19d6 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1416,7 +1416,6 @@ static OutputStream *new_output_stream(OptionsContext *o, 
AVFormatContext *oc, e
 {
 OutputStream *ost;
 AVStream *st = avformat_new_stream(oc, NULL);
-AVBSFList *bsf_list = NULL;
 int idx  = oc->nb_streams - 1, ret = 0;
 const char *bsfs = NULL, *time_base = NULL;
 char *next, *codec_tag = NULL;
@@ -1536,60 +1535,10 @@ static OutputStream *new_output_stream(OptionsContext 
*o, AVFormatContext *oc, e
 MATCH_PER_STREAM_OPT(copy_prior_start, i, ost->copy_prior_start, oc ,st);
 
 MATCH_PER_STREAM_OPT(bitstream_filters, str, bsfs, oc, st);
-while (bsfs && *bsfs) {
-const AVBitStreamFilter *filter;
-char *bsf, *bsf_options_str, *bsf_name;
-AVBSFContext *bsf_ctx;
-
-bsf = av_get_token(&bsfs, ",");
-if (!bsf)
-exit_program(1);
-bsf_name = av_strtok(bsf, "=", &bsf_options_str);
-if (!bsf_name)
-exit_program(1);
-
-filter = av_bsf_get_by_name(bsf_name);
-if (!filter) {
-av_log(NULL, AV_LOG_FATAL, "Unknown bitstream filter %s\n", 
bsf_name);
-exit_program(1);
-}
-
-ret = av_bsf_alloc(filter, &bsf_ctx);
-if (ret < 0) {
-av_log(NULL, AV_LOG_ERROR, "Error allocating a bitstream filter 
context\n");
-exit_program(1);
-}
-
-if (bsf_options_str && filter->priv_class) {
-const AVOption *opt = av_opt_next(bsf_ctx->priv_data, NULL);
-const char * shorthand[2] = {NULL};
-
-if (opt)
-shorthand[0] = opt->name;
-
-ret = av_opt_set_from_string(bsf_ctx->priv_data, bsf_options_str, 
shorthand, "=", ":");
-if (ret < 0) {
-av_log(NULL, AV_LOG_ERROR, "Error parsing options for 
bitstream filter %s\n", bsf_name);
-exit_program(1);
-}
-}
-
-if (!bsf_list)
-bsf_list = av_bsf_list_alloc();
-if (!bsf_list || av_bsf_list_append(bsf_list, bsf_ctx) < 0) {
-av_log(NULL, AV_LOG_ERROR, "Failed to allocate or append to bsf 
list\n");
-exit_program(1);
-}
-
-av_freep(&bsf);
-
-if (*bsfs)
-bsfs++;
-}
-if (bsf_list) {
-ret = av_bsf_list_finalize(&bsf_list, &ost->bsf_ctx);
+if (bsfs && *bsfs) {
+ret = av_bsf_list_parse_str(bsfs, &ost->bsf_ctx);
 if (ret < 0) {
-av_log(NULL, AV_LOG_ERROR, "Failed to finalize bsf list\n");
+av_log(NULL, AV_LOG_ERROR, "Error parsing bitstream filter 
sequence '%s': %s\n", bsfs, av_err2str(ret));
 exit_program(1);
 }
 }
-- 
2.16.4

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/3] fftools/ffmpeg: use a bsf list instead of individual bsfs

2020-04-25 Thread Marton Balint
Unfortunately the parsing part cannot use the API because it is supporting
shorthand options and the API is not.

Signed-off-by: Marton Balint 
---
 fftools/ffmpeg.c | 72 ++--
 fftools/ffmpeg.h |  3 +--
 fftools/ffmpeg_opt.c | 31 ++
 3 files changed, 40 insertions(+), 66 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index d896b14a14..e46575481b 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -558,9 +558,7 @@ static void ffmpeg_cleanup(int ret)
 if (!ost)
 continue;
 
-for (j = 0; j < ost->nb_bitstream_filters; j++)
-av_bsf_free(&ost->bsf_ctx[j]);
-av_freep(&ost->bsf_ctx);
+av_bsf_free(&ost->bsf_ctx);
 
 av_frame_free(&ost->filtered_frame);
 av_frame_free(&ost->last_frame);
@@ -859,40 +857,15 @@ static void output_packet(OutputFile *of, AVPacket *pkt,
 {
 int ret = 0;
 
-/* apply the output bitstream filters, if any */
-if (ost->nb_bitstream_filters) {
-int idx;
-
-ret = av_bsf_send_packet(ost->bsf_ctx[0], eof ? NULL : pkt);
+/* apply the output bitstream filters */
+if (ost->bsf_ctx) {
+ret = av_bsf_send_packet(ost->bsf_ctx, eof ? NULL : pkt);
 if (ret < 0)
 goto finish;
-
-eof = 0;
-idx = 1;
-while (idx) {
-/* get a packet from the previous filter up the chain */
-ret = av_bsf_receive_packet(ost->bsf_ctx[idx - 1], pkt);
-if (ret == AVERROR(EAGAIN)) {
-ret = 0;
-idx--;
-continue;
-} else if (ret == AVERROR_EOF) {
-eof = 1;
-} else if (ret < 0)
-goto finish;
-
-/* send it to the next filter down the chain or to the muxer */
-if (idx < ost->nb_bitstream_filters) {
-ret = av_bsf_send_packet(ost->bsf_ctx[idx], eof ? NULL : pkt);
-if (ret < 0)
-goto finish;
-idx++;
-eof = 0;
-} else if (eof)
-goto finish;
-else
-write_packet(of, pkt, ost, 0);
-}
+while ((ret = av_bsf_receive_packet(ost->bsf_ctx, pkt)) >= 0)
+write_packet(of, pkt, ost, 0);
+if (ret == AVERROR(EAGAIN))
+ret = 0;
 } else if (!eof)
 write_packet(of, pkt, ost, 0);
 
@@ -3015,35 +2988,28 @@ static int check_init_output_file(OutputFile *of, int 
file_index)
 
 static int init_output_bsfs(OutputStream *ost)
 {
-AVBSFContext *ctx;
+AVBSFContext *ctx = ost->bsf_ctx;
 int i, ret;
 
-if (!ost->nb_bitstream_filters)
+if (!ctx)
 return 0;
 
-for (i = 0; i < ost->nb_bitstream_filters; i++) {
-ctx = ost->bsf_ctx[i];
-
-ret = avcodec_parameters_copy(ctx->par_in,
-  i ? ost->bsf_ctx[i - 1]->par_out : 
ost->st->codecpar);
-if (ret < 0)
-return ret;
+ret = avcodec_parameters_copy(ctx->par_in, ost->st->codecpar);
+if (ret < 0)
+return ret;
 
-ctx->time_base_in = i ? ost->bsf_ctx[i - 1]->time_base_out : 
ost->st->time_base;
+ctx->time_base_in = ost->st->time_base;
 
-ret = av_bsf_init(ctx);
-if (ret < 0) {
-av_log(NULL, AV_LOG_ERROR, "Error initializing bitstream filter: 
%s\n",
-   ost->bsf_ctx[i]->filter->name);
-return ret;
-}
+ret = av_bsf_init(ctx);
+if (ret < 0) {
+av_log(NULL, AV_LOG_ERROR, "Error initializing bitstream filter: %s\n",
+   ctx->filter->name);
+return ret;
 }
 
-ctx = ost->bsf_ctx[ost->nb_bitstream_filters - 1];
 ret = avcodec_parameters_copy(ost->st->codecpar, ctx->par_out);
 if (ret < 0)
 return ret;
-
 ost->st->time_base = ctx->time_base_out;
 
 return 0;
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index fbaae15377..f2e30300c1 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -459,8 +459,7 @@ typedef struct OutputStream {
 AVRational mux_timebase;
 AVRational enc_timebase;
 
-intnb_bitstream_filters;
-AVBSFContext**bsf_ctx;
+AVBSFContext*bsf_ctx;
 
 AVCodecContext *enc_ctx;
 AVCodecParameters *ref_par; /* associated input codec parameters with 
encoders options applied */
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 680f0f1dfb..b52aa28626 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1416,6 +1416,7 @@ static OutputStream *new_output_stream(OptionsContext *o, 
AVFormatContext *oc, e
 {
 OutputStream *ost;
 AVStream *st = avformat_new_stream(oc, NULL);
+AVBSFList *bsf_list = NULL;
 int idx  = oc->nb_streams - 1, ret = 0;
 const char *bsfs = NULL, *time_base = NULL;
 char *next, *codec_tag = NULL;
@@ -1538,6 +1539,7 @@ static O

Re: [FFmpeg-devel] [PATCH v2] avcodec/bsf: simplify the code

2020-04-25 Thread Marton Balint



On Sat, 18 Apr 2020, lance.lmw...@gmail.com wrote:


From: Limin Wang 

Signed-off-by: Limin Wang 
---
libavcodec/bsf.c | 6 +-
1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
index b9fc771..3cacbd4 100644
--- a/libavcodec/bsf.c
+++ b/libavcodec/bsf.c
@@ -534,11 +534,7 @@ int av_bsf_list_parse_str(const char *str, AVBSFContext 
**bsf_lst)
goto end;
}

-while (1) {
-bsf_str = av_strtok(buf, ",", &saveptr);
-if (!bsf_str)
-break;
-
+while (bsf_str = av_strtok(buf, ",", &saveptr)) {
ret = bsf_parse_single(bsf_str, lst);
if (ret < 0)
goto end;


Thanks, applied.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] Patchwork inactive account cleanup

2020-04-25 Thread Andriy Gelman
Hello Patchwork users,

We currently have a large number of spam/bot accounts in patchwork that need to
be cleaned up.

If in the past you did not confirm your registration via an email link, your
account is inactive and will be deleted (note that currently these accounts 
cannot log
into patchwork or reset their password). 

Let me know if you have any questions (taliho on #ffmpeg-devel)

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] fate: hevc: Skip a few large testcases if large tests are disabled

2020-04-25 Thread Martin Storsjö

On Thu, 23 Apr 2020, Martin Storsjö wrote:


---
I've seen spurious failures of specifically these tests, in memory
constrained setups.
---
tests/fate/hevc.mak | 19 ++-
1 file changed, 18 insertions(+), 1 deletion(-)


Will apply soon unless there's any comments - same for the other patch for 
vsynth*-dnxhd-uhd-hr-sq.


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH]lavc/jpeg2000dec: Scale 4-7bit output to 8 bits

2020-04-25 Thread Carl Eugen Hoyos
Hi!

Attached patch makes the output of the reference sample p0_03.j2k
bit-exact with opj_decompress and kdu_render and more similar to
jasper's output.

Please comment, Carl Eugen
From de80453a8decd95b4a71cea71b20ba0bd74485cb Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Sat, 25 Apr 2020 18:31:22 +0200
Subject: [PATCH] lavc/jpeg2000dec: Scale 4-7 bit output to 8 bits.

Makes p0_03.j2k output bitexact with opj_decompress and kdu_render
and more similar with the output of jasper.
---
 libavcodec/jpeg2000dec.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 460a4ad95c..8d7c729530 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -1938,7 +1938,9 @@ static inline void tile_codeblocks(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile
 int val = lrintf(*datap) + (1 << (cbps - 1)); \
 /* DC level shift and clip see ISO 15444-1:2002 G.1.2 */  \
 val  = av_clip(val, 0, (1 << cbps) - 1);  \
-*dst = val << (precision - cbps); \
+*dst = val << ((precision < 8 ? 8 : precision) - cbps);   \
+if (precision < 8)\
+*dst |= *dst >> (8 - precision);  \
 datap++;  \
 dst += pixelsize; \
 } \
@@ -1947,7 +1949,9 @@ static inline void tile_codeblocks(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile
 int val = *i_datap + (1 << (cbps - 1));   \
 /* DC level shift and clip see ISO 15444-1:2002 G.1.2 */  \
 val  = av_clip(val, 0, (1 << cbps) - 1);  \
-*dst = val << (precision - cbps); \
+*dst = val << ((precision < 8 ? 8 : precision) - cbps);   \
+if (precision < 8)\
+*dst |= *dst >> (8 - precision);  \
 i_datap++;\
 dst += pixelsize; \
 } \
@@ -1989,7 +1993,7 @@ static int jpeg2000_decode_tile(AVCodecContext *avctx, void *td,
 }
 
 if (s->precision <= 8) {
-write_frame_8(s, tile, picture, 8);
+write_frame_8(s, tile, picture, s->precision);
 } else {
 int precision = picture->format == AV_PIX_FMT_XYZ12 ||
 picture->format == AV_PIX_FMT_RGB48 ||
-- 
2.24.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH V3 1/1] ensure closed caption info which is visible in default stream dump is also available in results when -show_streams is used

2020-04-25 Thread Marton Balint



On Sat, 25 Apr 2020, vectronic wrote:





On 25 Apr 2020, at 09:08, Marton Balint  wrote:



On Fri, 24 Apr 2020, vectronic wrote:


Signed-off-by: vectronic 
---
doc/ffprobe.xsd   | 1 +
fftools/ffprobe.c | 2 ++
tests/ref/fate/concat-demuxer-extended-lavf-mxf   | 2 +-
tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10   | 2 +-
tests/ref/fate/concat-demuxer-simple1-lavf-mxf| 2 +-
tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10| 2 +-
tests/ref/fate/concat-demuxer-simple2-lavf-ts | 2 +-
tests/ref/fate/ffprobe_compact| 4 ++--
tests/ref/fate/ffprobe_csv| 4 ++--
tests/ref/fate/ffprobe_default| 2 ++
tests/ref/fate/ffprobe_flat   | 2 ++
tests/ref/fate/ffprobe_ini| 2 ++
tests/ref/fate/ffprobe_json   | 2 ++
tests/ref/fate/ffprobe_xml| 4 ++--
tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov | 1 +
tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov | 1 +
tests/ref/fate/mov-zombie | 2 +-
tests/ref/fate/mxf-probe-d10  | 1 +
tests/ref/fate/mxf-probe-dnxhd| 1 +
tests/ref/fate/mxf-probe-dv25 | 1 +
20 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/doc/ffprobe.xsd b/doc/ffprobe.xsd
index 97dc67def6..f88045232f 100644
--- a/doc/ffprobe.xsd
+++ b/doc/ffprobe.xsd
@@ -227,6 +227,7 @@
 
 
 
+  


xsd:boolean seems more appropriate, no?


I was copying off has_b_frames above which I believed was also a 0/1. The 
output in the stream info is 0/1, not true/false.


xsd:boolean can be 0/1 according ot this:
https://www.w3schools.com/xml/schema_dtypes_misc.asp
And I think boolean is more appropriate.




 
 
 
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 840fcb71e2..f0916cbd70 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2550,6 +2550,7 @@ static int show_stream(WriterContext *w, AVFormatContext 
*fmt_ctx, int stream_id
   }
#endif
   print_int("has_b_frames", par->video_delay);
+print_int("closed_captions", !!(dec_ctx->properties & 
FF_CODEC_PROPERTY_CLOSED_CAPTIONS));


Not strictly related to this patch, but maybe these FF_CODEC_PROPERTY_* 
constants should be promoted to AV_*?


I’m not sure what is meant by this, but happy to do so if you can elaborate a 
bit more…?


We typically use AV_ prefix for part-of-the-API constants and FF_ prefix 
for internal or not-part-of-the-API constants. Admittedly it is not very 
consistent, but I think that is the idea. Anyway, this can be changed 
later and in a separate patch.






   sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
   if (sar.num) {
   print_q("sample_aspect_ratio", sar, ':');
@@ -2950,6 +2951,7 @@ static int open_input_file(InputFile *ifile, const char 
*filename,

   ist->dec_ctx->pkt_timebase = stream->time_base;
   ist->dec_ctx->framerate = stream->avg_frame_rate;
+ist->dec_ctx->properties = stream->codec->properties;


This is using the depreacted stream->codec, so I think this should go under the 
#IF below.


#if FF_API_LAVF_AVCTX
   ist->dec_ctx->coded_width = stream->codec->coded_width;
   ist->dec_ctx->coded_height = stream->codec->coded_height;


OK, if this is the case, is there anything to worry to worry about if 
FF_API_LAVF_AVCTX is not defined? Should I be outputting closed_captions value 
in this case? Or am I thinking too much?


You are right, printing it should probably go to the block which prints 
the similar coded_height/coded_width values.


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] lavc/pnm: Support signed pgm files from jasper

2020-04-25 Thread Carl Eugen Hoyos
Am Sa., 25. Apr. 2020 um 17:13 Uhr schrieb Nicolas George :
>
> Carl Eugen Hoyos (12020-04-25):
> > Hi!
> >
> > Attached patch allows reading the pgm file that jasper creates
> > using the jpeg 2000 reference file p0_03.j2k as input.
> >
> > Please comment, Carl Eugen
>
> > From 5da97c417d66b1e840b1feae31f0852cf3755c39 Mon Sep 17 00:00:00 2001
> > From: Carl Eugen Hoyos 
> > Date: Sat, 25 Apr 2020 17:05:40 +0200
> > Subject: [PATCH] lavc/pnm: Allow reading signed pgm values as written by
> >  jasper.
> >
> > ---
> >  libavcodec/pnm.c| 4 
> >  libavcodec/pnm.h| 1 +
> >  libavcodec/pnmdec.c | 2 +-
> >  3 files changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c
> > index b5c2881948..c9b9eb9ccd 100644
> > --- a/libavcodec/pnm.c
> > +++ b/libavcodec/pnm.c
> > @@ -176,6 +176,10 @@ int ff_pnm_decode_header(AVCodecContext *avctx, 
> > PNMContext * const s)
> >  if (avctx->pix_fmt != AV_PIX_FMT_MONOWHITE && avctx->pix_fmt != 
> > AV_PIX_FMT_MONOBLACK) {
> >  pnm_get(s, buf1, sizeof(buf1));
> >  s->maxval = atoi(buf1);
>
> > +if (s->maxval < 0) {
> > +s->maxval *= -1;
> > +s->jasper_signed = 1;
> > +}
> >  if (s->maxval <= 0 || s->maxval > UINT16_MAX) {
>
> The s->maxval <= 0 test here has become redundant.

I did not consider it redundant...

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] lavc/pnm: Support signed pgm files from jasper

2020-04-25 Thread Nicolas George
Carl Eugen Hoyos (12020-04-25):
> Hi!
> 
> Attached patch allows reading the pgm file that jasper creates
> using the jpeg 2000 reference file p0_03.j2k as input.
> 
> Please comment, Carl Eugen

> From 5da97c417d66b1e840b1feae31f0852cf3755c39 Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos 
> Date: Sat, 25 Apr 2020 17:05:40 +0200
> Subject: [PATCH] lavc/pnm: Allow reading signed pgm values as written by
>  jasper.
> 
> ---
>  libavcodec/pnm.c| 4 
>  libavcodec/pnm.h| 1 +
>  libavcodec/pnmdec.c | 2 +-
>  3 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c
> index b5c2881948..c9b9eb9ccd 100644
> --- a/libavcodec/pnm.c
> +++ b/libavcodec/pnm.c
> @@ -176,6 +176,10 @@ int ff_pnm_decode_header(AVCodecContext *avctx, 
> PNMContext * const s)
>  if (avctx->pix_fmt != AV_PIX_FMT_MONOWHITE && avctx->pix_fmt != 
> AV_PIX_FMT_MONOBLACK) {
>  pnm_get(s, buf1, sizeof(buf1));
>  s->maxval = atoi(buf1);

> +if (s->maxval < 0) {
> +s->maxval *= -1;
> +s->jasper_signed = 1;
> +}
>  if (s->maxval <= 0 || s->maxval > UINT16_MAX) {

The s->maxval <= 0 test here has become redundant.

I do not know if the patch itself is correct and wanted.

>  av_log(avctx, AV_LOG_ERROR, "Invalid maxval: %d\n", s->maxval);
>  s->maxval = 255;
> diff --git a/libavcodec/pnm.h b/libavcodec/pnm.h
> index 5bc0aad29f..2550cef92b 100644
> --- a/libavcodec/pnm.h
> +++ b/libavcodec/pnm.h
> @@ -30,6 +30,7 @@ typedef struct PNMContext {
>  uint8_t *bytestream_end;
>  int maxval; ///< maximum value of a pixel
>  int type;
> +int jasper_signed;
>  } PNMContext;
>  
>  int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s);
> diff --git a/libavcodec/pnmdec.c b/libavcodec/pnmdec.c
> index dbcaef3884..6e5f5b6c3b 100644
> --- a/libavcodec/pnmdec.c
> +++ b/libavcodec/pnmdec.c
> @@ -168,7 +168,7 @@ static int pnm_decode_frame(AVCodecContext *avctx, void 
> *data,
>  else if (upgrade == 1) {
>  unsigned int j, f = (255 * 128 + s->maxval / 2) / s->maxval;
>  for (j = 0; j < n; j++)
> -ptr[j] = (s->bytestream[j] * f + 64) >> 7;
> +ptr[j] = ((s->bytestream[j] - (s->maxval / 2 - 1) * 
> s->jasper_signed) * f + 64) >> 7;
>  } else if (upgrade == 2) {
>  unsigned int j, v, f = (65535 * 32768 + s->maxval / 2) / 
> s->maxval;
>  for (j = 0; j < n / 2; j++) {

Regards,

-- 
  Nicolas George


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] lavc/pnm: Support signed pgm files from jasper

2020-04-25 Thread Carl Eugen Hoyos
Hi!

Attached patch allows reading the pgm file that jasper creates
using the jpeg 2000 reference file p0_03.j2k as input.

Please comment, Carl Eugen
From 5da97c417d66b1e840b1feae31f0852cf3755c39 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Sat, 25 Apr 2020 17:05:40 +0200
Subject: [PATCH] lavc/pnm: Allow reading signed pgm values as written by
 jasper.

---
 libavcodec/pnm.c| 4 
 libavcodec/pnm.h| 1 +
 libavcodec/pnmdec.c | 2 +-
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c
index b5c2881948..c9b9eb9ccd 100644
--- a/libavcodec/pnm.c
+++ b/libavcodec/pnm.c
@@ -176,6 +176,10 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
 if (avctx->pix_fmt != AV_PIX_FMT_MONOWHITE && avctx->pix_fmt != AV_PIX_FMT_MONOBLACK) {
 pnm_get(s, buf1, sizeof(buf1));
 s->maxval = atoi(buf1);
+if (s->maxval < 0) {
+s->maxval *= -1;
+s->jasper_signed = 1;
+}
 if (s->maxval <= 0 || s->maxval > UINT16_MAX) {
 av_log(avctx, AV_LOG_ERROR, "Invalid maxval: %d\n", s->maxval);
 s->maxval = 255;
diff --git a/libavcodec/pnm.h b/libavcodec/pnm.h
index 5bc0aad29f..2550cef92b 100644
--- a/libavcodec/pnm.h
+++ b/libavcodec/pnm.h
@@ -30,6 +30,7 @@ typedef struct PNMContext {
 uint8_t *bytestream_end;
 int maxval; ///< maximum value of a pixel
 int type;
+int jasper_signed;
 } PNMContext;
 
 int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s);
diff --git a/libavcodec/pnmdec.c b/libavcodec/pnmdec.c
index dbcaef3884..6e5f5b6c3b 100644
--- a/libavcodec/pnmdec.c
+++ b/libavcodec/pnmdec.c
@@ -168,7 +168,7 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data,
 else if (upgrade == 1) {
 unsigned int j, f = (255 * 128 + s->maxval / 2) / s->maxval;
 for (j = 0; j < n; j++)
-ptr[j] = (s->bytestream[j] * f + 64) >> 7;
+ptr[j] = ((s->bytestream[j] - (s->maxval / 2 - 1) * s->jasper_signed) * f + 64) >> 7;
 } else if (upgrade == 2) {
 unsigned int j, v, f = (65535 * 32768 + s->maxval / 2) / s->maxval;
 for (j = 0; j < n / 2; j++) {
-- 
2.24.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v1] avformat/movenc: cosmetics

2020-04-25 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavformat/movenc.c | 138 +--
 1 file changed, 69 insertions(+), 69 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 253cff86eb..6b0235f115 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5703,87 +5703,87 @@ err:
 
 static int mov_write_single_packet(AVFormatContext *s, AVPacket *pkt)
 {
-MOVMuxContext *mov = s->priv_data;
-MOVTrack *trk = &mov->tracks[pkt->stream_index];
-AVCodecParameters *par = trk->par;
-int64_t frag_duration = 0;
-int size = pkt->size;
-
-int ret = check_pkt(s, pkt);
-if (ret < 0)
-return ret;
+MOVMuxContext *mov = s->priv_data;
+MOVTrack *trk = &mov->tracks[pkt->stream_index];
+AVCodecParameters *par = trk->par;
+int64_t frag_duration = 0;
+int size = pkt->size;
 
-if (mov->flags & FF_MOV_FLAG_FRAG_DISCONT) {
-int i;
-for (i = 0; i < s->nb_streams; i++)
-mov->tracks[i].frag_discont = 1;
-mov->flags &= ~FF_MOV_FLAG_FRAG_DISCONT;
-}
+int ret = check_pkt(s, pkt);
+if (ret < 0)
+return ret;
 
-if (mov->flags & FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS) {
-if (trk->dts_shift == AV_NOPTS_VALUE)
-trk->dts_shift = pkt->pts - pkt->dts;
-pkt->dts += trk->dts_shift;
-}
+if (mov->flags & FF_MOV_FLAG_FRAG_DISCONT) {
+int i;
+for (i = 0; i < s->nb_streams; i++)
+mov->tracks[i].frag_discont = 1;
+mov->flags &= ~FF_MOV_FLAG_FRAG_DISCONT;
+}
+
+if (mov->flags & FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS) {
+if (trk->dts_shift == AV_NOPTS_VALUE)
+trk->dts_shift = pkt->pts - pkt->dts;
+pkt->dts += trk->dts_shift;
+}
 
-if (trk->par->codec_id == AV_CODEC_ID_MP4ALS ||
+if (trk->par->codec_id == AV_CODEC_ID_MP4ALS ||
 trk->par->codec_id == AV_CODEC_ID_AAC ||
 trk->par->codec_id == AV_CODEC_ID_AV1 ||
 trk->par->codec_id == AV_CODEC_ID_FLAC) {
-int side_size = 0;
-uint8_t *side = av_packet_get_side_data(pkt, 
AV_PKT_DATA_NEW_EXTRADATA, &side_size);
-if (side && side_size > 0 && (side_size != par->extradata_size || 
memcmp(side, par->extradata, side_size))) {
-void *newextra = av_mallocz(side_size + 
AV_INPUT_BUFFER_PADDING_SIZE);
-if (!newextra)
-return AVERROR(ENOMEM);
-av_free(par->extradata);
-par->extradata = newextra;
-memcpy(par->extradata, side, side_size);
-par->extradata_size = side_size;
-if (!pkt->size) // Flush packet
-mov->need_rewrite_extradata = 1;
-}
+int side_size = 0;
+uint8_t *side = av_packet_get_side_data(pkt, 
AV_PKT_DATA_NEW_EXTRADATA, &side_size);
+if (side && side_size > 0 && (side_size != par->extradata_size || 
memcmp(side, par->extradata, side_size))) {
+void *newextra = av_mallocz(side_size + 
AV_INPUT_BUFFER_PADDING_SIZE);
+if (!newextra)
+return AVERROR(ENOMEM);
+av_free(par->extradata);
+par->extradata = newextra;
+memcpy(par->extradata, side, side_size);
+par->extradata_size = side_size;
+if (!pkt->size) // Flush packet
+mov->need_rewrite_extradata = 1;
 }
+}
 
-if (!pkt->size) {
-if (trk->start_dts == AV_NOPTS_VALUE && trk->frag_discont) {
-trk->start_dts = pkt->dts;
-if (pkt->pts != AV_NOPTS_VALUE)
-trk->start_cts = pkt->pts - pkt->dts;
-else
-trk->start_cts = 0;
-}
-
-return 0; /* Discard 0 sized packets */
+if (!pkt->size) {
+if (trk->start_dts == AV_NOPTS_VALUE && trk->frag_discont) {
+trk->start_dts = pkt->dts;
+if (pkt->pts != AV_NOPTS_VALUE)
+trk->start_cts = pkt->pts - pkt->dts;
+else
+trk->start_cts = 0;
 }
 
-if (trk->entry && pkt->stream_index < s->nb_streams)
-frag_duration = av_rescale_q(pkt->dts - trk->cluster[0].dts,
- 
s->streams[pkt->stream_index]->time_base,
- AV_TIME_BASE_Q);
-if ((mov->max_fragment_duration &&
- frag_duration >= mov->max_fragment_duration) ||
- (mov->max_fragment_size && mov->mdat_size + size >= 
mov->max_fragment_size) ||
- (mov->flags & FF_MOV_FLAG_FRAG_KEYFRAME &&
-  par->codec_type == AVMEDIA_TYPE_VIDEO &&
-  trk->entry && pkt->flags & AV_PKT_FLAG_KEY) ||
-  (mov->flags & FF_MOV_FLAG_FRAG_EVERY_FRAME)) {
-if

Re: [FFmpeg-devel] [PATCH v10 2/2] avformat: add demuxer for Pro Pinball Series' Soundbanks

2020-04-25 Thread Zane van Iperen
On Sat, 25 Apr 2020 13:15:25 +0200
"Michael Niedermayer"  wrote:

> > +static int pp_bnk_probe(const AVProbeData *p)
> > +{
> > +uint32_t sample_rate = AV_RL32(p->buf +  4);
> > +uint32_t track_count = AV_RL32(p->buf + 12);
> > +uint32_t flags   = AV_RL32(p->buf + 16);
> > +
> > +if (track_count == 0 || sample_rate == 0)
> > +return 0;  
> 
> the header code checks these also for INT_MAX
> 
> 

See below I check both track_count and sample_rate for sane upper
limits. Is it worth adding an INT_MAX check too?


/* These limits are based on analysing the game files. */
if (track_count > 113)
return 10;

if ((sample_rate !=  5512) && (sample_rate != 11025) &&
(sample_rate != 22050) && (sample_rate != 44100))
return 10;



> > +
> > +/* Sometimes we have the first track header, so check that
> > too. */
> > +if (p->buf_size >= 32 && AV_RL32(p->buf + 28) != sample_rate)
> > +return 0;  
> 
> are files with 32 or less bytes valid ?
> If not its probably better to not recognize such small pieces
> 

A file needs at least one track and the first track header is
immediately after the file header, so I guess the minimum valid size
would be 40 (assuming an empty track).

Would removing the "p->buf_size >= 32" check be alright?


Zane

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v10 2/2] avformat: add demuxer for Pro Pinball Series' Soundbanks

2020-04-25 Thread Michael Niedermayer
On Sat, Apr 18, 2020 at 12:20:49AM +, Zane van Iperen wrote:
> Signed-off-by: Zane van Iperen 
> ---
>  Changelog|   1 +
>  libavformat/Makefile |   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/pp_bnk.c | 293 +++
>  libavformat/version.h|   2 +-
>  5 files changed, 297 insertions(+), 1 deletion(-)
>  create mode 100644 libavformat/pp_bnk.c
> 
> diff --git a/Changelog b/Changelog
> index 1d219a56e0..592beca626 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -60,6 +60,7 @@ version :
>  - Expanded styling support for 3GPP Timed Text Subtitles (movtext)
>  - WebP parser
>  - Cunning Developments ADPCM decoder
> +- Pro Pinball Series Soundbank demuxer
>  
>  
>  version 4.2:
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index d4bed3c113..b744eb69b2 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -428,6 +428,7 @@ OBJS-$(CONFIG_PCM_VIDC_DEMUXER)  += pcmdec.o pcm.o
>  OBJS-$(CONFIG_PCM_VIDC_MUXER)+= pcmenc.o rawenc.o
>  OBJS-$(CONFIG_PJS_DEMUXER)   += pjsdec.o subtitles.o
>  OBJS-$(CONFIG_PMP_DEMUXER)   += pmpdec.o
> +OBJS-$(CONFIG_PP_BNK_DEMUXER)+= pp_bnk.o
>  OBJS-$(CONFIG_PVA_DEMUXER)   += pva.o
>  OBJS-$(CONFIG_PVF_DEMUXER)   += pvfdec.o pcm.o
>  OBJS-$(CONFIG_QCP_DEMUXER)   += qcp.o
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index 39d2c352f5..3919c9e4c1 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -341,6 +341,7 @@ extern AVInputFormat  ff_pcm_u8_demuxer;
>  extern AVOutputFormat ff_pcm_u8_muxer;
>  extern AVInputFormat  ff_pjs_demuxer;
>  extern AVInputFormat  ff_pmp_demuxer;
> +extern AVInputFormat  ff_pp_bnk_demuxer;
>  extern AVOutputFormat ff_psp_muxer;
>  extern AVInputFormat  ff_pva_demuxer;
>  extern AVInputFormat  ff_pvf_demuxer;
> diff --git a/libavformat/pp_bnk.c b/libavformat/pp_bnk.c
> new file mode 100644
> index 00..f67f04b699
> --- /dev/null
> +++ b/libavformat/pp_bnk.c
> @@ -0,0 +1,293 @@
> +/*
> + * Pro Pinball Series Soundbank (44c, 22c, 11c, 5c) demuxer.
> + *
> + * Copyright (C) 2020 Zane van Iperen (z...@zanevaniperen.com)
> + *
> + * 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 "avformat.h"
> +#include "internal.h"
> +#include "libavutil/intreadwrite.h"
> +#include "libavutil/avassert.h"
> +#include "libavutil/internal.h"
> +
> +#define PP_BNK_MAX_READ_SIZE4096
> +#define PP_BNK_FILE_HEADER_SIZE 20
> +#define PP_BNK_TRACK_SIZE   20
> +
> +typedef struct PPBnkHeader {
> +uint32_tbank_id;/*< Bank ID, useless for our purposes. */
> +uint32_tsample_rate;/*< Sample rate of the contained tracks. 
> */
> +uint32_talways1;/*< Unknown, always seems to be 1. */
> +uint32_ttrack_count;/*< Number of tracks in the file. */
> +uint32_tflags;  /*< Flags. */
> +} PPBnkHeader;
> +
> +typedef struct PPBnkTrack {
> +uint32_tid; /*< Track ID. Usually track[i].id == 
> track[i-1].id + 1, but not always */
> +uint32_tsize;   /*< Size of the data in bytes. */
> +uint32_tsample_rate;/*< Sample rate. */
> +uint32_talways1_1;  /*< Unknown, always seems to be 1. */
> +uint32_talways1_2;  /*< Unknown, always seems to be 1. */
> +} PPBnkTrack;
> +
> +typedef struct PPBnkCtxTrack {
> +int64_t data_offset;
> +uint32_tdata_size;
> +} PPBnkCtxTrack;
> +
> +typedef struct PPBnkCtx {
> +int track_count;
> +PPBnkCtxTrack   *tracks;
> +uint32_tcurrent_track;
> +uint32_tbytes_read;
> +} PPBnkCtx;
> +
> +enum {
> +PP_BNK_FLAG_PERSIST = (1 << 0), /*< This is a large file, keep in 
> memory. */
> +PP_BNK_FLAG_MUSIC   = (1 << 1), /*< This is music. */
> +PP_BNK_FLAG_MASK= (PP_BNK_FLAG_PERSIST | PP_BNK_FLAG_MUSIC)
> +};
> +
> +static void pp_bnk_parse_header(PPBnkHeader *hdr, const uint8_t *buf)
> +{
> +hdr->bank_id= AV_RL32(buf +  0);
> +hdr->sample_rate= AV_RL32(buf +  4);
> +hdr->always1= AV_RL32(bu

Re: [FFmpeg-devel] [PATCH V3 1/1] ensure closed caption info which is visible in default stream dump is also available in results when -show_streams is used

2020-04-25 Thread vectronic


> On 25 Apr 2020, at 09:08, Marton Balint  wrote:
> 
> 
> 
> On Fri, 24 Apr 2020, vectronic wrote:
> 
>> Signed-off-by: vectronic 
>> ---
>> doc/ffprobe.xsd   | 1 +
>> fftools/ffprobe.c | 2 ++
>> tests/ref/fate/concat-demuxer-extended-lavf-mxf   | 2 +-
>> tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10   | 2 +-
>> tests/ref/fate/concat-demuxer-simple1-lavf-mxf| 2 +-
>> tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10| 2 +-
>> tests/ref/fate/concat-demuxer-simple2-lavf-ts | 2 +-
>> tests/ref/fate/ffprobe_compact| 4 ++--
>> tests/ref/fate/ffprobe_csv| 4 ++--
>> tests/ref/fate/ffprobe_default| 2 ++
>> tests/ref/fate/ffprobe_flat   | 2 ++
>> tests/ref/fate/ffprobe_ini| 2 ++
>> tests/ref/fate/ffprobe_json   | 2 ++
>> tests/ref/fate/ffprobe_xml| 4 ++--
>> tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov | 1 +
>> tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov | 1 +
>> tests/ref/fate/mov-zombie | 2 +-
>> tests/ref/fate/mxf-probe-d10  | 1 +
>> tests/ref/fate/mxf-probe-dnxhd| 1 +
>> tests/ref/fate/mxf-probe-dv25 | 1 +
>> 20 files changed, 28 insertions(+), 12 deletions(-)
>> 
>> diff --git a/doc/ffprobe.xsd b/doc/ffprobe.xsd
>> index 97dc67def6..f88045232f 100644
>> --- a/doc/ffprobe.xsd
>> +++ b/doc/ffprobe.xsd
>> @@ -227,6 +227,7 @@
>>  
>>  
>>  
>> +  
> 
> xsd:boolean seems more appropriate, no?

I was copying off has_b_frames above which I believed was also a 0/1. The 
output in the stream info is 0/1, not true/false.

>>  
>>  
>>  
>> diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
>> index 840fcb71e2..f0916cbd70 100644
>> --- a/fftools/ffprobe.c
>> +++ b/fftools/ffprobe.c
>> @@ -2550,6 +2550,7 @@ static int show_stream(WriterContext *w, 
>> AVFormatContext *fmt_ctx, int stream_id
>>}
>> #endif
>>print_int("has_b_frames", par->video_delay);
>> +print_int("closed_captions", !!(dec_ctx->properties & 
>> FF_CODEC_PROPERTY_CLOSED_CAPTIONS));
> 
> Not strictly related to this patch, but maybe these FF_CODEC_PROPERTY_* 
> constants should be promoted to AV_*?

I’m not sure what is meant by this, but happy to do so if you can elaborate a 
bit more…?


>>sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
>>if (sar.num) {
>>print_q("sample_aspect_ratio", sar, ':');
>> @@ -2950,6 +2951,7 @@ static int open_input_file(InputFile *ifile, const 
>> char *filename,
>> 
>>ist->dec_ctx->pkt_timebase = stream->time_base;
>>ist->dec_ctx->framerate = stream->avg_frame_rate;
>> +ist->dec_ctx->properties = stream->codec->properties;
> 
> This is using the depreacted stream->codec, so I think this should go under 
> the #IF below.
> 
>> #if FF_API_LAVF_AVCTX
>>ist->dec_ctx->coded_width = stream->codec->coded_width;
>>ist->dec_ctx->coded_height = stream->codec->coded_height;

OK, if this is the case, is there anything to worry to worry about if 
FF_API_LAVF_AVCTX is not defined? Should I be outputting closed_captions value 
in this case? Or am I thinking too much?


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2 1/6] avformat: only allow a single bitstream filter when muxing

2020-04-25 Thread Marton Balint



On Sun, 19 Apr 2020, Andreas Rheinhardt wrote:


Marton Balint:

Current muxers only use a single bitstream filter, so there is no need to
maintain code which operates on a list of bitstream filters. When multiple
bitstream filters are needed muxers can simply use a list bitstream filter.

If there is a use case in the future when different bitstream filters should be
added at subsequent packets then a new API possibly involving reconfiguring the
list bistream filter can be added knowing the exact requirements.

Signed-off-by: Marton Balint 
---
 libavformat/dashenc.c  |  6 ++
 libavformat/internal.h |  5 ++---
 libavformat/mux.c  |  6 +++---
 libavformat/segment.c  |  6 ++
 libavformat/utils.c| 27 +--
 5 files changed, 18 insertions(+), 32 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 5a8cff4034..b977761a00 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -2307,10 +2307,8 @@ static int dash_check_bitstream(struct AVFormatContext 
*s, const AVPacket *avpkt
 if (ret == 1) {
 AVStream *st = s->streams[avpkt->stream_index];
 AVStream *ost = oc->streams[0];
-st->internal->bsfcs = ost->internal->bsfcs;
-st->internal->nb_bsfcs = ost->internal->nb_bsfcs;
-ost->internal->bsfcs = NULL;
-ost->internal->nb_bsfcs = 0;
+st->internal->bsfc = ost->internal->bsfc;
+ost->internal->bsfc = NULL;
 }
 return ret;
 }
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 7e4284b217..cafb4a9686 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -152,12 +152,11 @@ struct AVStreamInternal {
 int reorder;

 /**
- * bitstream filters to run on stream
+ * bitstream filter to run on stream
  * - encoding: Set by muxer using ff_stream_add_bitstream_filter
  * - decoding: unused
  */
-AVBSFContext **bsfcs;
-int nb_bsfcs;
+AVBSFContext *bsfc;

 /**
  * Whether or not check_bitstream should still be run on each packet
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 3d63d59faf..5209c84f40 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -824,7 +824,7 @@ static int prepare_input_packet(AVFormatContext *s, 
AVPacket *pkt)

 static int do_packet_auto_bsf(AVFormatContext *s, AVPacket *pkt) {
 AVStream *st = s->streams[pkt->stream_index];
-int i, ret;
+int ret;

 if (!(s->flags & AVFMT_FLAG_AUTO_BSF))
 return 1;
@@ -838,8 +838,8 @@ static int do_packet_auto_bsf(AVFormatContext *s, AVPacket 
*pkt) {
 }
 }

-for (i = 0; i < st->internal->nb_bsfcs; i++) {
-AVBSFContext *ctx = st->internal->bsfcs[i];
+if (st->internal->bsfc) {
+AVBSFContext *ctx = st->internal->bsfc;
 // TODO: when any bitstream filter requires flushing at EOF, we'll 
need to
 // flush each stream's BSF chain on write_trailer.
 if ((ret = av_bsf_send_packet(ctx, pkt)) < 0) {
diff --git a/libavformat/segment.c b/libavformat/segment.c
index 60b72b7d15..32c09827eb 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -1034,10 +1034,8 @@ static int seg_check_bitstream(struct AVFormatContext 
*s, const AVPacket *pkt)
 if (ret == 1) {
 AVStream *st = s->streams[pkt->stream_index];
 AVStream *ost = oc->streams[pkt->stream_index];
-st->internal->bsfcs = ost->internal->bsfcs;
-st->internal->nb_bsfcs = ost->internal->nb_bsfcs;
-ost->internal->bsfcs = NULL;
-ost->internal->nb_bsfcs = 0;
+st->internal->bsfc = ost->internal->bsfc;
+ost->internal->bsfc = NULL;
 }
 return ret;
 }
diff --git a/libavformat/utils.c b/libavformat/utils.c
index a58e47fabc..eff73252ec 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4410,10 +4410,7 @@ static void free_stream(AVStream **pst)

 if (st->internal) {
 avcodec_free_context(&st->internal->avctx);
-for (i = 0; i < st->internal->nb_bsfcs; i++) {
-av_bsf_free(&st->internal->bsfcs[i]);
-av_freep(&st->internal->bsfcs);


I can't believe it! This only works if there is only one bsf. So a real
list has indeed never been tested.


-}
+av_bsf_free(&st->internal->bsfc);
 av_freep(&st->internal->priv_pts);
 av_bsf_free(&st->internal->extract_extradata.bsf);
 av_packet_free(&st->internal->extract_extradata.pkt);
@@ -5574,7 +5571,11 @@ int ff_stream_add_bitstream_filter(AVStream *st, const 
char *name, const char *a
 int ret;
 const AVBitStreamFilter *bsf;
 AVBSFContext *bsfc;
-AVCodecParameters *in_par;
+
+if (st->internal->bsfc) {
+av_log(NULL, AV_LOG_ERROR, "A bitstream filter is already specified for stream 
%d\n", st->index);
+return AVERROR(EINVAL);
+}


Given that this is a situation which should not happen 

Re: [FFmpeg-devel] [PATCH V3 1/1] ensure closed caption info which is visible in default stream dump is also available in results when -show_streams is used

2020-04-25 Thread Marton Balint



On Fri, 24 Apr 2020, vectronic wrote:


Signed-off-by: vectronic 
---
doc/ffprobe.xsd   | 1 +
fftools/ffprobe.c | 2 ++
tests/ref/fate/concat-demuxer-extended-lavf-mxf   | 2 +-
tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10   | 2 +-
tests/ref/fate/concat-demuxer-simple1-lavf-mxf| 2 +-
tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10| 2 +-
tests/ref/fate/concat-demuxer-simple2-lavf-ts | 2 +-
tests/ref/fate/ffprobe_compact| 4 ++--
tests/ref/fate/ffprobe_csv| 4 ++--
tests/ref/fate/ffprobe_default| 2 ++
tests/ref/fate/ffprobe_flat   | 2 ++
tests/ref/fate/ffprobe_ini| 2 ++
tests/ref/fate/ffprobe_json   | 2 ++
tests/ref/fate/ffprobe_xml| 4 ++--
tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov | 1 +
tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov | 1 +
tests/ref/fate/mov-zombie | 2 +-
tests/ref/fate/mxf-probe-d10  | 1 +
tests/ref/fate/mxf-probe-dnxhd| 1 +
tests/ref/fate/mxf-probe-dv25 | 1 +
20 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/doc/ffprobe.xsd b/doc/ffprobe.xsd
index 97dc67def6..f88045232f 100644
--- a/doc/ffprobe.xsd
+++ b/doc/ffprobe.xsd
@@ -227,6 +227,7 @@
  
  
  
+  


xsd:boolean seems more appropriate, no?


  
  
  
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 840fcb71e2..f0916cbd70 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2550,6 +2550,7 @@ static int show_stream(WriterContext *w, AVFormatContext 
*fmt_ctx, int stream_id
}
#endif
print_int("has_b_frames", par->video_delay);
+print_int("closed_captions", !!(dec_ctx->properties & 
FF_CODEC_PROPERTY_CLOSED_CAPTIONS));


Not strictly related to this patch, but maybe these FF_CODEC_PROPERTY_* 
constants should be promoted to AV_*?



sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
if (sar.num) {
print_q("sample_aspect_ratio", sar, ':');
@@ -2950,6 +2951,7 @@ static int open_input_file(InputFile *ifile, const char 
*filename,

ist->dec_ctx->pkt_timebase = stream->time_base;
ist->dec_ctx->framerate = stream->avg_frame_rate;
+ist->dec_ctx->properties = stream->codec->properties;


This is using the depreacted stream->codec, so I think this should go 
under the #IF below.



#if FF_API_LAVF_AVCTX
ist->dec_ctx->coded_width = stream->codec->coded_width;
ist->dec_ctx->coded_height = stream->codec->coded_height;


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 0/2] ffprobe add closed caption output to stream info

2020-04-25 Thread Marton Balint



On Sat, 25 Apr 2020, Marton Balint wrote:




On Fri, 24 Apr 2020, vectronic wrote:


closed caption presence is detected with ffprobe and output as part of
av_dump_format() however it is not included in output from -show_streams
this add closed_captions=0 or 1 to the stream info output and updates
fate test results.

vectronic (2):
 tools ffprobe: add closed caption output to stream info
 fate: update test references for closed_caption output in ffprobe
   stream results


Functional changes and affected fate changes must be in the same patch.


Sorry, I missed your update.

Regards,
Marton



Regards,
Marton



fftools/ffprobe.c | 2 ++
tests/ref/fate/concat-demuxer-extended-lavf-mxf   | 2 +-
tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10   | 2 +-
tests/ref/fate/concat-demuxer-simple1-lavf-mxf| 2 +-
tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10| 2 +-
tests/ref/fate/concat-demuxer-simple2-lavf-ts | 2 +-
tests/ref/fate/ffprobe_compact| 4 ++--
tests/ref/fate/ffprobe_csv| 4 ++--
tests/ref/fate/ffprobe_default| 2 ++
tests/ref/fate/ffprobe_flat   | 2 ++
tests/ref/fate/ffprobe_ini| 2 ++
tests/ref/fate/ffprobe_json   | 2 ++
tests/ref/fate/ffprobe_xml| 4 ++--
tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov | 1 +
tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov | 1 +
tests/ref/fate/mov-zombie | 2 +-
tests/ref/fate/mxf-probe-d10  | 1 +
tests/ref/fate/mxf-probe-dnxhd| 1 +
tests/ref/fate/mxf-probe-dv25 | 1 +
19 files changed, 27 insertions(+), 12 deletions(-)

--
2.24.2 (Apple Git-127)

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 0/2] ffprobe add closed caption output to stream info

2020-04-25 Thread Marton Balint



On Fri, 24 Apr 2020, vectronic wrote:


closed caption presence is detected with ffprobe and output as part of
av_dump_format() however it is not included in output from -show_streams
this add closed_captions=0 or 1 to the stream info output and updates
fate test results.

vectronic (2):
 tools ffprobe: add closed caption output to stream info
 fate: update test references for closed_caption output in ffprobe
   stream results


Functional changes and affected fate changes must be in the same patch.

Regards,
Marton



fftools/ffprobe.c | 2 ++
tests/ref/fate/concat-demuxer-extended-lavf-mxf   | 2 +-
tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10   | 2 +-
tests/ref/fate/concat-demuxer-simple1-lavf-mxf| 2 +-
tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10| 2 +-
tests/ref/fate/concat-demuxer-simple2-lavf-ts | 2 +-
tests/ref/fate/ffprobe_compact| 4 ++--
tests/ref/fate/ffprobe_csv| 4 ++--
tests/ref/fate/ffprobe_default| 2 ++
tests/ref/fate/ffprobe_flat   | 2 ++
tests/ref/fate/ffprobe_ini| 2 ++
tests/ref/fate/ffprobe_json   | 2 ++
tests/ref/fate/ffprobe_xml| 4 ++--
tests/ref/fate/hapqa-extract-nosnappy-to-hapalphaonly-mov | 1 +
tests/ref/fate/hapqa-extract-nosnappy-to-hapq-mov | 1 +
tests/ref/fate/mov-zombie | 2 +-
tests/ref/fate/mxf-probe-d10  | 1 +
tests/ref/fate/mxf-probe-dnxhd| 1 +
tests/ref/fate/mxf-probe-dv25 | 1 +
19 files changed, 27 insertions(+), 12 deletions(-)

--
2.24.2 (Apple Git-127)

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".