Re: [FFmpeg-devel] [PATCH v2 1/2] avcodec/libaomenc.c: Add a libaom command-line option 'tune'

2020-04-10 Thread James Zern
On Fri, Apr 3, 2020 at 2:07 PM Wang Cao  wrote:
>
> Signed-off-by: Wang Cao 
> ---
>  doc/encoders.texi  | 9 +
>  libavcodec/libaomenc.c | 7 +++
>  libavcodec/version.h   | 2 +-
>  3 files changed, 17 insertions(+), 1 deletion(-)
>

lgtm. I'll apply this soon.
___
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] libavformat/mov: restore use of mfra time as dts

2020-04-10 Thread Gyan Doshi



On 10-04-2020 09:20 pm, Gyan Doshi wrote:



On 10-04-2020 08:04 pm, John Stebbins wrote:

On Thu, 2020-04-09 at 10:56 +0530, Gyan Doshi wrote:

On 06-04-2020 11:12 pm, John Stebbins wrote:

This was inadvertantly removed in 4a9d32baca
---
   libavformat/mov.c | 5 +
   1 file changed, 5 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 16a40debc7..eee98fb69c 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4813,6 +4813,11 @@ static int mov_read_trun(MOVContext *c,
AVIOContext *pb, MOVAtom atom)
   pts = frag_stream_info->first_tfra_pts;
   av_log(c->fc, AV_LOG_DEBUG, "found mfra time %"PRId64
   ", using it for pts\n", pts);
+    } else if (frag_stream_info->first_tfra_pts !=
AV_NOPTS_VALUE &&
+    c->use_mfra_for == FF_MOV_FLAG_MFRA_DTS) {
+    dts = frag_stream_info->first_tfra_pts;
+    av_log(c->fc, AV_LOG_DEBUG, "found mfra time %"PRId64
+    ", using it for dts\n", pts);
   } else if (frag_stream_info->sidx_pts != AV_NOPTS_VALUE)
{
   // FIXME: sidx earliest_presentation_time is *PTS*,
s.b.
   // pts = frag_stream_info->sidx_pts;

LGTM.

Gyan


Thanks for the review. I've got a couple other patch submissions that
fix problems that resulted from 4a9d32baca which have received no
comments in nearly 2 weeks.  I don't have commit access, so if no
comments means OK, can someone please commit?



I'll push this one. Someone may want to review the others.


Pushed as 99360990a916896421cb4173ba7bd8ce8878e4b5

Gyan
___
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 1/2] avfilter/delogo: remove deprecated options

2020-04-10 Thread Gyan Doshi



On 11-04-2020 02:17 am, James Almer wrote:

On 4/10/2020 4:30 PM, Gyan Doshi wrote:

Deprecated in 2015 in 8bc708fcee1
---
  libavfilter/vf_delogo.c | 15 +--
  1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c
index 5a2c5e7feb..8edbe03cdc 100644
--- a/libavfilter/vf_delogo.c
+++ b/libavfilter/vf_delogo.c
@@ -211,11 +211,6 @@ static const AVOption delogo_options[]= {
  { "y","set logo y position",   OFFSET(y_expr),AV_OPT_TYPE_STRING, { 
.str = "-1" }, 0, 0, FLAGS },
  { "w","set logo width",OFFSET(w_expr),AV_OPT_TYPE_STRING, { 
.str = "-1" }, 0, 0, FLAGS },
  { "h","set logo height",   OFFSET(h_expr),AV_OPT_TYPE_STRING, { 
.str = "-1" }, 0, 0, FLAGS },
-#if LIBAVFILTER_VERSION_MAJOR < 7
-/* Actual default value for band/t is 1, set in init */
-{ "band", "set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, { 
.i64 =  0 },  0, INT_MAX, FLAGS },
-{ "t","set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, { 
.i64 =  0 },  0, INT_MAX, FLAGS },
-#endif
  { "show", "show delogo area",  OFFSET(show), AV_OPT_TYPE_BOOL,{ 
.i64 =  0 },  0, 1,   FLAGS },
  { NULL }
  };
@@ -272,16 +267,8 @@ static av_cold int init(AVFilterContext *ctx)
  CHECK_UNSET_OPT(w);
  CHECK_UNSET_OPT(h);
  
-#if LIBAVFILTER_VERSION_MAJOR < 7

-if (s->band == 0) { /* Unset, use default */
-av_log(ctx, AV_LOG_WARNING, "Note: default band value was changed from 4 to 
1.\n");
-s->band = 1;
-} else if (s->band != 1) {
-av_log(ctx, AV_LOG_WARNING, "Option band is deprecated.\n");
-}
-#else
  s->band = 1;
-#endif
+
  av_log(ctx, AV_LOG_VERBOSE, "x:%d y:%d, w:%d h:%d band:%d show:%d\n",
 s->x, s->y, s->w, s->h, s->band, s->show);
  


LGTM.


Thanks. Pushed as 74fe697f965017f76203e659db08a7c2eda09b18

Gyan
___
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] libavcodec/jpeg2000: fix cblk decode error check

2020-04-10 Thread gautamramk
From: Gautam Ramakrishnan 

bpno becoming negative is not an error. This check has
been verified with openjpeg, where the loop ends safely
when bpno becomes negative, instead of returning an error.
This patch must resolve ticket #5630.
---
 libavcodec/jpeg2000dec.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 9684e57b34..2f6bdeb6e0 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -1622,11 +1622,7 @@ static int decode_cblk(Jpeg2000DecoderContext *s, 
Jpeg2000CodingStyle *codsty,
 cblk->data[cblk->length+1] = 0xff;
 ff_mqc_initdec(&t1->mqc, cblk->data, 0, 1);
 
-while (passno--) {
-if (bpno < 0) {
-av_log(s->avctx, AV_LOG_ERROR, "bpno became negative\n");
-return AVERROR_INVALIDDATA;
-}
+while (passno-- && bpno >= 0) {
 switch(pass_t) {
 case 0:
 decode_sigpass(t1, width, height, bpno + 1, bandpos,
-- 
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".

[FFmpeg-devel] [PATCH 2/3] libavcodec/jpeg2000dec.c: fix error in cod marker

2020-04-10 Thread gautamramk
From: Gautam Ramakrishnan 

This patch fixes an error where the COC marker
overrides all data of the SPcod field of the
COD marker. It must override only one bit of
SPcod field. This now allows p0_08.j2k to be
decoded correctly (mentioned in #4679).
---
 libavcodec/jpeg2000dec.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 2f6bdeb6e0..e7841a65b1 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -566,6 +566,7 @@ static int get_coc(Jpeg2000DecoderContext *s, 
Jpeg2000CodingStyle *c,
uint8_t *properties)
 {
 int compno, ret;
+uint8_t has_eph;
 
 if (bytestream2_get_bytes_left(&s->g) < 2) {
 av_log(s->avctx, AV_LOG_ERROR, "Insufficient space for COC\n");
@@ -582,7 +583,9 @@ static int get_coc(Jpeg2000DecoderContext *s, 
Jpeg2000CodingStyle *c,
 }
 
 c  += compno;
+has_eph = c->csty & JPEG2000_CSTY_EPH;
 c->csty = bytestream2_get_byteu(&s->g);
+c->csty |= has_eph; //do not override eph present bits from COD
 
 if ((ret = get_cox(s, c)) < 0)
 return ret;
-- 
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".

[FFmpeg-devel] [PATCH 3/3] libavcodec/jpeg2000: fix precinct coordinate calculation

2020-04-10 Thread gautamramk
From: Gautam Ramakrishnan 

The calculation of precinct boundaries has been
fixed. The precinct boundaries were calculated
as an offset to the band boundary, but must
instead be calculated as an offset from the
reslevel. This patch fixes #4669 and #4679.
---
 libavcodec/jpeg2000.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
index 3f50bf9fb3..73206d17f3 100644
--- a/libavcodec/jpeg2000.c
+++ b/libavcodec/jpeg2000.c
@@ -276,11 +276,11 @@ static int init_prec(Jpeg2000Band *band,
 /* TODO: Verify with previous count of codeblocks per band */
 
 /* Compute P_x0 */
-prec->coord[0][0] = ((band->coord[0][0] >> log2_band_prec_width) + precno 
% reslevel->num_precincts_x) *
+prec->coord[0][0] = ((reslevel->coord[0][0] >> reslevel->log2_prec_width) 
+ precno % reslevel->num_precincts_x) *
 (1 << log2_band_prec_width);
 
 /* Compute P_y0 */
-prec->coord[1][0] = ((band->coord[1][0] >> log2_band_prec_height) + precno 
/ reslevel->num_precincts_x) *
+prec->coord[1][0] = ((reslevel->coord[1][0] >> reslevel->log2_prec_height) 
+ precno / reslevel->num_precincts_x) *
 (1 << log2_band_prec_height);
 
 /* Compute P_x1 */
-- 
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".

Re: [FFmpeg-devel] [PATCH 2/2] avcodec/zerocodec: use init cleanup internal cap

2020-04-10 Thread Vittorio Giovara
On Thu, Apr 9, 2020 at 5:21 AM Paul B Mahol  wrote:

> Signed-off-by: Paul B Mahol 
> ---
>  libavcodec/zerocodec.c | 7 +++
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/libavcodec/zerocodec.c b/libavcodec/zerocodec.c
> index b0fab91004..1051fdaa45 100644
> --- a/libavcodec/zerocodec.c
> +++ b/libavcodec/zerocodec.c
> @@ -131,10 +131,8 @@ static av_cold int
> zerocodec_decode_init(AVCodecContext *avctx)
>  }
>
>  zc->previous_frame = av_frame_alloc();
> -if (!zc->previous_frame) {
> -zerocodec_decode_close(avctx);
> +if (!zc->previous_frame)
>  return AVERROR(ENOMEM);
> -}
>
>  return 0;
>  }
> @@ -157,5 +155,6 @@ AVCodec ff_zerocodec_decoder = {
>  .flush  = zerocodec_decode_flush,
>  .close  = zerocodec_decode_close,
>  .capabilities   = AV_CODEC_CAP_DR1,
> -.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
> +.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE |
> +  FF_CODEC_CAP_INIT_CLEANUP,
>  };
> --
> 2.17.1
>

seems good to me, I'd keep the {} for clarity as minor nit
-- 
Vittorio
___
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/2] avcodec/libaomenc.c: Add a libaom command-line option 'tune'

2020-04-10 Thread James Zern
On Fri, Apr 10, 2020 at 10:50 PM James Zern  wrote:
>
> On Fri, Apr 3, 2020 at 2:07 PM Wang Cao  wrote:
> >
> > Signed-off-by: Wang Cao 
> > ---
> >  doc/encoders.texi  | 9 +
> >  libavcodec/libaomenc.c | 7 +++
> >  libavcodec/version.h   | 2 +-
> >  3 files changed, 17 insertions(+), 1 deletion(-)
> >
>
> lgtm. I'll apply this soon.

I missed that the choosen -> chosen fix was missing. fixed locally.
___
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 2/2] avcodec/libaomenc.c: Add super-resolution options to libaom wrapper

2020-04-10 Thread James Zern
On Fri, Apr 3, 2020 at 2:10 PM Wang Cao  wrote:
>
> Signed-off-by: Wang Cao 
> ---
>  doc/encoders.texi  | 39 +++
>  libavcodec/libaomenc.c | 47 ++
>  libavcodec/version.h   |  2 +-
>  3 files changed, 87 insertions(+), 1 deletion(-)
>
> diff --git a/doc/encoders.texi b/doc/encoders.texi
> index 18bfe8f2eb..e32fecdca3 100644
> --- a/doc/encoders.texi
> +++ b/doc/encoders.texi

There is some trailing whitespace in this file. Don't forget to run
tools/patcheck / git diff --check.

> [...]
> +
> +enum AOMSuperresModes {
> +AOM_SUPERRES_MODE_NONE= 0,
> +AOM_SUPERRES_MODE_FIXED   = 1,
> +AOM_SUPERRES_MODE_RANDOM  = 2,
> +AOM_SUPERRES_MODE_QTHRESH = 3,
> +AOM_SUPERRES_MODE_AUTO= 4,
> +AOM_SUPERRES_MODE_NB
>  };
>

This really could be exposed by the library. Just use constants for
the options, it's dangerous to use the AOM_ namespace should libaom
make similar values public.

> [...]
> +{ "enable-superres", "Enable super-resolution mode", 
> OFFSET(enable_superres), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE},
> +{ "superres-mode",   "Select super-resultion mode", 
> OFFSET(superres_mode), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 
> AOM_SUPERRES_MODE_NB-1, VE, "superres_mode"},

resolution.
___
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/cbs: Allocate more CodedBitstreamUnit at once in cbs_insert_unit()

2020-04-10 Thread James Almer
On 4/10/2020 11:49 PM, James Almer wrote:
> On 4/10/2020 9:00 PM, James Almer wrote:
>> On 4/10/2020 8:53 PM, Michael Niedermayer wrote:
>>> On Fri, Apr 10, 2020 at 05:44:25PM -0300, James Almer wrote:
 On 4/10/2020 5:23 PM, Michael Niedermayer wrote:
> Fixes: Timeout (85sec -> 0.5sec)
> Fixes: 
> 20791/clusterfuzz-testcase-minimized-ffmpeg_BSF_AV1_FRAME_SPLIT_fuzzer-5659537719951360
> Fixes: 
> 21214/clusterfuzz-testcase-minimized-ffmpeg_BSF_MPEG2_METADATA_fuzzer-5165560875974656
> Fixes: 
> 21247/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-5715175257931776
>
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/cbs.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
> index 0bd5e1ac5d..42cb9711fa 100644
> --- a/libavcodec/cbs.c
> +++ b/libavcodec/cbs.c
> @@ -693,11 +693,11 @@ static int cbs_insert_unit(CodedBitstreamContext 
> *ctx,
>  memmove(units + position + 1, units + position,
>  (frag->nb_units - position) * sizeof(*units));
>  } else {
> -units = av_malloc_array(frag->nb_units + 1, sizeof(*units));
> +units = av_malloc_array(frag->nb_units*2 + 1, sizeof(*units));
>  if (!units)
>  return AVERROR(ENOMEM);
>  
> -++frag->nb_units_allocated;
> +frag->nb_units_allocated = 2*frag->nb_units_allocated + 1;

 Use ff_fast_malloc(), please. This is quite ugly and the *2 undocumented
 and not obvious.
>>>
>>> not sure i understood your suggestion correctly but 
>>> ff_fast_malloc() deallocates its buffer and clears the size on error, 
>>> which cbs_insert_unit() does not do.
>>> so using ff_fast_malloc() feels a bit like fitting a square peg in a round
>>> hole. But it works too
>>> is that what you had in mind ? (your comment sounded like something simpler 
>>> ...)
>>> so maybe iam missing something
>>
>> No, after thinking about it i realized it was not the best option and i
>> sent a follow up reply about it, but i guess it was too late. If you
>> have to change the implementation of ff_fast_malloc() then it's clearly
>> not what should be used here. I didn't intend you to do this much work.
>>
>> av_fast_realloc() could work instead as i mentioned in the follow up
>> reply, i think. Or porting this to AVTreeNode instead of a flat array,
>> but that's also quite a bit of work and will still allocate one node per
>> call, so your fuzzer cases may still timeout. So if av_fast_realloc() is
>> also not an option then maybe increase the buffer by a
>> small-but-bigger-than-1 amount of units instead of duplicating its size
>> each call, which can get quite big pretty fast.
> 
> Here's a version using av_fast_realloc(). FATE passes. Does it solve the
> timeout?
> 
> diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
> index 0bd5e1ac5d..d6cb94589f 100644
> --- a/libavcodec/cbs.c
> +++ b/libavcodec/cbs.c
> @@ -161,6 +161,7 @@ void ff_cbs_fragment_free(CodedBitstreamContext *ctx,
> 
>  av_freep(&frag->units);
>  frag->nb_units_allocated = 0;
> +frag->unit_buffer_size = 0;
>  }
> 
>  static int cbs_read_fragment_content(CodedBitstreamContext *ctx,
> @@ -684,35 +685,29 @@ static int cbs_insert_unit(CodedBitstreamContext *ctx,
> CodedBitstreamFragment *frag,
> int position)
>  {
> -CodedBitstreamUnit *units;
> +CodedBitstreamUnit *units = frag->units;
> 
> -if (frag->nb_units < frag->nb_units_allocated) {
> -units = frag->units;
> +if (frag->nb_units >= frag->nb_units_allocated) {
> +size_t new_size;
> +void *tmp;
> 
> -if (position < frag->nb_units)
> -memmove(units + position + 1, units + position,
> -(frag->nb_units - position) * sizeof(*units));
> -} else {
> -units = av_malloc_array(frag->nb_units + 1, sizeof(*units));
> -if (!units)
> +if (av_size_mult(frag->nb_units + 1, sizeof(*units), &new_size))
>  return AVERROR(ENOMEM);
> 
> -++frag->nb_units_allocated;
> -
> -if (position > 0)
> -memcpy(units, frag->units, position * sizeof(*units));
> +tmp = av_fast_realloc(units, &frag->unit_buffer_size,
> +  new_size * sizeof(*units));

Should be new_size alone, sorry. av_size_mult() already stored the
result of this calculation in there.

Also, if you can't apply this diff because my mail client mangled it, i
can re-send it as a proper patch.

> +if (!tmp)
> +return AVERROR(ENOMEM);
> 
> -if (position < frag->nb_units)
> -memcpy(units + position + 1, frag->units + position,
> -   (frag->nb_units - positio

Re: [FFmpeg-devel] [PATCH] avcodec/cbs: Allocate more CodedBitstreamUnit at once in cbs_insert_unit()

2020-04-10 Thread James Almer
On 4/10/2020 9:00 PM, James Almer wrote:
> On 4/10/2020 8:53 PM, Michael Niedermayer wrote:
>> On Fri, Apr 10, 2020 at 05:44:25PM -0300, James Almer wrote:
>>> On 4/10/2020 5:23 PM, Michael Niedermayer wrote:
 Fixes: Timeout (85sec -> 0.5sec)
 Fixes: 
 20791/clusterfuzz-testcase-minimized-ffmpeg_BSF_AV1_FRAME_SPLIT_fuzzer-5659537719951360
 Fixes: 
 21214/clusterfuzz-testcase-minimized-ffmpeg_BSF_MPEG2_METADATA_fuzzer-5165560875974656
 Fixes: 
 21247/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-5715175257931776

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

 diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
 index 0bd5e1ac5d..42cb9711fa 100644
 --- a/libavcodec/cbs.c
 +++ b/libavcodec/cbs.c
 @@ -693,11 +693,11 @@ static int cbs_insert_unit(CodedBitstreamContext 
 *ctx,
  memmove(units + position + 1, units + position,
  (frag->nb_units - position) * sizeof(*units));
  } else {
 -units = av_malloc_array(frag->nb_units + 1, sizeof(*units));
 +units = av_malloc_array(frag->nb_units*2 + 1, sizeof(*units));
  if (!units)
  return AVERROR(ENOMEM);
  
 -++frag->nb_units_allocated;
 +frag->nb_units_allocated = 2*frag->nb_units_allocated + 1;
>>>
>>> Use ff_fast_malloc(), please. This is quite ugly and the *2 undocumented
>>> and not obvious.
>>
>> not sure i understood your suggestion correctly but 
>> ff_fast_malloc() deallocates its buffer and clears the size on error, 
>> which cbs_insert_unit() does not do.
>> so using ff_fast_malloc() feels a bit like fitting a square peg in a round
>> hole. But it works too
>> is that what you had in mind ? (your comment sounded like something simpler 
>> ...)
>> so maybe iam missing something
> 
> No, after thinking about it i realized it was not the best option and i
> sent a follow up reply about it, but i guess it was too late. If you
> have to change the implementation of ff_fast_malloc() then it's clearly
> not what should be used here. I didn't intend you to do this much work.
> 
> av_fast_realloc() could work instead as i mentioned in the follow up
> reply, i think. Or porting this to AVTreeNode instead of a flat array,
> but that's also quite a bit of work and will still allocate one node per
> call, so your fuzzer cases may still timeout. So if av_fast_realloc() is
> also not an option then maybe increase the buffer by a
> small-but-bigger-than-1 amount of units instead of duplicating its size
> each call, which can get quite big pretty fast.

Here's a version using av_fast_realloc(). FATE passes. Does it solve the
timeout?

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 0bd5e1ac5d..d6cb94589f 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -161,6 +161,7 @@ void ff_cbs_fragment_free(CodedBitstreamContext *ctx,

 av_freep(&frag->units);
 frag->nb_units_allocated = 0;
+frag->unit_buffer_size = 0;
 }

 static int cbs_read_fragment_content(CodedBitstreamContext *ctx,
@@ -684,35 +685,29 @@ static int cbs_insert_unit(CodedBitstreamContext *ctx,
CodedBitstreamFragment *frag,
int position)
 {
-CodedBitstreamUnit *units;
+CodedBitstreamUnit *units = frag->units;

-if (frag->nb_units < frag->nb_units_allocated) {
-units = frag->units;
+if (frag->nb_units >= frag->nb_units_allocated) {
+size_t new_size;
+void *tmp;

-if (position < frag->nb_units)
-memmove(units + position + 1, units + position,
-(frag->nb_units - position) * sizeof(*units));
-} else {
-units = av_malloc_array(frag->nb_units + 1, sizeof(*units));
-if (!units)
+if (av_size_mult(frag->nb_units + 1, sizeof(*units), &new_size))
 return AVERROR(ENOMEM);

-++frag->nb_units_allocated;
-
-if (position > 0)
-memcpy(units, frag->units, position * sizeof(*units));
+tmp = av_fast_realloc(units, &frag->unit_buffer_size,
+  new_size * sizeof(*units));
+if (!tmp)
+return AVERROR(ENOMEM);

-if (position < frag->nb_units)
-memcpy(units + position + 1, frag->units + position,
-   (frag->nb_units - position) * sizeof(*units));
+frag->units = units = tmp;
+++frag->nb_units_allocated;
 }

-memset(units + position, 0, sizeof(*units));
+if (position < frag->nb_units)
+memmove(units + position + 1, units + position,
+(frag->nb_units - position) * sizeof(*units));

-if (units != frag->units) {
-av_free(frag->units);
-frag->units = units;
-}
+ 

Re: [FFmpeg-devel] [PATCH] libavcodec/jpeg2000dec.c: fix error in cod marker

2020-04-10 Thread Gautam Ramakrishnan
On Sat, Apr 11, 2020 at 2:25 AM Carl Eugen Hoyos  wrote:
>
> Am Fr., 10. Apr. 2020 um 20:28 Uhr schrieb :
> >
> > From: Gautam Ramakrishnan 
> >
> > This patch fixes an error where the COC marker
> > overrides all data of the SPcod field of the
> > COD marker. It must override only one bit of
> > SPcod field. This now allows p0_08.j2k to be
> > decoded correctly (mentioned in #4679).
>
> This patch makes p0_08.j2k decoding bit-exact,
> the other sample is in
> http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4679/
>
> 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".

Hi Carl,

Have been debugging the other sample. Looks like
the numeric calculations with initialization of bands
precincts and codeblock is slightly wrong. I shall
try fixing it.

-- 
-
Gautam |
___
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 v1] fftools/ffprobe: Use format specifier PRId64 instead of %lld

2020-04-10 Thread Limin Wang
On Fri, Apr 10, 2020 at 07:37:40PM +0200, Michael Niedermayer wrote:
> On Fri, Apr 10, 2020 at 07:04:38PM +0800, lance.lmw...@gmail.com wrote:
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  fftools/ffprobe.c | 14 +++---
> >  1 file changed, 7 insertions(+), 7 deletions(-)
> > 
> > diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
> > index e3f221f560..a32bc529d9 100644
> > --- a/fftools/ffprobe.c
> > +++ b/fftools/ffprobe.c
> > @@ -408,7 +408,7 @@ static char *value_string(char *buf, int buf_size, 
> > struct unit_value uv)
> >  if (show_float || (use_value_prefix && vald != (long long 
> > int)vald))
> >  snprintf(buf, buf_size, "%f", vald);
> >  else
> > -snprintf(buf, buf_size, "%lld", vali);
> > +snprintf(buf, buf_size, "%"PRId64, vali);
> >  av_strlcatf(buf, buf_size, "%s%s%s", *prefix_string || 
> > show_value_unit ? " " : "",
> >   prefix_string, show_value_unit ? uv.unit : "");
> >  }
> > @@ -1002,7 +1002,7 @@ static void default_print_int(WriterContext *wctx, 
> > const char *key, long long in
> >  
> >  if (!def->nokey)
> >  printf("%s%s=", wctx->section_pbuf[wctx->level].str, key);
> > -printf("%lld\n", value);
> > +printf("%"PRId64"\n", value);
> >  }
> >  
> >  static const Writer default_writer = {
> > @@ -1179,7 +1179,7 @@ static void compact_print_int(WriterContext *wctx, 
> > const char *key, long long in
> >  if (wctx->nb_item[wctx->level]) printf("%c", compact->item_sep);
> >  if (!compact->nokey)
> >  printf("%s%s=", wctx->section_pbuf[wctx->level].str, key);
> > -printf("%lld", value);
> > +printf("%"PRId64, value);
> >  }
> >  
> >  static const Writer compact_writer = {
> 
> > @@ -1322,7 +1322,7 @@ static void flat_print_section_header(WriterContext 
> > *wctx)
> >  
> >  static void flat_print_int(WriterContext *wctx, const char *key, long long 
> > int value)
> >  {
> > -printf("%s%s=%lld\n", wctx->section_pbuf[wctx->level].str, key, value);
> > +printf("%s%s=%"PRId64"\n", wctx->section_pbuf[wctx->level].str, key, 
> > value);
> >  }
> 
> the type does not match here

yes, my fault, lld is for "long long int" is no problem. I originally plan to 
change "long
long int" to int64_t, but I'm not sure if the original code has other ideas 
which I'm missing.  

> 
> [...]
> -- 
> 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.



> ___
> 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".


-- 
Thanks,
Limin Wang
___
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 v1 2/2] avfilter/vf_subtitles: add force_style option for ass subtitle filter

2020-04-10 Thread Limin Wang

please help to review, so that we can change the subtitle postion, color by
force_style.


On Mon, Mar 30, 2020 at 06:52:33PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  doc/filters.texi   |  4 
>  libavfilter/vf_subtitles.c | 23 +++
>  2 files changed, 27 insertions(+)
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 328e984e92..d26d90d1bb 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -6399,6 +6399,10 @@ Slower shaper using OpenType for substitutions and 
> positioning
>  @end table
>  
>  The default is @code{auto}.
> +
> +@item force_style
> +Override default style or script info parameters of the subtitles. It 
> accepts a
> +string containing ASS style format @code{KEY=VALUE} couples separated by ",".
>  @end table
>  
>  @section atadenoise
> diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c
> index 2f312b0ba8..e3ad8b8d94 100644
> --- a/libavfilter/vf_subtitles.c
> +++ b/libavfilter/vf_subtitles.c
> @@ -218,6 +218,7 @@ static const AVOption ass_options[] = {
>  {"auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = -1},
>   INT_MIN, INT_MAX, FLAGS, "shaping_mode"},
>  {"simple",  "simple shaping",  0, AV_OPT_TYPE_CONST, {.i64 = 
> ASS_SHAPING_SIMPLE},  INT_MIN, INT_MAX, FLAGS, "shaping_mode"},
>  {"complex", "complex shaping", 0, AV_OPT_TYPE_CONST, {.i64 = 
> ASS_SHAPING_COMPLEX}, INT_MIN, INT_MAX, FLAGS, "shaping_mode"},
> +{"force_style",  "force subtitle style", OFFSET(force_style),  
> AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS},
>  {NULL},
>  };
>  
> @@ -234,6 +235,28 @@ static av_cold int init_ass(AVFilterContext *ctx)
>  /* Initialize fonts */
>  ass_set_fonts(ass->renderer, NULL, NULL, 1, NULL, 1);
>  
> +if (ass->force_style) {
> +char **list = NULL;
> +char *temp = NULL;
> +char *ptr = av_strtok(ass->force_style, ",", &temp);
> +int i = 0;
> +while (ptr) {
> +av_dynarray_add(&list, &i, ptr);
> +if (!list) {
> +ret = AVERROR(ENOMEM);
> +return ret;
> +}
> +ptr = av_strtok(NULL, ",", &temp);
> +}
> +av_dynarray_add(&list, &i, NULL);
> +if (!list) {
> +ret = AVERROR(ENOMEM);
> +return ret;
> +}
> +ass_set_style_overrides(ass->library, list);
> +av_free(list);
> +}
> +
>  ass->track = ass_read_file(ass->library, ass->filename, NULL);
>  if (!ass->track) {
>  av_log(ctx, AV_LOG_ERROR,
> -- 
> 2.21.0
> 

-- 
Thanks,
Limin Wang
___
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] avformat/dashdec: add attribute lang for audio and subtitle streams

2020-04-10 Thread Steven Liu


> 2020年4月8日 下午10:39,Steven Liu  写道:
> 
> 
> 
>> 2020年3月31日 下午8:20,Steven Liu  写道:
>> 
>> There should have language in the metadata of streams which show to user
>> 
>> Signed-off-by: Steven Liu 
>> ---
>> libavformat/dashdec.c | 49 +++
>> 1 file changed, 45 insertions(+), 4 deletions(-)
>> 
>> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
>> index 271202b0a5..5ba7feb245 100644
>> --- a/libavformat/dashdec.c
>> +++ b/libavformat/dashdec.c
>> @@ -85,6 +85,7 @@ struct representation {
>> 
>>enum AVMediaType type;
>>char id[20];
>> +char *lang;
>>int bandwidth;
>>AVRational framerate;
>>AVStream *assoc_stream; /* demuxer stream associated with this 
>> representation */
>> @@ -144,6 +145,9 @@ typedef struct DASHContext {
>>uint64_t period_duration;
>>uint64_t period_start;
>> 
>> +/* AdaptationSet Attribute */
>> +char *adaptionset_lang;
>> +
>>int is_live;
>>AVIOInterruptCB *interrupt_callback;
>>char *allowed_extensions;
>> @@ -872,6 +876,15 @@ static int 
>> parse_manifest_representation(AVFormatContext *s, const char *url,
>>ret = AVERROR(ENOMEM);
>>goto end;
>>}
>> +if (c->adaptionset_lang) {
>> +rep->lang = av_strdup(c->adaptionset_lang);
>> +if (!rep->lang) {
>> +av_log(s, AV_LOG_ERROR, "alloc language memory failure\n");
>> +av_freep(&rep);
>> +ret = AVERROR(ENOMEM);
>> +goto end;
>> +}
>> +}
>>rep->parent = s;
>>representation_segmenttemplate_node = 
>> find_child_node_by_name(representation_node, "SegmentTemplate");
>>representation_baseurl_node = 
>> find_child_node_by_name(representation_node, "BaseURL");
>> @@ -1103,6 +1116,19 @@ end:
>>return ret;
>> }
>> 
>> +static int parse_manifest_adaptationset_attr(AVFormatContext *s, xmlNodePtr 
>> adaptionset_node)
>> +{
>> +DASHContext *c = s->priv_data;
>> +
>> +if (!adaptionset_node) {
>> +av_log(s, AV_LOG_WARNING, "Cannot get AdaptionSet\n");
>> +return AVERROR(EINVAL);
>> +}
>> +c->adaptionset_lang = xmlGetProp(adaptionset_node, "lang");
>> +
>> +return 0;
>> +}
>> +
>> static int parse_manifest_adaptationset(AVFormatContext *s, const char *url,
>>xmlNodePtr adaptionset_node,
>>xmlNodePtr mpd_baseurl_node,
>> @@ -,6 +1137,7 @@ static int 
>> parse_manifest_adaptationset(AVFormatContext *s, const char *url,
>>xmlNodePtr period_segmentlist_node)
>> {
>>int ret = 0;
>> +DASHContext *c = s->priv_data;
>>xmlNodePtr fragment_template_node = NULL;
>>xmlNodePtr content_component_node = NULL;
>>xmlNodePtr adaptionset_baseurl_node = NULL;
>> @@ -1118,6 +1145,10 @@ static int 
>> parse_manifest_adaptationset(AVFormatContext *s, const char *url,
>>xmlNodePtr adaptionset_supplementalproperty_node = NULL;
>>xmlNodePtr node = NULL;
>> 
>> +ret = parse_manifest_adaptationset_attr(s, adaptionset_node);
>> +if (ret < 0)
>> +return ret;
>> +
>>node = xmlFirstElementChild(adaptionset_node);
>>while (node) {
>>if (!av_strcasecmp(node->name, (const char *)"SegmentTemplate")) {
>> @@ -1142,13 +1173,15 @@ static int 
>> parse_manifest_adaptationset(AVFormatContext *s, const char *url,
>>adaptionset_baseurl_node,
>>adaptionset_segmentlist_node,
>>
>> adaptionset_supplementalproperty_node);
>> -if (ret < 0) {
>> -return ret;
>> -}
>> +if (ret < 0)
>> +goto err;
>>}
>>node = xmlNextElementSibling(node);
>>}
>> -return 0;
>> +
>> +err:
>> +av_freep(&c->adaptionset_lang);
>> +return ret;
>> }
>> 
>> static int parse_programinformation(AVFormatContext *s, xmlNodePtr node)
>> @@ -2121,6 +2154,10 @@ static int dash_read_header(AVFormatContext *s)
>>av_dict_set_int(&rep->assoc_stream->metadata, 
>> "variant_bitrate", rep->bandwidth, 0);
>>if (rep->id[0])
>>av_dict_set(&rep->assoc_stream->metadata, "id", rep->id, 0);
>> +if (rep->lang) {
>> +av_dict_set(&rep->assoc_stream->metadata, "language", 
>> rep->lang, 0);
>> +av_freep(&rep->lang);
>> +}
>>}
>>for (i = 0; i < c->n_subtitles; i++) {
>>rep = c->subtitles[i];
>> @@ -2128,6 +2165,10 @@ static int dash_read_header(AVFormatContext *s)
>>rep->assoc_stream = s->streams[rep->stream_index];
>>if (rep->id[0])
>>av_dict_set(&rep->assoc_stream->metadata, "id", rep->id, 0);
>> +if (rep->lang) {
>> +av_dict_set(&rep

Re: [FFmpeg-devel] [PATCH v2] avcodec: Add explicit capability flag for encoder flushing

2020-04-10 Thread Philip Langdale
On Fri, 10 Apr 2020 20:01:29 -0300
James Almer  wrote:

> The assert needs to be under the following chunk, like it was in the
> first version, after we have already established that we're dealing
> with a flush enabled encoder to ensure that it's not also wrongly
> marked as supporting frame threading.
> Otherwise you'll be crashing the user if they call
> avcodec_flush_buffers() on an encoder that supports frame threading
> but never claimed to support flushing, when we were only supposed to
> print the warning and return.

*sigh*. Right you are. sending a new one.

--phil
___
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] avcodec: Add explicit capability flag for encoder flushing

2020-04-10 Thread Philip Langdale
We've been in this fuzzy situation where maybe you could call
avcodec_flush_buffers() on an encoder but there weren't any encoders
that supported it except maybe audiotoolboxenc. Then we added flush
support to nvenc very intentionally, and it worked, but that was more a
coincidence than anything else. And if you call avcodec_flush_buffers()
on an encoder that doesn't support it, it'll leave the encoder in an
undefined state, so that's not great.

As part of cleaning this up, this change introduces a formal capability
flag for encoders that support flushing and ensures a flush call is a
no-op for any other encoder. This allows client code to check if it is
meaningful to call flush on an encoder before actually doing it.

I have not attempted to separate the steps taken inside
avcodec_flush_buffers() because it's not doing anything that's wrong
for an encoder. But I did add a sanity check to reject attempts to
flush a frame threaded encoder because I couldn't wrap my head around
whether that code path was actually safe or not. As this combination
doesn't exist today, we'll deal with it if it ever comes up.

Signed-off-by: Philip Langdale 
---
 doc/APIchanges   |  6 ++
 libavcodec/audiotoolboxenc.c |  3 ++-
 libavcodec/avcodec.h | 21 -
 libavcodec/decode.c  | 15 +++
 libavcodec/nvenc_h264.c  |  6 --
 libavcodec/nvenc_hevc.c  |  6 --
 libavcodec/version.h |  4 ++--
 7 files changed, 49 insertions(+), 12 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 4cc2367e69..938ccf3aaa 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,12 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2020-04-10 - xx - lavc 58.79.100 - avcodec.h
+  Add formal support for calling avcodec_flush_buffers() on encoders.
+  Encoders that set the cap AV_CODEC_CAP_ENCODER_FLUSH will be flushed.
+  For all other encoders, the call is now a no-op rather than undefined
+  behaviour.
+
 2020-xx-xx - xx - lavc 58.78.100 - avcodec.h codec_desc.h codec_id.h 
packet.h
   Move AVCodecDesc-related public API to new header codec_desc.h.
   Move AVCodecID enum to new header codec_id.h.
diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
index 2c1891693e..27632decf5 100644
--- a/libavcodec/audiotoolboxenc.c
+++ b/libavcodec/audiotoolboxenc.c
@@ -627,7 +627,8 @@ static const AVOption options[] = {
 .encode2= ffat_encode, \
 .flush  = ffat_encode_flush, \
 .priv_class = &ffat_##NAME##_enc_class, \
-.capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY __VA_ARGS__, \
+.capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | \
+  AV_CODEC_CAP_ENCODER_FLUSH __VA_ARGS__, \
 .sample_fmts= (const enum AVSampleFormat[]) { \
 AV_SAMPLE_FMT_S16, \
 AV_SAMPLE_FMT_U8,  AV_SAMPLE_FMT_NONE \
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 55151a0b71..5efe5583a1 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -513,6 +513,13 @@ typedef struct RcOverride{
  */
 #define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE (1 << 20)
 
+/**
+ * This encoder can be flushed using avcodec_flush_buffers(). If this flag is
+ * not set, the encoder must be closed and reopened to ensure that no frames
+ * remain pending.
+ */
+#define AV_CODEC_CAP_ENCODER_FLUSH   (1 << 21)
+
 /* Exported side data.
These flags can be passed in AVCodecContext.export_side_data before 
initialization.
 */
@@ -4473,13 +4480,17 @@ int avcodec_fill_audio_frame(AVFrame *frame, int 
nb_channels,
  int buf_size, int align);
 
 /**
- * Reset the internal decoder state / flush internal buffers. Should be called
+ * Reset the internal codec state / flush internal buffers. Should be called
  * e.g. when seeking or when switching to a different stream.
  *
- * @note when refcounted frames are not used (i.e. avctx->refcounted_frames is 
0),
- * this invalidates the frames previously returned from the decoder. When
- * refcounted frames are used, the decoder just releases any references it 
might
- * keep internally, but the caller's reference remains valid.
+ * @note for decoders, when refcounted frames are not used
+ * (i.e. avctx->refcounted_frames is 0), this invalidates the frames previously
+ * returned from the decoder. When refcounted frames are used, the decoder just
+ * releases any references it might keep internally, but the caller's reference
+ * remains valid.
+ *
+ * @note for encoders, this function will only do something if the encoder
+ * declares support for AV_CODEC_CAP_ENCODER_FLUSH.
  */
 void avcodec_flush_buffers(AVCodecContext *avctx);
 
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index b7ae1fbb84..d4bdb9b1c0 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -2084,6 +2084,21 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
 {
 

Re: [FFmpeg-devel] [PATCH] avcodec/cbs: Allocate more CodedBitstreamUnit at once in cbs_insert_unit()

2020-04-10 Thread James Almer
On 4/10/2020 8:53 PM, Michael Niedermayer wrote:
> On Fri, Apr 10, 2020 at 05:44:25PM -0300, James Almer wrote:
>> On 4/10/2020 5:23 PM, Michael Niedermayer wrote:
>>> Fixes: Timeout (85sec -> 0.5sec)
>>> Fixes: 
>>> 20791/clusterfuzz-testcase-minimized-ffmpeg_BSF_AV1_FRAME_SPLIT_fuzzer-5659537719951360
>>> Fixes: 
>>> 21214/clusterfuzz-testcase-minimized-ffmpeg_BSF_MPEG2_METADATA_fuzzer-5165560875974656
>>> Fixes: 
>>> 21247/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-5715175257931776
>>>
>>> Found-by: continuous fuzzing process 
>>> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
>>> Signed-off-by: Michael Niedermayer 
>>> ---
>>>  libavcodec/cbs.c | 4 ++--
>>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
>>> index 0bd5e1ac5d..42cb9711fa 100644
>>> --- a/libavcodec/cbs.c
>>> +++ b/libavcodec/cbs.c
>>> @@ -693,11 +693,11 @@ static int cbs_insert_unit(CodedBitstreamContext *ctx,
>>>  memmove(units + position + 1, units + position,
>>>  (frag->nb_units - position) * sizeof(*units));
>>>  } else {
>>> -units = av_malloc_array(frag->nb_units + 1, sizeof(*units));
>>> +units = av_malloc_array(frag->nb_units*2 + 1, sizeof(*units));
>>>  if (!units)
>>>  return AVERROR(ENOMEM);
>>>  
>>> -++frag->nb_units_allocated;
>>> +frag->nb_units_allocated = 2*frag->nb_units_allocated + 1;
>>
>> Use ff_fast_malloc(), please. This is quite ugly and the *2 undocumented
>> and not obvious.
> 
> not sure i understood your suggestion correctly but 
> ff_fast_malloc() deallocates its buffer and clears the size on error, 
> which cbs_insert_unit() does not do.
> so using ff_fast_malloc() feels a bit like fitting a square peg in a round
> hole. But it works too
> is that what you had in mind ? (your comment sounded like something simpler 
> ...)
> so maybe iam missing something

No, after thinking about it i realized it was not the best option and i
sent a follow up reply about it, but i guess it was too late. If you
have to change the implementation of ff_fast_malloc() then it's clearly
not what should be used here. I didn't intend you to do this much work.

av_fast_realloc() could work instead as i mentioned in the follow up
reply, i think. Or porting this to AVTreeNode instead of a flat array,
but that's also quite a bit of work and will still allocate one node per
call, so your fuzzer cases may still timeout. So if av_fast_realloc() is
also not an option then maybe increase the buffer by a
small-but-bigger-than-1 amount of units instead of duplicating its size
each call, which can get quite big pretty fast.
___
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/cbs: Allocate more CodedBitstreamUnit at once in cbs_insert_unit()

2020-04-10 Thread Michael Niedermayer
On Fri, Apr 10, 2020 at 05:44:25PM -0300, James Almer wrote:
> On 4/10/2020 5:23 PM, Michael Niedermayer wrote:
> > Fixes: Timeout (85sec -> 0.5sec)
> > Fixes: 
> > 20791/clusterfuzz-testcase-minimized-ffmpeg_BSF_AV1_FRAME_SPLIT_fuzzer-5659537719951360
> > Fixes: 
> > 21214/clusterfuzz-testcase-minimized-ffmpeg_BSF_MPEG2_METADATA_fuzzer-5165560875974656
> > Fixes: 
> > 21247/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-5715175257931776
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/cbs.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
> > index 0bd5e1ac5d..42cb9711fa 100644
> > --- a/libavcodec/cbs.c
> > +++ b/libavcodec/cbs.c
> > @@ -693,11 +693,11 @@ static int cbs_insert_unit(CodedBitstreamContext *ctx,
> >  memmove(units + position + 1, units + position,
> >  (frag->nb_units - position) * sizeof(*units));
> >  } else {
> > -units = av_malloc_array(frag->nb_units + 1, sizeof(*units));
> > +units = av_malloc_array(frag->nb_units*2 + 1, sizeof(*units));
> >  if (!units)
> >  return AVERROR(ENOMEM);
> >  
> > -++frag->nb_units_allocated;
> > +frag->nb_units_allocated = 2*frag->nb_units_allocated + 1;
> 
> Use ff_fast_malloc(), please. This is quite ugly and the *2 undocumented
> and not obvious.

not sure i understood your suggestion correctly but 
ff_fast_malloc() deallocates its buffer and clears the size on error, 
which cbs_insert_unit() does not do.
so using ff_fast_malloc() feels a bit like fitting a square peg in a round
hole. But it works too
is that what you had in mind ? (your comment sounded like something simpler ...)
so maybe iam missing something

From 10f4caf17ebf695112777dd73978a2992d0f78cc Mon Sep 17 00:00:00 2001
From: Michael Niedermayer 
Date: Fri, 10 Apr 2020 22:05:07 +0200
Subject: [PATCH] avcodec/cbs: Allocate more CodedBitstreamUnit at once in
 cbs_insert_unit()

Fixes: Timeout (85sec -> 0.5sec)
Fixes: 
20791/clusterfuzz-testcase-minimized-ffmpeg_BSF_AV1_FRAME_SPLIT_fuzzer-5659537719951360
Fixes: 
21214/clusterfuzz-testcase-minimized-ffmpeg_BSF_MPEG2_METADATA_fuzzer-5165560875974656
Fixes: 
21247/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-5715175257931776

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/cbs.c | 21 +++--
 libavcodec/cbs.h |  4 ++--
 libavcodec/utils.c   |  4 ++--
 libavutil/mem.c  |  4 ++--
 libavutil/mem_internal.h | 17 +++--
 5 files changed, 28 insertions(+), 22 deletions(-)

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 0bd5e1ac5d..4a1393cb44 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -23,6 +23,7 @@
 #include "libavutil/avassert.h"
 #include "libavutil/buffer.h"
 #include "libavutil/common.h"
+#include "libavutil/mem_internal.h"
 
 #include "cbs.h"
 #include "cbs_internal.h"
@@ -684,27 +685,27 @@ static int cbs_insert_unit(CodedBitstreamContext *ctx,
CodedBitstreamFragment *frag,
int position)
 {
-CodedBitstreamUnit *units;
+CodedBitstreamUnit *units = NULL;
+size_t new_size;
 
-if (frag->nb_units < frag->nb_units_allocated) {
-units = frag->units;
+if (av_size_mult(frag->nb_units + 1, sizeof(*units), &new_size))
+return AVERROR(ENOMEM);
 
-if (position < frag->nb_units)
-memmove(units + position + 1, units + position,
-(frag->nb_units - position) * sizeof(*units));
-} else {
-units = av_malloc_array(frag->nb_units + 1, sizeof(*units));
+if (ff_fast_malloc(&units, &frag->nb_units_allocated, new_size, 0, 0)) {
 if (!units)
 return AVERROR(ENOMEM);
 
-++frag->nb_units_allocated;
-
 if (position > 0)
 memcpy(units, frag->units, position * sizeof(*units));
 
 if (position < frag->nb_units)
 memcpy(units + position + 1, frag->units + position,
(frag->nb_units - position) * sizeof(*units));
+} else {
+units = frag->units;
+if (position < frag->nb_units)
+memmove(units + position + 1, units + position,
+(frag->nb_units - position) * sizeof(*units));
 }
 
 memset(units + position, 0, sizeof(*units));
diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
index 9ca1fbd609..b496ade74e 100644
--- a/libavcodec/cbs.h
+++ b/libavcodec/cbs.h
@@ -149,9 +149,9 @@ typedef struct CodedBitstreamFragment {
 /**
  * Number of allocated units.
  *
- * Must always be >= nb_units; designed for internal use by cbs.
+ * Must always be >= nb_units; designed for internal use by cbs and

Re: [FFmpeg-devel] [PATCH v2] avcodec: Add explicit capability flag for encoder flushing

2020-04-10 Thread James Almer
On 4/10/2020 7:38 PM, Philip Langdale wrote:
> We've been in this fuzzy situation where maybe you could call
> avcodec_flush_buffers() on an encoder but there weren't any encoders
> that supported it except maybe audiotoolboxenc. Then we added flush
> support to nvenc very intentionally, and it worked, but that was more a
> coincidence than anything else. And if you call avcodec_flush_buffers()
> on an encoder that doesn't support it, it'll leave the encoder in an
> undefined state, so that's not great.
> 
> As part of cleaning this up, this change introduces a formal capability
> flag for encoders that support flushing and ensures a flush call is a
> no-op for any other encoder. This allows client code to check if it is
> meaningful to call flush on an encoder before actually doing it.
> 
> I have not attempted to separate the steps taken inside
> avcodec_flush_buffers() because it's not doing anything that's wrong
> for an encoder. But I did add a sanity check to reject attempts to
> flush a frame threaded encoder because I couldn't wrap my head around
> whether that code path was actually safe or not. As this combination
> doesn't exist today, we'll deal with it if it ever comes up.
> 
> Signed-off-by: Philip Langdale 
> ---
>  doc/APIchanges   |  6 ++
>  libavcodec/audiotoolboxenc.c |  3 ++-
>  libavcodec/avcodec.h | 21 -
>  libavcodec/decode.c  | 15 +++
>  libavcodec/nvenc_h264.c  |  6 --
>  libavcodec/nvenc_hevc.c  |  6 --
>  libavcodec/version.h |  4 ++--
>  7 files changed, 49 insertions(+), 12 deletions(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 4cc2367e69..938ccf3aaa 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,12 @@ libavutil: 2017-10-21
>  
>  API changes, most recent first:
>  
> +2020-04-10 - xx - lavc 58.79.100 - avcodec.h
> +  Add formal support for calling avcodec_flush_buffers() on encoders.
> +  Encoders that set the cap AV_CODEC_CAP_ENCODER_FLUSH will be flushed.
> +  For all other encoders, the call is now a no-op rather than undefined
> +  behaviour.
> +
>  2020-xx-xx - xx - lavc 58.78.100 - avcodec.h codec_desc.h codec_id.h 
> packet.h
>Move AVCodecDesc-related public API to new header codec_desc.h.
>Move AVCodecID enum to new header codec_id.h.
> diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
> index 2c1891693e..27632decf5 100644
> --- a/libavcodec/audiotoolboxenc.c
> +++ b/libavcodec/audiotoolboxenc.c
> @@ -627,7 +627,8 @@ static const AVOption options[] = {
>  .encode2= ffat_encode, \
>  .flush  = ffat_encode_flush, \
>  .priv_class = &ffat_##NAME##_enc_class, \
> -.capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY __VA_ARGS__, 
> \
> +.capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | \
> +  AV_CODEC_CAP_ENCODER_FLUSH __VA_ARGS__, \
>  .sample_fmts= (const enum AVSampleFormat[]) { \
>  AV_SAMPLE_FMT_S16, \
>  AV_SAMPLE_FMT_U8,  AV_SAMPLE_FMT_NONE \
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 55151a0b71..5efe5583a1 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -513,6 +513,13 @@ typedef struct RcOverride{
>   */
>  #define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE (1 << 20)
>  
> +/**
> + * This encoder can be flushed using avcodec_flush_buffers(). If this flag is
> + * not set, the encoder must be closed and reopened to ensure that no frames
> + * remain pending.
> + */
> +#define AV_CODEC_CAP_ENCODER_FLUSH   (1 << 21)
> +
>  /* Exported side data.
> These flags can be passed in AVCodecContext.export_side_data before 
> initialization.
>  */
> @@ -4473,13 +4480,17 @@ int avcodec_fill_audio_frame(AVFrame *frame, int 
> nb_channels,
>   int buf_size, int align);
>  
>  /**
> - * Reset the internal decoder state / flush internal buffers. Should be 
> called
> + * Reset the internal codec state / flush internal buffers. Should be called
>   * e.g. when seeking or when switching to a different stream.
>   *
> - * @note when refcounted frames are not used (i.e. avctx->refcounted_frames 
> is 0),
> - * this invalidates the frames previously returned from the decoder. When
> - * refcounted frames are used, the decoder just releases any references it 
> might
> - * keep internally, but the caller's reference remains valid.
> + * @note for decoders, when refcounted frames are not used
> + * (i.e. avctx->refcounted_frames is 0), this invalidates the frames 
> previously
> + * returned from the decoder. When refcounted frames are used, the decoder 
> just
> + * releases any references it might keep internally, but the caller's 
> reference
> + * remains valid.
> + *
> + * @note for encoders, this function will only do something if the encoder
> + * declares support for AV_CODEC_CAP_ENCODER_FLUSH.
>   */
>  voi

Re: [FFmpeg-devel] [PATCH] avcodec: Add explicit capability flag for encoder flushing

2020-04-10 Thread Philip Langdale
On Fri, 10 Apr 2020 18:47:06 -0300
James Almer  wrote:

> 
> Seems fine in principle, but I'd like to hear Anton's opinion.


Thanks. I've sent an updated patch and will wait for Anton.

--phil
___
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 v2] avcodec: Add explicit capability flag for encoder flushing

2020-04-10 Thread Philip Langdale
We've been in this fuzzy situation where maybe you could call
avcodec_flush_buffers() on an encoder but there weren't any encoders
that supported it except maybe audiotoolboxenc. Then we added flush
support to nvenc very intentionally, and it worked, but that was more a
coincidence than anything else. And if you call avcodec_flush_buffers()
on an encoder that doesn't support it, it'll leave the encoder in an
undefined state, so that's not great.

As part of cleaning this up, this change introduces a formal capability
flag for encoders that support flushing and ensures a flush call is a
no-op for any other encoder. This allows client code to check if it is
meaningful to call flush on an encoder before actually doing it.

I have not attempted to separate the steps taken inside
avcodec_flush_buffers() because it's not doing anything that's wrong
for an encoder. But I did add a sanity check to reject attempts to
flush a frame threaded encoder because I couldn't wrap my head around
whether that code path was actually safe or not. As this combination
doesn't exist today, we'll deal with it if it ever comes up.

Signed-off-by: Philip Langdale 
---
 doc/APIchanges   |  6 ++
 libavcodec/audiotoolboxenc.c |  3 ++-
 libavcodec/avcodec.h | 21 -
 libavcodec/decode.c  | 15 +++
 libavcodec/nvenc_h264.c  |  6 --
 libavcodec/nvenc_hevc.c  |  6 --
 libavcodec/version.h |  4 ++--
 7 files changed, 49 insertions(+), 12 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 4cc2367e69..938ccf3aaa 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,12 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2020-04-10 - xx - lavc 58.79.100 - avcodec.h
+  Add formal support for calling avcodec_flush_buffers() on encoders.
+  Encoders that set the cap AV_CODEC_CAP_ENCODER_FLUSH will be flushed.
+  For all other encoders, the call is now a no-op rather than undefined
+  behaviour.
+
 2020-xx-xx - xx - lavc 58.78.100 - avcodec.h codec_desc.h codec_id.h 
packet.h
   Move AVCodecDesc-related public API to new header codec_desc.h.
   Move AVCodecID enum to new header codec_id.h.
diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
index 2c1891693e..27632decf5 100644
--- a/libavcodec/audiotoolboxenc.c
+++ b/libavcodec/audiotoolboxenc.c
@@ -627,7 +627,8 @@ static const AVOption options[] = {
 .encode2= ffat_encode, \
 .flush  = ffat_encode_flush, \
 .priv_class = &ffat_##NAME##_enc_class, \
-.capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY __VA_ARGS__, \
+.capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | \
+  AV_CODEC_CAP_ENCODER_FLUSH __VA_ARGS__, \
 .sample_fmts= (const enum AVSampleFormat[]) { \
 AV_SAMPLE_FMT_S16, \
 AV_SAMPLE_FMT_U8,  AV_SAMPLE_FMT_NONE \
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 55151a0b71..5efe5583a1 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -513,6 +513,13 @@ typedef struct RcOverride{
  */
 #define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE (1 << 20)
 
+/**
+ * This encoder can be flushed using avcodec_flush_buffers(). If this flag is
+ * not set, the encoder must be closed and reopened to ensure that no frames
+ * remain pending.
+ */
+#define AV_CODEC_CAP_ENCODER_FLUSH   (1 << 21)
+
 /* Exported side data.
These flags can be passed in AVCodecContext.export_side_data before 
initialization.
 */
@@ -4473,13 +4480,17 @@ int avcodec_fill_audio_frame(AVFrame *frame, int 
nb_channels,
  int buf_size, int align);
 
 /**
- * Reset the internal decoder state / flush internal buffers. Should be called
+ * Reset the internal codec state / flush internal buffers. Should be called
  * e.g. when seeking or when switching to a different stream.
  *
- * @note when refcounted frames are not used (i.e. avctx->refcounted_frames is 
0),
- * this invalidates the frames previously returned from the decoder. When
- * refcounted frames are used, the decoder just releases any references it 
might
- * keep internally, but the caller's reference remains valid.
+ * @note for decoders, when refcounted frames are not used
+ * (i.e. avctx->refcounted_frames is 0), this invalidates the frames previously
+ * returned from the decoder. When refcounted frames are used, the decoder just
+ * releases any references it might keep internally, but the caller's reference
+ * remains valid.
+ *
+ * @note for encoders, this function will only do something if the encoder
+ * declares support for AV_CODEC_CAP_ENCODER_FLUSH.
  */
 void avcodec_flush_buffers(AVCodecContext *avctx);
 
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index b7ae1fbb84..1602efdf03 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -2084,6 +2084,21 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
 {
 

Re: [FFmpeg-devel] [PATCH] avcodec/cbs: Allocate more CodedBitstreamUnit at once in cbs_insert_unit()

2020-04-10 Thread James Almer
On 4/10/2020 5:44 PM, James Almer wrote:
> On 4/10/2020 5:23 PM, Michael Niedermayer wrote:
>> Fixes: Timeout (85sec -> 0.5sec)
>> Fixes: 
>> 20791/clusterfuzz-testcase-minimized-ffmpeg_BSF_AV1_FRAME_SPLIT_fuzzer-5659537719951360
>> Fixes: 
>> 21214/clusterfuzz-testcase-minimized-ffmpeg_BSF_MPEG2_METADATA_fuzzer-5165560875974656
>> Fixes: 
>> 21247/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-5715175257931776
>>
>> Found-by: continuous fuzzing process 
>> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
>> Signed-off-by: Michael Niedermayer 
>> ---
>>  libavcodec/cbs.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
>> index 0bd5e1ac5d..42cb9711fa 100644
>> --- a/libavcodec/cbs.c
>> +++ b/libavcodec/cbs.c
>> @@ -693,11 +693,11 @@ static int cbs_insert_unit(CodedBitstreamContext *ctx,
>>  memmove(units + position + 1, units + position,
>>  (frag->nb_units - position) * sizeof(*units));
>>  } else {
>> -units = av_malloc_array(frag->nb_units + 1, sizeof(*units));
>> +units = av_malloc_array(frag->nb_units*2 + 1, sizeof(*units));
>>  if (!units)
>>  return AVERROR(ENOMEM);
>>  
>> -++frag->nb_units_allocated;
>> +frag->nb_units_allocated = 2*frag->nb_units_allocated + 1;
> 
> Use ff_fast_malloc(), please. This is quite ugly and the *2 undocumented
> and not obvious.

Actually no, ff_fast_malloc or av_fast_malloc can't be used for this. It
would need to be av_fast_realloc(), and the memcpy calls below changed
to memmove(), i think.

An alternative could be to maybe port this code to use AVTreeNodes. But
i still think that duplicating the amount of allocated units each time
sounds like it could go out of control fast.

> 
>>  
>>  if (position > 0)
>>  memcpy(units, frag->units, position * sizeof(*units));
>>
> 

___
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] libavformat/mov: fix multiple trun per traf

2020-04-10 Thread Michael Niedermayer
On Sun, Mar 29, 2020 at 02:27:38PM -0700, John Stebbins wrote:
> dts would start over at the beginning of each trun when they should be
> computed contiguously for each trun in a traf
> 
> Fixes ticket 8070
> ---
>  libavformat/isom.h |  1 +
>  libavformat/mov.c  | 12 +++-
>  2 files changed, 12 insertions(+), 1 deletion(-)

will apply tomorrow

fate tests for this and the previous fix might be a good idea
if someone has a small testcase

thx

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

What does censorship reveal? It reveals fear. -- Julian Assange


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] mov: fix seek to next root atom in fragmented mp4

2020-04-10 Thread Michael Niedermayer
On Sun, Mar 29, 2020 at 08:48:50PM +, John Stebbins wrote:
> On Sun, 2020-03-29 at 22:38 +0200, Andreas Rheinhardt wrote:
> > John Stebbins:
> > > If some but not all moof's are referenced in an sidx, whole
> > > fragments
> > > were being skipped.
> > > 
> > > Fixes tickets 7377, 7389, and 8502
> > > May also fix 8070 but the sample links expired, so I can't test.
> > 
> > Sample can be found here:
> > https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket8070/
> > (You may probably thank Carl-Eugen for this.)
> > 
> 
> Thanks.  So this patch *does not* fix 8070.  I'll investigate...

patch LGTM, ill apply it tomorrow without the reference to 8070

Thanks

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

The day soldiers stop bringing you their problems is the day you have stopped 
leading them. They have either lost confidence that you can help or concluded 
you do not care. Either case is a failure of leadership. - Colin Powell


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] Subtitle encoder return codes

2020-04-10 Thread John Stebbins
On Fri, 2020-04-10 at 14:12 -0700, Philip Langdale wrote:
> On Fri, 10 Apr 2020 13:02:16 -0600
> John Stebbins  wrote:
> 
> > Patch set makes return codes from subtitle encoders more meaningful
> > and consistent. Also fixes output buffer size checking where
> > needed.
> > 
> > After this, a user of a subtitle encoder can attempt to encode
> > again
> > with a larger buffer if the encoder returns
> > AVERROR_BUFFER_TOO_SMALL
> > 
> 
> The changes look good. Can you send me a branch for these?
> 
> 

Here it is
https://github.com/jstebbins/FFmpeg/tree/sub-enc-rets
___
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: Add explicit capability flag for encoder flushing

2020-04-10 Thread James Almer
On 4/10/2020 5:58 PM, Philip Langdale wrote:
> We've been in this fuzzy situation where maybe you could call
> avcodec_flush_buffers() on an encoder but there weren't any encoders
> that supported it except maybe audiotoolboxenc. Then we added flush
> support to nvenc very intentionally, and it worked, but that was more a
> coincidence than anything else. And if you call avcodec_flush_buffers()
> on an encoder that doesn't support it, it'll leave the encoder in an
> undefined state, so that's not great.
> 
> As part of cleaning this up, this change introduces a formal capability
> flag for encoders that support flushing and ensures a flush call is a
> no-op for any other encoder. This allows client code to check if it is
> meaningful to call flush on an encoder before actually doing it.
> 
> I have not attempted to separate the steps taken inside
> avcodec_flush_buffers() because it's not doing anything that's wrong
> for an encoder. But I did add a sanity check to reject attempts to
> flush a frame threaded encoder because I couldn't wrap my head around
> whether that code path was actually safe or not. As this combination
> doesn't exist today, we'll deal with it if it ever comes up.
> 
> Signed-off-by: Philip Langdale 
> ---
>  libavcodec/audiotoolboxenc.c |  3 ++-
>  libavcodec/avcodec.h | 21 -
>  libavcodec/decode.c  | 18 ++
>  libavcodec/nvenc_hevc.c  |  6 --
>  4 files changed, 40 insertions(+), 8 deletions(-)

Missing changes to nvenc_h264.c

Also a line in doc/APIChanges and a version bump, but that can be added
before pushing.

> 
> diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
> index 2c1891693e..7cb5ffd915 100644
> --- a/libavcodec/audiotoolboxenc.c
> +++ b/libavcodec/audiotoolboxenc.c
> @@ -627,7 +627,8 @@ static const AVOption options[] = {
>  .encode2= ffat_encode, \
>  .flush  = ffat_encode_flush, \
>  .priv_class = &ffat_##NAME##_enc_class, \
> -.capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY __VA_ARGS__, 
> \
> +.capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | \
> +  AV_CODEC_CAP_ENCODER_CAN_FLUSH __VA_ARGS__, \
>  .sample_fmts= (const enum AVSampleFormat[]) { \
>  AV_SAMPLE_FMT_S16, \
>  AV_SAMPLE_FMT_U8,  AV_SAMPLE_FMT_NONE \
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 55151a0b71..216ba3f79a 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -513,6 +513,13 @@ typedef struct RcOverride{
>   */
>  #define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE (1 << 20)
>  
> +/**
> + * This encoder can be flushed using avcodec_flush_buffers(). If this flag is
> + * not set, the encoder must be closed and reopened to ensure that no frames
> + * remain pending.
> + */
> +#define AV_CODEC_CAP_ENCODER_CAN_FLUSH   (1 << 21)

Maybe just AV_CODEC_CAP_ENCODER_FLUSH.

> +
>  /* Exported side data.
> These flags can be passed in AVCodecContext.export_side_data before 
> initialization.
>  */
> @@ -4473,13 +4480,17 @@ int avcodec_fill_audio_frame(AVFrame *frame, int 
> nb_channels,
>   int buf_size, int align);
>  
>  /**
> - * Reset the internal decoder state / flush internal buffers. Should be 
> called
> + * Reset the internal codec state / flush internal buffers. Should be called
>   * e.g. when seeking or when switching to a different stream.
>   *
> - * @note when refcounted frames are not used (i.e. avctx->refcounted_frames 
> is 0),
> - * this invalidates the frames previously returned from the decoder. When
> - * refcounted frames are used, the decoder just releases any references it 
> might
> - * keep internally, but the caller's reference remains valid.
> + * @note for decoders, when refcounted frames are not used
> + * (i.e. avctx->refcounted_frames is 0), this invalidates the frames 
> previously
> + * returned from the decoder. When refcounted frames are used, the decoder 
> just
> + * releases any references it might keep internally, but the caller's 
> reference
> + * remains valid.
> + *
> + * @note for encoders, this function will only do something if the encoder
> + * declares support for AV_CODEC_CAP_ENCODER_CAN_FLUSH.
>   */
>  void avcodec_flush_buffers(AVCodecContext *avctx);
>  
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index b7ae1fbb84..d21b5461e5 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -2084,6 +2084,24 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
>  {
>  AVCodecInternal *avci = avctx->internal;
>  
> +if (av_codec_is_encoder(avctx->codec)) {

Unrelated to this patch, but avcodec_is_open(avctx) may need to be
checked before even avci is set to avctx->internal above.

> +int caps = avctx->codec->capabilities;
> +if (!(caps & AV_CODEC_CAP_ENCODER_CAN_FLUSH)) {
> +// Only encoders that explicitly declare support f

Re: [FFmpeg-devel] Subtitle encoder return codes

2020-04-10 Thread Philip Langdale
On Fri, 10 Apr 2020 13:02:16 -0600
John Stebbins  wrote:

> Patch set makes return codes from subtitle encoders more meaningful
> and consistent. Also fixes output buffer size checking where needed.
> 
> After this, a user of a subtitle encoder can attempt to encode again
> with a larger buffer if the encoder returns AVERROR_BUFFER_TOO_SMALL
> 

The changes look good. Can you send me a branch for these?

Thanks,

--phil
___
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] avutil/log: update text requesting samples

2020-04-10 Thread Marton Balint



On Fri, 10 Apr 2020, Carl Eugen Hoyos wrote:


Am Fr., 10. Apr. 2020 um 20:12 Uhr schrieb Marton Balint :




On Sat, 4 Apr 2020, Carl Eugen Hoyos wrote:

> Am Sa., 4. Apr. 2020 um 19:26 Uhr schrieb Marton Balint :
>>
>> Signed-off-by: Marton Balint 
>> ---
>>  libavutil/log.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/libavutil/log.c b/libavutil/log.c
>> index 8d4945249e..a0b2348bd5 100644
>> --- a/libavutil/log.c
>> +++ b/libavutil/log.c
>> @@ -466,9 +466,9 @@ static void missing_feature_sample(int sample, void 
*avc, const char *msg,
>> "occurs, it means that your file has a feature which has not "
>> "been implemented.\n");
>>  if (sample)
>> -av_log(avc, AV_LOG_WARNING, "If you want to help, upload a sample "
>> -   "of this file to ftp://upload.ffmpeg.org/incoming/ "
>> -   "and contact the ffmpeg-devel mailing list. 
(ffmpeg-devel@ffmpeg.org)\n");
>> +av_log(avc, AV_LOG_WARNING, "If you want to help, open an enhancement 
"
>> +"ticket on https://trac.ffmpeg.org/ and upload a sample of this 
"
>> +"file to https://streams.videolan.org/upload/\n";);
>
> The change to the upload link is good, I would prefer if we
> do not ask for opening a ticket in every such case.

Why? Isn't the issue tracker more suitable for this then simple email?


No, because we typically ask for samples we already have.


Then maybe we should stop asking directly for samples and simply write 
that you should contact the developers, so the user won't have to upload 
the samples needlessly?


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] [PATCH] avcodec: Add explicit capability flag for encoder flushing

2020-04-10 Thread Philip Langdale
We've been in this fuzzy situation where maybe you could call
avcodec_flush_buffers() on an encoder but there weren't any encoders
that supported it except maybe audiotoolboxenc. Then we added flush
support to nvenc very intentionally, and it worked, but that was more a
coincidence than anything else. And if you call avcodec_flush_buffers()
on an encoder that doesn't support it, it'll leave the encoder in an
undefined state, so that's not great.

As part of cleaning this up, this change introduces a formal capability
flag for encoders that support flushing and ensures a flush call is a
no-op for any other encoder. This allows client code to check if it is
meaningful to call flush on an encoder before actually doing it.

I have not attempted to separate the steps taken inside
avcodec_flush_buffers() because it's not doing anything that's wrong
for an encoder. But I did add a sanity check to reject attempts to
flush a frame threaded encoder because I couldn't wrap my head around
whether that code path was actually safe or not. As this combination
doesn't exist today, we'll deal with it if it ever comes up.

Signed-off-by: Philip Langdale 
---
 libavcodec/audiotoolboxenc.c |  3 ++-
 libavcodec/avcodec.h | 21 -
 libavcodec/decode.c  | 18 ++
 libavcodec/nvenc_hevc.c  |  6 --
 4 files changed, 40 insertions(+), 8 deletions(-)

diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
index 2c1891693e..7cb5ffd915 100644
--- a/libavcodec/audiotoolboxenc.c
+++ b/libavcodec/audiotoolboxenc.c
@@ -627,7 +627,8 @@ static const AVOption options[] = {
 .encode2= ffat_encode, \
 .flush  = ffat_encode_flush, \
 .priv_class = &ffat_##NAME##_enc_class, \
-.capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY __VA_ARGS__, \
+.capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | \
+  AV_CODEC_CAP_ENCODER_CAN_FLUSH __VA_ARGS__, \
 .sample_fmts= (const enum AVSampleFormat[]) { \
 AV_SAMPLE_FMT_S16, \
 AV_SAMPLE_FMT_U8,  AV_SAMPLE_FMT_NONE \
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 55151a0b71..216ba3f79a 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -513,6 +513,13 @@ typedef struct RcOverride{
  */
 #define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE (1 << 20)
 
+/**
+ * This encoder can be flushed using avcodec_flush_buffers(). If this flag is
+ * not set, the encoder must be closed and reopened to ensure that no frames
+ * remain pending.
+ */
+#define AV_CODEC_CAP_ENCODER_CAN_FLUSH   (1 << 21)
+
 /* Exported side data.
These flags can be passed in AVCodecContext.export_side_data before 
initialization.
 */
@@ -4473,13 +4480,17 @@ int avcodec_fill_audio_frame(AVFrame *frame, int 
nb_channels,
  int buf_size, int align);
 
 /**
- * Reset the internal decoder state / flush internal buffers. Should be called
+ * Reset the internal codec state / flush internal buffers. Should be called
  * e.g. when seeking or when switching to a different stream.
  *
- * @note when refcounted frames are not used (i.e. avctx->refcounted_frames is 
0),
- * this invalidates the frames previously returned from the decoder. When
- * refcounted frames are used, the decoder just releases any references it 
might
- * keep internally, but the caller's reference remains valid.
+ * @note for decoders, when refcounted frames are not used
+ * (i.e. avctx->refcounted_frames is 0), this invalidates the frames previously
+ * returned from the decoder. When refcounted frames are used, the decoder just
+ * releases any references it might keep internally, but the caller's reference
+ * remains valid.
+ *
+ * @note for encoders, this function will only do something if the encoder
+ * declares support for AV_CODEC_CAP_ENCODER_CAN_FLUSH.
  */
 void avcodec_flush_buffers(AVCodecContext *avctx);
 
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index b7ae1fbb84..d21b5461e5 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -2084,6 +2084,24 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
 {
 AVCodecInternal *avci = avctx->internal;
 
+if (av_codec_is_encoder(avctx->codec)) {
+int caps = avctx->codec->capabilities;
+if (!(caps & AV_CODEC_CAP_ENCODER_CAN_FLUSH)) {
+// Only encoders that explicitly declare support for it can be
+// flushed. Otherwise, this is a no-op.
+av_log(avctx, AV_LOG_WARNING, "Ignoring attempt to flush encoder "
+   "that doesn't support it\n");
+return;
+}
+if (caps & AV_CODEC_CAP_FRAME_THREADS) {
+// We haven't implemented flushing for frame-threaded encoders.
+av_log(avctx, AV_LOG_WARNING, "Ignoring attempt to flush encoder "
+   "that claims to support both flushing and frame "
+   "threading\n");
+   

Re: [FFmpeg-devel] [PATCH] avutil/log: update text requesting samples

2020-04-10 Thread Carl Eugen Hoyos
Am Fr., 10. Apr. 2020 um 20:12 Uhr schrieb Marton Balint :
>
>
>
> On Sat, 4 Apr 2020, Carl Eugen Hoyos wrote:
>
> > Am Sa., 4. Apr. 2020 um 19:26 Uhr schrieb Marton Balint :
> >>
> >> Signed-off-by: Marton Balint 
> >> ---
> >>  libavutil/log.c | 6 +++---
> >>  1 file changed, 3 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/libavutil/log.c b/libavutil/log.c
> >> index 8d4945249e..a0b2348bd5 100644
> >> --- a/libavutil/log.c
> >> +++ b/libavutil/log.c
> >> @@ -466,9 +466,9 @@ static void missing_feature_sample(int sample, void 
> >> *avc, const char *msg,
> >> "occurs, it means that your file has a feature which has not "
> >> "been implemented.\n");
> >>  if (sample)
> >> -av_log(avc, AV_LOG_WARNING, "If you want to help, upload a sample 
> >> "
> >> -   "of this file to ftp://upload.ffmpeg.org/incoming/ "
> >> -   "and contact the ffmpeg-devel mailing list. 
> >> (ffmpeg-devel@ffmpeg.org)\n");
> >> +av_log(avc, AV_LOG_WARNING, "If you want to help, open an 
> >> enhancement "
> >> +"ticket on https://trac.ffmpeg.org/ and upload a sample of 
> >> this "
> >> +"file to https://streams.videolan.org/upload/\n";);
> >
> > The change to the upload link is good, I would prefer if we
> > do not ask for opening a ticket in every such case.
>
> Why? Isn't the issue tracker more suitable for this then simple email?

No, because we typically ask for samples we already have.

> Also, when you upload the file you reference the ticket, so the file will
> be put into the proper directory (right?) and you will know why the file

(No)

> is interesting by checking the ticket. Otherwise you get a file without a
> ticket number or proper description and good luck figuring out later why
> that got uploaded in the first place.

I upload it to the respective directory.

> > I believe I have dealt with every such (rare) mail in the past.
>
> If it is so rare, then one more reason why it should not matter. ;)

I believe we can deal with the few emails.

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] libavcodec/jpeg2000dec.c: Fix cblk decode error check

2020-04-10 Thread Carl Eugen Hoyos
Am Fr., 10. Apr. 2020 um 19:48 Uhr schrieb Gautam Ramakrishnan
:
>
> On Wed, Apr 1, 2020 at 5:48 PM Paul B Mahol  wrote:
> >
> > LGTM
> >
> > On 4/1/20, gautamr...@gmail.com  wrote:
> > > From: Gautam Ramakrishnan 
> > >
> > > bpno becoming negative is not an error. This check has
> > > been verified with openjpeg, where the loop ends safely
> > > when bpno becomes negative, instead of returning an error.
> > > This patch must resolve ticket #5630.
> > > ---
> > >  libavcodec/jpeg2000dec.c | 3 +--
> > >  1 file changed, 1 insertion(+), 2 deletions(-)
> > >
> > > diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> > > index 7103cd6ceb..c5711b60ec 100644
> > > --- a/libavcodec/jpeg2000dec.c
> > > +++ b/libavcodec/jpeg2000dec.c
> > > @@ -1562,8 +1562,7 @@ static int decode_cblk(Jpeg2000DecoderContext *s,
> > > Jpeg2000CodingStyle *codsty,
> > >
> > >  while (passno--) {
> > >  if (bpno < 0) {
> > > -av_log(s->avctx, AV_LOG_ERROR, "bpno became negative\n");
> > > -return AVERROR_INVALIDDATA;
> > > +break;
> > >  }
> > >  switch(pass_t) {
> > >  case 0:
> > > --
> > > 2.17.1

> There were a lot of other changes to jpeg2000dec.c
> after this was sent. Do I resubmit this patch?

Yes, please do.

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] libavcodec/jpeg2000dec.c: fix error in cod marker

2020-04-10 Thread Carl Eugen Hoyos
Am Fr., 10. Apr. 2020 um 20:28 Uhr schrieb :
>
> From: Gautam Ramakrishnan 
>
> This patch fixes an error where the COC marker
> overrides all data of the SPcod field of the
> COD marker. It must override only one bit of
> SPcod field. This now allows p0_08.j2k to be
> decoded correctly (mentioned in #4679).

This patch makes p0_08.j2k decoding bit-exact,
the other sample is in
http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4679/

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/cbs: Allocate more CodedBitstreamUnit at once in cbs_insert_unit()

2020-04-10 Thread James Almer
On 4/10/2020 5:23 PM, Michael Niedermayer wrote:
> Fixes: Timeout (85sec -> 0.5sec)
> Fixes: 
> 20791/clusterfuzz-testcase-minimized-ffmpeg_BSF_AV1_FRAME_SPLIT_fuzzer-5659537719951360
> Fixes: 
> 21214/clusterfuzz-testcase-minimized-ffmpeg_BSF_MPEG2_METADATA_fuzzer-5165560875974656
> Fixes: 
> 21247/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-5715175257931776
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/cbs.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
> index 0bd5e1ac5d..42cb9711fa 100644
> --- a/libavcodec/cbs.c
> +++ b/libavcodec/cbs.c
> @@ -693,11 +693,11 @@ static int cbs_insert_unit(CodedBitstreamContext *ctx,
>  memmove(units + position + 1, units + position,
>  (frag->nb_units - position) * sizeof(*units));
>  } else {
> -units = av_malloc_array(frag->nb_units + 1, sizeof(*units));
> +units = av_malloc_array(frag->nb_units*2 + 1, sizeof(*units));
>  if (!units)
>  return AVERROR(ENOMEM);
>  
> -++frag->nb_units_allocated;
> +frag->nb_units_allocated = 2*frag->nb_units_allocated + 1;

Use ff_fast_malloc(), please. This is quite ugly and the *2 undocumented
and not obvious.

>  
>  if (position > 0)
>  memcpy(units, frag->units, position * sizeof(*units));
> 

___
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 1/2] avfilter/delogo: remove deprecated options

2020-04-10 Thread James Almer
On 4/10/2020 4:30 PM, Gyan Doshi wrote:
> Deprecated in 2015 in 8bc708fcee1
> ---
>  libavfilter/vf_delogo.c | 15 +--
>  1 file changed, 1 insertion(+), 14 deletions(-)
> 
> diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c
> index 5a2c5e7feb..8edbe03cdc 100644
> --- a/libavfilter/vf_delogo.c
> +++ b/libavfilter/vf_delogo.c
> @@ -211,11 +211,6 @@ static const AVOption delogo_options[]= {
>  { "y","set logo y position",   OFFSET(y_expr),
> AV_OPT_TYPE_STRING, { .str = "-1" }, 0, 0, FLAGS },
>  { "w","set logo width",OFFSET(w_expr),
> AV_OPT_TYPE_STRING, { .str = "-1" }, 0, 0, FLAGS },
>  { "h","set logo height",   OFFSET(h_expr),
> AV_OPT_TYPE_STRING, { .str = "-1" }, 0, 0, FLAGS },
> -#if LIBAVFILTER_VERSION_MAJOR < 7
> -/* Actual default value for band/t is 1, set in init */
> -{ "band", "set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, { 
> .i64 =  0 },  0, INT_MAX, FLAGS },
> -{ "t","set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, { 
> .i64 =  0 },  0, INT_MAX, FLAGS },
> -#endif
>  { "show", "show delogo area",  OFFSET(show), AV_OPT_TYPE_BOOL,{ 
> .i64 =  0 },  0, 1,   FLAGS },
>  { NULL }
>  };
> @@ -272,16 +267,8 @@ static av_cold int init(AVFilterContext *ctx)
>  CHECK_UNSET_OPT(w);
>  CHECK_UNSET_OPT(h);
>  
> -#if LIBAVFILTER_VERSION_MAJOR < 7
> -if (s->band == 0) { /* Unset, use default */
> -av_log(ctx, AV_LOG_WARNING, "Note: default band value was changed 
> from 4 to 1.\n");
> -s->band = 1;
> -} else if (s->band != 1) {
> -av_log(ctx, AV_LOG_WARNING, "Option band is deprecated.\n");
> -}
> -#else
>  s->band = 1;
> -#endif
> +
>  av_log(ctx, AV_LOG_VERBOSE, "x:%d y:%d, w:%d h:%d band:%d show:%d\n",
> s->x, s->y, s->w, s->h, s->band, s->show);
>  
> 

LGTM.
___
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] avcodec/cbs: Allocate more CodedBitstreamUnit at once in cbs_insert_unit()

2020-04-10 Thread Michael Niedermayer
Fixes: Timeout (85sec -> 0.5sec)
Fixes: 
20791/clusterfuzz-testcase-minimized-ffmpeg_BSF_AV1_FRAME_SPLIT_fuzzer-5659537719951360
Fixes: 
21214/clusterfuzz-testcase-minimized-ffmpeg_BSF_MPEG2_METADATA_fuzzer-5165560875974656
Fixes: 
21247/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-5715175257931776

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

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 0bd5e1ac5d..42cb9711fa 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -693,11 +693,11 @@ static int cbs_insert_unit(CodedBitstreamContext *ctx,
 memmove(units + position + 1, units + position,
 (frag->nb_units - position) * sizeof(*units));
 } else {
-units = av_malloc_array(frag->nb_units + 1, sizeof(*units));
+units = av_malloc_array(frag->nb_units*2 + 1, sizeof(*units));
 if (!units)
 return AVERROR(ENOMEM);
 
-++frag->nb_units_allocated;
+frag->nb_units_allocated = 2*frag->nb_units_allocated + 1;
 
 if (position > 0)
 memcpy(units, frag->units, position * sizeof(*units));
-- 
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".

[FFmpeg-devel] [PATCH 2/4] avformat/mpegtsenc: only allow one program in m2ts mode

2020-04-10 Thread Marton Balint
The standard does not allow more.

Signed-off-by: Marton Balint 
---
 libavformat/mpegtsenc.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 5e71a0b6f8..97d2dda22d 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -869,8 +869,13 @@ static int mpegts_init(AVFormatContext *s)
 ts->m2ts_pgssub_pid  = M2TS_PGSSUB_START_PID;
 ts->m2ts_textsub_pid = M2TS_TEXTSUB_START_PID;
 
-if (ts->m2ts_mode)
+if (ts->m2ts_mode) {
 ts->pmt_start_pid = M2TS_PMT_PID;
+if (s->nb_programs > 1) {
+av_log(s, AV_LOG_ERROR, "Only one program is allowed in m2ts 
mode!\n");
+return AVERROR(EINVAL);
+}
+}
 
 if (s->max_delay < 0) /* Not set by the caller */
 s->max_delay = 0;
-- 
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/4] avformat/mpegtsenc: use standard pids for m2ts

2020-04-10 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 doc/muxers.texi |  6 --
 libavformat/mpegts.h| 10 ++
 libavformat/mpegtsenc.c | 44 +++-
 3 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 4b6ffaaf58..c7caf52ff4 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1630,11 +1630,13 @@ Advanced Codec Digital HDTV service.
 
 @item mpegts_pmt_start_pid @var{integer}
 Set the first PID for PMTs. Default is @code{0x1000}, minimum is @code{0x0020},
-maximum is @code{0x1ffa}.
+maximum is @code{0x1ffa}. This option has no effect in m2ts mode where the PMT
+PID is fixed @code{0x0100}.
 
 @item mpegts_start_pid @var{integer}
 Set the first PID for elementary streams. Default is @code{0x0100}, minimum is
-@code{0x0020}, maximum is @code{0x1ffa}.
+@code{0x0020}, maximum is @code{0x1ffa}. This option has no effect in m2ts mode
+where the elementary stream PIDs are fixed.
 
 @item mpegts_m2ts_mode @var{boolean}
 Enable m2ts mode if set to @code{1}. Default value is @code{-1} which
diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index 86a3eba4e2..f9a7e27564 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -65,6 +65,16 @@
  * streams and other data tables */
 #define NULL_PID0x1FFF /* Null packet (used for fixed bandwidth 
padding) */
 
+/* m2ts pids */
+#define M2TS_PMT_PID  0x0100
+#define M2TS_PCR_PID  0x1001
+#define M2TS_VIDEO_PID0x1011
+#define M2TS_AUDIO_START_PID  0x1100
+#define M2TS_PGSSUB_START_PID 0x1200
+#define M2TS_TEXTSUB_START_PID0x1800
+#define M2TS_SECONDARY_AUDIO_START_PID0x1A00
+#define M2TS_SECONDARY_VIDEO_START_PID0x1B00
+
 /* table ids */
 #define PAT_TID 0x00 /* Program Association section */
 #define CAT_TID 0x01 /* Conditional Access section */
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index ccb631d746..5e71a0b6f8 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -94,6 +94,10 @@ typedef struct MpegTSWrite {
 int pmt_start_pid;
 int start_pid;
 int m2ts_mode;
+int m2ts_video_pid;
+int m2ts_audio_pid;
+int m2ts_pgssub_pid;
+int m2ts_textsub_pid;
 
 int pcr_period_ms;
 #define MPEGTS_FLAG_REEMIT_PAT_PMT  0x01
@@ -860,6 +864,14 @@ static int mpegts_init(AVFormatContext *s)
 }
 }
 
+ts->m2ts_video_pid   = M2TS_VIDEO_PID;
+ts->m2ts_audio_pid   = M2TS_AUDIO_START_PID;
+ts->m2ts_pgssub_pid  = M2TS_PGSSUB_START_PID;
+ts->m2ts_textsub_pid = M2TS_TEXTSUB_START_PID;
+
+if (ts->m2ts_mode)
+ts->pmt_start_pid = M2TS_PMT_PID;
+
 if (s->max_delay < 0) /* Not set by the caller */
 s->max_delay = 0;
 
@@ -923,7 +935,37 @@ static int mpegts_init(AVFormatContext *s)
 /* MPEG pid values < 16 are reserved. Applications which set st->id in
  * this range are assigned a calculated pid. */
 if (st->id < 16) {
-ts_st->pid = ts->start_pid + i;
+if (ts->m2ts_mode) {
+switch (st->codecpar->codec_type) {
+case AVMEDIA_TYPE_VIDEO:
+ts_st->pid = ts->m2ts_video_pid++;
+break;
+case AVMEDIA_TYPE_AUDIO:
+ts_st->pid = ts->m2ts_audio_pid++;
+break;
+case AVMEDIA_TYPE_SUBTITLE:
+switch (st->codecpar->codec_id) {
+case AV_CODEC_ID_HDMV_PGS_SUBTITLE:
+ts_st->pid = ts->m2ts_pgssub_pid++;
+break;
+case AV_CODEC_ID_HDMV_TEXT_SUBTITLE:
+ts_st->pid = ts->m2ts_textsub_pid++;
+break;
+}
+break;
+}
+if (ts->m2ts_video_pid   > M2TS_VIDEO_PID + 1  ||
+ts->m2ts_audio_pid   > M2TS_AUDIO_START_PID + 32   ||
+ts->m2ts_pgssub_pid  > M2TS_PGSSUB_START_PID + 32  ||
+ts->m2ts_textsub_pid > M2TS_TEXTSUB_START_PID + 32 ||
+ts_st->pid < 16) {
+av_log(s, AV_LOG_ERROR, "Cannot automatically assign PID 
for stream %d\n", st->index);
+ret = AVERROR(EINVAL);
+goto fail;
+}
+} else {
+ts_st->pid = ts->start_pid + i;
+}
 } else {
 ts_st->pid = st->id;
 }
-- 
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/4] avformat/mpegtsenc: factorize determining stream_type

2020-04-10 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavformat/mpegtsenc.c | 147 ++--
 1 file changed, 79 insertions(+), 68 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 97d2dda22d..add35aca89 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -282,6 +282,83 @@ static void put_registration_descriptor(uint8_t **q_ptr, 
uint32_t tag)
 *q_ptr = q;
 }
 
+static int get_dvb_stream_type(AVFormatContext *s, AVStream *st)
+{
+MpegTSWrite *ts = s->priv_data;
+int stream_type;
+
+switch (st->codecpar->codec_id) {
+case AV_CODEC_ID_MPEG1VIDEO:
+case AV_CODEC_ID_MPEG2VIDEO:
+stream_type = STREAM_TYPE_VIDEO_MPEG2;
+break;
+case AV_CODEC_ID_MPEG4:
+stream_type = STREAM_TYPE_VIDEO_MPEG4;
+break;
+case AV_CODEC_ID_H264:
+stream_type = STREAM_TYPE_VIDEO_H264;
+break;
+case AV_CODEC_ID_HEVC:
+stream_type = STREAM_TYPE_VIDEO_HEVC;
+break;
+case AV_CODEC_ID_CAVS:
+stream_type = STREAM_TYPE_VIDEO_CAVS;
+break;
+case AV_CODEC_ID_DIRAC:
+stream_type = STREAM_TYPE_VIDEO_DIRAC;
+break;
+case AV_CODEC_ID_VC1:
+stream_type = STREAM_TYPE_VIDEO_VC1;
+break;
+case AV_CODEC_ID_MP2:
+case AV_CODEC_ID_MP3:
+if (   st->codecpar->sample_rate > 0
+&& st->codecpar->sample_rate < 32000) {
+stream_type = STREAM_TYPE_AUDIO_MPEG2;
+} else {
+stream_type = STREAM_TYPE_AUDIO_MPEG1;
+}
+break;
+case AV_CODEC_ID_AAC:
+stream_type = (ts->flags & MPEGTS_FLAG_AAC_LATM)
+  ? STREAM_TYPE_AUDIO_AAC_LATM
+  : STREAM_TYPE_AUDIO_AAC;
+break;
+case AV_CODEC_ID_AAC_LATM:
+stream_type = STREAM_TYPE_AUDIO_AAC_LATM;
+break;
+case AV_CODEC_ID_AC3:
+stream_type = (ts->flags & MPEGTS_FLAG_SYSTEM_B)
+  ? STREAM_TYPE_PRIVATE_DATA
+  : STREAM_TYPE_AUDIO_AC3;
+break;
+case AV_CODEC_ID_EAC3:
+stream_type = (ts->flags & MPEGTS_FLAG_SYSTEM_B)
+  ? STREAM_TYPE_PRIVATE_DATA
+  : STREAM_TYPE_AUDIO_EAC3;
+break;
+case AV_CODEC_ID_DTS:
+stream_type = STREAM_TYPE_AUDIO_DTS;
+break;
+case AV_CODEC_ID_TRUEHD:
+stream_type = STREAM_TYPE_AUDIO_TRUEHD;
+break;
+case AV_CODEC_ID_OPUS:
+stream_type = STREAM_TYPE_PRIVATE_DATA;
+break;
+case AV_CODEC_ID_TIMED_ID3:
+stream_type = STREAM_TYPE_METADATA;
+break;
+default:
+av_log(s, AV_LOG_WARNING, "Stream %d, codec %s, is muxed as a private 
data stream "
+   "and may not be recognized upon reading.\n", st->index, 
avcodec_get_name(st->codecpar->codec_id));
+stream_type = STREAM_TYPE_PRIVATE_DATA;
+break;
+}
+
+return stream_type;
+}
+
 static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
 {
 MpegTSWrite *ts = s->priv_data;
@@ -323,74 +400,8 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 err = 1;
 break;
 }
-switch (st->codecpar->codec_id) {
-case AV_CODEC_ID_MPEG1VIDEO:
-case AV_CODEC_ID_MPEG2VIDEO:
-stream_type = STREAM_TYPE_VIDEO_MPEG2;
-break;
-case AV_CODEC_ID_MPEG4:
-stream_type = STREAM_TYPE_VIDEO_MPEG4;
-break;
-case AV_CODEC_ID_H264:
-stream_type = STREAM_TYPE_VIDEO_H264;
-break;
-case AV_CODEC_ID_HEVC:
-stream_type = STREAM_TYPE_VIDEO_HEVC;
-break;
-case AV_CODEC_ID_CAVS:
-stream_type = STREAM_TYPE_VIDEO_CAVS;
-break;
-case AV_CODEC_ID_DIRAC:
-stream_type = STREAM_TYPE_VIDEO_DIRAC;
-break;
-case AV_CODEC_ID_VC1:
-stream_type = STREAM_TYPE_VIDEO_VC1;
-break;
-case AV_CODEC_ID_MP2:
-case AV_CODEC_ID_MP3:
-if (   st->codecpar->sample_rate > 0
-&& st->codecpar->sample_rate < 32000) {
-stream_type = STREAM_TYPE_AUDIO_MPEG2;
-} else {
-stream_type = STREAM_TYPE_AUDIO_MPEG1;
-}
-break;
-case AV_CODEC_ID_AAC:
-stream_type = (ts->flags & MPEGTS_FLAG_AAC_LATM)
-  ? STREAM_TYPE_AUDIO_AAC_LATM
-  : STREAM_TYPE_AUDIO_AAC;
-break;
-case AV_CODEC_ID_AAC_LATM:
-stream_type = STREAM_TYPE_AUDIO_AAC_LATM;
-break;
-case AV_CODEC_ID_AC3:
-stream_type = (ts->flags & MPEGTS_FLAG_SYSTEM_B)
-  ? STREAM_TYPE_PRIVATE_DATA
-  : STREAM_TYPE_AUDIO_AC3;
-break;
-case AV_CODEC_ID_EAC3:
-stre

[FFmpeg-devel] [PATCH 4/4] avformat/mpegtsenc: use the correct stream_types and write HDMV descriptors for m2ts

2020-04-10 Thread Marton Balint
Fixes ticket #2622.

Signed-off-by: Marton Balint 
---
 libavformat/mpegtsenc.c | 58 -
 1 file changed, 57 insertions(+), 1 deletion(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index add35aca89..b154675d60 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -359,6 +359,54 @@ static int get_dvb_stream_type(AVFormatContext *s, 
AVStream *st)
 return stream_type;
 }
 
+static int get_m2ts_stream_type(AVFormatContext *s, AVStream *st)
+{
+int stream_type;
+
+switch (st->codecpar->codec_id) {
+case AV_CODEC_ID_MPEG2VIDEO:
+stream_type = STREAM_TYPE_VIDEO_MPEG2;
+break;
+case AV_CODEC_ID_H264:
+stream_type = STREAM_TYPE_VIDEO_H264;
+break;
+case AV_CODEC_ID_VC1:
+stream_type = STREAM_TYPE_VIDEO_VC1;
+break;
+case AV_CODEC_ID_HEVC:
+stream_type = STREAM_TYPE_VIDEO_HEVC;
+break;
+case AV_CODEC_ID_PCM_BLURAY:
+stream_type = 0x80;
+break;
+case AV_CODEC_ID_AC3:
+stream_type = 0x81;
+break;
+case AV_CODEC_ID_DTS:
+stream_type = (st->codecpar->channels > 6) ? 0x85 : 0x82;
+break;
+case AV_CODEC_ID_TRUEHD:
+stream_type = 0x83;
+break;
+case AV_CODEC_ID_EAC3:
+stream_type = 0x84;
+break;
+case AV_CODEC_ID_HDMV_PGS_SUBTITLE:
+stream_type = 0x90;
+break;
+case AV_CODEC_ID_HDMV_TEXT_SUBTITLE:
+stream_type = 0x92;
+break;
+default:
+av_log(s, AV_LOG_WARNING, "Stream %d, codec %s, is muxed as a private 
data stream "
+   "and may not be recognized upon reading.\n", st->index, 
avcodec_get_name(st->codecpar->codec_id));
+stream_type = STREAM_TYPE_PRIVATE_DATA;
+break;
+}
+
+return stream_type;
+}
+
 static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
 {
 MpegTSWrite *ts = s->priv_data;
@@ -372,6 +420,14 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 q += 2; /* patched after */
 
 /* put program info here */
+if (ts->m2ts_mode) {
+put_registration_descriptor(&q, MKTAG('H', 'D', 'M', 'V'));
+*q++ = 0x88;// descriptor_tag - hdmv_copy_control_descriptor
+*q++ = 0x04;// descriptor_length
+put16(&q, 0x0fff);  // CA_System_ID
+*q++ = 0xfc;// private_data_byte
+*q++ = 0xfc;// private_data_byte
+}
 
 val = 0xf000 | (q - program_info_length_ptr - 2);
 program_info_length_ptr[0] = val >> 8;
@@ -401,7 +457,7 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 break;
 }
 
-stream_type = get_dvb_stream_type(s, st);
+stream_type = ts->m2ts_mode ? get_m2ts_stream_type(s, st) : 
get_dvb_stream_type(s, st);
 
 *q++ = stream_type;
 put16(&q, 0xe000 | ts_st->pid);
-- 
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 2/2] avfilter/delogo: correct indentation for option show.

2020-04-10 Thread Gyan Doshi
---
 libavfilter/vf_delogo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c
index 8edbe03cdc..e55673d5ad 100644
--- a/libavfilter/vf_delogo.c
+++ b/libavfilter/vf_delogo.c
@@ -211,7 +211,7 @@ static const AVOption delogo_options[]= {
 { "y","set logo y position",   OFFSET(y_expr),
AV_OPT_TYPE_STRING, { .str = "-1" }, 0, 0, FLAGS },
 { "w","set logo width",OFFSET(w_expr),
AV_OPT_TYPE_STRING, { .str = "-1" }, 0, 0, FLAGS },
 { "h","set logo height",   OFFSET(h_expr),
AV_OPT_TYPE_STRING, { .str = "-1" }, 0, 0, FLAGS },
-{ "show", "show delogo area",  OFFSET(show), AV_OPT_TYPE_BOOL,{ 
.i64 =  0 },  0, 1,   FLAGS },
+{ "show", "show delogo area",  OFFSET(show),  
AV_OPT_TYPE_BOOL,   { .i64 =  0 },   0, 1, FLAGS },
 { NULL }
 };
 
-- 
2.26.0

___
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/2] avfilter/delogo: remove deprecated options

2020-04-10 Thread Gyan Doshi
Deprecated in 2015 in 8bc708fcee1
---
 libavfilter/vf_delogo.c | 15 +--
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c
index 5a2c5e7feb..8edbe03cdc 100644
--- a/libavfilter/vf_delogo.c
+++ b/libavfilter/vf_delogo.c
@@ -211,11 +211,6 @@ static const AVOption delogo_options[]= {
 { "y","set logo y position",   OFFSET(y_expr),
AV_OPT_TYPE_STRING, { .str = "-1" }, 0, 0, FLAGS },
 { "w","set logo width",OFFSET(w_expr),
AV_OPT_TYPE_STRING, { .str = "-1" }, 0, 0, FLAGS },
 { "h","set logo height",   OFFSET(h_expr),
AV_OPT_TYPE_STRING, { .str = "-1" }, 0, 0, FLAGS },
-#if LIBAVFILTER_VERSION_MAJOR < 7
-/* Actual default value for band/t is 1, set in init */
-{ "band", "set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, { 
.i64 =  0 },  0, INT_MAX, FLAGS },
-{ "t","set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, { 
.i64 =  0 },  0, INT_MAX, FLAGS },
-#endif
 { "show", "show delogo area",  OFFSET(show), AV_OPT_TYPE_BOOL,{ 
.i64 =  0 },  0, 1,   FLAGS },
 { NULL }
 };
@@ -272,16 +267,8 @@ static av_cold int init(AVFilterContext *ctx)
 CHECK_UNSET_OPT(w);
 CHECK_UNSET_OPT(h);
 
-#if LIBAVFILTER_VERSION_MAJOR < 7
-if (s->band == 0) { /* Unset, use default */
-av_log(ctx, AV_LOG_WARNING, "Note: default band value was changed from 
4 to 1.\n");
-s->band = 1;
-} else if (s->band != 1) {
-av_log(ctx, AV_LOG_WARNING, "Option band is deprecated.\n");
-}
-#else
 s->band = 1;
-#endif
+
 av_log(ctx, AV_LOG_VERBOSE, "x:%d y:%d, w:%d h:%d band:%d show:%d\n",
s->x, s->y, s->w, s->h, s->band, s->show);
 
-- 
2.26.0

___
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] movtext decode/encode improvements

2020-04-10 Thread John Stebbins
On Fri, 2020-04-10 at 09:50 -0700, Philip Langdale wrote:
> On Thu, 9 Apr 2020 23:28:49 +
> John Stebbins  wrote:
> 
> 
> > Essentially yes.  We've had our own mov text encoder and decoder in
> > HandBrake for years.  I added support for using ffmpeg for decoding
> > subtitles last year but the movtext decoder wasn't up to the same
> > level as ours, so we weren't using ffmpeg for that yet. I'm
> > following
> > up that work from last year to add subtitle encoding with ffmpeg
> > and
> > dropping our decoder and encoder for mov text.
> 
> That's great - and I really appreciate you taking the extra effort to
> feed this back! Of course, I can't help but be greedy: Have you
> looked
> at subtitle positioning? I think that's the biggest functional gap
> left.
> 
> > I'm also almost finished writing a PGS subtitle encoder for ffmpeg
> > ;)
> 
> Very nice!
> 

Subtitle positioning is on my todo list.  But it wasn't supported in
HandBrake's mov text encoder, so I didn't need to add it for feature
parity.  I've got a bunch of subtitle TODOs for both HandBrake and
ffmpeg.

___
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 7/7] lavc/xsubenc: return meaningfull error codes

2020-04-10 Thread John Stebbins
---
 libavcodec/xsubenc.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/xsubenc.c b/libavcodec/xsubenc.c
index b3da909679..4d58e0f3b5 100644
--- a/libavcodec/xsubenc.c
+++ b/libavcodec/xsubenc.c
@@ -63,7 +63,7 @@ static int xsub_encode_rle(PutBitContext *pb, const uint8_t 
*bitmap,
 while (x0 < w) {
 // Make sure we have enough room for at least one run and padding
 if (pb->size_in_bits - put_bits_count(pb) < 7*8)
-return -1;
+return AVERROR_BUFFER_TOO_SMALL;
 
 x1 = x0;
 color = bitmap[x1++] & 3;
@@ -124,7 +124,7 @@ static int xsub_encode(AVCodecContext *avctx, unsigned char 
*buf,
 
 if (bufsize < 27 + 7*2 + 4*3) {
 av_log(avctx, AV_LOG_ERROR, "Buffer too small for XSUB header.\n");
-return -1;
+return AVERROR_BUFFER_TOO_SMALL;
 }
 
 // TODO: support multiple rects
@@ -147,7 +147,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 // TODO: render text-based subtitles into bitmaps
 if (!h->rects[0]->data[0] || !h->rects[0]->data[1]) {
 av_log(avctx, AV_LOG_WARNING, "No subtitle bitmap available.\n");
-return -1;
+return AVERROR(EINVAL);
 }
 
 // TODO: color reduction, similar to dvdsub encoder
@@ -160,7 +160,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 if (make_tc(startTime, start_tc) || make_tc(endTime, end_tc)) {
 av_log(avctx, AV_LOG_WARNING, "Time code >= 100 hours.\n");
-return -1;
+return AVERROR(EINVAL);
 }
 
 snprintf(buf, 28,
@@ -195,13 +195,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if (xsub_encode_rle(&pb, h->rects[0]->data[0],
 h->rects[0]->linesize[0] * 2,
 h->rects[0]->w, (h->rects[0]->h + 1) >> 1))
-return -1;
+return AVERROR_BUFFER_TOO_SMALL;
 bytestream_put_le16(&rlelenptr, put_bits_count(&pb) >> 3); // Length of 
first field
 
 if (xsub_encode_rle(&pb, h->rects[0]->data[0] + h->rects[0]->linesize[0],
 h->rects[0]->linesize[0] * 2,
 h->rects[0]->w, h->rects[0]->h >> 1))
-return -1;
+return AVERROR_BUFFER_TOO_SMALL;
 
 // Enforce total height to be a multiple of 2
 if (h->rects[0]->h & 1) {
-- 
2.25.2

___
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 6/7] lavc/webvttenc: return more meaningful error codes

2020-04-10 Thread John Stebbins
---
 libavcodec/webvttenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/webvttenc.c b/libavcodec/webvttenc.c
index c84bbf4b4e..febf6ee370 100644
--- a/libavcodec/webvttenc.c
+++ b/libavcodec/webvttenc.c
@@ -168,7 +168,7 @@ static int webvtt_encode_frame(AVCodecContext *avctx,
 
 if (sub->rects[i]->type != SUBTITLE_ASS) {
 av_log(avctx, AV_LOG_ERROR, "Only SUBTITLE_ASS type supported.\n");
-return AVERROR(ENOSYS);
+return AVERROR(EINVAL);
 }
 
 #if FF_API_ASS_TIMING
@@ -200,7 +200,7 @@ static int webvtt_encode_frame(AVCodecContext *avctx,
 
 if (s->buffer.len > bufsize) {
 av_log(avctx, AV_LOG_ERROR, "Buffer too small for ASS event.\n");
-return -1;
+return AVERROR_BUFFER_TOO_SMALL;
 }
 memcpy(buf, s->buffer.str, s->buffer.len);
 
-- 
2.25.2

___
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 4/7] lavc/movtextenc: return more meaningful error codes

2020-04-10 Thread John Stebbins
---
 libavcodec/movtextenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index d8dbc546aa..b2368b641b 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -693,7 +693,7 @@ static int mov_text_encode_frame(AVCodecContext *avctx, 
unsigned char *buf,
 
 if (sub->rects[i]->type != SUBTITLE_ASS) {
 av_log(avctx, AV_LOG_ERROR, "Only SUBTITLE_ASS type supported.\n");
-return AVERROR(ENOSYS);
+return AVERROR(EINVAL);
 }
 
 #if FF_API_ASS_TIMING
@@ -736,7 +736,7 @@ static int mov_text_encode_frame(AVCodecContext *avctx, 
unsigned char *buf,
 
 if (s->buffer.len > bufsize - 3) {
 av_log(avctx, AV_LOG_ERROR, "Buffer too small for ASS event.\n");
-length = AVERROR(EINVAL);
+length = AVERROR_BUFFER_TOO_SMALL;
 goto exit;
 }
 
-- 
2.25.2

___
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/7] lavc/dvbsub: return meaningful error codes

2020-04-10 Thread John Stebbins
---
 libavcodec/dvbsub.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/dvbsub.c b/libavcodec/dvbsub.c
index a0be0b1056..5c081f2b71 100644
--- a/libavcodec/dvbsub.c
+++ b/libavcodec/dvbsub.c
@@ -282,7 +282,7 @@ static int encode_dvb_subtitles(AVCodecContext *avctx,
 page_id = 1;
 
 if (h->num_rects && !h->rects)
-return -1;
+return AVERROR(EINVAL);
 
 if (avctx->width > 0 && avctx->height > 0) {
 if (buf_size < 11)
@@ -341,7 +341,7 @@ static int encode_dvb_subtitles(AVCodecContext *avctx,
 /* 8 bpp, standard encoding */
 bpp_index = 2;
 } else {
-return -1;
+return AVERROR(EINVAL);
 }
 
 
@@ -393,7 +393,7 @@ static int encode_dvb_subtitles(AVCodecContext *avctx,
 /* 8 bpp, standard encoding */
 bpp_index = 2;
 } else {
-return -1;
+return AVERROR(EINVAL);
 }
 
 *q++ = 0x0f; /* sync_byte */
@@ -441,7 +441,7 @@ static int encode_dvb_subtitles(AVCodecContext *avctx,
 /* 8 bpp, standard encoding */
 dvb_encode_rle = dvb_encode_rle8;
 } else {
-return -1;
+return AVERROR(EINVAL);
 }
 
 /* Object Data segment */
-- 
2.25.2

___
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 5/7] lavc/srtenc: return more meaninful error codes

2020-04-10 Thread John Stebbins
---
 libavcodec/srtenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/srtenc.c b/libavcodec/srtenc.c
index 34f0f0d5e6..655b65679e 100644
--- a/libavcodec/srtenc.c
+++ b/libavcodec/srtenc.c
@@ -241,7 +241,7 @@ static int encode_frame(AVCodecContext *avctx,
 
 if (sub->rects[i]->type != SUBTITLE_ASS) {
 av_log(avctx, AV_LOG_ERROR, "Only SUBTITLE_ASS type supported.\n");
-return AVERROR(ENOSYS);
+return AVERROR(EINVAL);
 }
 
 #if FF_API_ASS_TIMING
@@ -276,7 +276,7 @@ static int encode_frame(AVCodecContext *avctx,
 
 if (s->buffer.len > bufsize) {
 av_log(avctx, AV_LOG_ERROR, "Buffer too small for ASS event.\n");
-return -1;
+return AVERROR_BUFFER_TOO_SMALL;
 }
 memcpy(buf, s->buffer.str, s->buffer.len);
 
-- 
2.25.2

___
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/7] lavc/assenc: return more meaningful error code

2020-04-10 Thread John Stebbins
When the buffer is too small, return AVERROR_BUFFER_TOO_SMALL
---
 libavcodec/assenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/assenc.c b/libavcodec/assenc.c
index e54c1d8ec3..a6e1d5d8b9 100644
--- a/libavcodec/assenc.c
+++ b/libavcodec/assenc.c
@@ -93,7 +93,7 @@ static int ass_encode_frame(AVCodecContext *avctx,
 
 if (len > bufsize-total_len-1) {
 av_log(avctx, AV_LOG_ERROR, "Buffer too small for ASS event.\n");
-return AVERROR(EINVAL);
+return AVERROR_BUFFER_TOO_SMALL;
 }
 
 total_len += len;
-- 
2.25.2

___
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/7] lavc/dvbsub: fix potential encode buffer overflow

2020-04-10 Thread John Stebbins
encode buffer size was ignored
---
 libavcodec/dvbsub.c | 97 +++--
 1 file changed, 75 insertions(+), 22 deletions(-)

diff --git a/libavcodec/dvbsub.c b/libavcodec/dvbsub.c
index a8d43d81d6..a0be0b1056 100644
--- a/libavcodec/dvbsub.c
+++ b/libavcodec/dvbsub.c
@@ -37,11 +37,11 @@ typedef struct DVBSubtitleContext {
 }\
 }
 
-static void dvb_encode_rle2(uint8_t **pq,
-const uint8_t *bitmap, int linesize,
-int w, int h)
+static int dvb_encode_rle2(uint8_t **pq, int buf_size,
+   const uint8_t *bitmap, int linesize,
+   int w, int h)
 {
-uint8_t *q;
+uint8_t *q, *line_begin;
 unsigned int bitbuf;
 int bitcnt;
 int x, y, len, x1, v, color;
@@ -49,6 +49,10 @@ static void dvb_encode_rle2(uint8_t **pq,
 q = *pq;
 
 for(y = 0; y < h; y++) {
+// Worst case line is 3 bits per value + 4 bytes overhead
+if (buf_size * 8 < w * 3 + 32)
+return AVERROR_BUFFER_TOO_SMALL;
+line_begin = q;
 *q++ = 0x10;
 bitbuf = 0;
 bitcnt = 6;
@@ -109,8 +113,11 @@ static void dvb_encode_rle2(uint8_t **pq,
 }
 *q++ = 0xf0;
 bitmap += linesize;
+buf_size -= q - line_begin;
 }
+len = q - *pq;
 *pq = q;
+return len;
 }
 
 #define PUTBITS4(val)\
@@ -125,11 +132,11 @@ static void dvb_encode_rle2(uint8_t **pq,
 }
 
 /* some DVB decoders only implement 4 bits/pixel */
-static void dvb_encode_rle4(uint8_t **pq,
-const uint8_t *bitmap, int linesize,
-int w, int h)
+static int dvb_encode_rle4(uint8_t **pq, int buf_size,
+   const uint8_t *bitmap, int linesize,
+   int w, int h)
 {
-uint8_t *q;
+uint8_t *q, *line_begin;
 unsigned int bitbuf;
 int bitcnt;
 int x, y, len, x1, v, color;
@@ -137,6 +144,10 @@ static void dvb_encode_rle4(uint8_t **pq,
 q = *pq;
 
 for(y = 0; y < h; y++) {
+// Worst case line is 6 bits per value, + 4 bytes overhead
+if (buf_size * 8 < w * 6 + 32)
+return AVERROR_BUFFER_TOO_SMALL;
+line_begin = q;
 *q++ = 0x11;
 bitbuf = 0;
 bitcnt = 4;
@@ -189,20 +200,27 @@ static void dvb_encode_rle4(uint8_t **pq,
 }
 *q++ = 0xf0;
 bitmap += linesize;
+buf_size -= q - line_begin;
 }
+len = q - *pq;
 *pq = q;
+return len;
 }
 
-static void dvb_encode_rle8(uint8_t **pq,
-const uint8_t *bitmap, int linesize,
-int w, int h)
+static int dvb_encode_rle8(uint8_t **pq, int buf_size,
+   const uint8_t *bitmap, int linesize,
+   int w, int h)
 {
-uint8_t *q;
+uint8_t *q, *line_begin;
 int x, y, len, x1, color;
 
 q = *pq;
 
 for (y = 0; y < h; y++) {
+// Worst case line is 12 bits per value, + 3 bytes overhead
+if (buf_size * 8 < w * 12 + 24)
+return AVERROR_BUFFER_TOO_SMALL;
+line_begin = q;
 *q++ = 0x12;
 
 x = 0;
@@ -243,12 +261,16 @@ static void dvb_encode_rle8(uint8_t **pq,
 *q++ = 0x00;
 *q++ = 0xf0;
 bitmap += linesize;
+buf_size -= q - line_begin;
 }
+len = q - *pq;
 *pq = q;
+return len;
 }
 
 static int encode_dvb_subtitles(AVCodecContext *avctx,
-uint8_t *outbuf, const AVSubtitle *h)
+uint8_t *outbuf, int buf_size,
+const AVSubtitle *h)
 {
 DVBSubtitleContext *s = avctx->priv_data;
 uint8_t *q, *pseg_len;
@@ -263,6 +285,8 @@ static int encode_dvb_subtitles(AVCodecContext *avctx,
 return -1;
 
 if (avctx->width > 0 && avctx->height > 0) {
+if (buf_size < 11)
+return AVERROR_BUFFER_TOO_SMALL;
 /* display definition segment */
 *q++ = 0x0f; /* sync_byte */
 *q++ = 0x14; /* segment_type */
@@ -273,10 +297,13 @@ static int encode_dvb_subtitles(AVCodecContext *avctx,
 bytestream_put_be16(&q, avctx->width - 1); /* display width */
 bytestream_put_be16(&q, avctx->height - 1); /* display height */
 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
+buf_size -= 11;
 }
 
 /* page composition segment */
 
+if (buf_size < 8 + h->num_rects * 6)
+return AVERROR_BUFFER_TOO_SMALL;
 *q++ = 0x0f; /* sync_byte */
 *q++ = 0x10; /* segment_type */
 bytestream_put_be16(&q, page_id);
@@ -295,9 +322,12 @@ static int encode_dvb_subtitles(AVCodecContext *avctx,
 }
 
 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
+buf_size -= 8 + h->num_rects * 6;
 
 if (h->num_rects) {
 for (clut_id = 0; clut_id < h->num_rects; clut_id++) {
+if (buf_size < 6 + h->rects[clut_id]->nb_colors

[FFmpeg-devel] Subtitle encoder return codes

2020-04-10 Thread John Stebbins
Patch set makes return codes from subtitle encoders more meaningful and
consistent. Also fixes output buffer size checking where needed.

After this, a user of a subtitle encoder can attempt to encode again with
a larger buffer if the encoder returns AVERROR_BUFFER_TOO_SMALL

___
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] libavcodec/jpeg2000dec.c: fix error in cod marker

2020-04-10 Thread gautamramk
From: Gautam Ramakrishnan 

This patch fixes an error where the COC marker
overrides all data of the SPcod field of the
COD marker. It must override only one bit of
SPcod field. This now allows p0_08.j2k to be
decoded correctly (mentioned in #4679).
---
 libavcodec/jpeg2000dec.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 9684e57b34..290589934a 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -566,6 +566,7 @@ static int get_coc(Jpeg2000DecoderContext *s, 
Jpeg2000CodingStyle *c,
uint8_t *properties)
 {
 int compno, ret;
+uint8_t has_eph;
 
 if (bytestream2_get_bytes_left(&s->g) < 2) {
 av_log(s->avctx, AV_LOG_ERROR, "Insufficient space for COC\n");
@@ -582,7 +583,9 @@ static int get_coc(Jpeg2000DecoderContext *s, 
Jpeg2000CodingStyle *c,
 }
 
 c  += compno;
+has_eph = c->csty & JPEG2000_CSTY_EPH;
 c->csty = bytestream2_get_byteu(&s->g);
+c->csty |= has_eph;
 
 if ((ret = get_cox(s, c)) < 0)
 return ret;
-- 
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".

Re: [FFmpeg-devel] [PATCH 4/4] avcodec.h: split bitstream filters API into its own header

2020-04-10 Thread James Almer
On 4/10/2020 12:42 PM, Anton Khirnov wrote:
> ---
>  doc/APIchanges |   3 +-
>  libavcodec/Makefile|   1 +
>  libavcodec/aac_adtstoasc_bsf.c |   2 +-
>  libavcodec/av1_frame_merge_bsf.c   |   2 +-
>  libavcodec/av1_frame_split_bsf.c   |   2 +-
>  libavcodec/av1_metadata_bsf.c  |   1 +
>  libavcodec/avcodec.h   | 285 +-
>  libavcodec/bsf.c   |   4 +-
>  libavcodec/bsf.h   | 324 +
>  libavcodec/bsf_internal.h  |   5 +-
>  libavcodec/chomp_bsf.c |   2 +-
>  libavcodec/dca_core_bsf.c  |   2 +-
>  libavcodec/dump_extradata_bsf.c|   2 +-
>  libavcodec/eac3_core_bsf.c |   2 +-
>  libavcodec/extract_extradata_bsf.c |   2 +-
>  libavcodec/filter_units_bsf.c  |   1 +
>  libavcodec/h264_metadata_bsf.c |   1 +
>  libavcodec/h264_mp4toannexb_bsf.c  |   1 +
>  libavcodec/h264_redundant_pps_bsf.c|   1 +
>  libavcodec/h265_metadata_bsf.c |   1 +
>  libavcodec/hapqa_extract_bsf.c |   2 +-
>  libavcodec/hevc_mp4toannexb_bsf.c  |   1 +
>  libavcodec/imx_dump_header_bsf.c   |   2 +-
>  libavcodec/mjpeg2jpeg_bsf.c|   2 +-
>  libavcodec/mjpega_dump_header_bsf.c|   2 +-
>  libavcodec/movsub_bsf.c|   2 +-
>  libavcodec/mp3_header_decompress_bsf.c |   2 +-
>  libavcodec/mpeg2_metadata_bsf.c|   1 +
>  libavcodec/mpeg4_unpack_bframes_bsf.c  |   2 +-
>  libavcodec/noise_bsf.c |   2 +-
>  libavcodec/null_bsf.c  |   2 +-
>  libavcodec/prores_metadata_bsf.c   |   2 +
>  libavcodec/remove_extradata_bsf.c  |   1 +
>  libavcodec/trace_headers_bsf.c |   1 +
>  libavcodec/truehd_core_bsf.c   |   2 +-
>  libavcodec/vp9_metadata_bsf.c  |   1 +
>  libavcodec/vp9_raw_reorder_bsf.c   |   1 +
>  libavcodec/vp9_superframe_bsf.c|   3 +-
>  libavcodec/vp9_superframe_split_bsf.c  |   2 +-
>  39 files changed, 370 insertions(+), 307 deletions(-)
>  create mode 100644 libavcodec/bsf.h

Both this and patch 3/4 LGTM.

I'll wait for you to push this before i push my doxy patch.
___
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] avutil/log: update text requesting samples

2020-04-10 Thread Marton Balint



On Sat, 4 Apr 2020, Carl Eugen Hoyos wrote:


Am Sa., 4. Apr. 2020 um 19:26 Uhr schrieb Marton Balint :


Signed-off-by: Marton Balint 
---
 libavutil/log.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavutil/log.c b/libavutil/log.c
index 8d4945249e..a0b2348bd5 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -466,9 +466,9 @@ static void missing_feature_sample(int sample, void *avc, 
const char *msg,
"occurs, it means that your file has a feature which has not "
"been implemented.\n");
 if (sample)
-av_log(avc, AV_LOG_WARNING, "If you want to help, upload a sample "
-   "of this file to ftp://upload.ffmpeg.org/incoming/ "
-   "and contact the ffmpeg-devel mailing list. 
(ffmpeg-devel@ffmpeg.org)\n");
+av_log(avc, AV_LOG_WARNING, "If you want to help, open an enhancement "
+"ticket on https://trac.ffmpeg.org/ and upload a sample of this "
+"file to https://streams.videolan.org/upload/\n";);


The change to the upload link is good, I would prefer if we
do not ask for opening a ticket in every such case.


Why? Isn't the issue tracker more suitable for this then simple email? 
Also, when you upload the file you reference the ticket, so the file will 
be put into the proper directory (right?) and you will know why the file 
is interesting by checking the ticket. Otherwise you get a file without a 
ticket number or proper description and good luck figuring out later why 
that got uploaded in the first place.




I believe I have dealt with every such (rare) mail in the past.


If it is so rare, then one more reason why it should not matter. ;)

Thanks,
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] libavcodec/jpeg2000dec.c: Fix cblk decode error check

2020-04-10 Thread Gautam Ramakrishnan
On Wed, Apr 1, 2020 at 5:48 PM Paul B Mahol  wrote:
>
> LGTM
>
> On 4/1/20, gautamr...@gmail.com  wrote:
> > From: Gautam Ramakrishnan 
> >
> > bpno becoming negative is not an error. This check has
> > been verified with openjpeg, where the loop ends safely
> > when bpno becomes negative, instead of returning an error.
> > This patch must resolve ticket #5630.
> > ---
> >  libavcodec/jpeg2000dec.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> > index 7103cd6ceb..c5711b60ec 100644
> > --- a/libavcodec/jpeg2000dec.c
> > +++ b/libavcodec/jpeg2000dec.c
> > @@ -1562,8 +1562,7 @@ static int decode_cblk(Jpeg2000DecoderContext *s,
> > Jpeg2000CodingStyle *codsty,
> >
> >  while (passno--) {
> >  if (bpno < 0) {
> > -av_log(s->avctx, AV_LOG_ERROR, "bpno became negative\n");
> > -return AVERROR_INVALIDDATA;
> > +break;
> >  }
> >  switch(pass_t) {
> >  case 0:
> > --
> > 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".

Hi,

There were a lot of other changes to jpeg2000dec.c
after this was sent. Do I resubmit this patch?

-- 
-
Gautam |
___
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/2] avcodec/bsf: add av_bsf_join() to chain bitstream filters

2020-04-10 Thread Andreas Rheinhardt
James Almer:
> On 4/10/2020 11:56 AM, Marton Balint wrote:
>>
>>
>> On Fri, 10 Apr 2020, James Almer wrote:
>>
>>> On 4/10/2020 5:25 AM, Marton Balint wrote:
>>
>> [...]
>>
>>>
>>> Finally, (I feel bad having to tell you this given that you have
>>> clearly
>>> invested a lot of time in this) we currently have no case where we
>>> need
>>> more than one automatically inserted bitstream filter per stream.
>>> We do
>>> not know whether the current code does the right thing in case more
>>> than
>>> one packet needs to be analyzed to determine whether to insert
>>> bitstream
>>> filters (maybe the packets should instead be cached so that no bsf
>>> misses out on the initial packets?); of course what is the right
>>> thing
>>> might be format and codec-dependent. So I don't know whether we
>>> should
>>> add this function now (given that public API is hard to remove).
>>>
>>> This does not mean that we should not use a bsf_list bsf to simplify
>>> automatic bitstream filtering in mux.c (it really simplifies this
>>> alot
>>> and gets rid of code duplication). But I think we should leave the
>>> topic
>>> of adding a bsf to an already existing bsf open so that it can be
>>> determined when the need indeed arises.
>>
>> I see no sane way of sharing list bsf code other than adding public
>> API,
>> because mux.c is libavformat, bsf.c is libavcodec. This at least
>> allows
>> you to replace AVStreamInternal->nb_bsfcs and AVStreamInternal->bsfcs
>> with a single bitstream filter to which you join additional ones.
>>
>> Unless you want to remove the existing (admittedly unused, and
>> potentially inadequate) support for multiple bitstream filters in
>> AVStreamInternal, I really don't see a way which postpones adding
>> this API.
>
> Can't you achieve the same using existing bsf list API from within
> lavf?
> av_bsf_list_alloc(), followed by any required amount of calls to
> av_bsf_list_append(), av_bsf_list_append2() or av_bsf_list_parse_str()
> to add each bsf, then av_bsf_list_finalize() at the end?

 That API only works if you have all the bitstream filters before
 finalizing the list, you can't append a BSF to an already finalized
 list. The implementation in mux.c supports adding a BSF, then maybe
 passing a few packets through it, then appending another BSF to the list
 - this can happen if .check_bitstream_filters() adds a bsf but returns
 0, and at a later packet it adds another bsf.

 Regards,
 Marton
>>>
>>> I see what you mean. Do we really need the option to insert a bsf to a
>>> given stream after a few packets have already been processed? Any
>>> required bsf should be present since the beginning. They are all written
>>> to either modify the data or pass it through depending if something must
>>> be done or not.
>>>
>>> What could show up say five packets into the stream that would require a
>>> bsf to be inserted at that point and couldn't have been present since
>>> the beginning? Passing packets through within a bsf is almost free, so
>>> there's not a lot to win by postponing inserting a bsf. You'll simply be
>>> delegating the task of analyzing the bitstream to the muxer's
>>> check_bitstream(), when the bsf can already do it without any extra
>>> steps.
>>
>> Ok, so this also points me to the direction of removing the support of
>> multiple BSFs from AVStreamInternal, because if a demuxer wants multiple
>> bsfs it can simply create a single list bsf in one go.
> 
> This will also allow you to simplify things by moving the
> oformat->check_bitstream() calls from do_packet_auto_bsf() to
> init_muxer(), right after the call to oformat->init(), since you're not
> longer constrained by the need for packets mid muxing.
> 
If it is decided that we no longer need to actually look at packet data
any more for adding bitstream filters, then we can actually remove the
check_bitstream functions altogether and let the muxer set things up
during init.

But this is not how I understood Marton. He only wanted to take away the
muxer's ability to add bitstream filters during multiple calls to
check_bitstream().

Btw: need_auto_bsf() from [1] can also be simplified a lot: One adds a
new field to AVStreamInternal bsf_checking_status. Possible values are 1
(checking is finished and one needs bsf), 0 (checking is finished and no
bsf are needed) and -1 (checking not finished). If the
AVFMT_FLAG_AUTO_BSF is not set or if the AVOutputFormat doesn't have a
check_bitstream() function, it is set to 0 during init, otherwise to -1.
need_auto_bsf() would then begin with "if
(st->internal->bsf_checking_status >= 0) return
st->internal->bsf_checking_status;". Otherwise, the bitstream would
really be checked (the check for the existence of the check_bitstream
function could then be omitted, too, of course), which would 

Re: [FFmpeg-devel] [PATCH v1] fftools/ffprobe: Use format specifier PRId64 instead of %lld

2020-04-10 Thread Michael Niedermayer
On Fri, Apr 10, 2020 at 07:04:38PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  fftools/ffprobe.c | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
> index e3f221f560..a32bc529d9 100644
> --- a/fftools/ffprobe.c
> +++ b/fftools/ffprobe.c
> @@ -408,7 +408,7 @@ static char *value_string(char *buf, int buf_size, struct 
> unit_value uv)
>  if (show_float || (use_value_prefix && vald != (long long int)vald))
>  snprintf(buf, buf_size, "%f", vald);
>  else
> -snprintf(buf, buf_size, "%lld", vali);
> +snprintf(buf, buf_size, "%"PRId64, vali);
>  av_strlcatf(buf, buf_size, "%s%s%s", *prefix_string || 
> show_value_unit ? " " : "",
>   prefix_string, show_value_unit ? uv.unit : "");
>  }
> @@ -1002,7 +1002,7 @@ static void default_print_int(WriterContext *wctx, 
> const char *key, long long in
>  
>  if (!def->nokey)
>  printf("%s%s=", wctx->section_pbuf[wctx->level].str, key);
> -printf("%lld\n", value);
> +printf("%"PRId64"\n", value);
>  }
>  
>  static const Writer default_writer = {
> @@ -1179,7 +1179,7 @@ static void compact_print_int(WriterContext *wctx, 
> const char *key, long long in
>  if (wctx->nb_item[wctx->level]) printf("%c", compact->item_sep);
>  if (!compact->nokey)
>  printf("%s%s=", wctx->section_pbuf[wctx->level].str, key);
> -printf("%lld", value);
> +printf("%"PRId64, value);
>  }
>  
>  static const Writer compact_writer = {

> @@ -1322,7 +1322,7 @@ static void flat_print_section_header(WriterContext 
> *wctx)
>  
>  static void flat_print_int(WriterContext *wctx, const char *key, long long 
> int value)
>  {
> -printf("%s%s=%lld\n", wctx->section_pbuf[wctx->level].str, key, value);
> +printf("%s%s=%"PRId64"\n", wctx->section_pbuf[wctx->level].str, key, 
> value);
>  }

the type does not match here

[...]
-- 
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 04/10] avformat/mux: Fix leaks of uncoded frames on errors

2020-04-10 Thread Marton Balint



On Fri, 10 Apr 2020, Andreas Rheinhardt wrote:


Marton Balint:



On Tue, 31 Mar 2020, Andreas Rheinhardt wrote:


If writing an uncoded frame fails at the preparatory steps of
av_[interleaved_]write_frame(), the frame would be either not freed
at all in case of av_write_frame() or would leak when the fake packet
would be unreferenced like an ordinary packet.
There is also a memleak when the output format is not suited for
writing uncoded frames as the documentation states that ownership of the
frame passes to av_[interleaved_]write_uncoded_frame(). Both of these
memleaks have been fixed.


Yuck, does using uncoded_frames muxing have any benefit over using
AV_CODEC_ID_WRAPPED_AVFRAME with normal muxing? If not, then I'd very
much like to see uncoded frames dropped with the next bump...


I'd like to see them dropped, too, but the earliest possible time at
which they can be removed is the bump after the next major bump.


I tried to find a project on the internet which is using this API, failed 
to find one. Therefore I doubt that it is reasonable to keep it after the 
API bump (if we decide to drop it), it only makes sense to keep API 
deprectated longer which is indeed used in the wild.






Signed-off-by: Andreas Rheinhardt 
---
libavformat/mux.c | 23 ++-
1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/libavformat/mux.c b/libavformat/mux.c
index 814d773b9d..a0ebcec119 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -1239,7 +1239,11 @@ int av_interleaved_write_frame(AVFormatContext
*s, AVPacket *pkt)
    return ret;
    }
fail:
-    av_packet_unref(pkt);
+    // This is a deviation from the usual behaviour
+    // of av_interleaved_write_frame: We leave cleaning
+    // up uncoded frames to write_uncoded_frame_internal.
+    if (!(pkt->flags & AV_PKT_FLAG_UNCODED_FRAME))
+    av_packet_unref(pkt);
    return ret;
}

@@ -1324,10 +1328,13 @@ static int
write_uncoded_frame_internal(AVFormatContext *s, int stream_index,
    AVFrame *frame, int interleaved)
{
    AVPacket pkt, *pktp;
+    int ret;

    av_assert0(s->oformat);
-    if (!s->oformat->write_uncoded_frame)
-    return AVERROR(ENOSYS);
+    if (!s->oformat->write_uncoded_frame) {
+    ret = AVERROR(ENOSYS);
+    goto free;
+    }

    if (!frame) {
    pktp = NULL;
@@ -1343,8 +1350,14 @@ static int
write_uncoded_frame_internal(AVFormatContext *s, int stream_index,
    pkt.flags |= AV_PKT_FLAG_UNCODED_FRAME;
    }

-    return interleaved ? av_interleaved_write_frame(s, pktp) :
- av_write_frame(s, pktp);
+    ret = interleaved ? av_interleaved_write_frame(s, pktp) :
+    av_write_frame(s, pktp);
+    if (ret < 0 && pktp) {
+    frame = (AVFrame*)pktp->data;
+    free:


I think we always align labels to the start of the line.


+    av_frame_free(&frame);
+    }
+    return ret;
}

int av_write_uncoded_frame(AVFormatContext *s, int stream_index,


LGTM, thanks.


It is actually not good at all, but I only found this out later: As the
commit message says, this fixes leaks if one of the preparatory steps
fails. But if there is an error when actually writing the frame, then
this will lead to a double free in the non-interleaved codepath is used
because of:
   AVFrame *frame = (AVFrame *)pkt->data;
   av_assert0(pkt->size == UNCODED_FRAME_PACKET_SIZE);
   ret = s->oformat->write_uncoded_frame(s, pkt->stream_index,
&frame, 0);
   av_frame_free(&frame);

(Both times frame should be replaced by (AVFrame **)&pkt->data.)

And then the patch for no longer modifying packets we don't own needs to
be adapted, too: Using a spare packet for uncoded frames is not only
unnecessary, but harmful, because then the original packet would still
contain a dangling pointer to the frame even after it has been freed.

So far this stuff is easily fixable (and I have fixed it locally), but
there is more:
1. As I already said, there is a leak in case the functions for
interleaved output are used if the trailer is never written (e.g.
because an error occurs during an earlier write operation), because
ff_packet_list_free() is not aware of uncoded frames.
2. This is all very fragile. E.g. if one of these warnings in
write_packet() would be transformed into errors, then (all other things
equal) uncoded frames would leak if they have been written via the
interleaved codepath.
3. I do not even know whether the approach taken here (namely leaving
cleaning up to the callers in order to minimize the places where one
does cleanup) is compatible with Marton's patchset.

I see two ways going forward:
a) The way uncoded frames are handled is changed so that it respects the
ordinary AVBuffer-API: Ownership of the AVFrame is passed to an AVBuffer
with a custom free function (like it is for wrapped AVFrames). This will
automatically solve the first problem and it will simplify freeing more
generally (no constant 

Re: [FFmpeg-devel] movtext decode/encode improvements

2020-04-10 Thread Philip Langdale
On Thu, 9 Apr 2020 23:28:49 +
John Stebbins  wrote:


> Essentially yes.  We've had our own mov text encoder and decoder in
> HandBrake for years.  I added support for using ffmpeg for decoding
> subtitles last year but the movtext decoder wasn't up to the same
> level as ours, so we weren't using ffmpeg for that yet. I'm following
> up that work from last year to add subtitle encoding with ffmpeg and
> dropping our decoder and encoder for mov text.

That's great - and I really appreciate you taking the extra effort to
feed this back! Of course, I can't help but be greedy: Have you looked
at subtitle positioning? I think that's the biggest functional gap left.

> I'm also almost finished writing a PGS subtitle encoder for ffmpeg ;)

Very nice!

--phil
___
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/2] avcodec/bsf: add av_bsf_join() to chain bitstream filters

2020-04-10 Thread James Almer
On 4/10/2020 11:56 AM, Marton Balint wrote:
> 
> 
> On Fri, 10 Apr 2020, James Almer wrote:
> 
>> On 4/10/2020 5:25 AM, Marton Balint wrote:
> 
> [...]
> 
>>
>> Finally, (I feel bad having to tell you this given that you have
>> clearly
>> invested a lot of time in this) we currently have no case where we
>> need
>> more than one automatically inserted bitstream filter per stream.
>> We do
>> not know whether the current code does the right thing in case more
>> than
>> one packet needs to be analyzed to determine whether to insert
>> bitstream
>> filters (maybe the packets should instead be cached so that no bsf
>> misses out on the initial packets?); of course what is the right
>> thing
>> might be format and codec-dependent. So I don't know whether we
>> should
>> add this function now (given that public API is hard to remove).
>>
>> This does not mean that we should not use a bsf_list bsf to simplify
>> automatic bitstream filtering in mux.c (it really simplifies this
>> alot
>> and gets rid of code duplication). But I think we should leave the
>> topic
>> of adding a bsf to an already existing bsf open so that it can be
>> determined when the need indeed arises.
>
> I see no sane way of sharing list bsf code other than adding public
> API,
> because mux.c is libavformat, bsf.c is libavcodec. This at least
> allows
> you to replace AVStreamInternal->nb_bsfcs and AVStreamInternal->bsfcs
> with a single bitstream filter to which you join additional ones.
>
> Unless you want to remove the existing (admittedly unused, and
> potentially inadequate) support for multiple bitstream filters in
> AVStreamInternal, I really don't see a way which postpones adding
> this API.

 Can't you achieve the same using existing bsf list API from within
 lavf?
 av_bsf_list_alloc(), followed by any required amount of calls to
 av_bsf_list_append(), av_bsf_list_append2() or av_bsf_list_parse_str()
 to add each bsf, then av_bsf_list_finalize() at the end?
>>>
>>> That API only works if you have all the bitstream filters before
>>> finalizing the list, you can't append a BSF to an already finalized
>>> list. The implementation in mux.c supports adding a BSF, then maybe
>>> passing a few packets through it, then appending another BSF to the list
>>> - this can happen if .check_bitstream_filters() adds a bsf but returns
>>> 0, and at a later packet it adds another bsf.
>>>
>>> Regards,
>>> Marton
>>
>> I see what you mean. Do we really need the option to insert a bsf to a
>> given stream after a few packets have already been processed? Any
>> required bsf should be present since the beginning. They are all written
>> to either modify the data or pass it through depending if something must
>> be done or not.
>>
>> What could show up say five packets into the stream that would require a
>> bsf to be inserted at that point and couldn't have been present since
>> the beginning? Passing packets through within a bsf is almost free, so
>> there's not a lot to win by postponing inserting a bsf. You'll simply be
>> delegating the task of analyzing the bitstream to the muxer's
>> check_bitstream(), when the bsf can already do it without any extra
>> steps.
> 
> Ok, so this also points me to the direction of removing the support of
> multiple BSFs from AVStreamInternal, because if a demuxer wants multiple
> bsfs it can simply create a single list bsf in one go.

This will also allow you to simplify things by moving the
oformat->check_bitstream() calls from do_packet_auto_bsf() to
init_muxer(), right after the call to oformat->init(), since you're not
longer constrained by the need for packets mid muxing.

> 
> Is there anybody who objects removing support for multiple bsfs is
> AVStreamInternal?
> 
> Thanks,
> 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 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 04/10] avformat/mux: Fix leaks of uncoded frames on errors

2020-04-10 Thread Andreas Rheinhardt
Marton Balint:
> 
> 
> On Tue, 31 Mar 2020, Andreas Rheinhardt wrote:
> 
>> If writing an uncoded frame fails at the preparatory steps of
>> av_[interleaved_]write_frame(), the frame would be either not freed
>> at all in case of av_write_frame() or would leak when the fake packet
>> would be unreferenced like an ordinary packet.
>> There is also a memleak when the output format is not suited for
>> writing uncoded frames as the documentation states that ownership of the
>> frame passes to av_[interleaved_]write_uncoded_frame(). Both of these
>> memleaks have been fixed.
> 
> Yuck, does using uncoded_frames muxing have any benefit over using
> AV_CODEC_ID_WRAPPED_AVFRAME with normal muxing? If not, then I'd very
> much like to see uncoded frames dropped with the next bump...
> 
I'd like to see them dropped, too, but the earliest possible time at
which they can be removed is the bump after the next major bump.

>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>> libavformat/mux.c | 23 ++-
>> 1 file changed, 18 insertions(+), 5 deletions(-)
>>
>> diff --git a/libavformat/mux.c b/libavformat/mux.c
>> index 814d773b9d..a0ebcec119 100644
>> --- a/libavformat/mux.c
>> +++ b/libavformat/mux.c
>> @@ -1239,7 +1239,11 @@ int av_interleaved_write_frame(AVFormatContext
>> *s, AVPacket *pkt)
>>     return ret;
>>     }
>> fail:
>> -    av_packet_unref(pkt);
>> +    // This is a deviation from the usual behaviour
>> +    // of av_interleaved_write_frame: We leave cleaning
>> +    // up uncoded frames to write_uncoded_frame_internal.
>> +    if (!(pkt->flags & AV_PKT_FLAG_UNCODED_FRAME))
>> +    av_packet_unref(pkt);
>>     return ret;
>> }
>>
>> @@ -1324,10 +1328,13 @@ static int
>> write_uncoded_frame_internal(AVFormatContext *s, int stream_index,
>>     AVFrame *frame, int interleaved)
>> {
>>     AVPacket pkt, *pktp;
>> +    int ret;
>>
>>     av_assert0(s->oformat);
>> -    if (!s->oformat->write_uncoded_frame)
>> -    return AVERROR(ENOSYS);
>> +    if (!s->oformat->write_uncoded_frame) {
>> +    ret = AVERROR(ENOSYS);
>> +    goto free;
>> +    }
>>
>>     if (!frame) {
>>     pktp = NULL;
>> @@ -1343,8 +1350,14 @@ static int
>> write_uncoded_frame_internal(AVFormatContext *s, int stream_index,
>>     pkt.flags |= AV_PKT_FLAG_UNCODED_FRAME;
>>     }
>>
>> -    return interleaved ? av_interleaved_write_frame(s, pktp) :
>> - av_write_frame(s, pktp);
>> +    ret = interleaved ? av_interleaved_write_frame(s, pktp) :
>> +    av_write_frame(s, pktp);
>> +    if (ret < 0 && pktp) {
>> +    frame = (AVFrame*)pktp->data;
>> +    free:
> 
> I think we always align labels to the start of the line.
> 
>> +    av_frame_free(&frame);
>> +    }
>> +    return ret;
>> }
>>
>> int av_write_uncoded_frame(AVFormatContext *s, int stream_index,
> 
> LGTM, thanks.

It is actually not good at all, but I only found this out later: As the
commit message says, this fixes leaks if one of the preparatory steps
fails. But if there is an error when actually writing the frame, then
this will lead to a double free in the non-interleaved codepath is used
because of:
AVFrame *frame = (AVFrame *)pkt->data;
av_assert0(pkt->size == UNCODED_FRAME_PACKET_SIZE);
ret = s->oformat->write_uncoded_frame(s, pkt->stream_index,
&frame, 0);
av_frame_free(&frame);

(Both times frame should be replaced by (AVFrame **)&pkt->data.)

And then the patch for no longer modifying packets we don't own needs to
be adapted, too: Using a spare packet for uncoded frames is not only
unnecessary, but harmful, because then the original packet would still
contain a dangling pointer to the frame even after it has been freed.

So far this stuff is easily fixable (and I have fixed it locally), but
there is more:
1. As I already said, there is a leak in case the functions for
interleaved output are used if the trailer is never written (e.g.
because an error occurs during an earlier write operation), because
ff_packet_list_free() is not aware of uncoded frames.
2. This is all very fragile. E.g. if one of these warnings in
write_packet() would be transformed into errors, then (all other things
equal) uncoded frames would leak if they have been written via the
interleaved codepath.
3. I do not even know whether the approach taken here (namely leaving
cleaning up to the callers in order to minimize the places where one
does cleanup) is compatible with Marton's patchset.

I see two ways going forward:
a) The way uncoded frames are handled is changed so that it respects the
ordinary AVBuffer-API: Ownership of the AVFrame is passed to an AVBuffer
with a custom free function (like it is for wrapped AVFrames). This will
automatically solve the first problem and it will simplify freeing more
generally (no constant checks for whether this is an uncoded frame).
The downsides of this are that it involves two allocations* per fr

Re: [FFmpeg-devel] [PATCH] libavformat/mov: restore use of mfra time as dts

2020-04-10 Thread Gyan Doshi



On 10-04-2020 08:04 pm, John Stebbins wrote:

On Thu, 2020-04-09 at 10:56 +0530, Gyan Doshi wrote:

On 06-04-2020 11:12 pm, John Stebbins wrote:

This was inadvertantly removed in 4a9d32baca
---
   libavformat/mov.c | 5 +
   1 file changed, 5 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 16a40debc7..eee98fb69c 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4813,6 +4813,11 @@ static int mov_read_trun(MOVContext *c,
AVIOContext *pb, MOVAtom atom)
   pts = frag_stream_info->first_tfra_pts;
   av_log(c->fc, AV_LOG_DEBUG, "found mfra time %"PRId64
   ", using it for pts\n", pts);
+} else if (frag_stream_info->first_tfra_pts !=
AV_NOPTS_VALUE &&
+c->use_mfra_for == FF_MOV_FLAG_MFRA_DTS) {
+dts = frag_stream_info->first_tfra_pts;
+av_log(c->fc, AV_LOG_DEBUG, "found mfra time %"PRId64
+", using it for dts\n", pts);
   } else if (frag_stream_info->sidx_pts != AV_NOPTS_VALUE)
{
   // FIXME: sidx earliest_presentation_time is *PTS*,
s.b.
   // pts = frag_stream_info->sidx_pts;

LGTM.

Gyan


Thanks for the review. I've got a couple other patch submissions that
fix problems that resulted from 4a9d32baca which have received no
comments in nearly 2 weeks.  I don't have commit access, so if no
comments means OK, can someone please commit?



I'll push this one. Someone may want to review the others.

Gyan
___
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 1/4] lavc: install codec_desc.h

2020-04-10 Thread James Almer
On 4/10/2020 12:41 PM, Anton Khirnov wrote:
> Forgotten in 672946c7fe6de56ccf5d2271ad1bfeb2290f394f
> ---
> Oops, sorry
> ---
>  libavcodec/Makefile | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index d9b04964ca..1970ff027f 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -6,6 +6,7 @@ HEADERS = ac3_parser.h
>   \
>avcodec.h \
>avdct.h   \
>avfft.h   \
> +  codec_desc.h  \
>codec_id.h\
>d3d11va.h \
>dirac.h   \
> 

LGTM.
___
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/bsf: mention that av_bsf_send_packet() returning EAGAIN is not an error

2020-04-10 Thread James Almer
On 4/10/2020 11:07 AM, Derek Buitenhuis wrote:
> On 10/04/2020 00:09, James Almer wrote:
>> EAGAIN is returned when input is provided but can't be consumed. The 
>> filtering
>> process is unaffected in this case, and the function will be able to consume
>> new input after retrieving filtered packets with av_bsf_receive_packet().
>>
>> Remove the line about empty packets never failing added in
>> 41b05b849f215b03eeb9e3608571ba47de64182a while at it. Even if it's currently
>> the case, it unnecessarily constrains the API and could be changed in the 
>> future
>> in case it needs to be extended.
>> The user should always check for errors and never expect a call to never 
>> fail.
>>
>> Signed-off-by: James Almer 
>> ---
>>  libavcodec/avcodec.h | 5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> Sounds good to me.
> 
> - Derek

Will push, thanks.

That aside, I'm planning on restructuring these bsf functions
internally, making it behave more in line with the
send_packet/receive_frame API for decoding, and there are two options
for this: One, i keep the behavior described in the doxy after this
patch regarding return values from av_bsf_send_packet() (every AVERROR
code except EAGAIN being an error). Or two, make it return EOF instead
of 0 when extra unnecessary flush packets are passed to it, thus making
both bsf and decode APIs behave exactly the same.

The latter would be ideal, but i don't know if it could be considered an
API change or not. It would have no effect on existing usage for example
in decode.c and the CLI. The latter in fact considers EOF from
av_bsf_send_packet() a possibility, so it may have been an oversight
back when the bsf API was first written.

What do you think?
___
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/4] lavc: rename bsf.h to bsf_internal.h

2020-04-10 Thread Anton Khirnov
This will allow adding a public header named bsf.h
---
 libavcodec/aac_adtstoasc_bsf.c | 2 +-
 libavcodec/av1_frame_merge_bsf.c   | 2 +-
 libavcodec/av1_frame_split_bsf.c   | 2 +-
 libavcodec/av1_metadata_bsf.c  | 2 +-
 libavcodec/bitstream_filters.c | 2 +-
 libavcodec/bsf.c   | 2 +-
 libavcodec/{bsf.h => bsf_internal.h}   | 6 +++---
 libavcodec/chomp_bsf.c | 2 +-
 libavcodec/dca_core_bsf.c  | 2 +-
 libavcodec/dump_extradata_bsf.c| 2 +-
 libavcodec/eac3_core_bsf.c | 2 +-
 libavcodec/extract_extradata_bsf.c | 2 +-
 libavcodec/filter_units_bsf.c  | 2 +-
 libavcodec/h264_metadata_bsf.c | 2 +-
 libavcodec/h264_mp4toannexb_bsf.c  | 2 +-
 libavcodec/h264_redundant_pps_bsf.c| 2 +-
 libavcodec/h265_metadata_bsf.c | 2 +-
 libavcodec/hapqa_extract_bsf.c | 2 +-
 libavcodec/hevc_mp4toannexb_bsf.c  | 2 +-
 libavcodec/imx_dump_header_bsf.c   | 2 +-
 libavcodec/mjpeg2jpeg_bsf.c| 2 +-
 libavcodec/mjpega_dump_header_bsf.c| 2 +-
 libavcodec/movsub_bsf.c| 2 +-
 libavcodec/mp3_header_decompress_bsf.c | 2 +-
 libavcodec/mpeg2_metadata_bsf.c| 2 +-
 libavcodec/mpeg4_unpack_bframes_bsf.c  | 2 +-
 libavcodec/noise_bsf.c | 2 +-
 libavcodec/null_bsf.c  | 2 +-
 libavcodec/prores_metadata_bsf.c   | 2 +-
 libavcodec/remove_extradata_bsf.c  | 2 +-
 libavcodec/trace_headers_bsf.c | 2 +-
 libavcodec/truehd_core_bsf.c   | 2 +-
 libavcodec/vp9_metadata_bsf.c  | 2 +-
 libavcodec/vp9_raw_reorder_bsf.c   | 2 +-
 libavcodec/vp9_superframe_bsf.c| 2 +-
 libavcodec/vp9_superframe_split_bsf.c  | 2 +-
 36 files changed, 38 insertions(+), 38 deletions(-)
 rename libavcodec/{bsf.h => bsf_internal.h} (93%)

diff --git a/libavcodec/aac_adtstoasc_bsf.c b/libavcodec/aac_adtstoasc_bsf.c
index e378296950..1d0117fecb 100644
--- a/libavcodec/aac_adtstoasc_bsf.c
+++ b/libavcodec/aac_adtstoasc_bsf.c
@@ -22,7 +22,7 @@
 #include "adts_header.h"
 #include "adts_parser.h"
 #include "avcodec.h"
-#include "bsf.h"
+#include "bsf_internal.h"
 #include "put_bits.h"
 #include "get_bits.h"
 #include "mpeg4audio.h"
diff --git a/libavcodec/av1_frame_merge_bsf.c b/libavcodec/av1_frame_merge_bsf.c
index 49397111fc..c67b86c8d4 100644
--- a/libavcodec/av1_frame_merge_bsf.c
+++ b/libavcodec/av1_frame_merge_bsf.c
@@ -19,7 +19,7 @@
  */
 
 #include "avcodec.h"
-#include "bsf.h"
+#include "bsf_internal.h"
 #include "cbs.h"
 #include "cbs_av1.h"
 
diff --git a/libavcodec/av1_frame_split_bsf.c b/libavcodec/av1_frame_split_bsf.c
index a386c6edc1..fc9eac0324 100644
--- a/libavcodec/av1_frame_split_bsf.c
+++ b/libavcodec/av1_frame_split_bsf.c
@@ -33,7 +33,7 @@
 #include "libavutil/avassert.h"
 
 #include "avcodec.h"
-#include "bsf.h"
+#include "bsf_internal.h"
 #include "cbs.h"
 #include "cbs_av1.h"
 
diff --git a/libavcodec/av1_metadata_bsf.c b/libavcodec/av1_metadata_bsf.c
index dd0c9b6148..d704bc1409 100644
--- a/libavcodec/av1_metadata_bsf.c
+++ b/libavcodec/av1_metadata_bsf.c
@@ -19,7 +19,7 @@
 #include "libavutil/common.h"
 #include "libavutil/opt.h"
 
-#include "bsf.h"
+#include "bsf_internal.h"
 #include "cbs.h"
 #include "cbs_av1.h"
 
diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index 6b5ffe4d70..8a1005ac56 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -22,7 +22,7 @@
 #include "libavutil/log.h"
 
 #include "avcodec.h"
-#include "bsf.h"
+#include "bsf_internal.h"
 
 extern const AVBitStreamFilter ff_aac_adtstoasc_bsf;
 extern const AVBitStreamFilter ff_av1_frame_merge_bsf;
diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
index 7b96183e64..a8d5c3082a 100644
--- a/libavcodec/bsf.c
+++ b/libavcodec/bsf.c
@@ -25,7 +25,7 @@
 #include "libavutil/bprint.h"
 
 #include "avcodec.h"
-#include "bsf.h"
+#include "bsf_internal.h"
 
 struct AVBSFInternal {
 AVPacket *buffer_pkt;
diff --git a/libavcodec/bsf.h b/libavcodec/bsf_internal.h
similarity index 93%
rename from libavcodec/bsf.h
rename to libavcodec/bsf_internal.h
index af035eee44..de4684c4c2 100644
--- a/libavcodec/bsf.h
+++ b/libavcodec/bsf_internal.h
@@ -16,8 +16,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#ifndef AVCODEC_BSF_H
-#define AVCODEC_BSF_H
+#ifndef AVCODEC_BSF_INTERNAL_H
+#define AVCODEC_BSF_INTERNAL_H
 
 #include "avcodec.h"
 
@@ -41,4 +41,4 @@ int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt);
 
 const AVClass *ff_bsf_child_class_next(const AVClass *prev);
 
-#endif /* AVCODEC_BSF_H */
+#endif /* AVCODEC_BSF_INTERNAL_H */
diff --git a/libavcodec/chomp_bsf.c b/libavcodec/chomp_bsf.c
index 3ba45f3e06..d7461afebd 100644
--- a/libavcodec/chomp_bsf.c
+++ b/libavcodec/chomp_bsf.c
@@ -20,7 +20,7 @@
  */
 
 #include "avcodec.h"
-#include "bsf.h"
+#include "bsf_internal.h"
 #include "internal.h"
 
 static int chomp_filter(AVBSFContext 

[FFmpeg-devel] [PATCH 2/4] avcodec.h: split AVCodecParameters API into its own header

2020-04-10 Thread Anton Khirnov
---
Not sure what to do with AVFieldOrder. It gets moved to codec_par.h
since it is used in AVCodecParameters, but it isn't precisely the right
place for it, though it's not horribly wrong either.

Least bad solution I've come up with is making a separate header for
"misc small types used in lavc" and move there:
- AVFieldOrder
- AVAudioServiceType
- AVPanScan
- AVCPBProperties
- AVProducerReferenceTime
- AVProfile
- AVPictureStructure

but
- it's a "misc" header and misc headers are evil
- I can't come up with a good name for it

Suggestions?
---
 doc/APIchanges |   3 +
 libavcodec/Makefile|   1 +
 libavcodec/avcodec.h   | 189 +-
 libavcodec/codec_par.h | 229 +
 libavcodec/version.h   |   2 +-
 5 files changed, 235 insertions(+), 189 deletions(-)
 create mode 100644 libavcodec/codec_par.h

diff --git a/doc/APIchanges b/doc/APIchanges
index 4cc2367e69..dbe7f5cd55 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2020-xx-xx - xx - lavc 58.79.100 - avcodec.h codec_par.h
+  Move AVCodecParameters-related public API to new header codec_par.h.
+
 2020-xx-xx - xx - lavc 58.78.100 - avcodec.h codec_desc.h codec_id.h 
packet.h
   Move AVCodecDesc-related public API to new header codec_desc.h.
   Move AVCodecID enum to new header codec_id.h.
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 1970ff027f..7347f9c25b 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -8,6 +8,7 @@ HEADERS = ac3_parser.h  
\
   avfft.h   \
   codec_desc.h  \
   codec_id.h\
+  codec_par.h   \
   d3d11va.h \
   dirac.h   \
   dv_profile.h  \
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 55151a0b71..c91f0749ef 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -42,6 +42,7 @@
 #include "libavutil/rational.h"
 
 #include "codec_desc.h"
+#include "codec_par.h"
 #include "codec_id.h"
 #include "packet.h"
 #include "version.h"
@@ -624,15 +625,6 @@ typedef struct AVProducerReferenceTime {
 
 struct AVCodecInternal;
 
-enum AVFieldOrder {
-AV_FIELD_UNKNOWN,
-AV_FIELD_PROGRESSIVE,
-AV_FIELD_TT,  //< Top coded_first, top displayed first
-AV_FIELD_BB,  //< Bottom coded first, bottom displayed first
-AV_FIELD_TB,  //< Top coded first, bottom displayed first
-AV_FIELD_BT,  //< Bottom coded first, top displayed first
-};
-
 /**
  * main external API structure.
  * New fields can be added to the end with minor version bumps.
@@ -3040,164 +3032,6 @@ typedef struct AVSubtitle {
 int64_t pts;///< Same as packet pts, in AV_TIME_BASE
 } AVSubtitle;
 
-/**
- * This struct describes the properties of an encoded stream.
- *
- * sizeof(AVCodecParameters) is not a part of the public ABI, this struct must
- * be allocated with avcodec_parameters_alloc() and freed with
- * avcodec_parameters_free().
- */
-typedef struct AVCodecParameters {
-/**
- * General type of the encoded data.
- */
-enum AVMediaType codec_type;
-/**
- * Specific type of the encoded data (the codec used).
- */
-enum AVCodecID   codec_id;
-/**
- * Additional information about the codec (corresponds to the AVI FOURCC).
- */
-uint32_t codec_tag;
-
-/**
- * Extra binary data needed for initializing the decoder, codec-dependent.
- *
- * Must be allocated with av_malloc() and will be freed by
- * avcodec_parameters_free(). The allocated size of extradata must be at
- * least extradata_size + AV_INPUT_BUFFER_PADDING_SIZE, with the padding
- * bytes zeroed.
- */
-uint8_t *extradata;
-/**
- * Size of the extradata content in bytes.
- */
-int  extradata_size;
-
-/**
- * - video: the pixel format, the value corresponds to enum AVPixelFormat.
- * - audio: the sample format, the value corresponds to enum 
AVSampleFormat.
- */
-int format;
-
-/**
- * The average bitrate of the encoded data (in bits per second).
- */
-int64_t bit_rate;
-
-/**
- * The number of bits per sample in the codedwords.
- *
- * This is basically the bitrate per sample. It is mandatory for a bunch of
- * formats to actually decode them. It's the number of bits for one sample 
in
- * the actual coded bitstream.
- *
- * This could be for example 4 for ADPCM
- * For PCM formats this matches bits_per_raw_sample
- * Ca

[FFmpeg-devel] [PATCH 4/4] avcodec.h: split bitstream filters API into its own header

2020-04-10 Thread Anton Khirnov
---
 doc/APIchanges |   3 +-
 libavcodec/Makefile|   1 +
 libavcodec/aac_adtstoasc_bsf.c |   2 +-
 libavcodec/av1_frame_merge_bsf.c   |   2 +-
 libavcodec/av1_frame_split_bsf.c   |   2 +-
 libavcodec/av1_metadata_bsf.c  |   1 +
 libavcodec/avcodec.h   | 285 +-
 libavcodec/bsf.c   |   4 +-
 libavcodec/bsf.h   | 324 +
 libavcodec/bsf_internal.h  |   5 +-
 libavcodec/chomp_bsf.c |   2 +-
 libavcodec/dca_core_bsf.c  |   2 +-
 libavcodec/dump_extradata_bsf.c|   2 +-
 libavcodec/eac3_core_bsf.c |   2 +-
 libavcodec/extract_extradata_bsf.c |   2 +-
 libavcodec/filter_units_bsf.c  |   1 +
 libavcodec/h264_metadata_bsf.c |   1 +
 libavcodec/h264_mp4toannexb_bsf.c  |   1 +
 libavcodec/h264_redundant_pps_bsf.c|   1 +
 libavcodec/h265_metadata_bsf.c |   1 +
 libavcodec/hapqa_extract_bsf.c |   2 +-
 libavcodec/hevc_mp4toannexb_bsf.c  |   1 +
 libavcodec/imx_dump_header_bsf.c   |   2 +-
 libavcodec/mjpeg2jpeg_bsf.c|   2 +-
 libavcodec/mjpega_dump_header_bsf.c|   2 +-
 libavcodec/movsub_bsf.c|   2 +-
 libavcodec/mp3_header_decompress_bsf.c |   2 +-
 libavcodec/mpeg2_metadata_bsf.c|   1 +
 libavcodec/mpeg4_unpack_bframes_bsf.c  |   2 +-
 libavcodec/noise_bsf.c |   2 +-
 libavcodec/null_bsf.c  |   2 +-
 libavcodec/prores_metadata_bsf.c   |   2 +
 libavcodec/remove_extradata_bsf.c  |   1 +
 libavcodec/trace_headers_bsf.c |   1 +
 libavcodec/truehd_core_bsf.c   |   2 +-
 libavcodec/vp9_metadata_bsf.c  |   1 +
 libavcodec/vp9_raw_reorder_bsf.c   |   1 +
 libavcodec/vp9_superframe_bsf.c|   3 +-
 libavcodec/vp9_superframe_split_bsf.c  |   2 +-
 39 files changed, 370 insertions(+), 307 deletions(-)
 create mode 100644 libavcodec/bsf.h

diff --git a/doc/APIchanges b/doc/APIchanges
index dbe7f5cd55..b9e5895e95 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,7 +15,8 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
-2020-xx-xx - xx - lavc 58.79.100 - avcodec.h codec_par.h
+2020-xx-xx - xx - lavc 58.79.100 - avcodec.h bsf.h codec_par.h
+  Move AVBitstreamFilter-related public API to new header bsf.h.
   Move AVCodecParameters-related public API to new header codec_par.h.
 
 2020-xx-xx - xx - lavc 58.78.100 - avcodec.h codec_desc.h codec_id.h 
packet.h
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 7347f9c25b..77f77ec48b 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -6,6 +6,7 @@ HEADERS = ac3_parser.h  
\
   avcodec.h \
   avdct.h   \
   avfft.h   \
+  bsf.h \
   codec_desc.h  \
   codec_id.h\
   codec_par.h   \
diff --git a/libavcodec/aac_adtstoasc_bsf.c b/libavcodec/aac_adtstoasc_bsf.c
index 1d0117fecb..69453c706f 100644
--- a/libavcodec/aac_adtstoasc_bsf.c
+++ b/libavcodec/aac_adtstoasc_bsf.c
@@ -21,7 +21,7 @@
 
 #include "adts_header.h"
 #include "adts_parser.h"
-#include "avcodec.h"
+#include "bsf.h"
 #include "bsf_internal.h"
 #include "put_bits.h"
 #include "get_bits.h"
diff --git a/libavcodec/av1_frame_merge_bsf.c b/libavcodec/av1_frame_merge_bsf.c
index c67b86c8d4..b5aa57e0ff 100644
--- a/libavcodec/av1_frame_merge_bsf.c
+++ b/libavcodec/av1_frame_merge_bsf.c
@@ -18,7 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "avcodec.h"
+#include "bsf.h"
 #include "bsf_internal.h"
 #include "cbs.h"
 #include "cbs_av1.h"
diff --git a/libavcodec/av1_frame_split_bsf.c b/libavcodec/av1_frame_split_bsf.c
index fc9eac0324..87dfc83103 100644
--- a/libavcodec/av1_frame_split_bsf.c
+++ b/libavcodec/av1_frame_split_bsf.c
@@ -32,7 +32,7 @@
 
 #include "libavutil/avassert.h"
 
-#include "avcodec.h"
+#include "bsf.h"
 #include "bsf_internal.h"
 #include "cbs.h"
 #include "cbs_av1.h"
diff --git a/libavcodec/av1_metadata_bsf.c b/libavcodec/av1_metadata_bsf.c
index d704bc1409..d078ba3e8f 100644
--- a/libavcodec/av1_metadata_bsf.c
+++ b/libavcodec/av1_metadata_bsf.c
@@ -19,6 +19,7 @@
 #include "libavutil/common.h"
 #include "libavutil/opt.h"
 
+#include "bsf.h"
 #include "bsf_internal.h"
 #include "cbs.h"
 #include "cbs_av1.h"
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index c91f0749ef..0339edaeb3 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@

[FFmpeg-devel] [PATCH 1/4] lavc: install codec_desc.h

2020-04-10 Thread Anton Khirnov
Forgotten in 672946c7fe6de56ccf5d2271ad1bfeb2290f394f
---
Oops, sorry
---
 libavcodec/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index d9b04964ca..1970ff027f 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -6,6 +6,7 @@ HEADERS = ac3_parser.h  
\
   avcodec.h \
   avdct.h   \
   avfft.h   \
+  codec_desc.h  \
   codec_id.h\
   d3d11va.h \
   dirac.h   \
-- 
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".

Re: [FFmpeg-devel] [PATCH 00/10] libavformat/mux patches

2020-04-10 Thread Marton Balint



On Tue, 31 Mar 2020, Andreas Rheinhardt wrote:


This patchset is a slightly revised version of the remaining patches of
a patchset I originally sent last August [1]. I resend it because Marton
requested it [2]. I have also added three new patches at the end (but
they actually don't depend on any of the earlier patches).


Do you plan to apply the rest of these? If I ever get to a point where I 
can resend my original series, it should better be on top of these patches :)


Thanks,
Marton



- Andreas


[1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2019-August/248140.html
[2]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/259218.html


Andreas Rheinhardt (10):
 avformat/mux: Only prepare input packet if there is a packet
 avformat/audiointerleave: Fix memleak
 avformat/avformat.h: Correct some comments
 avformat/mux: Fix leaks of uncoded frames on errors
 avformat/mux: Fix memleaks on errors II, improve documentation
 avformat/mux: Don't modify packets we don't own
 avformat/mux: Remove pointless timestamp backups
 avformat/avformat: Clarify documentation of
   av_interleaved_write_frame()
 fftools/ffmpeg, doc/examples/remuxing: Remove redundant
   av_packet_unref
 libavformat/mux, mxfenc: Don't initialize unnecessarily

doc/APIchanges|   4 ++
doc/examples/remuxing.c   |   1 -
fftools/ffmpeg.c  |   1 -
libavformat/audiointerleave.c |   7 +-
libavformat/audiointerleave.h |   4 ++
libavformat/avformat.h|  25 ---
libavformat/internal.h|  20 +++---
libavformat/mux.c | 118 +++---
libavformat/mxfenc.c  |   1 -
9 files changed, 101 insertions(+), 80 deletions(-)

--
2.20.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 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/2] avcodec/bsf: add av_bsf_join() to chain bitstream filters

2020-04-10 Thread Marton Balint



On Fri, 10 Apr 2020, James Almer wrote:


On 4/10/2020 5:25 AM, Marton Balint wrote:


[...]



Finally, (I feel bad having to tell you this given that you have
clearly
invested a lot of time in this) we currently have no case where we need
more than one automatically inserted bitstream filter per stream. We do
not know whether the current code does the right thing in case more
than
one packet needs to be analyzed to determine whether to insert
bitstream
filters (maybe the packets should instead be cached so that no bsf
misses out on the initial packets?); of course what is the right thing
might be format and codec-dependent. So I don't know whether we should
add this function now (given that public API is hard to remove).

This does not mean that we should not use a bsf_list bsf to simplify
automatic bitstream filtering in mux.c (it really simplifies this alot
and gets rid of code duplication). But I think we should leave the
topic
of adding a bsf to an already existing bsf open so that it can be
determined when the need indeed arises.


I see no sane way of sharing list bsf code other than adding public API,
because mux.c is libavformat, bsf.c is libavcodec. This at least allows
you to replace AVStreamInternal->nb_bsfcs and AVStreamInternal->bsfcs
with a single bitstream filter to which you join additional ones.

Unless you want to remove the existing (admittedly unused, and
potentially inadequate) support for multiple bitstream filters in
AVStreamInternal, I really don't see a way which postpones adding
this API.


Can't you achieve the same using existing bsf list API from within lavf?
av_bsf_list_alloc(), followed by any required amount of calls to
av_bsf_list_append(), av_bsf_list_append2() or av_bsf_list_parse_str()
to add each bsf, then av_bsf_list_finalize() at the end?


That API only works if you have all the bitstream filters before
finalizing the list, you can't append a BSF to an already finalized
list. The implementation in mux.c supports adding a BSF, then maybe
passing a few packets through it, then appending another BSF to the list
- this can happen if .check_bitstream_filters() adds a bsf but returns
0, and at a later packet it adds another bsf.

Regards,
Marton


I see what you mean. Do we really need the option to insert a bsf to a
given stream after a few packets have already been processed? Any
required bsf should be present since the beginning. They are all written
to either modify the data or pass it through depending if something must
be done or not.

What could show up say five packets into the stream that would require a
bsf to be inserted at that point and couldn't have been present since
the beginning? Passing packets through within a bsf is almost free, so
there's not a lot to win by postponing inserting a bsf. You'll simply be
delegating the task of analyzing the bitstream to the muxer's
check_bitstream(), when the bsf can already do it without any extra steps.


Ok, so this also points me to the direction of removing the support of 
multiple BSFs from AVStreamInternal, because if a demuxer wants multiple 
bsfs it can simply create a single list bsf in one go.


Is there anybody who objects removing support for multiple bsfs is 
AVStreamInternal?


Thanks,
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] libavformat/mov: restore use of mfra time as dts

2020-04-10 Thread John Stebbins
On Thu, 2020-04-09 at 10:56 +0530, Gyan Doshi wrote:
> 
> On 06-04-2020 11:12 pm, John Stebbins wrote:
> > This was inadvertantly removed in 4a9d32baca
> > ---
> >   libavformat/mov.c | 5 +
> >   1 file changed, 5 insertions(+)
> > 
> > diff --git a/libavformat/mov.c b/libavformat/mov.c
> > index 16a40debc7..eee98fb69c 100644
> > --- a/libavformat/mov.c
> > +++ b/libavformat/mov.c
> > @@ -4813,6 +4813,11 @@ static int mov_read_trun(MOVContext *c,
> > AVIOContext *pb, MOVAtom atom)
> >   pts = frag_stream_info->first_tfra_pts;
> >   av_log(c->fc, AV_LOG_DEBUG, "found mfra time %"PRId64
> >   ", using it for pts\n", pts);
> > +} else if (frag_stream_info->first_tfra_pts !=
> > AV_NOPTS_VALUE &&
> > +c->use_mfra_for == FF_MOV_FLAG_MFRA_DTS) {
> > +dts = frag_stream_info->first_tfra_pts;
> > +av_log(c->fc, AV_LOG_DEBUG, "found mfra time %"PRId64
> > +", using it for dts\n", pts);
> >   } else if (frag_stream_info->sidx_pts != AV_NOPTS_VALUE)
> > {
> >   // FIXME: sidx earliest_presentation_time is *PTS*,
> > s.b.
> >   // pts = frag_stream_info->sidx_pts;
> 
> LGTM.
> 
> Gyan
> 

Thanks for the review. I've got a couple other patch submissions that
fix problems that resulted from 4a9d32baca which have received no
comments in nearly 2 weeks.  I don't have commit access, so if no
comments means OK, can someone please commit?

https://patchwork.ffmpeg.org/project/ffmpeg/patch/20200329203245.225679-1-jstebb...@jetheaddev.com/

https://patchwork.ffmpeg.org/project/ffmpeg/patch/20200329212738.226876-1-jstebb...@jetheaddev.com/

___
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 06/10] lavc/libopenh264enc: set slice_mode option to deprecated

2020-04-10 Thread Fu, Linjie
> From: ffmpeg-devel  On Behalf Of
> Anton Khirnov
> Sent: Friday, April 10, 2020 18:28
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 06/10] lavc/libopenh264enc: set
> slice_mode option to deprecated
> 
> Quoting Linjie Fu (2020-04-06 13:14:49)
> > "slice mode" seems to be unnecessary since it could be determined by
> > -slices/max_nal_size.
> >
> > default:SM_FIXEDSLCNUM_SLICE mode with cpu-number slices.
> > -slices N:  SM_FIXEDSLCNUM_SLICE mode with N slices.
> > -max_nal_size:  SM_SIZELIMITED_SLICE mode with limited size slices.
> >
> > This could be removed later.
> >
> > Signed-off-by: Linjie Fu 
> > ---
> 
> I'd say also schedule it for removal with new FF_API_ macros, otherwise
> deprecated things tend to stay around for way too long.
> 
Good idea, added OPENH264_API_SLICE_MODE macros to remove this
Options after LIBAVCODEC_VERSION_MAJOR = 59.

Thanks for the suggestion.

- 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".

[FFmpeg-devel] [RFC] Moving ffprobe's writers to lavu

2020-04-10 Thread Nicolas George
Hi.

In the comments on a recent patch to implement statistics outputs for a
specific filter, I noted that this is something that many filters need
to do, and therefore in need of unification. I also observed some JSON
code in a filter, which does not belong there.

https://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/260178.html

It reminded me of a project I have had for some time: moving the writers
written for ffprobe (XML, JSON, INI, etc.) into libavutil.

I am pretty sure it is doable, but I am also sure there will be
pitfalls, cases where the writer are very specific to ffprobe's need and
some careful design is needed to make them generic while keeping
compatibility.

And in any case, it will be quite some work, I do not want to do it if
it will be bikeshedded to death, so I first put the principle on
discussion here.

Do you think it is a good idea to add functions to produce formatted
output for structured data in libavutil?


There is another, smaller pitfall: where do these functions output to?
ffprobe outputs to stdout; the patch quoted above outputs through AVIO
to any supported format; some filters put data as string metadata. The
obvious answer to that is to "write" to a callback, and have the
callback decide to write the data to stdout, AVIO or a memory buffer.

A few months ago, I proposed the draft of an elegant (IMNSHO) API for
"write to a callback", but it immediately gave signs to be bikeshedded
to death. If I start working on this project, I intend to finish and use
it, because it's exactly the kind of use I had in mind for it.

https://ffmpeg.org/pipermail/ffmpeg-devel/2019-December/254042.html

Please share your thoughts, including if only to say you think it is a
good idea.

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".

Re: [FFmpeg-devel] [PATCH] avcodec/bsf: mention that av_bsf_send_packet() returning EAGAIN is not an error

2020-04-10 Thread Derek Buitenhuis
On 10/04/2020 00:09, James Almer wrote:
> EAGAIN is returned when input is provided but can't be consumed. The filtering
> process is unaffected in this case, and the function will be able to consume
> new input after retrieving filtered packets with av_bsf_receive_packet().
> 
> Remove the line about empty packets never failing added in
> 41b05b849f215b03eeb9e3608571ba47de64182a while at it. Even if it's currently
> the case, it unnecessarily constrains the API and could be changed in the 
> future
> in case it needs to be extended.
> The user should always check for errors and never expect a call to never fail.
> 
> Signed-off-by: James Almer 
> ---
>  libavcodec/avcodec.h | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Sounds good to me.

- Derek
___
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/2] avcodec/bsf: add av_bsf_join() to chain bitstream filters

2020-04-10 Thread James Almer
On 4/10/2020 5:25 AM, Marton Balint wrote:
> 
> 
> On Thu, 9 Apr 2020, James Almer wrote:
> 
>> On 4/9/2020 9:11 PM, Marton Balint wrote:
>>>
>>>
>>> On Fri, 10 Apr 2020, Andreas Rheinhardt wrote:
>>>
 Marton Balint:
> Signed-off-by: Marton Balint 
> ---
>  doc/APIchanges   |  3 +++
>  libavcodec/avcodec.h | 19 
>  libavcodec/bsf.c | 62
> 
>  libavcodec/version.h |  2 +-
>  4 files changed, 85 insertions(+), 1 deletion(-)
>
> diff --git a/doc/APIchanges b/doc/APIchanges
> index f1d7eac2ee..1473742139 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,9 @@ libavutil: 2017-10-21
>
>  API changes, most recent first:
>
> +2020-04-xx - xx - lavc 58.77.102 - avcodec.h
> +  Add av_bsf_join() to chain bitstream filters.
> +
>  2020-03-29 - xx - lavf 58.42.100 - avformat.h
>    av_read_frame() now guarantees to handle uninitialized input
> packets
>    and to return refcounted packets on success.
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 8fc0ad92c9..2812055e8a 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -6056,6 +6056,25 @@ int av_bsf_receive_packet(AVBSFContext *ctx,
> AVPacket *pkt);
>   */
>  void av_bsf_flush(AVBSFContext *ctx);
>
> +/**
> + * Join a new bitstream filter to an already operating one.
> + *
> + * @param[in,out] out_bsf *out_bsf contains the existing, already
> initialized bitstream
> + *    filter, the new filter will be joined to
> the output of this.
> + *    It can be NULL, in which case an empty
> filter is assumed.
> + *    Upon successful return *out_bsf will
> contain the new, combined
> + *    bitstream filter which will be initialized.
> + * @param[in] bsf the bitstream filter to be joined to the
> output of *out_bsf.
> + *    This filter must be uninitialized but it
> must be ready to be
> + *    initalized, so input codec parameters and
> time base must be
> + *    set if *out_bsf is NULL, otherwise the
> function will set these
> + *    automatically based on the output
> parameters of *out_bsf.
> + *    Upon successful return the bsf will be
> initialized.
> + *
> + * @return 0 on success, negative on error.

 One needs to be more explicit about what happens on error: bsf may be
 in a partially initialized state and is essentially only good for
 freeing (maybe the bsf parameter should be AVBSFContext **, too, and
 automatically free bsf on error?). But IMO we should aim to not cripple
 *out_bsf and document this.

> + */
> +int av_bsf_join(AVBSFContext **out_bsf, AVBSFContext *bsf);
> +
>  /**
>   * Free a bitstream filter context and everything associated with
> it; write NULL
>   * into the supplied pointer.
> diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
> index b9fc771a88..1bca28d1ae 100644
> --- a/libavcodec/bsf.c
> +++ b/libavcodec/bsf.c
> @@ -487,6 +487,68 @@ end:
>  return ret;
>  }
>
> +int av_bsf_join(AVBSFContext **out_bsf, AVBSFContext *bsf)
> +{
> +    BSFListContext *lst;
> +    AVBSFContext *obsf = *out_bsf;
> +    AVBSFContext *new_list_bsf = NULL;
> +    int ret;
> +
> +    if (!obsf) {
> +    ret = av_bsf_init(bsf);
> +    if (ret < 0)
> +    return ret;
> +    *out_bsf = bsf;
> +    return 0;
> +    }
> +
> +    if (obsf->filter != &ff_list_bsf) {
> +    ret = av_bsf_alloc(&ff_list_bsf, &new_list_bsf);
> +    if (ret < 0)
> +    return ret;
> +    lst = new_list_bsf->priv_data;
> +    ret = av_dynarray_add_nofree(&lst->bsfs, &lst->nb_bsfs,
> obsf);
> +    if (ret < 0)
> +    goto fail;
> +    ret = avcodec_parameters_copy(new_list_bsf->par_in,
> obsf->par_in);
> +    if (ret < 0)
> +    goto fail;
> +    new_list_bsf->time_base_in = obsf->time_base_in;
> +    obsf = new_list_bsf;
> +    } else {
> +    lst = obsf->priv_data;
> +    }
> +
> +    ret = avcodec_parameters_copy(bsf->par_in,
> lst->bsfs[lst->nb_bsfs-1]->par_out);
> +    if (ret < 0)
> +    goto fail;
> +    bsf->time_base_in = lst->bsfs[lst->nb_bsfs-1]->time_base_out;
> +
> +    ret = av_bsf_init(&bsf);
> +    if (ret < 0)
> +    goto fail;
> +
> +    ret = avcodec_parameters_copy(obsf->par_out, bsf->par_out);

 This will change obsf even on failure (w

Re: [FFmpeg-devel] [PATCH 08/10] lavc/libopenh264enc: add profile high option support

2020-04-10 Thread Fu, Linjie
> From: ffmpeg-devel  On Behalf Of
> Anton Khirnov
> Sent: Friday, April 10, 2020 18:57
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 08/10] lavc/libopenh264enc: add profile
> high option support
> 
> Quoting Linjie Fu (2020-04-06 13:14:51)
> > Add support for PRO_HIGH/PRO_BASELINE in SVC Encoding extention
> mode,
> > which determined by iEntropyCodingModeFlag in ParamTranscode().
> >
> >
>  param_svc.h#L394>
> >
> > Signed-off-by: Linjie Fu 
> > ---
> >  libavcodec/libopenh264enc.c | 32 ++--
> >  1 file changed, 26 insertions(+), 6 deletions(-)
> >
> > diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
> > index f02c5fd..d331cfd 100644
> > --- a/libavcodec/libopenh264enc.c
> > +++ b/libavcodec/libopenh264enc.c
> > @@ -42,7 +42,7 @@ typedef struct SVCContext {
> >  ISVCEncoder *encoder;
> >  int slice_mode; // deprecated
> >  int loopfilter;
> > -char *profile;
> > +int profile;
> 
> Wouldn't it be better to deprecate the encoder-private option and use
> only the AVCodecContext one?
> 

If I got it correctly, the general "profile" option in 
libavcodec/options_table.h
needs values of type INT like FF_PROFILE_H264_HIGH = 100;

It also works for encoders with "-profile:v 100" to encode a bitstream with 
profile
HIGH, however maybe not straight forward enough. And it seems to be one of the
reasons that many encoders have a private option with AV_OPT_TYPE_STRING type.

- 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 05/10] lavc/libopenh264enc: prompt slice number changing according to cpus

2020-04-10 Thread Fu, Linjie
> From: ffmpeg-devel  On Behalf Of
> Anton Khirnov
> Sent: Friday, April 10, 2020 18:23
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 05/10] lavc/libopenh264enc: prompt
> slice number changing according to cpus
> 
> Quoting Linjie Fu (2020-04-06 13:14:48)
> > Libopenh264enc would set the slice according to the number of cpu cores
> > if uiSliceNum equals to 0 (auto) in SM_FIXEDSLCNUM_SLICE mode.
> >
> > Prompt a warning for user to catch this.
> >
> > Signed-off-by: Linjie Fu 
> > ---
> >  libavcodec/libopenh264enc.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
> > index dab8244..01a85fb 100644
> > --- a/libavcodec/libopenh264enc.c
> > +++ b/libavcodec/libopenh264enc.c
> > @@ -237,6 +237,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
> >  param.sSpatialLayers[0].sSliceCfg.uiSliceMode   = 
> > s->slice_mode;
> >  param.sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceNum = avctx-
> >slices;
> >  #endif
> > +if (avctx->slices == 0 && s->slice_mode == SM_FIXEDSLCNUM_SLICE)
> > +av_log(avctx, AV_LOG_WARNING, "Auto slice number, "
> > +   "default to use the number of CPU cores: %d\n", 
> > av_cpu_count());
> 
> Generally makes sense, but I'd avoid the call to av_cpu_count() since we
> don't know what method precisely will libopenh264 use to set the slice
> count. So IMO just say something like "slice count will be set
> automatically".

There is a statement in the API definition[1] for uiSliceNum which says:
when uiSliceNum=0 means auto design it with cpu core number.
So IMHO it seems clear enough if I got it correctly.

I'm good with this suggestion and will update, since the detailed slice number
would also be dumped in debug level as well (however a little bit mixed up with
all the debug info), thx.

- Linjie

[1] 
https://github.com/cisco/openh264/blob/master/codec/api/svc/codec_app_def.h#L351

___
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] configure: add MV30 blockdsp dependency

2020-04-10 Thread Peter Ross
fix link error introduced in 481ebb1c8b3368e2a1bb9e33bd10b50a8818dbf7
---
 configure | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configure b/configure
index 09bda9b408..4d4c429be9 100755
--- a/configure
+++ b/configure
@@ -2790,6 +2790,7 @@ msmpeg4v3_decoder_select="h263_decoder"
 msmpeg4v3_encoder_select="h263_encoder"
 mss2_decoder_select="mpegvideo qpeldsp vc1_decoder"
 mts2_decoder_select="mss34dsp"
+mv30_decoder_select="blockdsp"
 mvha_decoder_deps="zlib"
 mvha_decoder_select="llviddsp"
 mwsc_decoder_deps="zlib"
-- 
2.20.1

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


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 03/10] lavc/libopenh264enc: add default gop size and bit rate

2020-04-10 Thread Fu, Linjie
> From: ffmpeg-devel  On Behalf Of
> Anton Khirnov
> Sent: Friday, April 10, 2020 18:14
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 03/10] lavc/libopenh264enc: add
> default gop size and bit rate
> 
> Quoting Linjie Fu (2020-04-06 13:14:46)
> > Signed-off-by: Linjie Fu 
> > ---
> >  libavcodec/libopenh264enc.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
> > index c7ae5b1..3ff5be7 100644
> > --- a/libavcodec/libopenh264enc.c
> > +++ b/libavcodec/libopenh264enc.c
> > @@ -335,6 +335,8 @@ static int svc_encode_frame(AVCodecContext
> *avctx, AVPacket *avpkt,
> >  }
> >
> >  static const AVCodecDefault svc_enc_defaults[] = {
> > +{ "b", "2M"},
> > +{ "g", "120"   },
> 
> Why these values specifically? 

According to the default settings in nvenc (b = 2M) and vaapi encoder for h264 
(g = 120).

>What happens if we leave them unset?

It would be 200kbps bitrate with gop size = 12.

There would be too much IDR frames with in small bitrate, which leads to
a poor quality. 

 (I should have added such statements in the commit message)

- 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 01/10] lavc/libopenh264enc: Add default qmin/qmax support

2020-04-10 Thread Fu, Linjie
> From: ffmpeg-devel  On Behalf Of
> Anton Khirnov
> Sent: Friday, April 10, 2020 18:12
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 01/10] lavc/libopenh264enc: Add
> default qmin/qmax support
> 
> Quoting Linjie Fu (2020-04-06 13:14:44)
> > Set default QP range to (1, 51) instead of (2, 32).
> >
> > QP = 0 is not well supported currently in libopenh264. If iMaxQp/iMinQp
> > equals 0, the QP range would be changed unexpectedly inside libopenh264
> > with a warning:
> >
> > Warning:Change QP Range from(0,51) to (12,42)
> >
> > [1]
>  encoder_ext.cpp#L375>
> > [2] 
> >
> > Signed-off-by: Linjie Fu 
> > ---
> >  libavcodec/libopenh264enc.c | 10 ++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
> > index ae6d17c..364926f 100644
> > --- a/libavcodec/libopenh264enc.c
> > +++ b/libavcodec/libopenh264enc.c
> > @@ -135,6 +135,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
> >  param.iTargetBitrate = avctx->bit_rate;
> >  param.iMaxBitrate= FFMAX(avctx->rc_max_rate, avctx-
> >bit_rate);
> >  param.iRCMode= RC_QUALITY_MODE;
> > +// QP = 0 is not well supported, so default to (1, 51)
> > +param.iMaxQp = avctx->qmax >= 0 ? 
> > av_clip(avctx->qmax, 1,
> 51) : 51;
> > +param.iMinQp = avctx->qmin >= 0 ? 
> > av_clip(avctx->qmin, 1,
> param.iMaxQp) : 1;
> 
> Should we set them at all if they are not specified by the user?

The answer is no and that's why I set qmin/qmax to -1 by default, otherwise
they would be set to (2, 31) by default [1] in VBR mode in FFmpeg.

> Wouldn't it be better to leave the unset, as is done now?

Most encoders would prefer to get a default QP range specifically if it's not
explicitly set by user, either choosing a default value inside ffmpeg or leave 
it
unset to be determined in core library/driver, like libx264, vaapi, qsv, nvenc.

For libopenh264enc specifically, the supported range is (1, 51), qp = 0 is not 
well
Supported yet in libopenh264 library [2]. If either of qmin or qmax equals 0, 
the
qp range would be reduced to (12, 42) inside libopenh264 library.

The default QP range is supposed to be as wide as enough IMHO, so set it to (1, 
51)
and avoid the warning inside the library. (and MaxQp =51 is the recommended 
value
in the demo config file in /openh264/testbin/welsenc.cfg)

Thanks for the review.

- Linjie

[1] https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/options_table.h#L97
[2] 

___
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/2] avcodec/bsf: add av_bsf_join() to chain bitstream filters

2020-04-10 Thread Andreas Rheinhardt
Marton Balint:
> 
> 
> On Fri, 10 Apr 2020, Andreas Rheinhardt wrote:
> 
>> Marton Balint:
>>>
>>>
>>> On Thu, 9 Apr 2020, James Almer wrote:
>>>
 On 4/9/2020 9:11 PM, Marton Balint wrote:
>
>
> On Fri, 10 Apr 2020, Andreas Rheinhardt wrote:
>
>> Marton Balint:
>>> Signed-off-by: Marton Balint 
>>> ---
>>>  doc/APIchanges   |  3 +++
>>>  libavcodec/avcodec.h | 19 
>>>  libavcodec/bsf.c | 62
>>> 
>>>  libavcodec/version.h |  2 +-
>>>  4 files changed, 85 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/doc/APIchanges b/doc/APIchanges
>>> index f1d7eac2ee..1473742139 100644
>>> --- a/doc/APIchanges
>>> +++ b/doc/APIchanges
>>> @@ -15,6 +15,9 @@ libavutil: 2017-10-21
>>>
>>>  API changes, most recent first:
>>>
>>> +2020-04-xx - xx - lavc 58.77.102 - avcodec.h
>>> +  Add av_bsf_join() to chain bitstream filters.
>>> +
>>>  2020-03-29 - xx - lavf 58.42.100 - avformat.h
>>>    av_read_frame() now guarantees to handle uninitialized input
>>> packets
>>>    and to return refcounted packets on success.
>>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
>>> index 8fc0ad92c9..2812055e8a 100644
>>> --- a/libavcodec/avcodec.h
>>> +++ b/libavcodec/avcodec.h
>>> @@ -6056,6 +6056,25 @@ int av_bsf_receive_packet(AVBSFContext *ctx,
>>> AVPacket *pkt);
>>>   */
>>>  void av_bsf_flush(AVBSFContext *ctx);
>>>
>>> +/**
>>> + * Join a new bitstream filter to an already operating one.
>>> + *
>>> + * @param[in,out] out_bsf *out_bsf contains the existing, already
>>> initialized bitstream
>>> + *    filter, the new filter will be joined to
>>> the output of this.
>>> + *    It can be NULL, in which case an empty
>>> filter is assumed.
>>> + *    Upon successful return *out_bsf will
>>> contain the new, combined
>>> + *    bitstream filter which will be
>>> initialized.
>>> + * @param[in] bsf the bitstream filter to be joined to the
>>> output of *out_bsf.
>>> + *    This filter must be uninitialized but it
>>> must be ready to be
>>> + *    initalized, so input codec parameters and
>>> time base must be
>>> + *    set if *out_bsf is NULL, otherwise the
>>> function will set these
>>> + *    automatically based on the output
>>> parameters of *out_bsf.
>>> + *    Upon successful return the bsf will be
>>> initialized.
>>> + *
>>> + * @return 0 on success, negative on error.
>>
>> One needs to be more explicit about what happens on error: bsf may be
>> in a partially initialized state and is essentially only good for
>> freeing (maybe the bsf parameter should be AVBSFContext **, too, and
>> automatically free bsf on error?). But IMO we should aim to not
>> cripple
>> *out_bsf and document this.
>>
>>> + */
>>> +int av_bsf_join(AVBSFContext **out_bsf, AVBSFContext *bsf);
>>> +
>>>  /**
>>>   * Free a bitstream filter context and everything associated with
>>> it; write NULL
>>>   * into the supplied pointer.
>>> diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
>>> index b9fc771a88..1bca28d1ae 100644
>>> --- a/libavcodec/bsf.c
>>> +++ b/libavcodec/bsf.c
>>> @@ -487,6 +487,68 @@ end:
>>>  return ret;
>>>  }
>>>
>>> +int av_bsf_join(AVBSFContext **out_bsf, AVBSFContext *bsf)
>>> +{
>>> +    BSFListContext *lst;
>>> +    AVBSFContext *obsf = *out_bsf;
>>> +    AVBSFContext *new_list_bsf = NULL;
>>> +    int ret;
>>> +
>>> +    if (!obsf) {
>>> +    ret = av_bsf_init(bsf);
>>> +    if (ret < 0)
>>> +    return ret;
>>> +    *out_bsf = bsf;
>>> +    return 0;
>>> +    }
>>> +
>>> +    if (obsf->filter != &ff_list_bsf) {
>>> +    ret = av_bsf_alloc(&ff_list_bsf, &new_list_bsf);
>>> +    if (ret < 0)
>>> +    return ret;
>>> +    lst = new_list_bsf->priv_data;
>>> +    ret = av_dynarray_add_nofree(&lst->bsfs, &lst->nb_bsfs,
>>> obsf);
>>> +    if (ret < 0)
>>> +    goto fail;
>>> +    ret = avcodec_parameters_copy(new_list_bsf->par_in,
>>> obsf->par_in);
>>> +    if (ret < 0)
>>> +    goto fail;
>>> +    new_list_bsf->time_base_in = obsf->time_base_in;
>>> +    obsf = new_list_bsf;
>>> +    } else {
>>> +    lst = obsf->priv_data;
>>> +    }
>>> +
>>> +    ret = avcodec_parameters_copy(bsf->par_in,
>>> lst->bsfs[lst->nb_bsfs-1]->par_out);
>>> +    if (ret < 0)
>>

[FFmpeg-devel] [PATCH v3 2/2] avformat: add kvag muxer

2020-04-10 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 Changelog|  1 +
 libavformat/Makefile |  1 +
 libavformat/allformats.c |  1 +
 libavformat/kvag.c   | 84 +++-
 libavformat/version.h|  2 +-
 5 files changed, 87 insertions(+), 2 deletions(-)

diff --git a/Changelog b/Changelog
index f84420c6eb..f9778cecef 100644
--- a/Changelog
+++ b/Changelog
@@ -58,6 +58,7 @@ version :
 - switch from AvxSynth to AviSynth+ on Linux
 - mv30 decoder
 - Simon & Schuster Interactive ADPCM encoder
+- Real War KVAG muxer
 
 
 version 4.2:
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 8fd0d43721..b74bc4c154 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -285,6 +285,7 @@ OBJS-$(CONFIG_JACOSUB_MUXER) += jacosubenc.o 
rawenc.o
 OBJS-$(CONFIG_JV_DEMUXER)+= jvdec.o
 OBJS-$(CONFIG_KUX_DEMUXER)   += flvdec.o
 OBJS-$(CONFIG_KVAG_DEMUXER)  += kvag.o
+OBJS-$(CONFIG_KVAG_MUXER)+= kvag.o rawenc.o
 OBJS-$(CONFIG_LATM_MUXER)+= latmenc.o rawenc.o
 OBJS-$(CONFIG_LMLM4_DEMUXER) += lmlm4.o
 OBJS-$(CONFIG_LOAS_DEMUXER)  += loasdec.o rawdec.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 39d2c352f5..e12b50375c 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -220,6 +220,7 @@ extern AVOutputFormat ff_jacosub_muxer;
 extern AVInputFormat  ff_jv_demuxer;
 extern AVInputFormat  ff_kux_demuxer;
 extern AVInputFormat  ff_kvag_demuxer;
+extern AVOutputFormat ff_kvag_muxer;
 extern AVOutputFormat ff_latm_muxer;
 extern AVInputFormat  ff_lmlm4_demuxer;
 extern AVInputFormat  ff_loas_demuxer;
diff --git a/libavformat/kvag.c b/libavformat/kvag.c
index 71b0eb4118..8be820a3c8 100644
--- a/libavformat/kvag.c
+++ b/libavformat/kvag.c
@@ -1,5 +1,5 @@
 /*
- * Simon & Schuster Interactive VAG demuxer
+ * Simon & Schuster Interactive VAG (de)muxer
  *
  * Copyright (C) 2020 Zane van Iperen (z...@zanevaniperen.com)
  *
@@ -21,6 +21,7 @@
  */
 #include "avformat.h"
 #include "internal.h"
+#include "rawenc.h"
 #include "libavutil/intreadwrite.h"
 
 #define KVAG_TAGMKTAG('K', 'V', 'A', 'G')
@@ -34,6 +35,7 @@ typedef struct KVAGHeader {
 uint16_tstereo;
 } KVAGHeader;
 
+#if CONFIG_KVAG_DEMUXER
 static int kvag_probe(const AVProbeData *p)
 {
 if (AV_RL32(p->buf) != KVAG_TAG)
@@ -115,3 +117,83 @@ AVInputFormat ff_kvag_demuxer = {
 .read_header= kvag_read_header,
 .read_packet= kvag_read_packet
 };
+#endif
+
+#if CONFIG_KVAG_MUXER
+static int kvag_write_init(AVFormatContext *s)
+{
+AVCodecParameters *par;
+
+if (s->nb_streams != 1) {
+av_log(s, AV_LOG_ERROR, "KVAG files have exactly one stream\n");
+return AVERROR(EINVAL);
+}
+
+par = s->streams[0]->codecpar;
+
+if (par->codec_id != AV_CODEC_ID_ADPCM_IMA_SSI) {
+av_log(s, AV_LOG_ERROR, "%s codec not supported\n",
+   avcodec_get_name(par->codec_id));
+return AVERROR(EINVAL);
+}
+
+if (par->channels > 2) {
+av_log(s, AV_LOG_ERROR, "KVAG files only support up to 2 channels\n");
+return AVERROR(EINVAL);
+}
+
+return 0;
+}
+
+static int kvag_write_header(AVFormatContext *s)
+{
+uint8_t buf[KVAG_HEADER_SIZE];
+AVCodecParameters *par = s->streams[0]->codecpar;
+
+AV_WL32(buf +  0, KVAG_TAG);
+AV_WL32(buf +  4, 0); /* Data size, we fix this up later. */
+AV_WL32(buf +  8, par->sample_rate);
+AV_WL16(buf + 12, par->channels == 2);
+
+avio_write(s->pb, buf, sizeof(buf));
+return 0;
+}
+
+static int kvag_write_trailer(AVFormatContext *s)
+{
+int64_t file_size, data_size;
+
+if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) {
+av_log(s, AV_LOG_WARNING,
+   "Stream not seekable, unable to write data size. "
+   "Output file will be broken\n");
+return 0;
+}
+
+file_size = avio_tell(s->pb);
+data_size = file_size - KVAG_HEADER_SIZE;
+if (data_size < UINT32_MAX) {
+avio_seek(s->pb, 4, SEEK_SET);
+avio_wl32(s->pb, (uint32_t)data_size);
+avio_seek(s->pb, file_size, SEEK_SET);
+} else {
+av_log(s, AV_LOG_WARNING,
+   "Filesize %"PRId64" invalid for KVAG, output file will be 
broken\n",
+   file_size);
+}
+
+return 0;
+}
+
+AVOutputFormat ff_kvag_muxer = {
+.name   = "kvag",
+.long_name  = NULL_IF_CONFIG_SMALL("Simon & Schuster Interactive VAG"),
+.extensions = "vag",
+.audio_codec= AV_CODEC_ID_ADPCM_IMA_SSI,
+.video_codec= AV_CODEC_ID_NONE,
+.init   = kvag_write_init,
+.write_header   = kvag_write_header,
+.write_packet   = ff_raw_write_packet,
+.write_trailer  = kvag_write_trailer
+};
+#endif
diff --git a/libavformat/version.h b/libavformat/version.h
index 18c2f5fec2..493a0b337f 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -3

[FFmpeg-devel] [PATCH v3 1/2] avcodec: add adpcm_ima_ssi encoder

2020-04-10 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 Changelog  |  1 +
 doc/general.texi   |  2 +-
 libavcodec/Makefile|  1 +
 libavcodec/adpcmenc.c  | 30 ++
 libavcodec/allcodecs.c |  1 +
 libavcodec/utils.c |  1 +
 libavcodec/version.h   |  2 +-
 7 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/Changelog b/Changelog
index b0c016185e..f84420c6eb 100644
--- a/Changelog
+++ b/Changelog
@@ -57,6 +57,7 @@ version :
 - overlay_cuda filter
 - switch from AvxSynth to AviSynth+ on Linux
 - mv30 decoder
+- Simon & Schuster Interactive ADPCM encoder
 
 
 version 4.2:
diff --git a/doc/general.texi b/doc/general.texi
index 4adcc9e742..a7b0cc1718 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -1107,7 +1107,7 @@ following image formats are supported:
 @item ADPCM IMA Funcom   @tab @tab  X
 @item ADPCM IMA High Voltage Software ALP   @tab @tab  X
 @item ADPCM IMA QuickTime@tab  X  @tab  X
-@item ADPCM IMA Simon & Schuster Interactive   @tab  @tab  X
+@item ADPCM IMA Simon & Schuster Interactive   @tab  X  @tab  X
 @item ADPCM IMA Ubisoft APM  @tab @tab X
 @item ADPCM IMA Loki SDL MJPEG  @tab @tab  X
 @item ADPCM IMA WAV  @tab  X  @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index abb4992b60..52b566fcfe 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -852,6 +852,7 @@ OBJS-$(CONFIG_ADPCM_IMA_QT_DECODER)   += adpcm.o 
adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_QT_ENCODER)   += adpcmenc.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_RAD_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_SSI_DECODER)  += adpcm.o adpcm_data.o
+OBJS-$(CONFIG_ADPCM_IMA_SSI_ENCODER)  += adpcmenc.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_SMJPEG_DECODER)   += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_WAV_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_WAV_ENCODER)  += adpcmenc.o adpcm_data.o
diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index 668939c778..1d6ea798a9 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -77,6 +77,15 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
 return AVERROR(EINVAL);
 }
 
+if (avctx->trellis && avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_SSI) {
+/*
+ * Trellis sort-of works, but has some DC offset problems.
+ * Disable it until I can figure out why.
+ */
+av_log(avctx, AV_LOG_ERROR, "trellis not supported\n");
+return AVERROR(EINVAL);
+}
+
 if (avctx->trellis) {
 int frontier  = 1 << avctx->trellis;
 int max_paths =  frontier * FREEZE_INTERVAL;
@@ -139,6 +148,10 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
 }
 avctx->frame_size = 512 * (avctx->sample_rate / 11025);
 break;
+case AV_CODEC_ID_ADPCM_IMA_SSI:
+avctx->frame_size = BLKSIZE;
+avctx->block_align = BLKSIZE;
+break;
 default:
 ret = AVERROR(EINVAL);
 goto error;
@@ -568,6 +581,22 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 flush_put_bits(&pb);
 break;
 }
+case AV_CODEC_ID_ADPCM_IMA_SSI:
+{
+PutBitContext pb;
+init_put_bits(&pb, dst, pkt_size);
+
+av_assert0(avctx->trellis == 0);
+
+for (i = 0; i < frame->nb_samples; i++) {
+for (ch = 0; ch < avctx->channels; ch++) {
+put_bits(&pb, 4, adpcm_ima_qt_compress_sample(c->status + ch, 
*samples++));
+}
+}
+
+flush_put_bits(&pb);
+break;
+}
 case AV_CODEC_ID_ADPCM_SWF:
 {
 PutBitContext pb;
@@ -720,6 +749,7 @@ AVCodec ff_ ## name_ ## _encoder = {
\
 }
 
 ADPCM_ENCODER(AV_CODEC_ID_ADPCM_IMA_QT,  adpcm_ima_qt,  sample_fmts_p, "ADPCM 
IMA QuickTime");
+ADPCM_ENCODER(AV_CODEC_ID_ADPCM_IMA_SSI, adpcm_ima_ssi, sample_fmts,   "ADPCM 
IMA Simon & Schuster Interactive");
 ADPCM_ENCODER(AV_CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav, sample_fmts_p, "ADPCM 
IMA WAV");
 ADPCM_ENCODER(AV_CODEC_ID_ADPCM_MS,  adpcm_ms,  sample_fmts,   "ADPCM 
Microsoft");
 ADPCM_ENCODER(AV_CODEC_ID_ADPCM_SWF, adpcm_swf, sample_fmts,   "ADPCM 
Shockwave Flash");
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index e7b29426db..b4e0d65052 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -617,6 +617,7 @@ extern AVCodec ff_adpcm_ima_qt_encoder;
 extern AVCodec ff_adpcm_ima_qt_decoder;
 extern AVCodec ff_adpcm_ima_rad_decoder;
 extern AVCodec ff_adpcm_ima_ssi_decoder;
+extern AVCodec ff_adpcm_ima_ssi_encoder;
 extern AVCodec ff_adpcm_ima_smjpeg_decoder;
 extern AVCodec ff_adpcm_ima_wav_encoder;
 extern AVCodec ff_adpcm_ima_wav_decoder;
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 4ab8cff4f5..b297eb3552 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1463,6 +1463,7 @@ int av_get_exact_bits_per_sample(enum AVCodecID co

Re: [FFmpeg-devel] [PATCH 2/3] avcodec.h: split codec IDs into their own header

2020-04-10 Thread Anton Khirnov
Quoting James Almer (2020-04-08 15:27:40)
> On 4/8/2020 4:42 AM, Anton Khirnov wrote:
> 
> The stuff below used to inside the lavc_core doxy group (Which is a
> subgroup of libavc). Can you either keep it that way, or maybe some
> alternative that reflects this change?

Right, that was a brainfart. I copied it from the first patch and
intended to change the doxy group but somehow forgot. Will fix.

-- 
Anton Khirnov
___
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/2] avcodec/bsf: add av_bsf_join() to chain bitstream filters

2020-04-10 Thread Marton Balint



On Fri, 10 Apr 2020, Andreas Rheinhardt wrote:


Marton Balint:



On Thu, 9 Apr 2020, James Almer wrote:


On 4/9/2020 9:11 PM, Marton Balint wrote:



On Fri, 10 Apr 2020, Andreas Rheinhardt wrote:


Marton Balint:

Signed-off-by: Marton Balint 
---
 doc/APIchanges   |  3 +++
 libavcodec/avcodec.h | 19 
 libavcodec/bsf.c | 62

 libavcodec/version.h |  2 +-
 4 files changed, 85 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index f1d7eac2ee..1473742139 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2017-10-21

 API changes, most recent first:

+2020-04-xx - xx - lavc 58.77.102 - avcodec.h
+  Add av_bsf_join() to chain bitstream filters.
+
 2020-03-29 - xx - lavf 58.42.100 - avformat.h
   av_read_frame() now guarantees to handle uninitialized input
packets
   and to return refcounted packets on success.
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 8fc0ad92c9..2812055e8a 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -6056,6 +6056,25 @@ int av_bsf_receive_packet(AVBSFContext *ctx,
AVPacket *pkt);
  */
 void av_bsf_flush(AVBSFContext *ctx);

+/**
+ * Join a new bitstream filter to an already operating one.
+ *
+ * @param[in,out] out_bsf *out_bsf contains the existing, already
initialized bitstream
+ *    filter, the new filter will be joined to
the output of this.
+ *    It can be NULL, in which case an empty
filter is assumed.
+ *    Upon successful return *out_bsf will
contain the new, combined
+ *    bitstream filter which will be initialized.
+ * @param[in] bsf the bitstream filter to be joined to the
output of *out_bsf.
+ *    This filter must be uninitialized but it
must be ready to be
+ *    initalized, so input codec parameters and
time base must be
+ *    set if *out_bsf is NULL, otherwise the
function will set these
+ *    automatically based on the output
parameters of *out_bsf.
+ *    Upon successful return the bsf will be
initialized.
+ *
+ * @return 0 on success, negative on error.


One needs to be more explicit about what happens on error: bsf may be
in a partially initialized state and is essentially only good for
freeing (maybe the bsf parameter should be AVBSFContext **, too, and
automatically free bsf on error?). But IMO we should aim to not cripple
*out_bsf and document this.


+ */
+int av_bsf_join(AVBSFContext **out_bsf, AVBSFContext *bsf);
+
 /**
  * Free a bitstream filter context and everything associated with
it; write NULL
  * into the supplied pointer.
diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
index b9fc771a88..1bca28d1ae 100644
--- a/libavcodec/bsf.c
+++ b/libavcodec/bsf.c
@@ -487,6 +487,68 @@ end:
 return ret;
 }

+int av_bsf_join(AVBSFContext **out_bsf, AVBSFContext *bsf)
+{
+    BSFListContext *lst;
+    AVBSFContext *obsf = *out_bsf;
+    AVBSFContext *new_list_bsf = NULL;
+    int ret;
+
+    if (!obsf) {
+    ret = av_bsf_init(bsf);
+    if (ret < 0)
+    return ret;
+    *out_bsf = bsf;
+    return 0;
+    }
+
+    if (obsf->filter != &ff_list_bsf) {
+    ret = av_bsf_alloc(&ff_list_bsf, &new_list_bsf);
+    if (ret < 0)
+    return ret;
+    lst = new_list_bsf->priv_data;
+    ret = av_dynarray_add_nofree(&lst->bsfs, &lst->nb_bsfs,
obsf);
+    if (ret < 0)
+    goto fail;
+    ret = avcodec_parameters_copy(new_list_bsf->par_in,
obsf->par_in);
+    if (ret < 0)
+    goto fail;
+    new_list_bsf->time_base_in = obsf->time_base_in;
+    obsf = new_list_bsf;
+    } else {
+    lst = obsf->priv_data;
+    }
+
+    ret = avcodec_parameters_copy(bsf->par_in,
lst->bsfs[lst->nb_bsfs-1]->par_out);
+    if (ret < 0)
+    goto fail;
+    bsf->time_base_in = lst->bsfs[lst->nb_bsfs-1]->time_base_out;
+
+    ret = av_bsf_init(&bsf);
+    if (ret < 0)
+    goto fail;
+
+    ret = avcodec_parameters_copy(obsf->par_out, bsf->par_out);


This will change obsf even on failure (when *out_bsf was already of
type
ff_list_bsf). This is something that ff_stream_add_bitstream_filter()
currently doesn't do. I think we should leave obsf in a mostly
unchanged
state even if it implies an unnecessary allocation (it is really only a
single allocation). This can be achieved by taking obsf's par_out in
the
else branch above and replacing it with fresh AVCodecParameters. On
success, the old par_out is freed; on failure it is restored.


+    if (ret < 0)
+    goto fail;
+    obsf->time_base_out = bsf->time_base_out;
+
+    ret = av_dynarray_add_nofree(&lst->bsfs, &lst->nb_bsfs, bsf);
+    if (ret < 0)
+    goto fail;
+
+    *out_bsf = obsf;
+    return 0;
+
+fail:
+    if (new_list_bsf) {
+    if (lst->nb_bsfs)
+  

[FFmpeg-devel] [PATCH v1] fftools/ffprobe: Use format specifier PRId64 instead of %lld

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

Signed-off-by: Limin Wang 
---
 fftools/ffprobe.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index e3f221f560..a32bc529d9 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -408,7 +408,7 @@ static char *value_string(char *buf, int buf_size, struct 
unit_value uv)
 if (show_float || (use_value_prefix && vald != (long long int)vald))
 snprintf(buf, buf_size, "%f", vald);
 else
-snprintf(buf, buf_size, "%lld", vali);
+snprintf(buf, buf_size, "%"PRId64, vali);
 av_strlcatf(buf, buf_size, "%s%s%s", *prefix_string || show_value_unit 
? " " : "",
  prefix_string, show_value_unit ? uv.unit : "");
 }
@@ -1002,7 +1002,7 @@ static void default_print_int(WriterContext *wctx, const 
char *key, long long in
 
 if (!def->nokey)
 printf("%s%s=", wctx->section_pbuf[wctx->level].str, key);
-printf("%lld\n", value);
+printf("%"PRId64"\n", value);
 }
 
 static const Writer default_writer = {
@@ -1179,7 +1179,7 @@ static void compact_print_int(WriterContext *wctx, const 
char *key, long long in
 if (wctx->nb_item[wctx->level]) printf("%c", compact->item_sep);
 if (!compact->nokey)
 printf("%s%s=", wctx->section_pbuf[wctx->level].str, key);
-printf("%lld", value);
+printf("%"PRId64, value);
 }
 
 static const Writer compact_writer = {
@@ -1322,7 +1322,7 @@ static void flat_print_section_header(WriterContext *wctx)
 
 static void flat_print_int(WriterContext *wctx, const char *key, long long int 
value)
 {
-printf("%s%s=%lld\n", wctx->section_pbuf[wctx->level].str, key, value);
+printf("%s%s=%"PRId64"\n", wctx->section_pbuf[wctx->level].str, key, 
value);
 }
 
 static void flat_print_str(WriterContext *wctx, const char *key, const char 
*value)
@@ -1440,7 +1440,7 @@ static void ini_print_str(WriterContext *wctx, const char 
*key, const char *valu
 
 static void ini_print_int(WriterContext *wctx, const char *key, long long int 
value)
 {
-printf("%s=%lld\n", key, value);
+printf("%s=%"PRId64"\n", key, value);
 }
 
 static const Writer ini_writer = {
@@ -1603,7 +1603,7 @@ static void json_print_int(WriterContext *wctx, const 
char *key, long long int v
 JSON_INDENT();
 
 av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
-printf("\"%s\": %lld", json_escape_str(&buf, key, wctx), value);
+printf("\"%s\": %"PRId64, json_escape_str(&buf, key, wctx), value);
 av_bprint_finalize(&buf, NULL);
 }
 
@@ -1776,7 +1776,7 @@ static void xml_print_int(WriterContext *wctx, const char 
*key, long long int va
 {
 if (wctx->nb_item[wctx->level])
 printf(" ");
-printf("%s=\"%lld\"", key, value);
+printf("%s=\"%"PRId64"\"", key, value);
 }
 
 static Writer xml_writer = {
-- 
2.21.0

___
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 2/2] avformat: add kvag muxer

2020-04-10 Thread Andreas Rheinhardt
Zane van Iperen:
> Signed-off-by: Zane van Iperen 
> ---
>  Changelog|  1 +
>  libavformat/Makefile |  1 +
>  libavformat/allformats.c |  1 +
>  libavformat/kvag.c   | 84 +++-
>  libavformat/version.h|  2 +-
>  5 files changed, 87 insertions(+), 2 deletions(-)
> 
> diff --git a/Changelog b/Changelog
> index b4fff44329..b2de88484b 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -57,6 +57,7 @@ version :
>  - overlay_cuda filter
>  - switch from AvxSynth to AviSynth+ on Linux
>  - Simon & Schuster Interactive ADPCM encoder
> +- Real War KVAG muxer
>  
>  
>  version 4.2:
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 8fd0d43721..ff920c4373 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -285,6 +285,7 @@ OBJS-$(CONFIG_JACOSUB_MUXER) += jacosubenc.o 
> rawenc.o
>  OBJS-$(CONFIG_JV_DEMUXER)+= jvdec.o
>  OBJS-$(CONFIG_KUX_DEMUXER)   += flvdec.o
>  OBJS-$(CONFIG_KVAG_DEMUXER)  += kvag.o
> +OBJS-$(CONFIG_KVAG_MUXER)+= kvag.o

You need to add rawenc.o here.

>  OBJS-$(CONFIG_LATM_MUXER)+= latmenc.o rawenc.o
>  OBJS-$(CONFIG_LMLM4_DEMUXER) += lmlm4.o
>  OBJS-$(CONFIG_LOAS_DEMUXER)  += loasdec.o rawdec.o
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index 39d2c352f5..e12b50375c 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -220,6 +220,7 @@ extern AVOutputFormat ff_jacosub_muxer;
>  extern AVInputFormat  ff_jv_demuxer;
>  extern AVInputFormat  ff_kux_demuxer;
>  extern AVInputFormat  ff_kvag_demuxer;
> +extern AVOutputFormat ff_kvag_muxer;
>  extern AVOutputFormat ff_latm_muxer;
>  extern AVInputFormat  ff_lmlm4_demuxer;
>  extern AVInputFormat  ff_loas_demuxer;
> diff --git a/libavformat/kvag.c b/libavformat/kvag.c
> index 71b0eb4118..8be820a3c8 100644
> --- a/libavformat/kvag.c
> +++ b/libavformat/kvag.c
> @@ -1,5 +1,5 @@
>  /*
> - * Simon & Schuster Interactive VAG demuxer
> + * Simon & Schuster Interactive VAG (de)muxer
>   *
>   * Copyright (C) 2020 Zane van Iperen (z...@zanevaniperen.com)
>   *
> @@ -21,6 +21,7 @@
>   */
>  #include "avformat.h"
>  #include "internal.h"
> +#include "rawenc.h"
>  #include "libavutil/intreadwrite.h"
>  
>  #define KVAG_TAGMKTAG('K', 'V', 'A', 'G')
> @@ -34,6 +35,7 @@ typedef struct KVAGHeader {
>  uint16_tstereo;
>  } KVAGHeader;
>  
> +#if CONFIG_KVAG_DEMUXER
>  static int kvag_probe(const AVProbeData *p)
>  {
>  if (AV_RL32(p->buf) != KVAG_TAG)
> @@ -115,3 +117,83 @@ AVInputFormat ff_kvag_demuxer = {
>  .read_header= kvag_read_header,
>  .read_packet= kvag_read_packet
>  };
> +#endif
> +
> +#if CONFIG_KVAG_MUXER
> +static int kvag_write_init(AVFormatContext *s)
> +{
> +AVCodecParameters *par;
> +
> +if (s->nb_streams != 1) {
> +av_log(s, AV_LOG_ERROR, "KVAG files have exactly one stream\n");
> +return AVERROR(EINVAL);
> +}
> +
> +par = s->streams[0]->codecpar;
> +
> +if (par->codec_id != AV_CODEC_ID_ADPCM_IMA_SSI) {
> +av_log(s, AV_LOG_ERROR, "%s codec not supported\n",
> +   avcodec_get_name(par->codec_id));
> +return AVERROR(EINVAL);
> +}
> +
> +if (par->channels > 2) {
> +av_log(s, AV_LOG_ERROR, "KVAG files only support up to 2 
> channels\n");
> +return AVERROR(EINVAL);
> +}
> +
> +return 0;
> +}
> +
> +static int kvag_write_header(AVFormatContext *s)
> +{
> +uint8_t buf[KVAG_HEADER_SIZE];
> +AVCodecParameters *par = s->streams[0]->codecpar;
> +
> +AV_WL32(buf +  0, KVAG_TAG);
> +AV_WL32(buf +  4, 0); /* Data size, we fix this up later. */
> +AV_WL32(buf +  8, par->sample_rate);
> +AV_WL16(buf + 12, par->channels == 2);
> +
> +avio_write(s->pb, buf, sizeof(buf));
> +return 0;
> +}
> +
> +static int kvag_write_trailer(AVFormatContext *s)
> +{
> +int64_t file_size, data_size;
> +
> +if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) {
> +av_log(s, AV_LOG_WARNING,
> +   "Stream not seekable, unable to write data size. "
> +   "Output file will be broken\n");
> +return 0;
> +}
> +
> +file_size = avio_tell(s->pb);
> +data_size = file_size - KVAG_HEADER_SIZE;
> +if (data_size < UINT32_MAX) {
> +avio_seek(s->pb, 4, SEEK_SET);
> +avio_wl32(s->pb, (uint32_t)data_size);
> +avio_seek(s->pb, file_size, SEEK_SET);
> +} else {
> +av_log(s, AV_LOG_WARNING,
> +   "Filesize %"PRId64" invalid for KVAG, output file will be 
> broken\n",
> +   file_size);
> +}
> +
> +return 0;
> +}
> +
> +AVOutputFormat ff_kvag_muxer = {
> +.name   = "kvag",
> +.long_name  = NULL_IF_CONFIG_SMALL("Simon & Schuster Interactive 
> VAG"),
> +.extensions = "vag",
> +.audio_codec= AV_CODEC_ID_ADPCM_IMA_SSI,
> +.video_codec  

Re: [FFmpeg-devel] [PATCH 10/10] lavc/libopenh264enc: replace cabac option with coder

2020-04-10 Thread Anton Khirnov
Quoting Linjie Fu (2020-04-06 13:14:53)
> Change the default option to -1 and allow the default cabac to be
> decided by profile.
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/libopenh264enc.c | 27 ---
>  1 file changed, 16 insertions(+), 11 deletions(-)
> 
> diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
> index 70ded55..94faeef 100644
> --- a/libavcodec/libopenh264enc.c
> +++ b/libavcodec/libopenh264enc.c
> @@ -46,7 +46,7 @@ typedef struct SVCContext {
>  int max_nal_size;
>  int skip_frames;
>  int skipped;
> -int cabac;
> +int coder;
>  
>  // rate control mode
>  int rc_mode;
> @@ -78,7 +78,12 @@ static const AVOption options[] = {
>  #undef PROFILE
>  { "max_nal_size", "set maximum NAL size in bytes", OFFSET(max_nal_size), 
> AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
>  { "allow_skip_frames", "allow skipping frames to hit the target 
> bitrate", OFFSET(skip_frames), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
> -{ "cabac", "Enable cabac", OFFSET(cabac), AV_OPT_TYPE_INT, { .i64 = 0 }, 
> 0, 1, VE },
> +{ "coder", "Coder type",  OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = -1 }, 
> -1, 1, VE, "coder" },

I think it's expected that options won't just randomly disappear. So the
old one should be deprecated and kept around for a while.

-- 
Anton Khirnov
___
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/2] avcodec/bsf: add av_bsf_join() to chain bitstream filters

2020-04-10 Thread Andreas Rheinhardt
Marton Balint:
> 
> 
> On Thu, 9 Apr 2020, James Almer wrote:
> 
>> On 4/9/2020 9:11 PM, Marton Balint wrote:
>>>
>>>
>>> On Fri, 10 Apr 2020, Andreas Rheinhardt wrote:
>>>
 Marton Balint:
> Signed-off-by: Marton Balint 
> ---
>  doc/APIchanges   |  3 +++
>  libavcodec/avcodec.h | 19 
>  libavcodec/bsf.c | 62
> 
>  libavcodec/version.h |  2 +-
>  4 files changed, 85 insertions(+), 1 deletion(-)
>
> diff --git a/doc/APIchanges b/doc/APIchanges
> index f1d7eac2ee..1473742139 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,9 @@ libavutil: 2017-10-21
>
>  API changes, most recent first:
>
> +2020-04-xx - xx - lavc 58.77.102 - avcodec.h
> +  Add av_bsf_join() to chain bitstream filters.
> +
>  2020-03-29 - xx - lavf 58.42.100 - avformat.h
>    av_read_frame() now guarantees to handle uninitialized input
> packets
>    and to return refcounted packets on success.
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 8fc0ad92c9..2812055e8a 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -6056,6 +6056,25 @@ int av_bsf_receive_packet(AVBSFContext *ctx,
> AVPacket *pkt);
>   */
>  void av_bsf_flush(AVBSFContext *ctx);
>
> +/**
> + * Join a new bitstream filter to an already operating one.
> + *
> + * @param[in,out] out_bsf *out_bsf contains the existing, already
> initialized bitstream
> + *    filter, the new filter will be joined to
> the output of this.
> + *    It can be NULL, in which case an empty
> filter is assumed.
> + *    Upon successful return *out_bsf will
> contain the new, combined
> + *    bitstream filter which will be initialized.
> + * @param[in] bsf the bitstream filter to be joined to the
> output of *out_bsf.
> + *    This filter must be uninitialized but it
> must be ready to be
> + *    initalized, so input codec parameters and
> time base must be
> + *    set if *out_bsf is NULL, otherwise the
> function will set these
> + *    automatically based on the output
> parameters of *out_bsf.
> + *    Upon successful return the bsf will be
> initialized.
> + *
> + * @return 0 on success, negative on error.

 One needs to be more explicit about what happens on error: bsf may be
 in a partially initialized state and is essentially only good for
 freeing (maybe the bsf parameter should be AVBSFContext **, too, and
 automatically free bsf on error?). But IMO we should aim to not cripple
 *out_bsf and document this.

> + */
> +int av_bsf_join(AVBSFContext **out_bsf, AVBSFContext *bsf);
> +
>  /**
>   * Free a bitstream filter context and everything associated with
> it; write NULL
>   * into the supplied pointer.
> diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
> index b9fc771a88..1bca28d1ae 100644
> --- a/libavcodec/bsf.c
> +++ b/libavcodec/bsf.c
> @@ -487,6 +487,68 @@ end:
>  return ret;
>  }
>
> +int av_bsf_join(AVBSFContext **out_bsf, AVBSFContext *bsf)
> +{
> +    BSFListContext *lst;
> +    AVBSFContext *obsf = *out_bsf;
> +    AVBSFContext *new_list_bsf = NULL;
> +    int ret;
> +
> +    if (!obsf) {
> +    ret = av_bsf_init(bsf);
> +    if (ret < 0)
> +    return ret;
> +    *out_bsf = bsf;
> +    return 0;
> +    }
> +
> +    if (obsf->filter != &ff_list_bsf) {
> +    ret = av_bsf_alloc(&ff_list_bsf, &new_list_bsf);
> +    if (ret < 0)
> +    return ret;
> +    lst = new_list_bsf->priv_data;
> +    ret = av_dynarray_add_nofree(&lst->bsfs, &lst->nb_bsfs,
> obsf);
> +    if (ret < 0)
> +    goto fail;
> +    ret = avcodec_parameters_copy(new_list_bsf->par_in,
> obsf->par_in);
> +    if (ret < 0)
> +    goto fail;
> +    new_list_bsf->time_base_in = obsf->time_base_in;
> +    obsf = new_list_bsf;
> +    } else {
> +    lst = obsf->priv_data;
> +    }
> +
> +    ret = avcodec_parameters_copy(bsf->par_in,
> lst->bsfs[lst->nb_bsfs-1]->par_out);
> +    if (ret < 0)
> +    goto fail;
> +    bsf->time_base_in = lst->bsfs[lst->nb_bsfs-1]->time_base_out;
> +
> +    ret = av_bsf_init(&bsf);
> +    if (ret < 0)
> +    goto fail;
> +
> +    ret = avcodec_parameters_copy(obsf->par_out, bsf->par_out);

 This will change obsf even on failure (when *out_bsf was already of

Re: [FFmpeg-devel] [PATCH 08/10] lavc/libopenh264enc: add profile high option support

2020-04-10 Thread Anton Khirnov
Quoting Linjie Fu (2020-04-06 13:14:51)
> Add support for PRO_HIGH/PRO_BASELINE in SVC Encoding extention mode,
> which determined by iEntropyCodingModeFlag in ParamTranscode().
> 
> 
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/libopenh264enc.c | 32 ++--
>  1 file changed, 26 insertions(+), 6 deletions(-)
> 
> diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
> index f02c5fd..d331cfd 100644
> --- a/libavcodec/libopenh264enc.c
> +++ b/libavcodec/libopenh264enc.c
> @@ -42,7 +42,7 @@ typedef struct SVCContext {
>  ISVCEncoder *encoder;
>  int slice_mode; // deprecated
>  int loopfilter;
> -char *profile;
> +int profile;

Wouldn't it be better to deprecate the encoder-private option and use
only the AVCodecContext one?

-- 
Anton Khirnov
___
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 v1 1/4] avfilter/af_loudnorm: Add file option for the measured stats

2020-04-10 Thread Nicolas George
Limin Wang (12020-04-10):
> If someone can rework the ffprobe writers with a helper function, I'm 
> glad to use it. I'm not code maintainer, if no other developer review
> my code and help to push it, then it's difficult to merge. The time cycle
> is too long, so I have no plan to do such work.

Ok. This is something I was intending to work on anyway, and it seems
ripe. I will bring it to the mailing-list.

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".

Re: [FFmpeg-devel] [PATCH v1 1/4] avfilter/af_loudnorm: Add file option for the measured stats

2020-04-10 Thread Nicolas George
Kyle Swanson (12020-04-09):
> Is there already a helper API for filters (or codecs) that output a
> statistics file? If not, that's probably a pretty big undertaking. In

I do not think it is that big a task. It needs a convention for the name
of the option(s), a convention for the name of the file(s), and a few
functions to write and read them.

> the codec case, there are probably stats files which we have no
> control over, since they are written directly by some linked library.

Since they are out of our control, they should have no impact on our
development choices.

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".

Re: [FFmpeg-devel] [PATCH 06/10] lavc/libopenh264enc: set slice_mode option to deprecated

2020-04-10 Thread Anton Khirnov
Quoting Linjie Fu (2020-04-06 13:14:49)
> "slice mode" seems to be unnecessary since it could be determined by
> -slices/max_nal_size.
> 
> default:SM_FIXEDSLCNUM_SLICE mode with cpu-number slices.
> -slices N:  SM_FIXEDSLCNUM_SLICE mode with N slices.
> -max_nal_size:  SM_SIZELIMITED_SLICE mode with limited size slices.
> 
> This could be removed later.
> 
> Signed-off-by: Linjie Fu 
> ---

I'd say also schedule it for removal with new FF_API_ macros, otherwise
deprecated things tend to stay around for way too long.

-- 
Anton Khirnov
___
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 05/10] lavc/libopenh264enc: prompt slice number changing according to cpus

2020-04-10 Thread Anton Khirnov
Quoting Linjie Fu (2020-04-06 13:14:48)
> Libopenh264enc would set the slice according to the number of cpu cores
> if uiSliceNum equals to 0 (auto) in SM_FIXEDSLCNUM_SLICE mode.
> 
> Prompt a warning for user to catch this.
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/libopenh264enc.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
> index dab8244..01a85fb 100644
> --- a/libavcodec/libopenh264enc.c
> +++ b/libavcodec/libopenh264enc.c
> @@ -237,6 +237,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  param.sSpatialLayers[0].sSliceCfg.uiSliceMode   = 
> s->slice_mode;
>  param.sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceNum = 
> avctx->slices;
>  #endif
> +if (avctx->slices == 0 && s->slice_mode == SM_FIXEDSLCNUM_SLICE)
> +av_log(avctx, AV_LOG_WARNING, "Auto slice number, "
> +   "default to use the number of CPU cores: %d\n", 
> av_cpu_count());

Generally makes sense, but I'd avoid the call to av_cpu_count() since we
don't know what method precisely will libopenh264 use to set the slice
count. So IMO just say something like "slice count will be set
automatically".

-- 
Anton Khirnov
___
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 04/10] lavc/libopenh264enc: add bit rate control select support

2020-04-10 Thread Anton Khirnov
Quoting Linjie Fu (2020-04-06 13:14:47)
> RC_BITRATE_MODE:
> set BITS_EXCEEDED to iCurrentBitsLevel and allows QP adjust
> in RcCalculatePictureQp().
> 
> RC_BUFFERBASED_MODE:
> use buffer status to adjust the video quality.
> 
> RC_TIMESTAMP_MODE:
> bit rate control based on timestamp.
> 
> Default to use RC_QUALITY_MODE.
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/libopenh264enc.c | 12 +++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 

Doesn't this functionality depend on what variables the user specified
explicitly (like qscale, max/min/avg bitrates, buffer sizes etc.).
Wouldn't it be better to choose the default RC type based on those, like
vaapi does it?

-- 
Anton Khirnov
___
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 v2 2/2] avformat: add kvag muxer

2020-04-10 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 Changelog|  1 +
 libavformat/Makefile |  1 +
 libavformat/allformats.c |  1 +
 libavformat/kvag.c   | 84 +++-
 libavformat/version.h|  2 +-
 5 files changed, 87 insertions(+), 2 deletions(-)

diff --git a/Changelog b/Changelog
index b4fff44329..b2de88484b 100644
--- a/Changelog
+++ b/Changelog
@@ -57,6 +57,7 @@ version :
 - overlay_cuda filter
 - switch from AvxSynth to AviSynth+ on Linux
 - Simon & Schuster Interactive ADPCM encoder
+- Real War KVAG muxer
 
 
 version 4.2:
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 8fd0d43721..ff920c4373 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -285,6 +285,7 @@ OBJS-$(CONFIG_JACOSUB_MUXER) += jacosubenc.o 
rawenc.o
 OBJS-$(CONFIG_JV_DEMUXER)+= jvdec.o
 OBJS-$(CONFIG_KUX_DEMUXER)   += flvdec.o
 OBJS-$(CONFIG_KVAG_DEMUXER)  += kvag.o
+OBJS-$(CONFIG_KVAG_MUXER)+= kvag.o
 OBJS-$(CONFIG_LATM_MUXER)+= latmenc.o rawenc.o
 OBJS-$(CONFIG_LMLM4_DEMUXER) += lmlm4.o
 OBJS-$(CONFIG_LOAS_DEMUXER)  += loasdec.o rawdec.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 39d2c352f5..e12b50375c 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -220,6 +220,7 @@ extern AVOutputFormat ff_jacosub_muxer;
 extern AVInputFormat  ff_jv_demuxer;
 extern AVInputFormat  ff_kux_demuxer;
 extern AVInputFormat  ff_kvag_demuxer;
+extern AVOutputFormat ff_kvag_muxer;
 extern AVOutputFormat ff_latm_muxer;
 extern AVInputFormat  ff_lmlm4_demuxer;
 extern AVInputFormat  ff_loas_demuxer;
diff --git a/libavformat/kvag.c b/libavformat/kvag.c
index 71b0eb4118..8be820a3c8 100644
--- a/libavformat/kvag.c
+++ b/libavformat/kvag.c
@@ -1,5 +1,5 @@
 /*
- * Simon & Schuster Interactive VAG demuxer
+ * Simon & Schuster Interactive VAG (de)muxer
  *
  * Copyright (C) 2020 Zane van Iperen (z...@zanevaniperen.com)
  *
@@ -21,6 +21,7 @@
  */
 #include "avformat.h"
 #include "internal.h"
+#include "rawenc.h"
 #include "libavutil/intreadwrite.h"
 
 #define KVAG_TAGMKTAG('K', 'V', 'A', 'G')
@@ -34,6 +35,7 @@ typedef struct KVAGHeader {
 uint16_tstereo;
 } KVAGHeader;
 
+#if CONFIG_KVAG_DEMUXER
 static int kvag_probe(const AVProbeData *p)
 {
 if (AV_RL32(p->buf) != KVAG_TAG)
@@ -115,3 +117,83 @@ AVInputFormat ff_kvag_demuxer = {
 .read_header= kvag_read_header,
 .read_packet= kvag_read_packet
 };
+#endif
+
+#if CONFIG_KVAG_MUXER
+static int kvag_write_init(AVFormatContext *s)
+{
+AVCodecParameters *par;
+
+if (s->nb_streams != 1) {
+av_log(s, AV_LOG_ERROR, "KVAG files have exactly one stream\n");
+return AVERROR(EINVAL);
+}
+
+par = s->streams[0]->codecpar;
+
+if (par->codec_id != AV_CODEC_ID_ADPCM_IMA_SSI) {
+av_log(s, AV_LOG_ERROR, "%s codec not supported\n",
+   avcodec_get_name(par->codec_id));
+return AVERROR(EINVAL);
+}
+
+if (par->channels > 2) {
+av_log(s, AV_LOG_ERROR, "KVAG files only support up to 2 channels\n");
+return AVERROR(EINVAL);
+}
+
+return 0;
+}
+
+static int kvag_write_header(AVFormatContext *s)
+{
+uint8_t buf[KVAG_HEADER_SIZE];
+AVCodecParameters *par = s->streams[0]->codecpar;
+
+AV_WL32(buf +  0, KVAG_TAG);
+AV_WL32(buf +  4, 0); /* Data size, we fix this up later. */
+AV_WL32(buf +  8, par->sample_rate);
+AV_WL16(buf + 12, par->channels == 2);
+
+avio_write(s->pb, buf, sizeof(buf));
+return 0;
+}
+
+static int kvag_write_trailer(AVFormatContext *s)
+{
+int64_t file_size, data_size;
+
+if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) {
+av_log(s, AV_LOG_WARNING,
+   "Stream not seekable, unable to write data size. "
+   "Output file will be broken\n");
+return 0;
+}
+
+file_size = avio_tell(s->pb);
+data_size = file_size - KVAG_HEADER_SIZE;
+if (data_size < UINT32_MAX) {
+avio_seek(s->pb, 4, SEEK_SET);
+avio_wl32(s->pb, (uint32_t)data_size);
+avio_seek(s->pb, file_size, SEEK_SET);
+} else {
+av_log(s, AV_LOG_WARNING,
+   "Filesize %"PRId64" invalid for KVAG, output file will be 
broken\n",
+   file_size);
+}
+
+return 0;
+}
+
+AVOutputFormat ff_kvag_muxer = {
+.name   = "kvag",
+.long_name  = NULL_IF_CONFIG_SMALL("Simon & Schuster Interactive VAG"),
+.extensions = "vag",
+.audio_codec= AV_CODEC_ID_ADPCM_IMA_SSI,
+.video_codec= AV_CODEC_ID_NONE,
+.init   = kvag_write_init,
+.write_header   = kvag_write_header,
+.write_packet   = ff_raw_write_packet,
+.write_trailer  = kvag_write_trailer
+};
+#endif
diff --git a/libavformat/version.h b/libavformat/version.h
index 18c2f5fec2..493a0b337f 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,

[FFmpeg-devel] [PATCH v2 1/2] avcodec: add adpcm_ima_ssi encoder

2020-04-10 Thread Zane van Iperen
Signed-off-by: Zane van Iperen 
---
 Changelog  |  1 +
 doc/general.texi   |  2 +-
 libavcodec/Makefile|  1 +
 libavcodec/adpcmenc.c  | 30 ++
 libavcodec/allcodecs.c |  1 +
 libavcodec/utils.c |  1 +
 libavcodec/version.h   |  4 ++--
 7 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/Changelog b/Changelog
index e6db88af07..b4fff44329 100644
--- a/Changelog
+++ b/Changelog
@@ -56,6 +56,7 @@ version :
 - CRI HCA demuxer
 - overlay_cuda filter
 - switch from AvxSynth to AviSynth+ on Linux
+- Simon & Schuster Interactive ADPCM encoder
 
 
 version 4.2:
diff --git a/doc/general.texi b/doc/general.texi
index 4adcc9e742..a7b0cc1718 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -1107,7 +1107,7 @@ following image formats are supported:
 @item ADPCM IMA Funcom   @tab @tab  X
 @item ADPCM IMA High Voltage Software ALP   @tab @tab  X
 @item ADPCM IMA QuickTime@tab  X  @tab  X
-@item ADPCM IMA Simon & Schuster Interactive   @tab  @tab  X
+@item ADPCM IMA Simon & Schuster Interactive   @tab  X  @tab  X
 @item ADPCM IMA Ubisoft APM  @tab @tab X
 @item ADPCM IMA Loki SDL MJPEG  @tab @tab  X
 @item ADPCM IMA WAV  @tab  X  @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index c1c9a44f2b..0c46396ae0 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -851,6 +851,7 @@ OBJS-$(CONFIG_ADPCM_IMA_QT_DECODER)   += adpcm.o 
adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_QT_ENCODER)   += adpcmenc.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_RAD_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_SSI_DECODER)  += adpcm.o adpcm_data.o
+OBJS-$(CONFIG_ADPCM_IMA_SSI_ENCODER)  += adpcmenc.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_SMJPEG_DECODER)   += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_WAV_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_WAV_ENCODER)  += adpcmenc.o adpcm_data.o
diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index 668939c778..1d6ea798a9 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -77,6 +77,15 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
 return AVERROR(EINVAL);
 }
 
+if (avctx->trellis && avctx->codec->id == AV_CODEC_ID_ADPCM_IMA_SSI) {
+/*
+ * Trellis sort-of works, but has some DC offset problems.
+ * Disable it until I can figure out why.
+ */
+av_log(avctx, AV_LOG_ERROR, "trellis not supported\n");
+return AVERROR(EINVAL);
+}
+
 if (avctx->trellis) {
 int frontier  = 1 << avctx->trellis;
 int max_paths =  frontier * FREEZE_INTERVAL;
@@ -139,6 +148,10 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
 }
 avctx->frame_size = 512 * (avctx->sample_rate / 11025);
 break;
+case AV_CODEC_ID_ADPCM_IMA_SSI:
+avctx->frame_size = BLKSIZE;
+avctx->block_align = BLKSIZE;
+break;
 default:
 ret = AVERROR(EINVAL);
 goto error;
@@ -568,6 +581,22 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 flush_put_bits(&pb);
 break;
 }
+case AV_CODEC_ID_ADPCM_IMA_SSI:
+{
+PutBitContext pb;
+init_put_bits(&pb, dst, pkt_size);
+
+av_assert0(avctx->trellis == 0);
+
+for (i = 0; i < frame->nb_samples; i++) {
+for (ch = 0; ch < avctx->channels; ch++) {
+put_bits(&pb, 4, adpcm_ima_qt_compress_sample(c->status + ch, 
*samples++));
+}
+}
+
+flush_put_bits(&pb);
+break;
+}
 case AV_CODEC_ID_ADPCM_SWF:
 {
 PutBitContext pb;
@@ -720,6 +749,7 @@ AVCodec ff_ ## name_ ## _encoder = {
\
 }
 
 ADPCM_ENCODER(AV_CODEC_ID_ADPCM_IMA_QT,  adpcm_ima_qt,  sample_fmts_p, "ADPCM 
IMA QuickTime");
+ADPCM_ENCODER(AV_CODEC_ID_ADPCM_IMA_SSI, adpcm_ima_ssi, sample_fmts,   "ADPCM 
IMA Simon & Schuster Interactive");
 ADPCM_ENCODER(AV_CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav, sample_fmts_p, "ADPCM 
IMA WAV");
 ADPCM_ENCODER(AV_CODEC_ID_ADPCM_MS,  adpcm_ms,  sample_fmts,   "ADPCM 
Microsoft");
 ADPCM_ENCODER(AV_CODEC_ID_ADPCM_SWF, adpcm_swf, sample_fmts,   "ADPCM 
Shockwave Flash");
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index b3184af954..8dd02f2f8a 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -616,6 +616,7 @@ extern AVCodec ff_adpcm_ima_qt_encoder;
 extern AVCodec ff_adpcm_ima_qt_decoder;
 extern AVCodec ff_adpcm_ima_rad_decoder;
 extern AVCodec ff_adpcm_ima_ssi_decoder;
+extern AVCodec ff_adpcm_ima_ssi_encoder;
 extern AVCodec ff_adpcm_ima_smjpeg_decoder;
 extern AVCodec ff_adpcm_ima_wav_encoder;
 extern AVCodec ff_adpcm_ima_wav_decoder;
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 4ab8cff4f5..b297eb3552 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1463,6 +1463,7 @@ int av_get_exact_bits_per_sample(enum AVCodec

Re: [FFmpeg-devel] [PATCH 03/10] lavc/libopenh264enc: add default gop size and bit rate

2020-04-10 Thread Anton Khirnov
Quoting Linjie Fu (2020-04-06 13:14:46)
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/libopenh264enc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
> index c7ae5b1..3ff5be7 100644
> --- a/libavcodec/libopenh264enc.c
> +++ b/libavcodec/libopenh264enc.c
> @@ -335,6 +335,8 @@ static int svc_encode_frame(AVCodecContext *avctx, 
> AVPacket *avpkt,
>  }
>  
>  static const AVCodecDefault svc_enc_defaults[] = {
> +{ "b", "2M"},
> +{ "g", "120"   },

Why these values specifically? What happens if we leave them unset?

-- 
Anton Khirnov
___
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 02/10] lavc/libopenh264enc: fix the if-else coding style

2020-04-10 Thread Anton Khirnov
Quoting Linjie Fu (2020-04-06 13:14:45)
> Signed-off-by: Linjie Fu 
> ---

ok

-- 
Anton Khirnov
___
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 01/10] lavc/libopenh264enc: Add default qmin/qmax support

2020-04-10 Thread Anton Khirnov
Quoting Linjie Fu (2020-04-06 13:14:44)
> Set default QP range to (1, 51) instead of (2, 32).
> 
> QP = 0 is not well supported currently in libopenh264. If iMaxQp/iMinQp
> equals 0, the QP range would be changed unexpectedly inside libopenh264
> with a warning:
> 
> Warning:Change QP Range from(0,51) to (12,42)
> 
> [1] 
> 
> [2] 
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/libopenh264enc.c | 10 ++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
> index ae6d17c..364926f 100644
> --- a/libavcodec/libopenh264enc.c
> +++ b/libavcodec/libopenh264enc.c
> @@ -135,6 +135,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  param.iTargetBitrate = avctx->bit_rate;
>  param.iMaxBitrate= FFMAX(avctx->rc_max_rate, 
> avctx->bit_rate);
>  param.iRCMode= RC_QUALITY_MODE;
> +// QP = 0 is not well supported, so default to (1, 51)
> +param.iMaxQp = avctx->qmax >= 0 ? 
> av_clip(avctx->qmax, 1, 51) : 51;
> +param.iMinQp = avctx->qmin >= 0 ? 
> av_clip(avctx->qmin, 1, param.iMaxQp) : 1;

Should we set them at all if they are not specified by the user?
Wouldn't it be better to leave the unset, as is done now?

-- 
Anton Khirnov
___
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".

  1   2   >