Re: [FFmpeg-devel] [PATCH v3 3/3] libavcodec/jpeb2000dec.c: Handle non EOC streams

2020-03-27 Thread Gautam Ramakrishnan
On Sat, Mar 28, 2020 at 9:59 AM Steven Liu  wrote:
>
>
>
> > 2020年3月28日 下午12:24,Gautam Ramakrishnan  写道:
> >
> > On Sat, Mar 28, 2020 at 9:49 AM  wrote:
> should the title be jpeg2000dec?, it maybe is a typo if I don’t misunderstand.
You are right, it is a typo. It must be jpeg2000dec.
> >>
> >> From: Gautam Ramakrishnan 
> >>
> >> This patch allows decoding of j2k streams which do
> >> not have an EOC marker. OpenJPEG implements a similar
> >> check.
> >> ---
> >> libavcodec/jpeg2000dec.c | 5 +++--
> >> 1 file changed, 3 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> >> index 44b3e7e41b..99fcb2cf68 100644
> >> --- a/libavcodec/jpeg2000dec.c
> >> +++ b/libavcodec/jpeg2000dec.c
> >> @@ -2076,8 +2076,9 @@ static int 
> >> jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
> >>
> >> len = bytestream2_get_be16(>g);
> >> if (len < 2 || bytestream2_get_bytes_left(>g) < len - 2) {
> >> -av_log(s->avctx, AV_LOG_ERROR, "Invalid len %d left=%d\n", 
> >> len, bytestream2_get_bytes_left(>g));
> >> -return AVERROR_INVALIDDATA;
> >> +av_log(s->avctx, AV_LOG_WARNING, "Invalid len %d left=%d\n", 
> >> len, bytestream2_get_bytes_left(>g));
> >> +av_log(s->avctx, AV_LOG_WARNING, "Stream does not end with 
> >> EOC.\n");
> >> +return 0;
> >> }
> >>
> >> switch (marker) {
> >> --
> >> 2.17.1
> >>
> > Hi,
> >
> > @Carl, on adding this patch series, looks like the frames of
> > http://samples.ffmpeg.org/jpeg2000/jpeg2000_mxf_first_10mb.mxf
> > also seems to be decoded correctly. Have sent this patch for your
> > comments.
> >
> > --
> > -
> > 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".
>
> Thanks
>
> Steven Liu
>
>
>
> ___
> 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".



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

[FFmpeg-devel] [PATCH v3 2/3] libavcodec/jpeg2000dec.c: Functional changes to support PPT marker

2020-03-27 Thread gautamramk
From: Gautam Ramakrishnan 

This patch adds functional changes to support the PPT marker. It
allows the PPT marker to be read in jpeg2000_read_main_headers().
---
 libavcodec/jpeg2000dec.c | 270 ---
 1 file changed, 82 insertions(+), 188 deletions(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 001bc8d057..44b3e7e41b 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -1173,179 +1173,6 @@ static int 
jpeg2000_decode_packet_data(Jpeg2000DecoderContext *s, Jpeg2000Tile *
 return 0;
 }
 
-static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile 
*tile, int *tp_index,
-  Jpeg2000CodingStyle *codsty,
-  Jpeg2000ResLevel *rlevel, int precno,
-  int layno, uint8_t *expn, int numgbits)
-{
-int bandno, cblkno, ret, nb_code_blocks;
-int cwsno;
-
-if (layno < rlevel->band[0].prec[precno].decoded_layers)
-return 0;
-rlevel->band[0].prec[precno].decoded_layers = layno + 1;
-
-if (bytestream2_get_bytes_left(>g) == 0 && s->bit_index == 8) {
-if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
-s->g = tile->tile_part[++(*tp_index)].tpg;
-}
-}
-
-if (bytestream2_peek_be32(>g) == JPEG2000_SOP_FIXED_BYTES)
-bytestream2_skip(>g, JPEG2000_SOP_BYTE_LENGTH);
-
-if (!(ret = get_bits(s, 1))) {
-jpeg2000_flush(s);
-return 0;
-} else if (ret < 0)
-return ret;
-
-for (bandno = 0; bandno < rlevel->nbands; bandno++) {
-Jpeg2000Band *band = rlevel->band + bandno;
-Jpeg2000Prec *prec = band->prec + precno;
-
-if (band->coord[0][0] == band->coord[0][1] ||
-band->coord[1][0] == band->coord[1][1])
-continue;
-nb_code_blocks =  prec->nb_codeblocks_height *
-  prec->nb_codeblocks_width;
-for (cblkno = 0; cblkno < nb_code_blocks; cblkno++) {
-Jpeg2000Cblk *cblk = prec->cblk + cblkno;
-int incl, newpasses, llen;
-void *tmp;
-
-if (cblk->npasses)
-incl = get_bits(s, 1);
-else
-incl = tag_tree_decode(s, prec->cblkincl + cblkno, layno + 1) 
== layno;
-if (!incl)
-continue;
-else if (incl < 0)
-return incl;
-
-if (!cblk->npasses) {
-int v = expn[bandno] + numgbits - 1 -
-tag_tree_decode(s, prec->zerobits + cblkno, 100);
-if (v < 0 || v > 30) {
-av_log(s->avctx, AV_LOG_ERROR,
-   "nonzerobits %d invalid or unsupported\n", v);
-return AVERROR_INVALIDDATA;
-}
-cblk->nonzerobits = v;
-}
-if ((newpasses = getnpasses(s)) < 0)
-return newpasses;
-av_assert2(newpasses > 0);
-if (cblk->npasses + newpasses >= JPEG2000_MAX_PASSES) {
-avpriv_request_sample(s->avctx, "Too many passes");
-return AVERROR_PATCHWELCOME;
-}
-if ((llen = getlblockinc(s)) < 0)
-return llen;
-if (cblk->lblock + llen + av_log2(newpasses) > 16) {
-avpriv_request_sample(s->avctx,
-  "Block with length beyond 16 bits");
-return AVERROR_PATCHWELCOME;
-}
-
-cblk->lblock += llen;
-
-cblk->nb_lengthinc = 0;
-cblk->nb_terminationsinc = 0;
-av_free(cblk->lengthinc);
-cblk->lengthinc  = av_mallocz_array(newpasses, 
sizeof(*cblk->lengthinc));
-if (!cblk->lengthinc)
-return AVERROR(ENOMEM);
-tmp = av_realloc_array(cblk->data_start, cblk->nb_terminations + 
newpasses + 1, sizeof(*cblk->data_start));
-if (!tmp)
-return AVERROR(ENOMEM);
-cblk->data_start = tmp;
-do {
-int newpasses1 = 0;
-
-while (newpasses1 < newpasses) {
-newpasses1 ++;
-if (needs_termination(codsty->cblk_style, cblk->npasses + 
newpasses1 - 1)) {
-cblk->nb_terminationsinc ++;
-break;
-}
-}
-
-if ((ret = get_bits(s, av_log2(newpasses1) + cblk->lblock)) < 
0)
-return ret;
-if (ret > cblk->data_allocated) {
-size_t new_size = FFMAX(2*cblk->data_allocated, ret);
-void *new = av_realloc(cblk->data, new_size);
-if (new) {
-cblk->data = new;
-cblk->data_allocated = new_size;
-}
-}
-if (ret > 

Re: [FFmpeg-devel] [PATCH v3 3/3] libavcodec/jpeb2000dec.c: Handle non EOC streams

2020-03-27 Thread Steven Liu


> 2020年3月28日 下午12:24,Gautam Ramakrishnan  写道:
> 
> On Sat, Mar 28, 2020 at 9:49 AM  wrote:
should the title be jpeg2000dec?, it maybe is a typo if I don’t misunderstand.
>> 
>> From: Gautam Ramakrishnan 
>> 
>> This patch allows decoding of j2k streams which do
>> not have an EOC marker. OpenJPEG implements a similar
>> check.
>> ---
>> libavcodec/jpeg2000dec.c | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>> 
>> diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
>> index 44b3e7e41b..99fcb2cf68 100644
>> --- a/libavcodec/jpeg2000dec.c
>> +++ b/libavcodec/jpeg2000dec.c
>> @@ -2076,8 +2076,9 @@ static int 
>> jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
>> 
>> len = bytestream2_get_be16(>g);
>> if (len < 2 || bytestream2_get_bytes_left(>g) < len - 2) {
>> -av_log(s->avctx, AV_LOG_ERROR, "Invalid len %d left=%d\n", len, 
>> bytestream2_get_bytes_left(>g));
>> -return AVERROR_INVALIDDATA;
>> +av_log(s->avctx, AV_LOG_WARNING, "Invalid len %d left=%d\n", 
>> len, bytestream2_get_bytes_left(>g));
>> +av_log(s->avctx, AV_LOG_WARNING, "Stream does not end with 
>> EOC.\n");
>> +return 0;
>> }
>> 
>> switch (marker) {
>> --
>> 2.17.1
>> 
> Hi,
> 
> @Carl, on adding this patch series, looks like the frames of
> http://samples.ffmpeg.org/jpeg2000/jpeg2000_mxf_first_10mb.mxf
> also seems to be decoded correctly. Have sent this patch for your
> comments.
> 
> -- 
> -
> 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".

Thanks

Steven Liu



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

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

[FFmpeg-devel] [PATCH v3 1/3] libavcodec/jpeg2000dec.c: Add functions and modify structs for PPT marker support

2020-03-27 Thread gautamramk
From: Gautam Ramakrishnan 

This patch modifies the Jpeg2000Tile struct and breaks the
jpeg2000_decode_packet() function into two to decode packet
header and data separately.
---
 libavcodec/jpeg2000dec.c | 250 ++-
 1 file changed, 248 insertions(+), 2 deletions(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 7103cd6ceb..001bc8d057 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -83,8 +83,12 @@ typedef struct Jpeg2000Tile {
 Jpeg2000QuantStyle  qntsty[4];
 Jpeg2000POC poc;
 Jpeg2000TileParttile_part[32];
-uint16_t tp_idx;// Tile-part index
-int coord[2][2];// border coordinates {{x0, x1}, {y0, 
y1}}
+uint8_t has_ppt;// whether this tile has a ppt 
marker
+uint8_t *packed_headers;// contains packed headers. 
Used only along with PPT marker
+int packed_headers_size;// size in bytes of the packed 
headers
+GetByteContext  packed_headers_stream;  // byte context corresponding 
to packed headers
+uint16_t tp_idx;// Tile-part index
+int coord[2][2];// border coordinates {{x0, 
x1}, {y0, y1}}
 } Jpeg2000Tile;
 
 typedef struct Jpeg2000DecoderContext {
@@ -855,6 +859,38 @@ static int get_plt(Jpeg2000DecoderContext *s, int n)
 return 0;
 }
 
+static int get_ppt(Jpeg2000DecoderContext *s, int n)
+{
+Jpeg2000Tile *tile;
+
+tile = >tile[s->curtileno];
+
+av_assert1(s->curtileno >= 0);
+if (tile->tp_idx != 0) {
+av_log(s->avctx, AV_LOG_ERROR,
+   "PPT marker can occur only on first tile part of a tile.\n");
+return AVERROR_INVALIDDATA;
+}
+
+tile->has_ppt = 1;  // this tile has a ppt marker
+/*Zppt = */ bytestream2_get_byte(>g);
+if (!tile->packed_headers) {
+tile->packed_headers = av_malloc_array(n - 3, sizeof(uint8_t));
+memcpy(tile->packed_headers, s->g.buffer, sizeof(uint8_t)*(n - 3));
+tile->packed_headers_size = n - 3;
+} else {
+tile->packed_headers = av_realloc_array(tile->packed_headers,
+tile->packed_headers_size + n 
- 3,
+sizeof(uint8_t));
+memcpy(tile->packed_headers + tile->packed_headers_size,
+   s->g.buffer, sizeof(uint8_t)*(n - 3));
+tile->packed_headers_size += n - 3;
+}
+bytestream2_skip(>g, n - 3);
+
+return 0;
+}
+
 static int init_tile(Jpeg2000DecoderContext *s, int tileno)
 {
 int compno;
@@ -927,6 +963,216 @@ static int getlblockinc(Jpeg2000DecoderContext *s)
 return res;
 }
 
+static int jpeg2000_decode_packet_header(Jpeg2000DecoderContext *s, 
Jpeg2000Tile *tile,
+ int *tp_index,
+ Jpeg2000CodingStyle *codsty,
+ Jpeg2000ResLevel *rlevel, int precno,
+ int layno, uint8_t *expn, int 
numgbits,
+ int *process_data)
+{
+int bandno, cblkno, ret, nb_code_blocks;
+
+if (layno < rlevel->band[0].prec[precno].decoded_layers) {
+*process_data = 0;
+return 0;
+}
+rlevel->band[0].prec[precno].decoded_layers = layno + 1;
+
+if (tile->has_ppt) {
+s->g = tile->packed_headers_stream;
+} else {
+s->g = tile->tile_part[*tp_index].tpg;
+if (bytestream2_get_bytes_left(>g) == 0 && s->bit_index == 8) {
+if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
+s->g = tile->tile_part[++(*tp_index)].tpg;
+}
+}
+if (bytestream2_peek_be32(>g) == JPEG2000_SOP_FIXED_BYTES)
+bytestream2_skip(>g, JPEG2000_SOP_BYTE_LENGTH);
+}
+
+if (!(ret = get_bits(s, 1))) {
+jpeg2000_flush(s);
+*process_data = 0;
+goto end;
+} else if (ret < 0)
+return ret;
+
+for (bandno = 0; bandno < rlevel->nbands; bandno++) {
+Jpeg2000Band *band = rlevel->band + bandno;
+Jpeg2000Prec *prec = band->prec + precno;
+
+if (band->coord[0][0] == band->coord[0][1] ||
+band->coord[1][0] == band->coord[1][1])
+continue;
+nb_code_blocks =  prec->nb_codeblocks_height *
+  prec->nb_codeblocks_width;
+for (cblkno = 0; cblkno < nb_code_blocks; cblkno++) {
+Jpeg2000Cblk *cblk = prec->cblk + cblkno;
+int incl, newpasses, llen;
+void *tmp;
+
+if (cblk->npasses)
+incl = get_bits(s, 1);
+else
+incl = tag_tree_decode(s, prec->cblkincl + cblkno, layno + 1) 
== layno;
+if (!incl)
+continue;
+else if (incl < 0)
+  

Re: [FFmpeg-devel] [PATCH v3 3/3] libavcodec/jpeb2000dec.c: Handle non EOC streams

2020-03-27 Thread Gautam Ramakrishnan
On Sat, Mar 28, 2020 at 9:49 AM  wrote:
>
> From: Gautam Ramakrishnan 
>
> This patch allows decoding of j2k streams which do
> not have an EOC marker. OpenJPEG implements a similar
> check.
> ---
>  libavcodec/jpeg2000dec.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> index 44b3e7e41b..99fcb2cf68 100644
> --- a/libavcodec/jpeg2000dec.c
> +++ b/libavcodec/jpeg2000dec.c
> @@ -2076,8 +2076,9 @@ static int 
> jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
>
>  len = bytestream2_get_be16(>g);
>  if (len < 2 || bytestream2_get_bytes_left(>g) < len - 2) {
> -av_log(s->avctx, AV_LOG_ERROR, "Invalid len %d left=%d\n", len, 
> bytestream2_get_bytes_left(>g));
> -return AVERROR_INVALIDDATA;
> +av_log(s->avctx, AV_LOG_WARNING, "Invalid len %d left=%d\n", 
> len, bytestream2_get_bytes_left(>g));
> +av_log(s->avctx, AV_LOG_WARNING, "Stream does not end with 
> EOC.\n");
> +return 0;
>  }
>
>  switch (marker) {
> --
> 2.17.1
>
Hi,

@Carl, on adding this patch series, looks like the frames of
http://samples.ffmpeg.org/jpeg2000/jpeg2000_mxf_first_10mb.mxf
also seems to be decoded correctly. Have sent this patch for your
comments.

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

[FFmpeg-devel] [PATCH v3 3/3] libavcodec/jpeb2000dec.c: Handle non EOC streams

2020-03-27 Thread gautamramk
From: Gautam Ramakrishnan 

This patch allows decoding of j2k streams which do
not have an EOC marker. OpenJPEG implements a similar
check.
---
 libavcodec/jpeg2000dec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 44b3e7e41b..99fcb2cf68 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -2076,8 +2076,9 @@ static int 
jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
 
 len = bytestream2_get_be16(>g);
 if (len < 2 || bytestream2_get_bytes_left(>g) < len - 2) {
-av_log(s->avctx, AV_LOG_ERROR, "Invalid len %d left=%d\n", len, 
bytestream2_get_bytes_left(>g));
-return AVERROR_INVALIDDATA;
+av_log(s->avctx, AV_LOG_WARNING, "Invalid len %d left=%d\n", len, 
bytestream2_get_bytes_left(>g));
+av_log(s->avctx, AV_LOG_WARNING, "Stream does not end with 
EOC.\n");
+return 0;
 }
 
 switch (marker) {
-- 
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 v2] ffplay, avcodec, avformat: Don't initialize before av_packet_ref()

2020-03-27 Thread Andreas Rheinhardt
Anton Khirnov:
> Quoting Andreas Rheinhardt (2020-03-13 14:28:33)
>> It already initializes the packet.
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>> Resending because of 3117f47f19d051d47ba29c9b78c2ca525f0fdb45.
>>
>>  fftools/ffplay.c  | 2 +-
>>  libavcodec/qsvdec_h2645.c | 2 +-
>>  libavcodec/qsvdec_other.c | 2 +-
>>  libavformat/fifo.c| 1 -
>>  libavformat/img2enc.c | 8 
>>  libavformat/tee.c | 1 -
>>  6 files changed, 7 insertions(+), 9 deletions(-)
> 
> Generally looks good, but it occurred to me that the semantics of what
> happens on failure in av_packet_ref() is unspecified, which might lead
> to those uninitialized packets now being full of random data, which
> might be dangerous.
> 
> So we might want to specify that on failure dst is reset to a clean
> state and replace the call to av_packet_free_side_data() with
> av_packet_unref().
> 
Applied, thanks.

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

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

Re: [FFmpeg-devel] [PATCH 2/2] avcodec/avcodec, avpacket: Return blank packet on av_packet_ref() failure

2020-03-27 Thread Andreas Rheinhardt
Anton Khirnov:
> Quoting Andreas Rheinhardt (2020-03-27 03:25:14)
>> Up until now, it was completely unspecified what the content of the
>> destination packet dst was on error. Depending upon where the error
>> happened calling av_packet_unref() on dst might be dangerous.
>>
>> This commit changes this by making sure that dst is blank on error, so
>> unreferencing it again is safe (and still pointless). This behaviour is
>> documented.
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>>  doc/APIchanges| 4 
>>  libavcodec/avcodec.h  | 3 ++-
>>  libavcodec/avpacket.c | 7 ---
>>  libavcodec/version.h  | 2 +-
>>  4 files changed, 11 insertions(+), 5 deletions(-)
>>
>> diff --git a/doc/APIchanges b/doc/APIchanges
>> index 8eeaec2028..f2bb2d242b 100644
>> --- a/doc/APIchanges
>> +++ b/doc/APIchanges
>> @@ -15,6 +15,10 @@ libavutil: 2017-10-21
>>  
>>  API changes, most recent first:
>>  
>> +2020-03-27 - xx - lavc 58.77.100 - avcodec.h
>> +  av_packet_ref() now guarantees to return the destination packet
>> +  in a blank state on error.
>> +
>>  2020-03-10 - xx - lavc 58.75.100 - avcodec.h
>>Add AV_PKT_DATA_ICC_PROFILE.
>>  
>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
>> index f918d20a61..8fc0ad92c9 100644
>> --- a/libavcodec/avcodec.h
>> +++ b/libavcodec/avcodec.h
>> @@ -4651,7 +4651,8 @@ void av_packet_free_side_data(AVPacket *pkt);
>>   * @param dst Destination packet. Will be completely overwritten.
>>   * @param src Source packet
>>   *
>> - * @return 0 on success, a negative AVERROR on error.
>> + * @return 0 on success, a negative AVERROR on error. On error, dst
>> + * will be blank (as if returned by av_packet_alloc()).
>>   */
>>  int av_packet_ref(AVPacket *dst, const AVPacket *src);
>>  
>> diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
>> index 132567bc2d..c622718a45 100644
>> --- a/libavcodec/avpacket.c
>> +++ b/libavcodec/avpacket.c
>> @@ -610,12 +610,13 @@ int av_packet_ref(AVPacket *dst, const AVPacket *src)
>>  {
>>  int ret;
>>  
>> +dst->buf = NULL;
>> +
> 
> I really think av_init_packet() would be more robust against future
> changes. But I'm not going to push for that especially strongly, so feel
> free to push whichever version you prefer.
> 
Applied as is. After all, avpacket.c would be checked thoroughly in case
of a future addition to AVPacket with something that needs to be
allocated and freed (whereas lots of other places might be forgotten).

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

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

Re: [FFmpeg-devel] [PATCH v2 1/2] avcodec/avpacket: Always treat dst in av_packet_ref as uninitialized

2020-03-27 Thread Andreas Rheinhardt
Anton Khirnov:
> Quoting Andreas Rheinhardt (2020-03-27 03:25:13)
>> av_packet_ref() mostly treated the destination packet dst as uninitialized,
>> i.e. the destination fields were simply overwritten. But if the source
>> packet was not reference-counted, dst->buf was treated as if it pointed
>> to an already allocated buffer (if != NULL) to be reallocated to the
>> desired size.
>>
>> The documentation did not explicitly state whether the dst will be treated
>> as uninitialized, but it stated that if the source packet is not refcounted,
>> a new buffer in dst will be allocated. This and the fact that the side-data
>> as well as the codepath taken in case src is refcounted always treated the
>> packet as uninitialized means that dst should always be treated as
>> uninitialized for the sake of consistency. And this behaviour has been
>> explicitly documented.
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>>  libavcodec/avcodec.h  | 2 +-
>>  libavcodec/avpacket.c | 1 +
>>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> ok
> 
Applied, thanks.

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

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

Re: [FFmpeg-devel] [PATCH] [GSOC]add a fuzz testing in libavcodec/tests

2020-03-27 Thread Andreas Rheinhardt
a397341...@163.com:
> From: toseven 
> 
> ---
>  libavcodec/tests/target_avpacket_fuzzer.c | 114 ++
>  1 file changed, 114 insertions(+)
>  create mode 100644 libavcodec/tests/target_avpacket_fuzzer.c
> 
> diff --git a/libavcodec/tests/target_avpacket_fuzzer.c 
> b/libavcodec/tests/target_avpacket_fuzzer.c
> new file mode 100644
> index 00..22f9898210
> --- /dev/null
> +++ b/libavcodec/tests/target_avpacket_fuzzer.c
> @@ -0,0 +1,114 @@
> +/*
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include "libavcodec/avcodec.h"
> +#include "libavutil/error.h"
> +#include "config.h"
> +
> +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
> +
> +static int setup_side_data_entry(AVPacket* avpkt)
> +{
> +const char *data_name = NULL;
> +int ret = 0, bytes;
> +uint8_t *extra_data = NULL;
> +
> +
> +/* get side_data_name string */
> +data_name = av_packet_side_data_name(AV_PKT_DATA_NEW_EXTRADATA);
> +
> +/* Allocate a memory bloc */
> +bytes = strlen(data_name);
> +
> +if(!(extra_data = (uint8_t *)av_malloc(bytes))){

Extradata is supposed to be padded with AV_INPUT_BUFFER_PADDING_BYTES
and I guess the same requirement exists for extradata in side-data
(although it doesn't seem to be explicitly stated).

> +ret = AVERROR(ENOMEM);
> +fprintf(stderr, "Error occurred: %s\n", av_err2str(ret));
> +exit(1);
> +}
> +/* copy side_data_name to extra_data array */
> +memcpy(extra_data, data_name, bytes);

Isn't it the point of fuzzing to use nondeterministic data?

> +
> +/* create side data for AVPacket */
> +ret = av_packet_add_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA,
> +extra_data, bytes);
> +if(ret < 0){
> +fprintf(stderr,
> +"Error occurred in av_packet_add_side_data: %s\n",
> +av_err2str(ret));

You are leaking extra_data here.

> +}
> +
> +return ret;
> +}
> +
> +static int initializations(AVPacket* avpkt)
> +{
> +av_init_packet(avpkt);

Statement before declaration.

> +int ret;
> +ret = setup_side_data_entry(avpkt);
> +
> +return ret;
> +}
> +
> +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) 
> +{
> +AVPacket avpkt;
> +memcmp(,data,sizeof(AVPacket));

memcmp? You mean memcpy, don't you? Anyway, FFmpeg is written in C90 and
that implies that statements must follow all the definitions in a block.
> +
> +int num;
> +memcmp(,data+sizeof(AVPacket),sizeof(int));

Same here.

> +AVPacket *avpkt_clone = NULL;
> +int ret = 0;
> +
> +if(initializations() < 0){
> +printf("failed to initialize variables\n");
> +return 1;
> +}
> +/* test av_packet_clone*/
> +avpkt_clone = av_packet_clone();

At this point avpkt will either contain garbage values for size and data
or it will contain something from your fuzzer data (if you replace
memcmp by memcpy above). In any case, avpkt.buf is not set and therefore
a full copy of the data will be performed and this will usually
segfault. So what's the point of this test?

> +
> +if(!avpkt_clone) {
> +av_log(NULL, AV_LOG_ERROR,"av_packet_clone failed to clone 
> AVPacket\n");
> +return 1;
> +}
> +/*test av_grow_packet*/
> +if(av_grow_packet(avpkt_clone, num) < 0){

What has been said about avpkt.data and avpkt.size applies here, too.
av_grow_packet() will e.g. fail if num is < 0, but this is no bug in
av_grow_packet. So given that a nonzero return value does not really
indicate a bug I wonder what it is supposed to mean.

Btw: You are leaking avpkt and avpkt_clone here (if you have made it so
far).

> +av_log(NULL, AV_LOG_ERROR, "av_grow_packet failed\n");
> +return 1;
> +}
> +/* test size error check in av_new_packet*/
> +if(av_new_packet(avpkt_clone, num) == 0){

av_new_packet() treats its destination as uninitialized which means that
you are leaking what is already in the avpkt_clone here.

> +printf( "av_new_packet failed to return error "
> +"when \"size\" parameter is too large.\n" );

? What makes you sure 

Re: [FFmpeg-devel] [PATCH] avformat/movenc: remove write_colr flag and write colr by default

2020-03-27 Thread Michael Bradshaw
Looking at this further, Apple's HDR requirements[1] say for Dolby Vision:


The color (‘colr’) atom with these values shall be present.

   - Color Primaries shall be set to 2 (Unspecified).
   - Color Transfer Function Index shall be set to 2 (Unspecified).
   - Color Matrix Index shall be set to 2 (Unspecified).



In that case this patch is wrong because it will not write the colr atom.
The original code doesn't work for this either because it will try to guess
the values instead of writing "unspecified".

I'm going to abandon this patch for now.

[1]:
https://developer.apple.com/av-foundation/High-Dynamic-Range-Metadata-for-Apple-Devices.pdf

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

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

Re: [FFmpeg-devel] [PATCH v3] avformat/dashdec: fix memleak for commit commit e134c203

2020-03-27 Thread Steven Liu


> 2020年3月28日 上午10:15,Andreas Rheinhardt  写道:
> 
> Steven Liu:
>> 
>> 
>>> 2020年3月28日 上午9:37,Andreas Rheinhardt  写道:
>>> 
>>> Steven Liu:
 These member will be used for get more correct information of the MPD
 
 Suggested-by: Andreas Rheinhardt 
 Suggested-by: Nicolas George 
 Signed-off-by: Steven Liu 
 ---
 libavformat/dashdec.c | 244 --
 1 file changed, 214 insertions(+), 30 deletions(-)
 
 diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
 index 5bbe5d3985..b5bb8e674c 100644
 --- a/libavformat/dashdec.c
 +++ b/libavformat/dashdec.c
 @@ -108,6 +108,7 @@ struct representation {
int64_t cur_seg_offset;
int64_t cur_seg_size;
struct fragment *cur_seg;
 +char *lang;
 
/* Currently active Media Initialization Section */
struct fragment *init_section;
 @@ -122,19 +123,15 @@ struct representation {
 typedef struct DASHContext {
const AVClass *class;
char *base_url;
 -char *adaptionset_contenttype_val;
 -char *adaptionset_par_val;
 -char *adaptionset_lang_val;
 -char *adaptionset_minbw_val;
 -char *adaptionset_maxbw_val;
 -char *adaptionset_minwidth_val;
 -char *adaptionset_maxwidth_val;
 -char *adaptionset_minheight_val;
 -char *adaptionset_maxheight_val;
 -char *adaptionset_minframerate_val;
 -char *adaptionset_maxframerate_val;
 -char *adaptionset_segmentalignment_val;
 -char *adaptionset_bitstreamswitching_val;
 +char *adaptionset_lang;
 +uint64_t adaptionset_minbw;
 +uint64_t adaptionset_maxbw;
 +uint64_t adaptionset_minwidth;
 +uint64_t adaptionset_maxwidth;
 +uint64_t adaptionset_minheight;
 +uint64_t adaptionset_maxheight;
 +AVRational adaptionset_minframerate;
 +AVRational adaptionset_maxframerate;
 
int n_videos;
struct representation **videos;
 @@ -169,6 +166,79 @@ typedef struct DASHContext {
 
 } DASHContext;
 
 +static int get_ratio_from_string(AVRational *dst, char *src)
 +{
 +char *p = src;
 +char *end = NULL;
 +char *end_ptr = NULL;
 +int num, den;
 +
 +num = (int)strtol(p, _ptr, 10);
 +if (errno == ERANGE || end_ptr == src) {
 +return AVERROR_INVALIDDATA;
 +}
 +
 +if (end_ptr[0] == '\0') {
 +dst->den = 1;
 +dst->num = num;
 +return 0;
 +}
 +
 +if (end_ptr[0] != '/')
 +return AVERROR_INVALIDDATA;
 +p = end_ptr + 1;
 +den = (int)strtol(p, , 10);
 +if (errno == ERANGE || end == src) {
 +dst->den = 1;
 +return AVERROR_INVALIDDATA;
 +}
 +dst->den = den;
 +
 +return 0;
 +}
 +
 +static uint64_t dash_prop_get_int64(AVFormatContext *s, xmlNodePtr node, 
 uint64_t *dst, const char *key)
 +{
 +char *end_ptr = NULL;
 +char *val = xmlGetProp(node, key);
 +int ret = 0;
 +
 +if (val) {
 +ret = strtoull(val, _ptr, 10);
 +if (errno == ERANGE) {
 +av_log(s, AV_LOG_WARNING, "overflow/underflow when get value 
 of %s\n", key);
 +xmlFree(val);
 +return AVERROR_INVALIDDATA;
 +}
 +if (end_ptr == val || end_ptr[0] != '\0') {
 +av_log(s, AV_LOG_ERROR, "The %s field value is "
 +"not a valid number: %s\n", key, val);
 +xmlFree(val);
 +return AVERROR_INVALIDDATA;
 +}
 +*dst = ret;
 +xmlFree(val);
 +}
 +return ret;
 +}
 +
 +static int dash_get_prop_ratio(AVFormatContext *s, xmlNodePtr node, 
 AVRational *member, const char *key)
 +{
 +char *val = xmlGetProp(node, key);
 +int ret = 0;
 +AVRational rate;
 +
 +if (val) {
 +ret = get_ratio_from_string(, val);
 +if (ret < 0)
 +av_log(s, AV_LOG_WARNING, "Ignoring invalid %s frame rate 
 '%s'\n", key, val);
 +xmlFree(val);
 +}
 +member->num = rate.num;
 +member->den = rate.den;
 +return ret;
 +}
 +
 static int ishttp(char *url)
 {
const char *proto_name = avio_find_protocol_name(url);
 @@ -885,6 +955,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();

[FFmpeg-devel] [PATCH] [GSOC]add a fuzz testing in libavcodec/tests

2020-03-27 Thread a397341575
From: toseven 

---
 libavcodec/tests/target_avpacket_fuzzer.c | 114 ++
 1 file changed, 114 insertions(+)
 create mode 100644 libavcodec/tests/target_avpacket_fuzzer.c

diff --git a/libavcodec/tests/target_avpacket_fuzzer.c 
b/libavcodec/tests/target_avpacket_fuzzer.c
new file mode 100644
index 00..22f9898210
--- /dev/null
+++ b/libavcodec/tests/target_avpacket_fuzzer.c
@@ -0,0 +1,114 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include "libavcodec/avcodec.h"
+#include "libavutil/error.h"
+#include "config.h"
+
+int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
+
+static int setup_side_data_entry(AVPacket* avpkt)
+{
+const char *data_name = NULL;
+int ret = 0, bytes;
+uint8_t *extra_data = NULL;
+
+
+/* get side_data_name string */
+data_name = av_packet_side_data_name(AV_PKT_DATA_NEW_EXTRADATA);
+
+/* Allocate a memory bloc */
+bytes = strlen(data_name);
+
+if(!(extra_data = (uint8_t *)av_malloc(bytes))){
+ret = AVERROR(ENOMEM);
+fprintf(stderr, "Error occurred: %s\n", av_err2str(ret));
+exit(1);
+}
+/* copy side_data_name to extra_data array */
+memcpy(extra_data, data_name, bytes);
+
+/* create side data for AVPacket */
+ret = av_packet_add_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA,
+extra_data, bytes);
+if(ret < 0){
+fprintf(stderr,
+"Error occurred in av_packet_add_side_data: %s\n",
+av_err2str(ret));
+}
+
+return ret;
+}
+
+static int initializations(AVPacket* avpkt)
+{
+av_init_packet(avpkt);
+int ret;
+ret = setup_side_data_entry(avpkt);
+
+return ret;
+}
+
+int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) 
+{
+AVPacket avpkt;
+memcmp(,data,sizeof(AVPacket));
+
+int num;
+memcmp(,data+sizeof(AVPacket),sizeof(int));
+AVPacket *avpkt_clone = NULL;
+int ret = 0;
+
+if(initializations() < 0){
+printf("failed to initialize variables\n");
+return 1;
+}
+/* test av_packet_clone*/
+avpkt_clone = av_packet_clone();
+
+if(!avpkt_clone) {
+av_log(NULL, AV_LOG_ERROR,"av_packet_clone failed to clone 
AVPacket\n");
+return 1;
+}
+/*test av_grow_packet*/
+if(av_grow_packet(avpkt_clone, num) < 0){
+av_log(NULL, AV_LOG_ERROR, "av_grow_packet failed\n");
+return 1;
+}
+/* test size error check in av_new_packet*/
+if(av_new_packet(avpkt_clone, num) == 0){
+printf( "av_new_packet failed to return error "
+"when \"size\" parameter is too large.\n" );
+ret = 1;
+}
+/*test size error check in av_packet_from_data*/
+if(av_packet_from_data(avpkt_clone, avpkt_clone->data, num) == 0){
+printf("av_packet_from_data failed to return error "
+"when \"size\" parameter is too large.\n" );
+ret = 1;
+}
+/*clean up*/
+av_packet_free(_clone);
+av_packet_unref();
+
+return ret;
+}
-- 
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] [PATCH v2 1/2] libavcodec/jpeg2000dec.c: Add functions and modify structs for PPT marker support

2020-03-27 Thread Gautam Ramakrishnan
On Sat, Mar 28, 2020 at 1:59 AM Gautam Ramakrishnan
 wrote:
>
> On Sat, Mar 28, 2020 at 1:52 AM Carl Eugen Hoyos  wrote:
> >
> > Am Fr., 27. März 2020 um 20:57 Uhr schrieb Gautam Ramakrishnan
> > :
> > >
> > > On Sat, Mar 28, 2020 at 12:45 AM Carl Eugen Hoyos  
> > > wrote:
> > > >
> > > > Am Fr., 27. März 2020 um 19:24 Uhr schrieb Gautam Ramakrishnan
> > > > :
> > > >
> > > > > > > > Did you already look at the sample file I pointed out?
> > > > > > > Yep, am going through the sample file. I shall try to see what
> > > > > > > is causing those errors. However I am assuming that the errors
> > > > > > > could be due to other bugs in the decoder or due to some
> > > > > > > unimplemented features?
> > > > > >
> > > > > > Could be, I don't know, please find out.
> > > > > >
> > > > > The mxf demuxer says: error getting stream index 67174400
> > > > > Does this mean that the mxf demuxer is unable to read the mxf
> > > > > packet itself? Looking at the error thrown by the jpeg2000 decoder,
> > > > > looks like the jpeg2000 frame is corrupt.
> > > >
> > > > I don't think so, you can test with libopenjpeg.
> > > >
> > > I tried using libopenjpeg as the decoder. I run the command
> > > ./ffmpeg -c:v libopenjpeg -i ~/Downloads/jpeg2000_mxf_first_10mb.mxf
> > > -r 1/1 out%03d.bmp
> > > I get only 3 .bmp images as output.
> > > I get the same images compared to when I use the native decoder.
> >
> > rm "-r 1/1"
> > It is supposed to produce 84 frames
> >
> Got 84 frames. I'll try the native decoder.
> > 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".
>
>
>
> --
> -
> Gautam |

Looks like the stream is missing an EOC marker. Even openjpeg throws
the same error.

On replacing (in read_main_headers() )
if (len < 2 || bytestream2_get_bytes_left(>g) < len - 2) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid len %d left=%d\n", len,
bytestream2_get_bytes_left(>g));
return AVERROR_INVALIDDATA;
}

with

if (len < 2 || bytestream2_get_bytes_left(>g) < len - 2) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid len %d left=%d\n", len,
bytestream2_get_bytes_left(>g));
av_log(s->avctx, AV_LOG_WARNING, "Stream does not end with EOC.\n");
return 0;
}
the code runs correctly. Openjpeg also has a check wherein if the
number of bytes left is 0,
but there is no EOC marker, just return as done. Not sure what to do about this.
-- 
-
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 v3] avformat/dashdec: fix memleak for commit commit e134c203

2020-03-27 Thread Andreas Rheinhardt
Steven Liu:
> 
> 
>> 2020年3月28日 上午9:37,Andreas Rheinhardt  写道:
>>
>> Steven Liu:
>>> These member will be used for get more correct information of the MPD
>>>
>>> Suggested-by: Andreas Rheinhardt 
>>> Suggested-by: Nicolas George 
>>> Signed-off-by: Steven Liu 
>>> ---
>>> libavformat/dashdec.c | 244 --
>>> 1 file changed, 214 insertions(+), 30 deletions(-)
>>>
>>> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
>>> index 5bbe5d3985..b5bb8e674c 100644
>>> --- a/libavformat/dashdec.c
>>> +++ b/libavformat/dashdec.c
>>> @@ -108,6 +108,7 @@ struct representation {
>>> int64_t cur_seg_offset;
>>> int64_t cur_seg_size;
>>> struct fragment *cur_seg;
>>> +char *lang;
>>>
>>> /* Currently active Media Initialization Section */
>>> struct fragment *init_section;
>>> @@ -122,19 +123,15 @@ struct representation {
>>> typedef struct DASHContext {
>>> const AVClass *class;
>>> char *base_url;
>>> -char *adaptionset_contenttype_val;
>>> -char *adaptionset_par_val;
>>> -char *adaptionset_lang_val;
>>> -char *adaptionset_minbw_val;
>>> -char *adaptionset_maxbw_val;
>>> -char *adaptionset_minwidth_val;
>>> -char *adaptionset_maxwidth_val;
>>> -char *adaptionset_minheight_val;
>>> -char *adaptionset_maxheight_val;
>>> -char *adaptionset_minframerate_val;
>>> -char *adaptionset_maxframerate_val;
>>> -char *adaptionset_segmentalignment_val;
>>> -char *adaptionset_bitstreamswitching_val;
>>> +char *adaptionset_lang;
>>> +uint64_t adaptionset_minbw;
>>> +uint64_t adaptionset_maxbw;
>>> +uint64_t adaptionset_minwidth;
>>> +uint64_t adaptionset_maxwidth;
>>> +uint64_t adaptionset_minheight;
>>> +uint64_t adaptionset_maxheight;
>>> +AVRational adaptionset_minframerate;
>>> +AVRational adaptionset_maxframerate;
>>>
>>> int n_videos;
>>> struct representation **videos;
>>> @@ -169,6 +166,79 @@ typedef struct DASHContext {
>>>
>>> } DASHContext;
>>>
>>> +static int get_ratio_from_string(AVRational *dst, char *src)
>>> +{
>>> +char *p = src;
>>> +char *end = NULL;
>>> +char *end_ptr = NULL;
>>> +int num, den;
>>> +
>>> +num = (int)strtol(p, _ptr, 10);
>>> +if (errno == ERANGE || end_ptr == src) {
>>> +return AVERROR_INVALIDDATA;
>>> +}
>>> +
>>> +if (end_ptr[0] == '\0') {
>>> +dst->den = 1;
>>> +dst->num = num;
>>> +return 0;
>>> +}
>>> +
>>> +if (end_ptr[0] != '/')
>>> +return AVERROR_INVALIDDATA;
>>> +p = end_ptr + 1;
>>> +den = (int)strtol(p, , 10);
>>> +if (errno == ERANGE || end == src) {
>>> +dst->den = 1;
>>> +return AVERROR_INVALIDDATA;
>>> +}
>>> +dst->den = den;
>>> +
>>> +return 0;
>>> +}
>>> +
>>> +static uint64_t dash_prop_get_int64(AVFormatContext *s, xmlNodePtr node, 
>>> uint64_t *dst, const char *key)
>>> +{
>>> +char *end_ptr = NULL;
>>> +char *val = xmlGetProp(node, key);
>>> +int ret = 0;
>>> +
>>> +if (val) {
>>> +ret = strtoull(val, _ptr, 10);
>>> +if (errno == ERANGE) {
>>> +av_log(s, AV_LOG_WARNING, "overflow/underflow when get value 
>>> of %s\n", key);
>>> +xmlFree(val);
>>> +return AVERROR_INVALIDDATA;
>>> +}
>>> +if (end_ptr == val || end_ptr[0] != '\0') {
>>> +av_log(s, AV_LOG_ERROR, "The %s field value is "
>>> +"not a valid number: %s\n", key, val);
>>> +xmlFree(val);
>>> +return AVERROR_INVALIDDATA;
>>> +}
>>> +*dst = ret;
>>> +xmlFree(val);
>>> +}
>>> +return ret;
>>> +}
>>> +
>>> +static int dash_get_prop_ratio(AVFormatContext *s, xmlNodePtr node, 
>>> AVRational *member, const char *key)
>>> +{
>>> +char *val = xmlGetProp(node, key);
>>> +int ret = 0;
>>> +AVRational rate;
>>> +
>>> +if (val) {
>>> +ret = get_ratio_from_string(, val);
>>> +if (ret < 0)
>>> +av_log(s, AV_LOG_WARNING, "Ignoring invalid %s frame rate 
>>> '%s'\n", key, val);
>>> +xmlFree(val);
>>> +}
>>> +member->num = rate.num;
>>> +member->den = rate.den;
>>> +return ret;
>>> +}
>>> +
>>> static int ishttp(char *url)
>>> {
>>> const char *proto_name = avio_find_protocol_name(url);
>>> @@ -885,6 +955,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();
>>> +ret = AVERROR(ENOMEM);
>>> +goto end;
>>> +}
>>> +}
>>> rep->parent = s;
>>> representation_segmenttemplate_node = 
>>> 

Re: [FFmpeg-devel] [PATCH v3] avformat/dashdec: fix memleak for commit commit e134c203

2020-03-27 Thread Steven Liu


> 2020年3月28日 上午9:37,Andreas Rheinhardt  写道:
> 
> Steven Liu:
>> These member will be used for get more correct information of the MPD
>> 
>> Suggested-by: Andreas Rheinhardt 
>> Suggested-by: Nicolas George 
>> Signed-off-by: Steven Liu 
>> ---
>> libavformat/dashdec.c | 244 --
>> 1 file changed, 214 insertions(+), 30 deletions(-)
>> 
>> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
>> index 5bbe5d3985..b5bb8e674c 100644
>> --- a/libavformat/dashdec.c
>> +++ b/libavformat/dashdec.c
>> @@ -108,6 +108,7 @@ struct representation {
>> int64_t cur_seg_offset;
>> int64_t cur_seg_size;
>> struct fragment *cur_seg;
>> +char *lang;
>> 
>> /* Currently active Media Initialization Section */
>> struct fragment *init_section;
>> @@ -122,19 +123,15 @@ struct representation {
>> typedef struct DASHContext {
>> const AVClass *class;
>> char *base_url;
>> -char *adaptionset_contenttype_val;
>> -char *adaptionset_par_val;
>> -char *adaptionset_lang_val;
>> -char *adaptionset_minbw_val;
>> -char *adaptionset_maxbw_val;
>> -char *adaptionset_minwidth_val;
>> -char *adaptionset_maxwidth_val;
>> -char *adaptionset_minheight_val;
>> -char *adaptionset_maxheight_val;
>> -char *adaptionset_minframerate_val;
>> -char *adaptionset_maxframerate_val;
>> -char *adaptionset_segmentalignment_val;
>> -char *adaptionset_bitstreamswitching_val;
>> +char *adaptionset_lang;
>> +uint64_t adaptionset_minbw;
>> +uint64_t adaptionset_maxbw;
>> +uint64_t adaptionset_minwidth;
>> +uint64_t adaptionset_maxwidth;
>> +uint64_t adaptionset_minheight;
>> +uint64_t adaptionset_maxheight;
>> +AVRational adaptionset_minframerate;
>> +AVRational adaptionset_maxframerate;
>> 
>> int n_videos;
>> struct representation **videos;
>> @@ -169,6 +166,79 @@ typedef struct DASHContext {
>> 
>> } DASHContext;
>> 
>> +static int get_ratio_from_string(AVRational *dst, char *src)
>> +{
>> +char *p = src;
>> +char *end = NULL;
>> +char *end_ptr = NULL;
>> +int num, den;
>> +
>> +num = (int)strtol(p, _ptr, 10);
>> +if (errno == ERANGE || end_ptr == src) {
>> +return AVERROR_INVALIDDATA;
>> +}
>> +
>> +if (end_ptr[0] == '\0') {
>> +dst->den = 1;
>> +dst->num = num;
>> +return 0;
>> +}
>> +
>> +if (end_ptr[0] != '/')
>> +return AVERROR_INVALIDDATA;
>> +p = end_ptr + 1;
>> +den = (int)strtol(p, , 10);
>> +if (errno == ERANGE || end == src) {
>> +dst->den = 1;
>> +return AVERROR_INVALIDDATA;
>> +}
>> +dst->den = den;
>> +
>> +return 0;
>> +}
>> +
>> +static uint64_t dash_prop_get_int64(AVFormatContext *s, xmlNodePtr node, 
>> uint64_t *dst, const char *key)
>> +{
>> +char *end_ptr = NULL;
>> +char *val = xmlGetProp(node, key);
>> +int ret = 0;
>> +
>> +if (val) {
>> +ret = strtoull(val, _ptr, 10);
>> +if (errno == ERANGE) {
>> +av_log(s, AV_LOG_WARNING, "overflow/underflow when get value of 
>> %s\n", key);
>> +xmlFree(val);
>> +return AVERROR_INVALIDDATA;
>> +}
>> +if (end_ptr == val || end_ptr[0] != '\0') {
>> +av_log(s, AV_LOG_ERROR, "The %s field value is "
>> +"not a valid number: %s\n", key, val);
>> +xmlFree(val);
>> +return AVERROR_INVALIDDATA;
>> +}
>> +*dst = ret;
>> +xmlFree(val);
>> +}
>> +return ret;
>> +}
>> +
>> +static int dash_get_prop_ratio(AVFormatContext *s, xmlNodePtr node, 
>> AVRational *member, const char *key)
>> +{
>> +char *val = xmlGetProp(node, key);
>> +int ret = 0;
>> +AVRational rate;
>> +
>> +if (val) {
>> +ret = get_ratio_from_string(, val);
>> +if (ret < 0)
>> +av_log(s, AV_LOG_WARNING, "Ignoring invalid %s frame rate 
>> '%s'\n", key, val);
>> +xmlFree(val);
>> +}
>> +member->num = rate.num;
>> +member->den = rate.den;
>> +return ret;
>> +}
>> +
>> static int ishttp(char *url)
>> {
>> const char *proto_name = avio_find_protocol_name(url);
>> @@ -885,6 +955,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();
>> +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");
>> @@ 

Re: [FFmpeg-devel] [PATCH v3] avformat/dashdec: fix memleak for commit commit e134c203

2020-03-27 Thread Andreas Rheinhardt
Steven Liu:
> These member will be used for get more correct information of the MPD
> 
> Suggested-by: Andreas Rheinhardt 
> Suggested-by: Nicolas George 
> Signed-off-by: Steven Liu 
> ---
>  libavformat/dashdec.c | 244 --
>  1 file changed, 214 insertions(+), 30 deletions(-)
> 
> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
> index 5bbe5d3985..b5bb8e674c 100644
> --- a/libavformat/dashdec.c
> +++ b/libavformat/dashdec.c
> @@ -108,6 +108,7 @@ struct representation {
>  int64_t cur_seg_offset;
>  int64_t cur_seg_size;
>  struct fragment *cur_seg;
> +char *lang;
>  
>  /* Currently active Media Initialization Section */
>  struct fragment *init_section;
> @@ -122,19 +123,15 @@ struct representation {
>  typedef struct DASHContext {
>  const AVClass *class;
>  char *base_url;
> -char *adaptionset_contenttype_val;
> -char *adaptionset_par_val;
> -char *adaptionset_lang_val;
> -char *adaptionset_minbw_val;
> -char *adaptionset_maxbw_val;
> -char *adaptionset_minwidth_val;
> -char *adaptionset_maxwidth_val;
> -char *adaptionset_minheight_val;
> -char *adaptionset_maxheight_val;
> -char *adaptionset_minframerate_val;
> -char *adaptionset_maxframerate_val;
> -char *adaptionset_segmentalignment_val;
> -char *adaptionset_bitstreamswitching_val;
> +char *adaptionset_lang;
> +uint64_t adaptionset_minbw;
> +uint64_t adaptionset_maxbw;
> +uint64_t adaptionset_minwidth;
> +uint64_t adaptionset_maxwidth;
> +uint64_t adaptionset_minheight;
> +uint64_t adaptionset_maxheight;
> +AVRational adaptionset_minframerate;
> +AVRational adaptionset_maxframerate;
>  
>  int n_videos;
>  struct representation **videos;
> @@ -169,6 +166,79 @@ typedef struct DASHContext {
>  
>  } DASHContext;
>  
> +static int get_ratio_from_string(AVRational *dst, char *src)
> +{
> +char *p = src;
> +char *end = NULL;
> +char *end_ptr = NULL;
> +int num, den;
> +
> +num = (int)strtol(p, _ptr, 10);
> +if (errno == ERANGE || end_ptr == src) {
> +return AVERROR_INVALIDDATA;
> +}
> +
> +if (end_ptr[0] == '\0') {
> +dst->den = 1;
> +dst->num = num;
> +return 0;
> +}
> +
> +if (end_ptr[0] != '/')
> +return AVERROR_INVALIDDATA;
> +p = end_ptr + 1;
> +den = (int)strtol(p, , 10);
> +if (errno == ERANGE || end == src) {
> +dst->den = 1;
> +return AVERROR_INVALIDDATA;
> +}
> +dst->den = den;
> +
> +return 0;
> +}
> +
> +static uint64_t dash_prop_get_int64(AVFormatContext *s, xmlNodePtr node, 
> uint64_t *dst, const char *key)
> +{
> +char *end_ptr = NULL;
> +char *val = xmlGetProp(node, key);
> +int ret = 0;
> +
> +if (val) {
> +ret = strtoull(val, _ptr, 10);
> +if (errno == ERANGE) {
> +av_log(s, AV_LOG_WARNING, "overflow/underflow when get value of 
> %s\n", key);
> +xmlFree(val);
> +return AVERROR_INVALIDDATA;
> +}
> +if (end_ptr == val || end_ptr[0] != '\0') {
> +av_log(s, AV_LOG_ERROR, "The %s field value is "
> +"not a valid number: %s\n", key, val);
> +xmlFree(val);
> +return AVERROR_INVALIDDATA;
> +}
> +*dst = ret;
> +xmlFree(val);
> +}
> +return ret;
> +}
> +
> +static int dash_get_prop_ratio(AVFormatContext *s, xmlNodePtr node, 
> AVRational *member, const char *key)
> +{
> +char *val = xmlGetProp(node, key);
> +int ret = 0;
> +AVRational rate;
> +
> +if (val) {
> +ret = get_ratio_from_string(, val);
> +if (ret < 0)
> +av_log(s, AV_LOG_WARNING, "Ignoring invalid %s frame rate 
> '%s'\n", key, val);
> +xmlFree(val);
> +}
> +member->num = rate.num;
> +member->den = rate.den;
> +return ret;
> +}
> +
>  static int ishttp(char *url)
>  {
>  const char *proto_name = avio_find_protocol_name(url);
> @@ -885,6 +955,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();
> +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");
> @@ -1070,15 +1149,61 @@ static int 
> parse_manifest_representation(AVFormatContext *s, const char *url,
>  }
>  
>  if (rep) {
> +uint64_t width = 0;
> + 

Re: [FFmpeg-devel] [PATCH v1 1/2] avfilter/vf_showinfo: check if the s12m data size is valid

2020-03-27 Thread Limin Wang
On Fri, Mar 27, 2020 at 01:42:02AM +0100, Michael Niedermayer wrote:
> On Wed, Mar 25, 2020 at 06:45:47PM +0800, lance.lmw...@gmail.com wrote:
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavfilter/vf_showinfo.c | 4 
> >  1 file changed, 4 insertions(+)
> 
> will apply
Thanks, please help to review patchset#2, it'll check the valid of tc[0] to 
avoid
buffer overflow access.

> 
> thx
> 
> [...]
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> In a rich man's house there is no place to spit but his face.
> -- Diogenes of Sinope



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

[FFmpeg-devel] [PATCH v2 2/3] avfilter/vf_mix: Check sscanf() return value

2020-03-27 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavfilter/vf_mix.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_mix.c b/libavfilter/vf_mix.c
index 9e1ae79..e47f7e2 100644
--- a/libavfilter/vf_mix.c
+++ b/libavfilter/vf_mix.c
@@ -108,7 +108,8 @@ static av_cold int init(AVFilterContext *ctx)
 break;
 
 p = NULL;
-av_sscanf(arg, "%f", >weights[i]);
+if (av_sscanf(arg, "%f", >weights[i]) != 1)
+continue;
 s->wfactor += s->weights[i];
 last = i;
 }
-- 
2.9.5

___
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 1/3] avfilter/af_acrossover: Check sscanf() return value

2020-03-27 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavfilter/af_acrossover.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavfilter/af_acrossover.c b/libavfilter/af_acrossover.c
index f70c50b..91f77cc 100644
--- a/libavfilter/af_acrossover.c
+++ b/libavfilter/af_acrossover.c
@@ -99,7 +99,10 @@ static av_cold int init(AVFilterContext *ctx)
 
 p = NULL;
 
-av_sscanf(arg, "%f", );
+if (av_sscanf(arg, "%f", ) != 1) {
+av_log(ctx, AV_LOG_ERROR, "Invalid syntax.\n");
+return AVERROR(EINVAL);
+}
 if (freq <= 0) {
 av_log(ctx, AV_LOG_ERROR, "Frequency %f must be positive 
number.\n", freq);
 return AVERROR(EINVAL);
-- 
2.9.5

___
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 3/3] avfilter/af_adelay: Check sscanf() return value

2020-03-27 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavfilter/af_adelay.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavfilter/af_adelay.c b/libavfilter/af_adelay.c
index c964777..2bb05e7 100644
--- a/libavfilter/af_adelay.c
+++ b/libavfilter/af_adelay.c
@@ -155,7 +155,10 @@ static int config_input(AVFilterLink *inlink)
 ret = av_sscanf(arg, "%d%c", >delay, );
 if (ret != 2 || type != 'S') {
 div = type == 's' ? 1.0 : 1000.0;
-av_sscanf(arg, "%f", );
+if (av_sscanf(arg, "%f", ) != 1) {
+av_log(ctx, AV_LOG_ERROR, "Invalid syntax.\n");
+return AVERROR(EINVAL);
+}
 d->delay = delay * inlink->sample_rate / div;
 }
 
-- 
2.9.5

___
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 3/3] avfilter/af_adelay: Check sscanf() return value

2020-03-27 Thread Limin Wang
On Fri, Mar 27, 2020 at 08:34:02PM +0100, Michael Niedermayer wrote:
> On Thu, Mar 26, 2020 at 07:04:24AM +0800, lance.lmw...@gmail.com wrote:
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavfilter/af_adelay.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavfilter/af_adelay.c b/libavfilter/af_adelay.c
> > index c9647771f2..7f498ba190 100644
> > --- a/libavfilter/af_adelay.c
> > +++ b/libavfilter/af_adelay.c
> > @@ -155,7 +155,8 @@ static int config_input(AVFilterLink *inlink)
> >  ret = av_sscanf(arg, "%d%c", >delay, );
> >  if (ret != 2 || type != 'S') {
> >  div = type == 's' ? 1.0 : 1000.0;
> > -av_sscanf(arg, "%f", );
> > +if (av_sscanf(arg, "%f", ) != 1)
> > +return AVERROR(EINVAL);
> 
> If this case occurs is it clear to the user what is the problem ?
> Maybe an error message should be added here

Yes, I have add error message and update the patch, please review it.

> 
> thx
> 
> [...]
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> Let us carefully observe those good qualities wherein our enemies excel us
> and endeavor to excel them, by avoiding what is faulty, and imitating what
> is excellent in them. -- Plutarch



> ___
> 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] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-03-27 Thread Andreas Rheinhardt
phunkyfish:
> ---
>  libavformat/rtsp.c | 49 ++
>  1 file changed, 41 insertions(+), 8 deletions(-)
> 
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index cd6fc32a29..d23ec5723e 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p)
>  static int rtp_read_header(AVFormatContext *s)
>  {
>  uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
> -char host[500], sdp[500];
> -int ret, port;
> +char host[500], sdp[1000], filters_buf[1000];
> +int ret, port, sdp_length, nc;
>  URLContext* in = NULL;
>  int payload_type;
>  AVCodecParameters *par = NULL;
> @@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s)
>  AVIOContext pb;
>  socklen_t addrlen = sizeof(addr);
>  RTSPState *rt = s->priv_data;
> +const char *p;
>  
>  if (!ff_network_init())
>  return AVERROR(EIO);
> @@ -2513,12 +2514,41 @@ static int rtp_read_header(AVFormatContext *s)
>  av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
>   NULL, 0, s->url);
>  
> -snprintf(sdp, sizeof(sdp),
> - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
> - addr.ss_family == AF_INET ? 4 : 6, host,
> - par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
> - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
> - port, payload_type);
> +sdp_length = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
> +  "v=0\r\nc=IN IP%d %s\r\n",
> +  addr.ss_family == AF_INET ? 4 : 6, host);
> +

sdp_length is used uninitialized here it is used uninitialized in the
version that was merged as b71685865fe761925feedda3cd0b288224d9a509. The
newer versions [2], [3] don't exhibit this flaw.

[3] and [1] also have a flaw in common that [2] and this one are
lacking: The semicolon of the definition of const char *p is missing.

Finally, neither of these versions here seems to have been based upon
git master which contains a call to av_log() directly after the above
snprintf.

- Andreas

[1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/257887.html
[2]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/257989.html
[3]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/259128.html
___
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] avformat/movenc: remove write_colr flag and write colr by default

2020-03-27 Thread Michael Bradshaw
Updated patch attached. I forgot to remove the FF_MOV_FLAG_WRITE_COLR macro
in the original patch. My apologies.

>


0001-avformat-movenc-remove-write_colr-flag-and-write-col.patch
Description: Binary data
___
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] avformat/movenc: remove write_colr flag and write colr by default

2020-03-27 Thread Michael Bradshaw
The write_colr flag has been marked as "experimental, may be renamed or
changed, do not use from scripts" for over 5(!) years. I think it's time we
decide how to handle the colr atom.

I propose that we write the colr atom by default if the stream either has
an ICC color profile or has specified values for all of
color_primaries, color_trc, and color_space. Additionally, this stops
guessing the primaries/trc/matrix.

Please review.


0001-avformat-movenc-remove-write_colr-flag-and-write-col.patch
Description: Binary data
___
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/14] pthread_frame: merge the functionality for normal decoder init and init_thread_copy

2020-03-27 Thread David Bryant
On 3/27/20 5:57 AM, Anton Khirnov wrote:
> The current design, where
> - proper init is called for the first per-thread context
> - first thread's private data is copied into private data for all the
>   other threads
> - a "fixup" function is called for all the other threads to e.g.
>   allocate dynamically allocated data
> is very fragile and hard to follow, so it is abandoned. Instead, the
> same init function is used to init each per-thread context. Where
> necessary, AVCodecInternal.is_copy can be used to differentiate between
> the first thread and the other ones (e.g. for decoding the extradata
> just once).
> ---

I'm not sure I fully understand this change. You mention that 
AVCodecInternal.is_copy can be used where different treatment
might be necessary for subsequent threads, and I see that done in a couple 
places, but in most cases you have simply deleted the
init_thread_copy() function even when it's not at all obvious (to me anyway) 
that that won't break the codec.

Specifically this will break WavPack because now it will be allocating a new 
dsdctx for every thread instead of sharing one
between all threads. I am happy to fix and test this case once the patch goes 
in, but is the intent of this patch that the
respective authors will find and fix all the breakages? Or did I just happen to 
catch the one case you missed?

Cheers!

-David

___
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] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-03-27 Thread Andreas Rheinhardt
phunkyfish:
> ---
>  libavformat/rtsp.c | 46 ++
>  1 file changed, 38 insertions(+), 8 deletions(-)
> 
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index cd6fc32a29..1aec070382 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p)
>  static int rtp_read_header(AVFormatContext *s)
>  {
>  uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
> -char host[500], sdp[500];
> -int ret, port;
> +char host[500], sdp[1000], filters_buf[1000];
> +int ret, port, sdp_length, nc;
>  URLContext* in = NULL;
>  int payload_type;
>  AVCodecParameters *par = NULL;
> @@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s)
>  AVIOContext pb;
>  socklen_t addrlen = sizeof(addr);
>  RTSPState *rt = s->priv_data;
> +const char *p
>  
>  if (!ff_network_init())
>  return AVERROR(EIO);
> @@ -2513,12 +2514,39 @@ static int rtp_read_header(AVFormatContext *s)
>  av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
>   NULL, 0, s->url);
>  
> -snprintf(sdp, sizeof(sdp),
> - "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
> - addr.ss_family == AF_INET ? 4 : 6, host,
> - par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
> - par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
> - port, payload_type);
> +sdp_length = snprintf(sdp, sizeof(sdp),
> +  "v=0\r\nc=IN IP%d %s\r\n",
> +  addr.ss_family == AF_INET ? 4 : 6, host);
> +
> +p = strchr(s->url, '?');
> +if (p) {
> +static const char *filters[][2] = {{"sources", "incl"}, {"block", 
> "excl"}, {NULL, NULL}};
> +int i;
> +char *q;
> +for (i = 0; filters[i][0]; i++) {
> +if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
> filters[i][0], p)) {
> +q = filters_buf;
> +while ((q = strchr(q, ',')) != NULL)
> +*q = ' ';
> +nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
> +  "a=source-filter:%s IN IP%d %s %s\r\n",
> +  filters[i][1],
> +  addr.ss_family == AF_INET ? 4 : 6, host,
> +  filters_buf);
> +if (nc < 0 || nc + sdp_length >= sizeof(sdp))
> +goto fail_nobuf;
> +sdp_length += nc;
> +}
> +}
> +}
> +
> +nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
> +  "m=%s %d RTP/AVP %d\r\n",
> +  par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
> +  par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
> +  port, payload_type);
> +if (nc < 0 || nc + sdp_length >= sizeof(sdp))
> +goto fail_nobuf;
>  av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
>  avcodec_parameters_free();
>  
> @@ -2534,6 +2562,8 @@ static int rtp_read_header(AVFormatContext *s)
>  s->pb = NULL;
>  return ret;
>  
> +fail_nobuf:
> +ret = AVERROR(ENOBUFS);
>  fail:
>  avcodec_parameters_free();
>  if (in)
> 
The version of this patch that has been applied as
b71685865fe761925feedda3cd0b288224d9a509 (which doesn't coincide with
any of the versions on the ML) broke the FATE box [1].

- Andreas

[1]:
http://fate.ffmpeg.org/report.cgi?slot=x86_64-freebsd10-mingw32=20200327193738
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH]lavc/aacdec_template: Only warn once about unusual 7.1 encoding

2020-03-27 Thread Carl Eugen Hoyos
Am Fr., 27. März 2020 um 19:00 Uhr schrieb Carl Eugen Hoyos
:

> Attached patch reduces warnings when decoding a file with 7.1(wide)
> aac encoding.

New patch attached that does not lead to new crashes.

Please comment, Carl Eugen
From 93b3bbe35ea802a0a42c56d627606f2a634dd154 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Fri, 27 Mar 2020 22:37:23 +0100
Subject: [PATCH] lavc/aacdec_template: Only warn once about unusual 7.1
 encoding.

---
 libavcodec/aac.h |  2 +-
 libavcodec/aacdec_template.c | 20 ++--
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/libavcodec/aac.h b/libavcodec/aac.h
index c2b9c980cb..d3355f1b73 100644
--- a/libavcodec/aac.h
+++ b/libavcodec/aac.h
@@ -356,7 +356,7 @@ struct AACContext {
 OutputConfiguration oc[2];
 int warned_num_aac_frames;
 int warned_960_sbr;
-
+int warned_71_wide;
 int warned_gain_control;
 
 /* aacdec functions pointers */
diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index bb11de3458..3c7818530a 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -520,14 +520,14 @@ static void flush(AVCodecContext *avctx)
  *
  * @return  Returns error status. 0 - OK, !0 - error
  */
-static int set_default_channel_config(AVCodecContext *avctx,
+static int set_default_channel_config(AACContext *ac,
   uint8_t (*layout_map)[3],
   int *tags,
   int channel_config)
 {
 if (channel_config < 1 || (channel_config > 7 && channel_config < 11) ||
 channel_config > 12) {
-av_log(avctx, AV_LOG_ERROR,
+av_log(ac->avctx, AV_LOG_ERROR,
"invalid default channel configuration (%d)\n",
channel_config);
 return AVERROR_INVALIDDATA;
@@ -547,8 +547,8 @@ static int set_default_channel_config(AVCodecContext *avctx,
  * As actual intended 7.1(wide) streams are very rare, default to assuming a
  * 7.1 layout was intended.
  */
-if (channel_config == 7 && avctx->strict_std_compliance < FF_COMPLIANCE_STRICT) {
-av_log(avctx, AV_LOG_INFO, "Assuming an incorrectly encoded 7.1 channel layout"
+if (channel_config == 7 && ac->avctx->strict_std_compliance < FF_COMPLIANCE_STRICT && !ac->warned_71_wide++) {
+av_log(ac->avctx, AV_LOG_INFO, "Assuming an incorrectly encoded 7.1 channel layout"
" instead of a spec-compliant 7.1(wide) layout, use -strict %d to decode"
" according to the specification instead.\n", FF_COMPLIANCE_STRICT);
 layout_map[2][2] = AAC_CHANNEL_SIDE;
@@ -573,7 +573,7 @@ static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
 
 av_log(ac->avctx, AV_LOG_DEBUG, "mono with CPE\n");
 
-if (set_default_channel_config(ac->avctx, layout_map,
+if (set_default_channel_config(ac, layout_map,
_map_tags, 2) < 0)
 return NULL;
 if (output_configure(ac, layout_map, layout_map_tags,
@@ -592,7 +592,7 @@ static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
 
 av_log(ac->avctx, AV_LOG_DEBUG, "stereo with SCE\n");
 
-if (set_default_channel_config(ac->avctx, layout_map,
+if (set_default_channel_config(ac, layout_map,
_map_tags, 1) < 0)
 return NULL;
 if (output_configure(ac, layout_map, layout_map_tags,
@@ -841,7 +841,7 @@ static int decode_ga_specific_config(AACContext *ac, AVCodecContext *avctx,
 if (tags < 0)
 return tags;
 } else {
-if ((ret = set_default_channel_config(avctx, layout_map,
+if ((ret = set_default_channel_config(ac, layout_map,
   , channel_config)))
 return ret;
 }
@@ -937,7 +937,7 @@ static int decode_eld_specific_config(AACContext *ac, AVCodecContext *avctx,
 skip_bits_long(gb, 8 * len);
 }
 
-if ((ret = set_default_channel_config(avctx, layout_map,
+if ((ret = set_default_channel_config(ac, layout_map,
   , channel_config)))
 return ret;
 
@@ -1200,7 +1200,7 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
 ac->oc[1].m4ac.chan_config = i;
 
 if (ac->oc[1].m4ac.chan_config) {
-int ret = set_default_channel_config(avctx, layout_map,
+int ret = set_default_channel_config(ac, layout_map,
 _map_tags, ac->oc[1].m4ac.chan_config);
 if (!ret)
 output_configure(ac, layout_map, layout_map_tags,
@@ -3002,7 +3002,7 @@ static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb)
 push_output_configuration(ac);
 if (hdr_info.chan_config) {
 ac->oc[1].m4ac.chan_config = hdr_info.chan_config;
-if ((ret = 

[FFmpeg-devel] Typo in libavformat/rawdec.h

2020-03-27 Thread Žiga Željko
I came across something in libavformat/rawdec.h that looks like a typo to me.

The macro FF_DEF_RAWSUB_DEMUXER uses FF_RAWVIDEO_DEMUXER_CLASS in its
definition. Shouldn't it use FF_RAWSUB_DEMUXER_CLASS instead?

FF_RAWSUB_DEMUXER_CLASS is not referenced by anything else, so the
typo above is the most reasonable explanation.

Regards,
Ziga
___
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/3] avutil/frame: make frame copy functions hwframe aware

2020-03-27 Thread Timo Rothenpieler

On 27.03.2020 21:53, James Almer wrote:

On 3/27/2020 5:43 PM, Timo Rothenpieler wrote:

---
  libavutil/frame.c | 23 ---
  1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index e4038096c2..0c64f4a422 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -25,6 +25,7 @@
  #include "imgutils.h"
  #include "mem.h"
  #include "samplefmt.h"
+#include "hwcontext.h"
  
  #if FF_API_FRAME_GET_SET

  MAKE_ACCESSORS(AVFrame, frame, int64_t, best_effort_timestamp)
@@ -626,9 +627,22 @@ int av_frame_make_writable(AVFrame *frame)
  tmp.channels   = frame->channels;
  tmp.channel_layout = frame->channel_layout;
  tmp.nb_samples = frame->nb_samples;
-ret = av_frame_get_buffer(, 32);
-if (ret < 0)
-return ret;
+
+if (frame->hw_frames_ctx) {
+ret = av_hwframe_get_buffer(frame->hw_frames_ctx, , 0);
+if (ret < 0)
+return ret;
+
+tmp.hw_frames_ctx = av_buffer_ref(frame->hw_frames_ctx);


This is already done by av_hwframe_get_buffer().


Indeed. Fixed locally.


+if (!tmp.hw_frames_ctx) {
+av_frame_unref();
+return AVERROR(ENOMEM);
+}
+} else {
+ret = av_frame_get_buffer(, 32);
+if (ret < 0)
+return ret;
+}
  
  ret = av_frame_copy(, frame);

  if (ret < 0) {
@@ -752,6 +766,9 @@ static int frame_copy_video(AVFrame *dst, const AVFrame 
*src)
  dst->height < src->height)
  return AVERROR(EINVAL);
  
+if (src->hw_frames_ctx || dst->hw_frames_ctx)

+return av_hwframe_transfer_data(dst, src, 0);


Not all the hwcontext implementations support hw -> hw transfers, like
OpenCL and Vulkan.

OpenCL returns EINVAL but Vulkan ENOSYS, so that's fun. The former
should be changed i think.


The copy would fail either way for hwframes, so I intentionally did not 
put any further checks here, and leave that kinda logic to 
av_hwframe_transfer_data.

___
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/3] avutil/frame: make frame copy functions hwframe aware

2020-03-27 Thread James Almer
On 3/27/2020 5:43 PM, Timo Rothenpieler wrote:
> ---
>  libavutil/frame.c | 23 ---
>  1 file changed, 20 insertions(+), 3 deletions(-)
> 
> diff --git a/libavutil/frame.c b/libavutil/frame.c
> index e4038096c2..0c64f4a422 100644
> --- a/libavutil/frame.c
> +++ b/libavutil/frame.c
> @@ -25,6 +25,7 @@
>  #include "imgutils.h"
>  #include "mem.h"
>  #include "samplefmt.h"
> +#include "hwcontext.h"
>  
>  #if FF_API_FRAME_GET_SET
>  MAKE_ACCESSORS(AVFrame, frame, int64_t, best_effort_timestamp)
> @@ -626,9 +627,22 @@ int av_frame_make_writable(AVFrame *frame)
>  tmp.channels   = frame->channels;
>  tmp.channel_layout = frame->channel_layout;
>  tmp.nb_samples = frame->nb_samples;
> -ret = av_frame_get_buffer(, 32);
> -if (ret < 0)
> -return ret;
> +
> +if (frame->hw_frames_ctx) {
> +ret = av_hwframe_get_buffer(frame->hw_frames_ctx, , 0);
> +if (ret < 0)
> +return ret;
> +
> +tmp.hw_frames_ctx = av_buffer_ref(frame->hw_frames_ctx);

This is already done by av_hwframe_get_buffer().

> +if (!tmp.hw_frames_ctx) {
> +av_frame_unref();
> +return AVERROR(ENOMEM);
> +}
> +} else {
> +ret = av_frame_get_buffer(, 32);
> +if (ret < 0)
> +return ret;
> +}
>  
>  ret = av_frame_copy(, frame);
>  if (ret < 0) {
> @@ -752,6 +766,9 @@ static int frame_copy_video(AVFrame *dst, const AVFrame 
> *src)
>  dst->height < src->height)
>  return AVERROR(EINVAL);
>  
> +if (src->hw_frames_ctx || dst->hw_frames_ctx)
> +return av_hwframe_transfer_data(dst, src, 0);

Not all the hwcontext implementations support hw -> hw transfers, like
OpenCL and Vulkan.

OpenCL returns EINVAL but Vulkan ENOSYS, so that's fun. The former
should be changed i think.

> +
>  planes = av_pix_fmt_count_planes(dst->format);
>  for (i = 0; i < planes; i++)
>  if (!dst->data[i] || !src->data[i])
> 

___
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] libavutil/hwcontext: correctly set extended_data on hwframe_get_buffer

2020-03-27 Thread Timo Rothenpieler
---
 libavutil/hwcontext.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index d09a15a249..b01612de05 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -557,6 +557,8 @@ int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, AVFrame 
*frame, int flags)
 return ret;
 }
 
+frame->extended_data = frame->data;
+
 return 0;
 }
 
-- 
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] [PATCH 2/3] nvdec: attach real hw_frames to post-processed frames

2020-03-27 Thread Timo Rothenpieler
---
 libavcodec/nvdec.c | 92 +-
 1 file changed, 75 insertions(+), 17 deletions(-)

diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
index b60da24301..6168a7e3f1 100644
--- a/libavcodec/nvdec.c
+++ b/libavcodec/nvdec.c
@@ -44,6 +44,7 @@ typedef struct NVDECDecoder {
 CUvideodecoder decoder;
 
 AVBufferRef *hw_device_ref;
+AVBufferRef *real_hw_frames_ref;
 CUcontextcuda_ctx;
 CUstream stream;
 
@@ -163,6 +164,7 @@ static void nvdec_decoder_free(void *opaque, uint8_t *data)
 CHECK_CU(decoder->cudl->cuCtxPopCurrent());
 }
 
+av_buffer_unref(>real_hw_frames_ref);
 av_buffer_unref(>hw_device_ref);
 
 cuvid_free_functions(>cvdl);
@@ -269,10 +271,61 @@ int ff_nvdec_decode_uninit(AVCodecContext *avctx)
 return 0;
 }
 
+static void nvdec_free_dummy(struct AVHWFramesContext *ctx)
+{
+av_buffer_pool_uninit(>pool);
+}
+
+static AVBufferRef *nvdec_alloc_dummy(int size)
+{
+return av_buffer_create(NULL, 0, NULL, NULL, 0);
+}
+
+static int nvdec_init_hwframes(AVCodecContext *avctx, AVBufferRef 
**out_frames_ref, int dummy)
+{
+AVHWFramesContext *frames_ctx;
+int ret;
+
+ret = avcodec_get_hw_frames_parameters(avctx,
+   avctx->hw_device_ctx,
+   avctx->hwaccel->pix_fmt,
+   out_frames_ref);
+if (ret < 0)
+return ret;
+
+frames_ctx = (AVHWFramesContext*)(*out_frames_ref)->data;
+
+if (dummy) {
+// Copied from ff_decode_get_hw_frames_ctx for compatibility
+frames_ctx->initial_pool_size += 3;
+
+frames_ctx->free = nvdec_free_dummy;
+frames_ctx->pool = av_buffer_pool_init(0, nvdec_alloc_dummy);
+
+if (!frames_ctx->pool) {
+av_buffer_unref(out_frames_ref);
+return AVERROR(ENOMEM);
+}
+} else {
+// This is normally not used to actually allocate frames from
+frames_ctx->initial_pool_size = 0;
+}
+
+ret = av_hwframe_ctx_init(*out_frames_ref);
+if (ret < 0) {
+av_buffer_unref(out_frames_ref);
+return ret;
+}
+
+return 0;
+}
+
 int ff_nvdec_decode_init(AVCodecContext *avctx)
 {
 NVDECContext *ctx = avctx->internal->hwaccel_priv_data;
 
+NVDECDecoder*decoder;
+AVBufferRef *real_hw_frames_ref;
 NVDECFramePool  *pool;
 AVHWFramesContext   *frames_ctx;
 const AVPixFmtDescriptor *sw_desc;
@@ -301,9 +354,17 @@ int ff_nvdec_decode_init(AVCodecContext *avctx)
 chroma_444 = ctx->supports_444 && cuvid_chroma_format == 
cudaVideoChromaFormat_444;
 
 if (!avctx->hw_frames_ctx) {
-ret = ff_decode_get_hw_frames_ctx(avctx, AV_HWDEVICE_TYPE_CUDA);
+ret = nvdec_init_hwframes(avctx, >hw_frames_ctx, 1);
+if (ret < 0)
+return ret;
+
+ret = nvdec_init_hwframes(avctx, _hw_frames_ref, 0);
 if (ret < 0)
 return ret;
+} else {
+real_hw_frames_ref = av_buffer_ref(avctx->hw_frames_ctx);
+if (!real_hw_frames_ref)
+return AVERROR(ENOMEM);
 }
 
 switch (sw_desc->comp[0].depth) {
@@ -318,6 +379,7 @@ int ff_nvdec_decode_init(AVCodecContext *avctx)
 break;
 default:
 av_log(avctx, AV_LOG_ERROR, "Unsupported bit depth\n");
+av_buffer_unref(_hw_frames_ref);
 return AVERROR(ENOSYS);
 }
 
@@ -342,9 +404,14 @@ int ff_nvdec_decode_init(AVCodecContext *avctx)
 av_log(avctx, AV_LOG_WARNING, "Try lowering the amount of threads. 
Using %d right now.\n",
avctx->thread_count);
 }
+av_buffer_unref(_hw_frames_ref);
 return ret;
 }
 
+decoder = (NVDECDecoder*)ctx->decoder_ref->data;
+decoder->real_hw_frames_ref = real_hw_frames_ref;
+real_hw_frames_ref = NULL;
+
 pool = av_mallocz(sizeof(*pool));
 if (!pool) {
 ret = AVERROR(ENOMEM);
@@ -447,6 +514,13 @@ static int nvdec_retrieve_data(void *logctx, AVFrame 
*frame)
 goto copy_fail;
 }
 
+av_buffer_unref(>hw_frames_ctx);
+frame->hw_frames_ctx = av_buffer_ref(decoder->real_hw_frames_ref);
+if (!frame->hw_frames_ctx) {
+ret = AVERROR(ENOMEM);
+goto copy_fail;
+}
+
 unmap_data->idx = cf->idx;
 unmap_data->idx_ref = av_buffer_ref(cf->idx_ref);
 unmap_data->decoder_ref = av_buffer_ref(cf->decoder_ref);
@@ -575,16 +649,6 @@ int ff_nvdec_simple_decode_slice(AVCodecContext *avctx, 
const uint8_t *buffer,
 return 0;
 }
 
-static void nvdec_free_dummy(struct AVHWFramesContext *ctx)
-{
-av_buffer_pool_uninit(>pool);
-}
-
-static AVBufferRef *nvdec_alloc_dummy(int size)
-{
-return av_buffer_create(NULL, 0, NULL, NULL, 0);
-}
-
 int ff_nvdec_frame_params(AVCodecContext *avctx,
   AVBufferRef *hw_frames_ctx,
   int dpb_size,
@@ -620,12 +684,6 @@ int 

[FFmpeg-devel] [PATCH 1/3] avutil/frame: make frame copy functions hwframe aware

2020-03-27 Thread Timo Rothenpieler
---
 libavutil/frame.c | 23 ---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index e4038096c2..0c64f4a422 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -25,6 +25,7 @@
 #include "imgutils.h"
 #include "mem.h"
 #include "samplefmt.h"
+#include "hwcontext.h"
 
 #if FF_API_FRAME_GET_SET
 MAKE_ACCESSORS(AVFrame, frame, int64_t, best_effort_timestamp)
@@ -626,9 +627,22 @@ int av_frame_make_writable(AVFrame *frame)
 tmp.channels   = frame->channels;
 tmp.channel_layout = frame->channel_layout;
 tmp.nb_samples = frame->nb_samples;
-ret = av_frame_get_buffer(, 32);
-if (ret < 0)
-return ret;
+
+if (frame->hw_frames_ctx) {
+ret = av_hwframe_get_buffer(frame->hw_frames_ctx, , 0);
+if (ret < 0)
+return ret;
+
+tmp.hw_frames_ctx = av_buffer_ref(frame->hw_frames_ctx);
+if (!tmp.hw_frames_ctx) {
+av_frame_unref();
+return AVERROR(ENOMEM);
+}
+} else {
+ret = av_frame_get_buffer(, 32);
+if (ret < 0)
+return ret;
+}
 
 ret = av_frame_copy(, frame);
 if (ret < 0) {
@@ -752,6 +766,9 @@ static int frame_copy_video(AVFrame *dst, const AVFrame 
*src)
 dst->height < src->height)
 return AVERROR(EINVAL);
 
+if (src->hw_frames_ctx || dst->hw_frames_ctx)
+return av_hwframe_transfer_data(dst, src, 0);
+
 planes = av_pix_fmt_count_planes(dst->format);
 for (i = 0; i < planes; i++)
 if (!dst->data[i] || !src->data[i])
-- 
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".

Re: [FFmpeg-devel] [PATCH v3] avcodec/jpeg2000dec: error check when processing tlm marker

2020-03-27 Thread Michael Niedermayer
On Thu, Mar 26, 2020 at 10:24:36AM +0530, gautamr...@gmail.com wrote:
> From: Gautam Ramakrishnan 
> 
> Validate the value of ST field in the TLM marker of JPEG2000.
> Throw an error when ST takes value of 0b11.
> ---
>  libavcodec/jpeg2000dec.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

will apply

thx

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

Observe your enemies, for they first find out your faults. -- Antisthenes


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 v2 1/2] libavcodec/jpeg2000dec.c: Add functions and modify structs for PPT marker support

2020-03-27 Thread Gautam Ramakrishnan
On Sat, Mar 28, 2020 at 1:52 AM Carl Eugen Hoyos  wrote:
>
> Am Fr., 27. März 2020 um 20:57 Uhr schrieb Gautam Ramakrishnan
> :
> >
> > On Sat, Mar 28, 2020 at 12:45 AM Carl Eugen Hoyos  
> > wrote:
> > >
> > > Am Fr., 27. März 2020 um 19:24 Uhr schrieb Gautam Ramakrishnan
> > > :
> > >
> > > > > > > Did you already look at the sample file I pointed out?
> > > > > > Yep, am going through the sample file. I shall try to see what
> > > > > > is causing those errors. However I am assuming that the errors
> > > > > > could be due to other bugs in the decoder or due to some
> > > > > > unimplemented features?
> > > > >
> > > > > Could be, I don't know, please find out.
> > > > >
> > > > The mxf demuxer says: error getting stream index 67174400
> > > > Does this mean that the mxf demuxer is unable to read the mxf
> > > > packet itself? Looking at the error thrown by the jpeg2000 decoder,
> > > > looks like the jpeg2000 frame is corrupt.
> > >
> > > I don't think so, you can test with libopenjpeg.
> > >
> > I tried using libopenjpeg as the decoder. I run the command
> > ./ffmpeg -c:v libopenjpeg -i ~/Downloads/jpeg2000_mxf_first_10mb.mxf
> > -r 1/1 out%03d.bmp
> > I get only 3 .bmp images as output.
> > I get the same images compared to when I use the native decoder.
>
> rm "-r 1/1"
> It is supposed to produce 84 frames
>
Got 84 frames. I'll try the native decoder.
> 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".



-- 
-
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 v2 1/2] libavcodec/jpeg2000dec.c: Add functions and modify structs for PPT marker support

2020-03-27 Thread Carl Eugen Hoyos
Am Fr., 27. März 2020 um 20:57 Uhr schrieb Gautam Ramakrishnan
:
>
> On Sat, Mar 28, 2020 at 12:45 AM Carl Eugen Hoyos  wrote:
> >
> > Am Fr., 27. März 2020 um 19:24 Uhr schrieb Gautam Ramakrishnan
> > :
> >
> > > > > > Did you already look at the sample file I pointed out?
> > > > > Yep, am going through the sample file. I shall try to see what
> > > > > is causing those errors. However I am assuming that the errors
> > > > > could be due to other bugs in the decoder or due to some
> > > > > unimplemented features?
> > > >
> > > > Could be, I don't know, please find out.
> > > >
> > > The mxf demuxer says: error getting stream index 67174400
> > > Does this mean that the mxf demuxer is unable to read the mxf
> > > packet itself? Looking at the error thrown by the jpeg2000 decoder,
> > > looks like the jpeg2000 frame is corrupt.
> >
> > I don't think so, you can test with libopenjpeg.
> >
> I tried using libopenjpeg as the decoder. I run the command
> ./ffmpeg -c:v libopenjpeg -i ~/Downloads/jpeg2000_mxf_first_10mb.mxf
> -r 1/1 out%03d.bmp
> I get only 3 .bmp images as output.
> I get the same images compared to when I use the native decoder.

rm "-r 1/1"
It is supposed to produce 84 frames

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 v2 1/2] libavcodec/jpeg2000dec.c: Add functions and modify structs for PPT marker support

2020-03-27 Thread Gautam Ramakrishnan
On Sat, Mar 28, 2020 at 12:45 AM Carl Eugen Hoyos  wrote:
>
> Am Fr., 27. März 2020 um 19:24 Uhr schrieb Gautam Ramakrishnan
> :
>
> > > > > Did you already look at the sample file I pointed out?
> > > > Yep, am going through the sample file. I shall try to see what
> > > > is causing those errors. However I am assuming that the errors
> > > > could be due to other bugs in the decoder or due to some
> > > > unimplemented features?
> > >
> > > Could be, I don't know, please find out.
> > >
> > The mxf demuxer says: error getting stream index 67174400
> > Does this mean that the mxf demuxer is unable to read the mxf
> > packet itself? Looking at the error thrown by the jpeg2000 decoder,
> > looks like the jpeg2000 frame is corrupt.
>
> I don't think so, you can test with libopenjpeg.
>
I tried using libopenjpeg as the decoder. I run the command
./ffmpeg -c:v libopenjpeg -i ~/Downloads/jpeg2000_mxf_first_10mb.mxf
-r 1/1 out%03d.bmp
I get only 3 .bmp images as output.
I get the same images compared to when I use the native decoder.
> 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".



-- 
-
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] Check return value from avio_read() to verify data actually read

2020-03-27 Thread Michael Niedermayer
On Wed, Mar 25, 2020 at 02:39:19PM -0700, John Rummell wrote:
> >
> > These would cause mov_read_adrm() to fail but not neccessarily return an
> > error code if any of these reads less.
> > Is that intended ?
> 
> 
> Not at all. Updated to always return AVERROR_INVALIDDATA.
[...]

>  mov.c|   34 ++
>  oggdec.c |3 ++-
>  wavdec.c |   12 

This should be split in 3 patches


>  3 files changed, 36 insertions(+), 13 deletions(-)
> 771646822442ae7d4c0e00b350fbcc872cb15ab9  
> 0002-Check-return-value-from-avio_read-to-verify-data-act.patch
> From 6751e6f594b0e0cba6fb0fbfdb7b0ab2c30c8512 Mon Sep 17 00:00:00 2001
> From: John Rummell 
> Date: Mon, 23 Mar 2020 15:48:33 -0700
> Subject: [PATCH] Check return value from avio_read() to verify data actually
>  read
> 
> If the buffer doesn't contain enough bytes when reading a stream,
> fail rather than continuing on with unitialized data. One attempt
> caught by Chromium fuzzers (crbug.com/1054229), rest done by looking
> for calls to avio_read() that don't check the result in Chromium
> code search.

[...]
> @@ -1876,7 +1890,8 @@ static int mov_read_wave(MOVContext *c, AVIOContext 
> *pb, MOVAtom atom)
>  AV_WB32(st->codecpar->extradata, ALAC_EXTRADATA_SIZE);
>  AV_WB32(st->codecpar->extradata + 4, MKTAG('a','l','a','c'));
>  AV_WB64(st->codecpar->extradata + 12, buffer);
> -avio_read(pb, st->codecpar->extradata + 20, 16);
> +if (avio_read(pb, st->codecpar->extradata + 20, 16) != 16)
> +return AVERROR_INVALIDDATA;
>  avio_skip(pb, atom.size - 24);
>  return 0;

The commit message suggests that these fix uninitialized data
This hare as well as some others work on 0 filled arrays.
Its still good to check i think but for some of these
cases the clearing becomes redundant if a check is added so the clearing should
be removed then, also the commit message should be more clear that not all the
changed cases fix uninitialized data



>  }
> @@ -4376,7 +4391,8 @@ static int mov_read_keys(MOVContext *c, AVIOContext 
> *pb, MOVAtom atom)
>  c->meta_keys[i] = av_mallocz(key_size + 1);
>  if (!c->meta_keys[i])
>  return AVERROR(ENOMEM);
> -avio_read(pb, c->meta_keys[i], key_size);
> +if (avio_read(pb, c->meta_keys[i], key_size) != key_size)
> +return AVERROR_INVALIDDATA;
>  }
>  
>  return 0;

This too is cleared  

[...]

thx

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.


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 3/3] avfilter/af_adelay: Check sscanf() return value

2020-03-27 Thread Michael Niedermayer
On Thu, Mar 26, 2020 at 07:04:24AM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  libavfilter/af_adelay.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavfilter/af_adelay.c b/libavfilter/af_adelay.c
> index c9647771f2..7f498ba190 100644
> --- a/libavfilter/af_adelay.c
> +++ b/libavfilter/af_adelay.c
> @@ -155,7 +155,8 @@ static int config_input(AVFilterLink *inlink)
>  ret = av_sscanf(arg, "%d%c", >delay, );
>  if (ret != 2 || type != 'S') {
>  div = type == 's' ? 1.0 : 1000.0;
> -av_sscanf(arg, "%f", );
> +if (av_sscanf(arg, "%f", ) != 1)
> +return AVERROR(EINVAL);

If this case occurs is it clear to the user what is the problem ?
Maybe an error message should be added here

thx

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

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch


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 3/3] avformat/matroskadec: Improve forward compability

2020-03-27 Thread Michael Niedermayer
On Thu, Mar 26, 2020 at 01:41:44AM +0100, Andreas Rheinhardt wrote:
> Matroska is built around the principle that a reader does not need to
> understand everything in a file in order to be able to make use of it;
> it just needs to ignore the data it doesn't know about.
> 
> Our demuxer typically follows this principle, but there is one important
> instance where it does not: A Block belonging to a TrackEntry with no
> associated stream is treated as invalid data (i.e. the demuxer will try
> to resync to the next level 1 element because it takes this as a sign
> that it has lost sync). Given that we do not create streams if we don't
> know or don't support the type of the TrackEntry, this impairs this
> demuxer's forward compability.
> 
> Furthermore, ignoring Blocks belonging to a TrackEntry without
> corresponding stream can (in future commits) also be used to ignore
> TrackEntries with obviously bogus entries without affecting the other
> TrackEntries (by not creating a stream for said TrackEntry).
> 
> Finally, given that matroska_find_track_by_num() already emits its own
> error message in case there is no TrackEntry with a given TrackNumber,
> the error message (with level AV_LOG_INFO) for this can be removed.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/matroskadec.c | 15 +--
>  1 file changed, 9 insertions(+), 6 deletions(-)

does this affect the efficiency of the demuxer to resync in case of
actual errors ?

if so it may make sense to check the format version before accepting
unreferenced track numbers

thanks

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

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


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 v2 1/2] libavcodec/jpeg2000dec.c: Add functions and modify structs for PPT marker support

2020-03-27 Thread Carl Eugen Hoyos
Am Fr., 27. März 2020 um 19:24 Uhr schrieb Gautam Ramakrishnan
:

> > > > Did you already look at the sample file I pointed out?
> > > Yep, am going through the sample file. I shall try to see what
> > > is causing those errors. However I am assuming that the errors
> > > could be due to other bugs in the decoder or due to some
> > > unimplemented features?
> >
> > Could be, I don't know, please find out.
> >
> The mxf demuxer says: error getting stream index 67174400
> Does this mean that the mxf demuxer is unable to read the mxf
> packet itself? Looking at the error thrown by the jpeg2000 decoder,
> looks like the jpeg2000 frame is corrupt.

I don't think so, you can test with libopenjpeg.

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 v2 1/2] libavcodec/jpeg2000dec.c: Add functions and modify structs for PPT marker support

2020-03-27 Thread Gautam Ramakrishnan
On Fri, Mar 27, 2020 at 11:27 PM Carl Eugen Hoyos  wrote:
>
> Am Fr., 27. März 2020 um 18:48 Uhr schrieb Gautam Ramakrishnan
> :
> >
> > On Fri, Mar 27, 2020 at 10:59 PM Carl Eugen Hoyos  
> > wrote:
> > >
> > > Am Fr., 27. März 2020 um 17:21 Uhr schrieb :
> > > >
> > > > From: Gautam Ramakrishnan 
> > > >
> > > > This patch modifies the Jpeg2000Tile struct and breaks the
> > > > jpeg2000_decode_packet() function into two to decode packet
> > > > header and data separately.
> > >
> > > The solution is also not to add functions that are unused at first.
> > >
> > > I don't know if it is good to split the patch but you mentioned
> > > that you had to split a particular function. That makes it sound
> > > as if you should - with the first patch - split the function without
> > > changing FFmpeg's behaviour, and then with a second patch
> > > change FFmpeg's behaviour by adding the new functionality.
> > > As said, I don't know if that simplifies the review in this
> > > specific case.
> > I was not too sure what to do in this case. Thought that splitting it
> > in the first patch could show what new functions are present.
>
> Michael will have to comment.
>
> > > Did you already look at the sample file I pointed out?
> > Yep, am going through the sample file. I shall try to see what
> > is causing those errors. However I am assuming that the errors
> > could be due to other bugs in the decoder or due to some
> > unimplemented features?
>
> Could be, I don't know, please find out.
>
The mxf demuxer says: error getting stream index 67174400
Does this mean that the mxf demuxer is unable to read the mxf
packet itself? Looking at the error thrown by the jpeg2000 decoder,
looks like the jpeg2000 frame is corrupt.
> 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".



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

[FFmpeg-devel] [PATCH]lavc/aacdec_template: Only warn once about unusual 7.1 encoding

2020-03-27 Thread Carl Eugen Hoyos
Hi!

Attached patch reduces warnings when decoding a file with 7.1(wide)
aac encoding.

Please comment, Carl Eugen
From fbbfb50842a5e47ac8aab34308c278d17df6ba12 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Fri, 27 Mar 2020 18:52:16 +0100
Subject: [PATCH] lavc/aacdec_template: Only warn once about unusual 7.1
 encoding.

---
 libavcodec/aac.h |  2 +-
 libavcodec/aacdec_template.c | 20 ++--
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/libavcodec/aac.h b/libavcodec/aac.h
index c2b9c980cb..d3355f1b73 100644
--- a/libavcodec/aac.h
+++ b/libavcodec/aac.h
@@ -356,7 +356,7 @@ struct AACContext {
 OutputConfiguration oc[2];
 int warned_num_aac_frames;
 int warned_960_sbr;
-
+int warned_71_wide;
 int warned_gain_control;
 
 /* aacdec functions pointers */
diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index bb11de3458..8f647667ee 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -520,14 +520,14 @@ static void flush(AVCodecContext *avctx)
  *
  * @return  Returns error status. 0 - OK, !0 - error
  */
-static int set_default_channel_config(AVCodecContext *avctx,
+static int set_default_channel_config(AACContext *ac,
   uint8_t (*layout_map)[3],
   int *tags,
   int channel_config)
 {
 if (channel_config < 1 || (channel_config > 7 && channel_config < 11) ||
 channel_config > 12) {
-av_log(avctx, AV_LOG_ERROR,
+av_log(ac->avctx, AV_LOG_ERROR,
"invalid default channel configuration (%d)\n",
channel_config);
 return AVERROR_INVALIDDATA;
@@ -547,8 +547,8 @@ static int set_default_channel_config(AVCodecContext *avctx,
  * As actual intended 7.1(wide) streams are very rare, default to assuming a
  * 7.1 layout was intended.
  */
-if (channel_config == 7 && avctx->strict_std_compliance < FF_COMPLIANCE_STRICT) {
-av_log(avctx, AV_LOG_INFO, "Assuming an incorrectly encoded 7.1 channel layout"
+if (!ac->warned_71_wide++ && channel_config == 7 && ac->avctx->strict_std_compliance < FF_COMPLIANCE_STRICT) {
+av_log(ac->avctx, AV_LOG_INFO, "Assuming an incorrectly encoded 7.1 channel layout"
" instead of a spec-compliant 7.1(wide) layout, use -strict %d to decode"
" according to the specification instead.\n", FF_COMPLIANCE_STRICT);
 layout_map[2][2] = AAC_CHANNEL_SIDE;
@@ -573,7 +573,7 @@ static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
 
 av_log(ac->avctx, AV_LOG_DEBUG, "mono with CPE\n");
 
-if (set_default_channel_config(ac->avctx, layout_map,
+if (set_default_channel_config(ac, layout_map,
_map_tags, 2) < 0)
 return NULL;
 if (output_configure(ac, layout_map, layout_map_tags,
@@ -592,7 +592,7 @@ static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
 
 av_log(ac->avctx, AV_LOG_DEBUG, "stereo with SCE\n");
 
-if (set_default_channel_config(ac->avctx, layout_map,
+if (set_default_channel_config(ac, layout_map,
_map_tags, 1) < 0)
 return NULL;
 if (output_configure(ac, layout_map, layout_map_tags,
@@ -841,7 +841,7 @@ static int decode_ga_specific_config(AACContext *ac, AVCodecContext *avctx,
 if (tags < 0)
 return tags;
 } else {
-if ((ret = set_default_channel_config(avctx, layout_map,
+if ((ret = set_default_channel_config(ac, layout_map,
   , channel_config)))
 return ret;
 }
@@ -937,7 +937,7 @@ static int decode_eld_specific_config(AACContext *ac, AVCodecContext *avctx,
 skip_bits_long(gb, 8 * len);
 }
 
-if ((ret = set_default_channel_config(avctx, layout_map,
+if ((ret = set_default_channel_config(ac, layout_map,
   , channel_config)))
 return ret;
 
@@ -1200,7 +1200,7 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
 ac->oc[1].m4ac.chan_config = i;
 
 if (ac->oc[1].m4ac.chan_config) {
-int ret = set_default_channel_config(avctx, layout_map,
+int ret = set_default_channel_config(ac, layout_map,
 _map_tags, ac->oc[1].m4ac.chan_config);
 if (!ret)
 output_configure(ac, layout_map, layout_map_tags,
@@ -3002,7 +3002,7 @@ static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb)
 push_output_configuration(ac);
 if (hdr_info.chan_config) {
 ac->oc[1].m4ac.chan_config = hdr_info.chan_config;
-if ((ret = set_default_channel_config(ac->avctx,
+if ((ret = set_default_channel_config(ac,
  

[FFmpeg-devel] [PATCH] avformat/rtp: Pass sources and block filter addresses via sdp file for rtp

2020-03-27 Thread phunkyfish
---
 libavformat/rtsp.c | 46 ++
 1 file changed, 38 insertions(+), 8 deletions(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index cd6fc32a29..1aec070382 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -2447,8 +2447,8 @@ static int rtp_probe(const AVProbeData *p)
 static int rtp_read_header(AVFormatContext *s)
 {
 uint8_t recvbuf[RTP_MAX_PACKET_LENGTH];
-char host[500], sdp[500];
-int ret, port;
+char host[500], sdp[1000], filters_buf[1000];
+int ret, port, sdp_length, nc;
 URLContext* in = NULL;
 int payload_type;
 AVCodecParameters *par = NULL;
@@ -2456,6 +2456,7 @@ static int rtp_read_header(AVFormatContext *s)
 AVIOContext pb;
 socklen_t addrlen = sizeof(addr);
 RTSPState *rt = s->priv_data;
+const char *p
 
 if (!ff_network_init())
 return AVERROR(EIO);
@@ -2513,12 +2514,39 @@ static int rtp_read_header(AVFormatContext *s)
 av_url_split(NULL, 0, NULL, 0, host, sizeof(host), ,
  NULL, 0, s->url);
 
-snprintf(sdp, sizeof(sdp),
- "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
- addr.ss_family == AF_INET ? 4 : 6, host,
- par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
- par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
- port, payload_type);
+sdp_length = snprintf(sdp, sizeof(sdp),
+  "v=0\r\nc=IN IP%d %s\r\n",
+  addr.ss_family == AF_INET ? 4 : 6, host);
+
+p = strchr(s->url, '?');
+if (p) {
+static const char *filters[][2] = {{"sources", "incl"}, {"block", 
"excl"}, {NULL, NULL}};
+int i;
+char *q;
+for (i = 0; filters[i][0]; i++) {
+if (av_find_info_tag(filters_buf, sizeof(filters_buf), 
filters[i][0], p)) {
+q = filters_buf;
+while ((q = strchr(q, ',')) != NULL)
+*q = ' ';
+nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
+  "a=source-filter:%s IN IP%d %s %s\r\n",
+  filters[i][1],
+  addr.ss_family == AF_INET ? 4 : 6, host,
+  filters_buf);
+if (nc < 0 || nc + sdp_length >= sizeof(sdp))
+goto fail_nobuf;
+sdp_length += nc;
+}
+}
+}
+
+nc = snprintf(sdp + sdp_length, sizeof(sdp) - sdp_length,
+  "m=%s %d RTP/AVP %d\r\n",
+  par->codec_type == AVMEDIA_TYPE_DATA  ? "application" :
+  par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
+  port, payload_type);
+if (nc < 0 || nc + sdp_length >= sizeof(sdp))
+goto fail_nobuf;
 av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
 avcodec_parameters_free();
 
@@ -2534,6 +2562,8 @@ static int rtp_read_header(AVFormatContext *s)
 s->pb = NULL;
 return ret;
 
+fail_nobuf:
+ret = AVERROR(ENOBUFS);
 fail:
 avcodec_parameters_free();
 if (in)
-- 
2.21.1 (Apple Git-122.3)

___
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] libavcodec/jpeg2000dec.c: Add functions and modify structs for PPT marker support

2020-03-27 Thread Carl Eugen Hoyos
Am Fr., 27. März 2020 um 18:48 Uhr schrieb Gautam Ramakrishnan
:
>
> On Fri, Mar 27, 2020 at 10:59 PM Carl Eugen Hoyos  wrote:
> >
> > Am Fr., 27. März 2020 um 17:21 Uhr schrieb :
> > >
> > > From: Gautam Ramakrishnan 
> > >
> > > This patch modifies the Jpeg2000Tile struct and breaks the
> > > jpeg2000_decode_packet() function into two to decode packet
> > > header and data separately.
> >
> > The solution is also not to add functions that are unused at first.
> >
> > I don't know if it is good to split the patch but you mentioned
> > that you had to split a particular function. That makes it sound
> > as if you should - with the first patch - split the function without
> > changing FFmpeg's behaviour, and then with a second patch
> > change FFmpeg's behaviour by adding the new functionality.
> > As said, I don't know if that simplifies the review in this
> > specific case.
> I was not too sure what to do in this case. Thought that splitting it
> in the first patch could show what new functions are present.

Michael will have to comment.

> > Did you already look at the sample file I pointed out?
> Yep, am going through the sample file. I shall try to see what
> is causing those errors. However I am assuming that the errors
> could be due to other bugs in the decoder or due to some
> unimplemented features?

Could be, I don't know, please find out.

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 V2] avformat: Add Dynacolor MVC Demuxer

2020-03-27 Thread Michael Niedermayer
On Thu, Mar 26, 2020 at 10:28:32AM +, Tom Needham wrote:
> Thanks for your feedback. Please see the attached patch with all the style
> changes addressed which also applies properly.

>  Changelog|1 
>  doc/general.texi |1 
>  libavformat/Makefile |1 
>  libavformat/allformats.c |1 
>  libavformat/dynacolor.c  |  497 
> +++
>  libavformat/dynacolor.h  |  273 +
>  libavformat/version.h|2 
>  7 files changed, 775 insertions(+), 1 deletion(-)
> 373e3c7f910ae4d2d005ca0f764afa8f41c0adf4  
> 0001-avformat-Add-Dynacolor-MVC-Demuxer.patch
> From 8f741899b7f6b3884d613f622a548b353af2489e Mon Sep 17 00:00:00 2001
> From: Tom Needham <06needh...@gmail.com>
> Date: Sun, 21 Jul 2019 21:11:19 +0100
> Subject: [PATCH] avformat: Add Dynacolor MVC Demuxer
> 
> This demuxer adds support for demuxing files in the Dynacolor format
> such as the sample located at:
> 
> http://samples.ffmpeg.org/camera-dvr/dynacolor/dynacolor-camera-sample
> 
> However some decode errors are showing on the resulting MPEG4 stream.
> I don't know whether this is a bug with the demuxer or the file as there is 
> only one sample
> but the output results in a 1 second mp4 file that is playable in VLC media 
> player.
> 
> Signed-off-by: Tom Needham <06needh...@gmail.com>
> ---
>  Changelog|   1 +
>  doc/general.texi |   1 +
>  libavformat/Makefile |   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/dynacolor.c  | 497 +++
>  libavformat/dynacolor.h  | 273 +
>  libavformat/version.h|   2 +-
>  7 files changed, 775 insertions(+), 1 deletion(-)
>  create mode 100644 libavformat/dynacolor.c
>  create mode 100644 libavformat/dynacolor.h

fails to build on mingw64 with --disable-debug --disable-stripping 
--enable-small

libavformat/libavformat.a(dynacolor.o):dynacolor.c:(.text+0x200): undefined 
reference to `ff_dyna_callback_checksum'
libavformat/libavformat.a(dynacolor.o):dynacolor.c:(.text+0x200): relocation 
truncated to fit: R_X86_64_PC32 against undefined symbol 
`ff_dyna_callback_checksum'
libavformat/libavformat.a(dynacolor.o):dynacolor.c:(.text+0x227): undefined 
reference to `ff_dyna_extra_checksum'
libavformat/libavformat.a(dynacolor.o):dynacolor.c:(.text+0x227): relocation 
truncated to fit: R_X86_64_PC32 against undefined symbol 
`ff_dyna_extra_checksum'
libavformat/libavformat.a(dynacolor.o):dynacolor.c:(.text+0x200): undefined 
reference to `ff_dyna_callback_checksum'
libavformat/libavformat.a(dynacolor.o):dynacolor.c:(.text+0x200): relocation 
truncated to fit: R_X86_64_PC32 against undefined symbol 
`ff_dyna_callback_checksum'
libavformat/libavformat.a(dynacolor.o):dynacolor.c:(.text+0x227): undefined 
reference to `ff_dyna_extra_checksum'
libavformat/libavformat.a(dynacolor.o):dynacolor.c:(.text+0x227): relocation 
truncated to fit: R_X86_64_PC32 against undefined symbol 
`ff_dyna_extra_checksum'


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

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact


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 v2 1/2] libavcodec/jpeg2000dec.c: Add functions and modify structs for PPT marker support

2020-03-27 Thread Gautam Ramakrishnan
On Fri, Mar 27, 2020 at 10:59 PM Carl Eugen Hoyos  wrote:
>
> Am Fr., 27. März 2020 um 17:21 Uhr schrieb :
> >
> > From: Gautam Ramakrishnan 
> >
> > This patch modifies the Jpeg2000Tile struct and breaks the
> > jpeg2000_decode_packet() function into two to decode packet
> > header and data separately.
>
> The solution is also not to add functions that are unused at first.
>
> I don't know if it is good to split the patch but you mentioned
> that you had to split a particular function. That makes it sound
> as if you should - with the first patch - split the function without
> changing FFmpeg's behaviour, and then with a second patch
> change FFmpeg's behaviour by adding the new functionality.
> As said, I don't know if that simplifies the review in this
> specific case.
I was not too sure what to do in this case. Thought that splitting it
in the first patch could show what new functions are present.
> Did you already look at the sample file I pointed out?
Yep, am going through the sample file. I shall try to see what
is causing those errors. However I am assuming that the errors
could be due to other bugs in the decoder or due to some
unimplemented features?
>
> 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".



-- 
-
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 v2 1/2] libavcodec/jpeg2000dec.c: Add functions and modify structs for PPT marker support

2020-03-27 Thread Carl Eugen Hoyos
Am Fr., 27. März 2020 um 17:21 Uhr schrieb :
>
> From: Gautam Ramakrishnan 
>
> This patch modifies the Jpeg2000Tile struct and breaks the
> jpeg2000_decode_packet() function into two to decode packet
> header and data separately.

The solution is also not to add functions that are unused at first.

I don't know if it is good to split the patch but you mentioned
that you had to split a particular function. That makes it sound
as if you should - with the first patch - split the function without
changing FFmpeg's behaviour, and then with a second patch
change FFmpeg's behaviour by adding the new functionality.
As said, I don't know if that simplifies the review in this
specific case.
Did you already look at the sample file I pointed out?

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

[FFmpeg-devel] [PATCH v2 1/2] libavcodec/jpeg2000dec.c: Add functions and modify structs for PPT marker support

2020-03-27 Thread gautamramk
From: Gautam Ramakrishnan 

This patch modifies the Jpeg2000Tile struct and breaks the
jpeg2000_decode_packet() function into two to decode packet
header and data separately.
---
 libavcodec/jpeg2000dec.c | 250 ++-
 1 file changed, 248 insertions(+), 2 deletions(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 019dc81f56..7236e9b7bb 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -83,8 +83,12 @@ typedef struct Jpeg2000Tile {
 Jpeg2000QuantStyle  qntsty[4];
 Jpeg2000POC poc;
 Jpeg2000TileParttile_part[32];
-uint16_t tp_idx;// Tile-part index
-int coord[2][2];// border coordinates {{x0, x1}, {y0, 
y1}}
+uint8_t has_ppt;// whether this tile has a ppt 
marker
+uint8_t *packed_headers;// contains packed headers. 
Used only along with PPT marker
+int packed_headers_size;// size in bytes of the packed 
headers
+GetByteContext  packed_headers_stream;  // byte context corresponding 
to packed headers
+uint16_t tp_idx;// Tile-part index
+int coord[2][2];// border coordinates {{x0, 
x1}, {y0, y1}}
 } Jpeg2000Tile;
 
 typedef struct Jpeg2000DecoderContext {
@@ -851,6 +855,38 @@ static int get_plt(Jpeg2000DecoderContext *s, int n)
 return 0;
 }
 
+static int get_ppt(Jpeg2000DecoderContext *s, int n)
+{
+Jpeg2000Tile *tile;
+
+tile = >tile[s->curtileno];
+
+av_assert1(s->curtileno >= 0);
+if (tile->tp_idx != 0) {
+av_log(s->avctx, AV_LOG_ERROR,
+   "PPT marker can occur only on first tile part of a tile.\n");
+return AVERROR_INVALIDDATA;
+}
+
+tile->has_ppt = 1;  // this tile has a ppt marker
+/*Zppt = */ bytestream2_get_byte(>g);
+if (!tile->packed_headers) {
+tile->packed_headers = av_malloc_array(n - 3, sizeof(uint8_t));
+memcpy(tile->packed_headers, s->g.buffer, sizeof(uint8_t)*(n - 3));
+tile->packed_headers_size = n - 3;
+} else {
+tile->packed_headers = av_realloc_array(tile->packed_headers,
+tile->packed_headers_size + n 
- 3,
+sizeof(uint8_t));
+memcpy(tile->packed_headers + tile->packed_headers_size,
+   s->g.buffer, sizeof(uint8_t)*(n - 3));
+tile->packed_headers_size += n - 3;
+}
+bytestream2_skip(>g, n - 3);
+
+return 0;
+}
+
 static int init_tile(Jpeg2000DecoderContext *s, int tileno)
 {
 int compno;
@@ -923,6 +959,216 @@ static int getlblockinc(Jpeg2000DecoderContext *s)
 return res;
 }
 
+static int jpeg2000_decode_packet_header(Jpeg2000DecoderContext *s, 
Jpeg2000Tile *tile,
+ int *tp_index,
+ Jpeg2000CodingStyle *codsty,
+ Jpeg2000ResLevel *rlevel, int precno,
+ int layno, uint8_t *expn, int 
numgbits,
+ int *process_data)
+{
+int bandno, cblkno, ret, nb_code_blocks;
+
+if (layno < rlevel->band[0].prec[precno].decoded_layers) {
+*process_data = 0;
+return 0;
+}
+rlevel->band[0].prec[precno].decoded_layers = layno + 1;
+
+if (tile->has_ppt) {
+s->g = tile->packed_headers_stream;
+} else {
+s->g = tile->tile_part[*tp_index].tpg;
+if (bytestream2_get_bytes_left(>g) == 0 && s->bit_index == 8) {
+if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
+s->g = tile->tile_part[++(*tp_index)].tpg;
+}
+}
+if (bytestream2_peek_be32(>g) == JPEG2000_SOP_FIXED_BYTES)
+bytestream2_skip(>g, JPEG2000_SOP_BYTE_LENGTH);
+}
+
+if (!(ret = get_bits(s, 1))) {
+jpeg2000_flush(s);
+*process_data = 0;
+goto end;
+} else if (ret < 0)
+return ret;
+
+for (bandno = 0; bandno < rlevel->nbands; bandno++) {
+Jpeg2000Band *band = rlevel->band + bandno;
+Jpeg2000Prec *prec = band->prec + precno;
+
+if (band->coord[0][0] == band->coord[0][1] ||
+band->coord[1][0] == band->coord[1][1])
+continue;
+nb_code_blocks =  prec->nb_codeblocks_height *
+  prec->nb_codeblocks_width;
+for (cblkno = 0; cblkno < nb_code_blocks; cblkno++) {
+Jpeg2000Cblk *cblk = prec->cblk + cblkno;
+int incl, newpasses, llen;
+void *tmp;
+
+if (cblk->npasses)
+incl = get_bits(s, 1);
+else
+incl = tag_tree_decode(s, prec->cblkincl + cblkno, layno + 1) 
== layno;
+if (!incl)
+continue;
+else if (incl < 0)
+  

[FFmpeg-devel] [PATCH v2 2/2] libavcodec/jpeg2000dec.c: Functional changes to support PPT marker

2020-03-27 Thread gautamramk
From: Gautam Ramakrishnan 

This patch adds functional changes to support the PPT marker. It
allows the PPT marker to be read in jpeg2000_read_main_headers().
---
 libavcodec/jpeg2000dec.c | 270 ---
 1 file changed, 82 insertions(+), 188 deletions(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 7236e9b7bb..fbc025449a 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -1169,179 +1169,6 @@ static int 
jpeg2000_decode_packet_data(Jpeg2000DecoderContext *s, Jpeg2000Tile *
 return 0;
 }
 
-static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile 
*tile, int *tp_index,
-  Jpeg2000CodingStyle *codsty,
-  Jpeg2000ResLevel *rlevel, int precno,
-  int layno, uint8_t *expn, int numgbits)
-{
-int bandno, cblkno, ret, nb_code_blocks;
-int cwsno;
-
-if (layno < rlevel->band[0].prec[precno].decoded_layers)
-return 0;
-rlevel->band[0].prec[precno].decoded_layers = layno + 1;
-
-if (bytestream2_get_bytes_left(>g) == 0 && s->bit_index == 8) {
-if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
-s->g = tile->tile_part[++(*tp_index)].tpg;
-}
-}
-
-if (bytestream2_peek_be32(>g) == JPEG2000_SOP_FIXED_BYTES)
-bytestream2_skip(>g, JPEG2000_SOP_BYTE_LENGTH);
-
-if (!(ret = get_bits(s, 1))) {
-jpeg2000_flush(s);
-return 0;
-} else if (ret < 0)
-return ret;
-
-for (bandno = 0; bandno < rlevel->nbands; bandno++) {
-Jpeg2000Band *band = rlevel->band + bandno;
-Jpeg2000Prec *prec = band->prec + precno;
-
-if (band->coord[0][0] == band->coord[0][1] ||
-band->coord[1][0] == band->coord[1][1])
-continue;
-nb_code_blocks =  prec->nb_codeblocks_height *
-  prec->nb_codeblocks_width;
-for (cblkno = 0; cblkno < nb_code_blocks; cblkno++) {
-Jpeg2000Cblk *cblk = prec->cblk + cblkno;
-int incl, newpasses, llen;
-void *tmp;
-
-if (cblk->npasses)
-incl = get_bits(s, 1);
-else
-incl = tag_tree_decode(s, prec->cblkincl + cblkno, layno + 1) 
== layno;
-if (!incl)
-continue;
-else if (incl < 0)
-return incl;
-
-if (!cblk->npasses) {
-int v = expn[bandno] + numgbits - 1 -
-tag_tree_decode(s, prec->zerobits + cblkno, 100);
-if (v < 0 || v > 30) {
-av_log(s->avctx, AV_LOG_ERROR,
-   "nonzerobits %d invalid or unsupported\n", v);
-return AVERROR_INVALIDDATA;
-}
-cblk->nonzerobits = v;
-}
-if ((newpasses = getnpasses(s)) < 0)
-return newpasses;
-av_assert2(newpasses > 0);
-if (cblk->npasses + newpasses >= JPEG2000_MAX_PASSES) {
-avpriv_request_sample(s->avctx, "Too many passes");
-return AVERROR_PATCHWELCOME;
-}
-if ((llen = getlblockinc(s)) < 0)
-return llen;
-if (cblk->lblock + llen + av_log2(newpasses) > 16) {
-avpriv_request_sample(s->avctx,
-  "Block with length beyond 16 bits");
-return AVERROR_PATCHWELCOME;
-}
-
-cblk->lblock += llen;
-
-cblk->nb_lengthinc = 0;
-cblk->nb_terminationsinc = 0;
-av_free(cblk->lengthinc);
-cblk->lengthinc  = av_mallocz_array(newpasses, 
sizeof(*cblk->lengthinc));
-if (!cblk->lengthinc)
-return AVERROR(ENOMEM);
-tmp = av_realloc_array(cblk->data_start, cblk->nb_terminations + 
newpasses + 1, sizeof(*cblk->data_start));
-if (!tmp)
-return AVERROR(ENOMEM);
-cblk->data_start = tmp;
-do {
-int newpasses1 = 0;
-
-while (newpasses1 < newpasses) {
-newpasses1 ++;
-if (needs_termination(codsty->cblk_style, cblk->npasses + 
newpasses1 - 1)) {
-cblk->nb_terminationsinc ++;
-break;
-}
-}
-
-if ((ret = get_bits(s, av_log2(newpasses1) + cblk->lblock)) < 
0)
-return ret;
-if (ret > cblk->data_allocated) {
-size_t new_size = FFMAX(2*cblk->data_allocated, ret);
-void *new = av_realloc(cblk->data, new_size);
-if (new) {
-cblk->data = new;
-cblk->data_allocated = new_size;
-}
-}
-if (ret > 

Re: [FFmpeg-devel] [PATCH 10/14] h264_sei: use a separate reader for the individual SEI messages

2020-03-27 Thread James Almer
On 3/27/2020 9:57 AM, Anton Khirnov wrote:
> This tells the parsing functions the payload size and prevents them from
> overreading.
> ---
>  libavcodec/h264_sei.c | 33 +++--
>  1 file changed, 19 insertions(+), 14 deletions(-)
> 
> diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
> index a565feabe2..32d13985f3 100644
> --- a/libavcodec/h264_sei.c
> +++ b/libavcodec/h264_sei.c
> @@ -407,9 +407,9 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext 
> *gb,
>  int master_ret = 0;
>  
>  while (get_bits_left(gb) > 16 && show_bits(gb, 16)) {
> +GetBitContext gb_payload;
>  int type = 0;
>  unsigned size = 0;
> -unsigned next;
>  int ret  = 0;
>  
>  do {
> @@ -429,35 +429,38 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext 
> *gb,
> type, 8*size, get_bits_left(gb));
>  return AVERROR_INVALIDDATA;
>  }
> -next = get_bits_count(gb) + 8 * size;
> +
> +ret = init_get_bits8(_payload, gb->buffer + get_bits_count(gb) / 
> 8, size);

Could use init_get_bits() instead, since size was already checked above.

> +if (ret < 0)
> +return ret;
>  
>  switch (type) {
>  case H264_SEI_TYPE_PIC_TIMING: // Picture timing SEI
> -ret = decode_picture_timing(>picture_timing, gb, ps, logctx);
> +ret = decode_picture_timing(>picture_timing, _payload, ps, 
> logctx);
>  break;
>  case H264_SEI_TYPE_USER_DATA_REGISTERED:
> -ret = decode_registered_user_data(h, gb, logctx, size);
> +ret = decode_registered_user_data(h, _payload, logctx, size);
>  break;
>  case H264_SEI_TYPE_USER_DATA_UNREGISTERED:
> -ret = decode_unregistered_user_data(>unregistered, gb, 
> logctx, size);
> +ret = decode_unregistered_user_data(>unregistered, 
> _payload, logctx, size);
>  break;
>  case H264_SEI_TYPE_RECOVERY_POINT:
> -ret = decode_recovery_point(>recovery_point, gb, logctx);
> +ret = decode_recovery_point(>recovery_point, _payload, 
> logctx);
>  break;
>  case H264_SEI_TYPE_BUFFERING_PERIOD:
> -ret = decode_buffering_period(>buffering_period, gb, ps, 
> logctx);
> +ret = decode_buffering_period(>buffering_period, _payload, 
> ps, logctx);
>  break;
>  case H264_SEI_TYPE_FRAME_PACKING:
> -ret = decode_frame_packing_arrangement(>frame_packing, gb);
> +ret = decode_frame_packing_arrangement(>frame_packing, 
> _payload);
>  break;
>  case H264_SEI_TYPE_DISPLAY_ORIENTATION:
> -ret = decode_display_orientation(>display_orientation, gb);
> +ret = decode_display_orientation(>display_orientation, 
> _payload);
>  break;
>  case H264_SEI_TYPE_GREEN_METADATA:
> -ret = decode_green_metadata(>green_metadata, gb);
> +ret = decode_green_metadata(>green_metadata, _payload);
>  break;
>  case H264_SEI_TYPE_ALTERNATIVE_TRANSFER:
> -ret = decode_alternative_transfer(>alternative_transfer, gb);
> +ret = decode_alternative_transfer(>alternative_transfer, 
> _payload);
>  break;
>  default:
>  av_log(logctx, AV_LOG_DEBUG, "unknown SEI type %d\n", type);
> @@ -467,10 +470,12 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext 
> *gb,
>  if (ret < 0)
>  master_ret = ret;
>  
> -skip_bits_long(gb, next - get_bits_count(gb));
> +if (get_bits_left(_payload) < 0) {
> +av_log(logctx, AV_LOG_WARNING, "SEI type %d overread by %d 
> bits\n",
> +   type, -get_bits_left(_payload));

Maybe check for explode and abort?

> +}
>  
> -// FIXME check bits here
> -align_get_bits(gb);
> +skip_bits_long(gb, 8 * size);
>  }
>  
>  return master_ret;
> 

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/jpeg2000dec Support for PPT marker

2020-03-27 Thread Gautam Ramakrishnan
On Fri, Mar 27, 2020 at 8:30 PM Carl Eugen Hoyos  wrote:
>
> Am Fr., 27. März 2020 um 15:58 Uhr schrieb Gautam Ramakrishnan
> :
>
> > I was a bit apprehensive about removing the jpeg2000_decode_packet()
> > function. I had basically split that function into 2 separate ones.
> > Should I keep it till we add more changes to the decoder or do I
> > remove it now itself?
>
> Not sure what the right solution is but there should be no (new)
> compilation warning.
>
> If you have split a function, then this should be a separate patch
> that makes the reviews easier.
I'll make a patch series and send a v2
> (First patch: Splitting a function without functional improvement,
> second patch: Functional improvement)
>
> Please find out what top-posting means and avoid it here.
>
Got it
> 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".



-- 
-
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 08/14] decode: plug leaks on error in update_frame_pool()

2020-03-27 Thread James Almer
On 3/27/2020 9:57 AM, Anton Khirnov wrote:
> ---
>  libavcodec/decode.c | 8 +---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index 8925ce6edc..f43dc0dd5d 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -1595,7 +1595,7 @@ static int update_frame_pool(AVCodecContext *avctx, 
> AVFrame *frame)
>  // that linesize[0] == 2*linesize[1] in the MPEG-encoder for 
> 4:2:2
>  ret = av_image_fill_linesizes(linesize, avctx->pix_fmt, w);
>  if (ret < 0)
> -return ret;
> +goto fail;
>  // increase alignment of w for next try (rhs gives the lowest 
> bit set in w)
>  w += w & ~(w - 1);
>  
> @@ -1606,8 +1606,10 @@ static int update_frame_pool(AVCodecContext *avctx, 
> AVFrame *frame)
>  
>  tmpsize = av_image_fill_pointers(data, avctx->pix_fmt, h,
>   NULL, linesize);
> -if (tmpsize < 0)
> -return tmpsize;
> +if (tmpsize < 0) {
> +ret = tmpsize;
> +goto fail;
> +}
>  
>  for (i = 0; i < 3 && data[i + 1]; i++)
>  size[i] = data[i + 1] - data[i];

Nit: Not really a leak since the pool was not changed in any way if
either of these two checks fail, so new calls to get_buffer2() or
closing the context would free everything just fine.

LGTM with or without changing the commit message to say something about
cleaning on error rather than fixing a leak.
___
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/jpeg2000dec Support for PPT marker

2020-03-27 Thread Carl Eugen Hoyos
Am Fr., 27. März 2020 um 15:58 Uhr schrieb Gautam Ramakrishnan
:

> I was a bit apprehensive about removing the jpeg2000_decode_packet()
> function. I had basically split that function into 2 separate ones.
> Should I keep it till we add more changes to the decoder or do I
> remove it now itself?

Not sure what the right solution is but there should be no (new)
compilation warning.

If you have split a function, then this should be a separate patch
that makes the reviews easier.
(First patch: Splitting a function without functional improvement,
second patch: Functional improvement)

Please find out what top-posting means and avoid it here.

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/jpeg2000dec Support for PPT marker

2020-03-27 Thread Carl Eugen Hoyos
Am Fr., 27. März 2020 um 14:47 Uhr schrieb :
>
> From: Gautam Ramakrishnan 
>
> This patch adds support for the JPEG2000 PPT marker. This patch hence,
> fixes #4610. The patch was tested on the samples posted along with
> ticket #4610.

Some frames in this sample are now decoded correctly, some still fail:
http://samples.ffmpeg.org/jpeg2000/jpeg2000_mxf_first_10mb.mxf
(Also a SAMMA sample)

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/jpeg2000dec Support for PPT marker

2020-03-27 Thread Gautam Ramakrishnan
Hi,

I was a bit apprehensive about removing the jpeg2000_decode_packet()
function. I had basically split that function into 2 separate ones.
Should I keep it till we add more changes to the decoder or do I
remove it now itself?

On Fri, Mar 27, 2020 at 8:03 PM Carl Eugen Hoyos  wrote:
>
> Am Fr., 27. März 2020 um 15:29 Uhr schrieb Carl Eugen Hoyos
> :
> >
> > Am Fr., 27. März 2020 um 14:47 Uhr schrieb :
> > >
> > > From: Gautam Ramakrishnan 
> > >
> > > This patch adds support for the JPEG2000 PPT marker. This patch hence,
> > > fixes #4610. The patch was tested on the samples posted along with
> > > ticket #4610.
> >
> > Your patch adds a compile-time warning here, please fix that.
> >
> > @Michael: Both samples from ticket #4610 are decoded visually correct,
> > the sample from the testsrc (p1_02.j2k) is not lossless afaict (jasper and
> > openjpeg produce different output), the samma sample is lossless but
> > since it is yuv, it will take a little time to test for bit-exactness.
>
> Not so difficult: The samma sample produces bit-exact output with the patch.
>
> 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".



-- 
-
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 09/14] h264dec: do not abort if decoding extradata fails

2020-03-27 Thread James Almer
On 3/27/2020 9:57 AM, Anton Khirnov wrote:
> Such errors are not necessarily fatal and decoding might still be
> possible, e.g. it happens for MVC streams where we do not handle the
> subset SPS thus failing to parse its corresponding PPS.
> ---
>  libavcodec/h264dec.c | 12 
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
> index b6c51ed1e2..dba0634fa0 100644
> --- a/libavcodec/h264dec.c
> +++ b/libavcodec/h264dec.c
> @@ -414,10 +414,14 @@ static av_cold int h264_decode_init(AVCodecContext 
> *avctx)
>  ret = ff_h264_decode_extradata(avctx->extradata, 
> avctx->extradata_size,
> >ps, >is_avc, 
> >nal_length_size,
> avctx->err_recognition, avctx);
> -if (ret < 0) {
> -h264_decode_end(avctx);
> -return ret;
> -}
> +   if (ret < 0) {
> +   av_log(avctx, AV_LOG_WARNING, "Error decoding the 
> extradata\n");

Should be AV_LOG_ERROR if AV_EF_EXPLODE is enabled.

> +   if (avctx->err_recognition & AV_EF_EXPLODE) {
> +   h264_decode_end(avctx);
> +   return ret;
> +   }
> +   ret = 0;
> +   }
>  }
>  }

LGTM otherwise.
___
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/jpeg2000dec Support for PPT marker

2020-03-27 Thread Carl Eugen Hoyos
Am Fr., 27. März 2020 um 15:29 Uhr schrieb Carl Eugen Hoyos
:
>
> Am Fr., 27. März 2020 um 14:47 Uhr schrieb :
> >
> > From: Gautam Ramakrishnan 
> >
> > This patch adds support for the JPEG2000 PPT marker. This patch hence,
> > fixes #4610. The patch was tested on the samples posted along with
> > ticket #4610.
>
> Your patch adds a compile-time warning here, please fix that.
>
> @Michael: Both samples from ticket #4610 are decoded visually correct,
> the sample from the testsrc (p1_02.j2k) is not lossless afaict (jasper and
> openjpeg produce different output), the samma sample is lossless but
> since it is yuv, it will take a little time to test for bit-exactness.

Not so difficult: The samma sample produces bit-exact output with the patch.

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/jpeg2000dec Support for PPT marker

2020-03-27 Thread Carl Eugen Hoyos
Am Fr., 27. März 2020 um 14:47 Uhr schrieb :
>
> From: Gautam Ramakrishnan 
>
> This patch adds support for the JPEG2000 PPT marker. This patch hence,
> fixes #4610. The patch was tested on the samples posted along with
> ticket #4610.

Your patch adds a compile-time warning here, please fix that.

@Michael: Both samples from ticket #4610 are decoded visually correct,
the sample from the testsrc (p1_02.j2k) is not lossless afaict (jasper and
openjpeg produce different output), the samma sample is lossless but
since it is yuv, it will take a little time to test for bit-exactness.

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 v2 2/2] avformat: add demuxer for Pro Pinball Series' Soundbanks

2020-03-27 Thread Zane van Iperen
On Wed, 18 Mar 2020 15:19:19 +0100
"Carl Eugen Hoyos"  wrote:
> 
> Any restrictions on track_count and sample_rate that can be used for
> auto-detection?
> 

I've done a preliminary probe function. How's this?

On all the files I tested, I received one of two values:
99 - For music (these have an extra condition I can test for)
87 - For everything else

static int pp_bnk_probe(const AVProbeData *p)
{
PPBnkHeader hdr;
uint32_t expected_sample_rate;
int score;

pp_bnk_parse_header(, p->buf);

if (hdr.track_count == 0 || hdr.sample_rate == 0)
return 0;

score = 0;

/* These limits are based on analysing the game files. */
if (hdr.track_count <= 113)
score += AVPROBE_SCORE_MAX / 4;

if (hdr.sample_rate <= 44100)
score += AVPROBE_SCORE_MAX / 4;

if ((hdr.flags & ~PP_BNK_FLAG_MASK) == 0)
score += AVPROBE_SCORE_MAX / 4;

if ((hdr.flags & PP_BNK_FLAG_MUSIC) && hdr.track_count == 2)
score += AVPROBE_SCORE_MAX / 8;

/* Also check based on file extension, if we have it. */
if (av_match_ext(p->filename, "5c"))
expected_sample_rate = 5512;
else if (av_match_ext(p->filename, "11c"))
expected_sample_rate = 11025;
else if (av_match_ext(p->filename, "22c"))
expected_sample_rate = 22050;
else if (av_match_ext(p->filename, "44c"))
expected_sample_rate = 44100;
else
expected_sample_rate = 0;

if (expected_sample_rate && hdr.sample_rate == expected_sample_rate)
score += AVPROBE_SCORE_MAX / 8;

return score;
}

Zane

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

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

[FFmpeg-devel] [PATCH] avcodec/jpeg2000dec Support for PPT marker

2020-03-27 Thread gautamramk
From: Gautam Ramakrishnan 

This patch adds support for the JPEG2000 PPT marker. This patch hence,
fixes #4610. The patch was tested on the samples posted along with
ticket #4610.
---
 libavcodec/jpeg2000dec.c | 348 +--
 1 file changed, 331 insertions(+), 17 deletions(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 019dc81f56..ee003bebf2 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -83,8 +83,12 @@ typedef struct Jpeg2000Tile {
 Jpeg2000QuantStyle  qntsty[4];
 Jpeg2000POC poc;
 Jpeg2000TileParttile_part[32];
-uint16_t tp_idx;// Tile-part index
-int coord[2][2];// border coordinates {{x0, x1}, {y0, 
y1}}
+uint8_t has_ppt;// whether this tile has a ppt 
marker
+uint8_t *packed_headers;// contains packed headers. 
Used only along with PPT marker
+int packed_headers_size;// size in bytes of the packed 
headers
+GetByteContext  packed_headers_stream;  // byte context corresponding 
to packed headers
+uint16_t tp_idx;// Tile-part index
+int coord[2][2];// border coordinates {{x0, 
x1}, {y0, y1}}
 } Jpeg2000Tile;
 
 typedef struct Jpeg2000DecoderContext {
@@ -851,6 +855,38 @@ static int get_plt(Jpeg2000DecoderContext *s, int n)
 return 0;
 }
 
+static int get_ppt(Jpeg2000DecoderContext *s, int n)
+{
+Jpeg2000Tile *tile;
+
+tile = >tile[s->curtileno];
+
+av_assert1(s->curtileno >= 0);
+if (tile->tp_idx != 0) {
+av_log(s->avctx, AV_LOG_ERROR,
+   "PPT marker can occur only on first tile part of a tile.\n");
+return AVERROR_INVALIDDATA;
+}
+
+tile->has_ppt = 1;  // this tile has a ppt marker
+/*Zppt = */ bytestream2_get_byte(>g);
+if (!tile->packed_headers) {
+tile->packed_headers = av_malloc_array(n - 3, sizeof(uint8_t));
+memcpy(tile->packed_headers, s->g.buffer, sizeof(uint8_t)*(n - 3));
+tile->packed_headers_size = n - 3;
+} else {
+tile->packed_headers = av_realloc_array(tile->packed_headers,
+tile->packed_headers_size + n 
- 3,
+sizeof(uint8_t));
+memcpy(tile->packed_headers + tile->packed_headers_size,
+   s->g.buffer, sizeof(uint8_t)*(n - 3));
+tile->packed_headers_size += n - 3;
+}
+bytestream2_skip(>g, n - 3);
+
+return 0;
+}
+
 static int init_tile(Jpeg2000DecoderContext *s, int tileno)
 {
 int compno;
@@ -923,6 +959,216 @@ static int getlblockinc(Jpeg2000DecoderContext *s)
 return res;
 }
 
+static int jpeg2000_decode_packet_header(Jpeg2000DecoderContext *s, 
Jpeg2000Tile *tile,
+ int *tp_index,
+ Jpeg2000CodingStyle *codsty,
+ Jpeg2000ResLevel *rlevel, int precno,
+ int layno, uint8_t *expn, int 
numgbits,
+ int *process_data)
+{
+int bandno, cblkno, ret, nb_code_blocks;
+
+if (layno < rlevel->band[0].prec[precno].decoded_layers) {
+*process_data = 0;
+return 0;
+}
+rlevel->band[0].prec[precno].decoded_layers = layno + 1;
+
+if (tile->has_ppt) {
+s->g = tile->packed_headers_stream;
+} else {
+s->g = tile->tile_part[*tp_index].tpg;
+if (bytestream2_get_bytes_left(>g) == 0 && s->bit_index == 8) {
+if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
+s->g = tile->tile_part[++(*tp_index)].tpg;
+}
+}
+if (bytestream2_peek_be32(>g) == JPEG2000_SOP_FIXED_BYTES)
+bytestream2_skip(>g, JPEG2000_SOP_BYTE_LENGTH);
+}
+
+if (!(ret = get_bits(s, 1))) {
+jpeg2000_flush(s);
+*process_data = 0;
+goto end;
+} else if (ret < 0)
+return ret;
+
+for (bandno = 0; bandno < rlevel->nbands; bandno++) {
+Jpeg2000Band *band = rlevel->band + bandno;
+Jpeg2000Prec *prec = band->prec + precno;
+
+if (band->coord[0][0] == band->coord[0][1] ||
+band->coord[1][0] == band->coord[1][1])
+continue;
+nb_code_blocks =  prec->nb_codeblocks_height *
+  prec->nb_codeblocks_width;
+for (cblkno = 0; cblkno < nb_code_blocks; cblkno++) {
+Jpeg2000Cblk *cblk = prec->cblk + cblkno;
+int incl, newpasses, llen;
+void *tmp;
+
+if (cblk->npasses)
+incl = get_bits(s, 1);
+else
+incl = tag_tree_decode(s, prec->cblkincl + cblkno, layno + 1) 
== layno;
+if (!incl)
+continue;
+else if (incl < 0)
+

[FFmpeg-devel] [PATCH 13/14] h264dec: rename flush_dpb()

2020-03-27 Thread Anton Khirnov
The name is misleading, this function does a lot more than just flushing
the DPB.
---
 libavcodec/h264dec.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 67a9cb5438..7679567548 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -485,8 +485,7 @@ void ff_h264_flush_change(H264Context *h)
 h->mmco_reset = 1;
 }
 
-/* forget old pics after a seek */
-static void flush_dpb(AVCodecContext *avctx)
+static void h264_decode_flush(AVCodecContext *avctx)
 {
 H264Context *h = avctx->priv_data;
 int i;
@@ -1063,7 +1062,7 @@ AVCodec ff_h264_decoder = {
},
 .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | 
FF_CODEC_CAP_EXPORTS_CROPPING |
  FF_CODEC_CAP_ALLOCATE_PROGRESS,
-.flush = flush_dpb,
+.flush = h264_decode_flush,
 .update_thread_context = 
ONLY_IF_THREADS_ENABLED(ff_h264_update_thread_context),
 .profiles  = NULL_IF_CONFIG_SMALL(ff_h264_profiles),
 .priv_class= _class,
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 03/14] pthread_frame: merge the functionality for normal decoder init and init_thread_copy

2020-03-27 Thread Anton Khirnov
The current design, where
- proper init is called for the first per-thread context
- first thread's private data is copied into private data for all the
  other threads
- a "fixup" function is called for all the other threads to e.g.
  allocate dynamically allocated data
is very fragile and hard to follow, so it is abandoned. Instead, the
same init function is used to init each per-thread context. Where
necessary, AVCodecInternal.is_copy can be used to differentiate between
the first thread and the other ones (e.g. for decoding the extradata
just once).
---
 doc/multithreading.txt |  3 ---
 libavcodec/aic.c   |  1 -
 libavcodec/alac.c  | 10 -
 libavcodec/avcodec.h   |  6 -
 libavcodec/cfhd.c  |  6 ++---
 libavcodec/cllc.c  | 14 
 libavcodec/dnxhddec.c  | 16 --
 libavcodec/exr.c   | 15 -
 libavcodec/ffv1dec.c   | 29 
 libavcodec/flacdec.c   | 14 
 libavcodec/h264dec.c   | 38 
 libavcodec/hevcdec.c   | 29 ++--
 libavcodec/hqx.c   |  3 ---
 libavcodec/huffyuvdec.c| 32 ---
 libavcodec/lagarith.c  | 11 --
 libavcodec/lcldec.c|  9 
 libavcodec/magicyuv.c  | 16 --
 libavcodec/mdec.c  | 12 --
 libavcodec/mimic.c | 22 +--
 libavcodec/mpeg4videodec.c | 10 -
 libavcodec/pixlet.c| 16 --
 libavcodec/pngdec.c|  6 +
 libavcodec/proresdec2.c| 12 --
 libavcodec/pthread_frame.c | 31 +++---
 libavcodec/rv30.c  |  1 -
 libavcodec/rv34.c  | 28 
 libavcodec/rv34.h  |  1 -
 libavcodec/rv40.c  |  1 -
 libavcodec/sheervideo.c| 14 
 libavcodec/takdec.c|  8 ---
 libavcodec/tiff.c  |  1 -
 libavcodec/tta.c   |  8 ---
 libavcodec/vble.c  |  1 -
 libavcodec/vp3.c   | 45 --
 libavcodec/vp8.c   | 16 --
 libavcodec/vp9.c   |  6 -
 libavcodec/wavpack.c   | 15 -
 libavcodec/ylc.c   | 19 
 38 files changed, 42 insertions(+), 483 deletions(-)

diff --git a/doc/multithreading.txt b/doc/multithreading.txt
index 5b9dcb0bfc..4f645dc147 100644
--- a/doc/multithreading.txt
+++ b/doc/multithreading.txt
@@ -51,9 +51,6 @@ the decode process starts. Call ff_thread_finish_setup() 
afterwards. If
 some code can't be moved, have update_thread_context() run it in the next
 thread.
 
-If the codec allocates writable tables in its init(), add an init_thread_copy()
-which re-allocates them for other threads.
-
 Add AV_CODEC_CAP_FRAME_THREADS to the codec capabilities. There will be very 
little
 speed gain at this point but it should work.
 
diff --git a/libavcodec/aic.c b/libavcodec/aic.c
index 956d71fcff..f027fa99ef 100644
--- a/libavcodec/aic.c
+++ b/libavcodec/aic.c
@@ -504,6 +504,5 @@ AVCodec ff_aic_decoder = {
 .close  = aic_decode_close,
 .decode = aic_decode_frame,
 .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
-.init_thread_copy = ONLY_IF_THREADS_ENABLED(aic_decode_init),
 .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
diff --git a/libavcodec/alac.c b/libavcodec/alac.c
index ea5ab182f9..c8c04223a0 100644
--- a/libavcodec/alac.c
+++ b/libavcodec/alac.c
@@ -601,15 +601,6 @@ static av_cold int alac_decode_init(AVCodecContext * avctx)
 return 0;
 }
 
-#if HAVE_THREADS
-static int init_thread_copy(AVCodecContext *avctx)
-{
-ALACContext *alac = avctx->priv_data;
-alac->avctx = avctx;
-return allocate_buffers(alac);
-}
-#endif
-
 static const AVOption options[] = {
 { "extra_bits_bug", "Force non-standard decoding process",
   offsetof(ALACContext, extra_bit_bug), AV_OPT_TYPE_BOOL, { .i64 = 0 },
@@ -633,7 +624,6 @@ AVCodec ff_alac_decoder = {
 .init   = alac_decode_init,
 .close  = alac_decode_close,
 .decode = alac_decode_frame,
-.init_thread_copy = ONLY_IF_THREADS_ENABLED(init_thread_copy),
 .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
 .priv_class = _class
 };
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 78c483c25c..6bf49c47e2 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3606,12 +3606,6 @@ typedef struct AVCodec {
  * @name Frame-level threading support functions
  * @{
  */
-/**
- * If defined, called on thread contexts when they are created.
- * If the codec allocates writable tables in init(), re-allocate them here.
- * priv_data will be set to a copy of the original.
- */
-int (*init_thread_copy)(AVCodecContext *);
 /**
  * Copy necessary context variables from a previous thread context to the 
current 

[FFmpeg-devel] [PATCH 10/14] h264_sei: use a separate reader for the individual SEI messages

2020-03-27 Thread Anton Khirnov
This tells the parsing functions the payload size and prevents them from
overreading.
---
 libavcodec/h264_sei.c | 33 +++--
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
index a565feabe2..32d13985f3 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -407,9 +407,9 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb,
 int master_ret = 0;
 
 while (get_bits_left(gb) > 16 && show_bits(gb, 16)) {
+GetBitContext gb_payload;
 int type = 0;
 unsigned size = 0;
-unsigned next;
 int ret  = 0;
 
 do {
@@ -429,35 +429,38 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext 
*gb,
type, 8*size, get_bits_left(gb));
 return AVERROR_INVALIDDATA;
 }
-next = get_bits_count(gb) + 8 * size;
+
+ret = init_get_bits8(_payload, gb->buffer + get_bits_count(gb) / 8, 
size);
+if (ret < 0)
+return ret;
 
 switch (type) {
 case H264_SEI_TYPE_PIC_TIMING: // Picture timing SEI
-ret = decode_picture_timing(>picture_timing, gb, ps, logctx);
+ret = decode_picture_timing(>picture_timing, _payload, ps, 
logctx);
 break;
 case H264_SEI_TYPE_USER_DATA_REGISTERED:
-ret = decode_registered_user_data(h, gb, logctx, size);
+ret = decode_registered_user_data(h, _payload, logctx, size);
 break;
 case H264_SEI_TYPE_USER_DATA_UNREGISTERED:
-ret = decode_unregistered_user_data(>unregistered, gb, logctx, 
size);
+ret = decode_unregistered_user_data(>unregistered, _payload, 
logctx, size);
 break;
 case H264_SEI_TYPE_RECOVERY_POINT:
-ret = decode_recovery_point(>recovery_point, gb, logctx);
+ret = decode_recovery_point(>recovery_point, _payload, 
logctx);
 break;
 case H264_SEI_TYPE_BUFFERING_PERIOD:
-ret = decode_buffering_period(>buffering_period, gb, ps, 
logctx);
+ret = decode_buffering_period(>buffering_period, _payload, 
ps, logctx);
 break;
 case H264_SEI_TYPE_FRAME_PACKING:
-ret = decode_frame_packing_arrangement(>frame_packing, gb);
+ret = decode_frame_packing_arrangement(>frame_packing, 
_payload);
 break;
 case H264_SEI_TYPE_DISPLAY_ORIENTATION:
-ret = decode_display_orientation(>display_orientation, gb);
+ret = decode_display_orientation(>display_orientation, 
_payload);
 break;
 case H264_SEI_TYPE_GREEN_METADATA:
-ret = decode_green_metadata(>green_metadata, gb);
+ret = decode_green_metadata(>green_metadata, _payload);
 break;
 case H264_SEI_TYPE_ALTERNATIVE_TRANSFER:
-ret = decode_alternative_transfer(>alternative_transfer, gb);
+ret = decode_alternative_transfer(>alternative_transfer, 
_payload);
 break;
 default:
 av_log(logctx, AV_LOG_DEBUG, "unknown SEI type %d\n", type);
@@ -467,10 +470,12 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext 
*gb,
 if (ret < 0)
 master_ret = ret;
 
-skip_bits_long(gb, next - get_bits_count(gb));
+if (get_bits_left(_payload) < 0) {
+av_log(logctx, AV_LOG_WARNING, "SEI type %d overread by %d bits\n",
+   type, -get_bits_left(_payload));
+}
 
-// FIXME check bits here
-align_get_bits(gb);
+skip_bits_long(gb, 8 * size);
 }
 
 return master_ret;
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 08/14] decode: plug leaks on error in update_frame_pool()

2020-03-27 Thread Anton Khirnov
---
 libavcodec/decode.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 8925ce6edc..f43dc0dd5d 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1595,7 +1595,7 @@ static int update_frame_pool(AVCodecContext *avctx, 
AVFrame *frame)
 // that linesize[0] == 2*linesize[1] in the MPEG-encoder for 4:2:2
 ret = av_image_fill_linesizes(linesize, avctx->pix_fmt, w);
 if (ret < 0)
-return ret;
+goto fail;
 // increase alignment of w for next try (rhs gives the lowest bit 
set in w)
 w += w & ~(w - 1);
 
@@ -1606,8 +1606,10 @@ static int update_frame_pool(AVCodecContext *avctx, 
AVFrame *frame)
 
 tmpsize = av_image_fill_pointers(data, avctx->pix_fmt, h,
  NULL, linesize);
-if (tmpsize < 0)
-return tmpsize;
+if (tmpsize < 0) {
+ret = tmpsize;
+goto fail;
+}
 
 for (i = 0; i < 3 && data[i + 1]; i++)
 size[i] = data[i + 1] - data[i];
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 14/14] h264dec: do not set picture_structure on init

2020-03-27 Thread Anton Khirnov
This has been cargo culted from mpegvideo and serves no useful purpose.
It will be initialize correctly in h264_field_start()
---
 libavcodec/h264dec.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 7679567548..57f4fec3ca 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -309,7 +309,6 @@ static int h264_init_context(AVCodecContext *avctx, 
H264Context *h)
 h->width_from_caller = avctx->width;
 h->height_from_caller= avctx->height;
 
-h->picture_structure = PICT_FRAME;
 h->workaround_bugs   = avctx->workaround_bugs;
 h->flags = avctx->flags;
 h->poc.prev_poc_msb  = 1 << 16;
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 06/14] pthread_frame: do not copy a range of AVCodecContext fields at once

2020-03-27 Thread Anton Khirnov
This is extremely fragile against reordering and hides what is actually
being copied. Copy all the fields manually instead.
---
 libavcodec/pthread_frame.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 639c5ce574..7ebeef357a 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -322,7 +322,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
  */
 static int update_context_from_user(AVCodecContext *dst, AVCodecContext *src)
 {
-#define copy_fields(s, e) memcpy(>s, >s, (char*)>e - 
(char*)>s);
 dst->flags  = src->flags;
 
 dst->draw_horiz_band= src->draw_horiz_band;
@@ -336,7 +335,9 @@ static int update_context_from_user(AVCodecContext *dst, 
AVCodecContext *src)
 dst->flags2  = src->flags2;
 dst->export_side_data = src->export_side_data;
 
-copy_fields(skip_loop_filter, subtitle_header);
+dst->skip_loop_filter = src->skip_loop_filter;
+dst->skip_idct= src->skip_idct;
+dst->skip_frame   = src->skip_frame;
 
 dst->frame_number = src->frame_number;
 dst->reordered_opaque = src->reordered_opaque;
@@ -354,7 +355,6 @@ static int update_context_from_user(AVCodecContext *dst, 
AVCodecContext *src)
 }
 dst->slice_count = src->slice_count;
 return 0;
-#undef copy_fields
 }
 
 /// Releases the buffers that this decoding thread was the last user of.
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 12/14] h264_ps: make the PPS hold a reference to its SPS

2020-03-27 Thread Anton Khirnov
It represents the relationship between them more naturally and will be
useful in the following commits.

Allows significantly more frames in fate-h264-attachment-631 to be
decoded.
---
 libavcodec/h264_parser.c   |  16 +---
 libavcodec/h264_ps.c   |  30 +-
 libavcodec/h264_ps.h   |   4 +-
 libavcodec/h264_slice.c|  27 +-
 libavcodec/h264dec.c   |   4 +-
 tests/ref/fate/h264-attachment-631 | 148 +
 6 files changed, 184 insertions(+), 45 deletions(-)

diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index ec1cbc6a66..aacd44cf3b 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -361,26 +361,14 @@ static inline int parse_nal_units(AVCodecParserContext *s,
 }
 
 av_buffer_unref(>ps.pps_ref);
-av_buffer_unref(>ps.sps_ref);
 p->ps.pps = NULL;
 p->ps.sps = NULL;
 p->ps.pps_ref = av_buffer_ref(p->ps.pps_list[pps_id]);
 if (!p->ps.pps_ref)
 goto fail;
 p->ps.pps = (const PPS*)p->ps.pps_ref->data;
-
-if (!p->ps.sps_list[p->ps.pps->sps_id]) {
-av_log(avctx, AV_LOG_ERROR,
-   "non-existing SPS %u referenced\n", p->ps.pps->sps_id);
-goto fail;
-}
-
-p->ps.sps_ref = av_buffer_ref(p->ps.sps_list[p->ps.pps->sps_id]);
-if (!p->ps.sps_ref)
-goto fail;
-p->ps.sps = (const SPS*)p->ps.sps_ref->data;
-
-sps = p->ps.sps;
+p->ps.sps = p->ps.pps->sps;
+sps   = p->ps.sps;
 
 // heuristic to detect non marked keyframes
 if (p->ps.sps->ref_frame_count <= 1 && p->ps.pps->ref_count[0] <= 
1 && s->pict_type == AV_PICTURE_TYPE_I)
diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c
index 8df195e0a9..e774929e21 100644
--- a/libavcodec/h264_ps.c
+++ b/libavcodec/h264_ps.c
@@ -324,7 +324,6 @@ void ff_h264_ps_uninit(H264ParamSets *ps)
 for (i = 0; i < MAX_PPS_COUNT; i++)
 av_buffer_unref(>pps_list[i]);
 
-av_buffer_unref(>sps_ref);
 av_buffer_unref(>pps_ref);
 
 ps->pps = NULL;
@@ -738,6 +737,15 @@ static int more_rbsp_data_in_pps(const SPS *sps, void 
*logctx)
 return 1;
 }
 
+static void pps_free(void *opaque, uint8_t *data)
+{
+PPS *pps = (PPS*)data;
+
+av_buffer_unref(>sps_ref);
+
+av_freep();
+}
+
 int ff_h264_decode_picture_parameter_set(GetBitContext *gb, AVCodecContext 
*avctx,
  H264ParamSets *ps, int bit_length)
 {
@@ -754,10 +762,15 @@ int ff_h264_decode_picture_parameter_set(GetBitContext 
*gb, AVCodecContext *avct
 return AVERROR_INVALIDDATA;
 }
 
-pps_buf = av_buffer_allocz(sizeof(*pps));
-if (!pps_buf)
+pps = av_mallocz(sizeof(*pps));
+if (!pps)
 return AVERROR(ENOMEM);
-pps = (PPS*)pps_buf->data;
+pps_buf = av_buffer_create((uint8_t*)pps, sizeof(*pps),
+   pps_free, NULL, 0);
+if (!pps_buf) {
+av_freep();
+return AVERROR(ENOMEM);
+}
 
 pps->data_size = gb->buffer_end - gb->buffer;
 if (pps->data_size > sizeof(pps->data)) {
@@ -775,7 +788,14 @@ int ff_h264_decode_picture_parameter_set(GetBitContext 
*gb, AVCodecContext *avct
 ret = AVERROR_INVALIDDATA;
 goto fail;
 }
-sps = (const SPS*)ps->sps_list[pps->sps_id]->data;
+pps->sps_ref = av_buffer_ref(ps->sps_list[pps->sps_id]);
+if (!pps->sps_ref) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
+pps->sps = (const SPS*)pps->sps_ref->data;
+sps  = pps->sps;
+
 if (sps->bit_depth_luma > 14) {
 av_log(avctx, AV_LOG_ERROR,
"Invalid luma bit depth=%d\n",
diff --git a/libavcodec/h264_ps.h b/libavcodec/h264_ps.h
index d6798ca0ef..3f1ab72e38 100644
--- a/libavcodec/h264_ps.h
+++ b/libavcodec/h264_ps.h
@@ -135,6 +135,9 @@ typedef struct PPS {
 uint32_t dequant8_buffer[6][QP_MAX_NUM + 1][64];
 uint32_t(*dequant4_coeff[6])[16];
 uint32_t(*dequant8_coeff[6])[64];
+
+AVBufferRef *sps_ref;
+const SPS   *sps;
 } PPS;
 
 typedef struct H264ParamSets {
@@ -142,7 +145,6 @@ typedef struct H264ParamSets {
 AVBufferRef *pps_list[MAX_PPS_COUNT];
 
 AVBufferRef *pps_ref;
-AVBufferRef *sps_ref;
 /* currently active parameters sets */
 const PPS *pps;
 const SPS *sps;
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index c6072738d7..5a8a4a7f86 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -333,7 +333,6 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
 }
 
 av_buffer_unref(>ps.pps_ref);
-av_buffer_unref(>ps.sps_ref);
 h->ps.pps = NULL;
 h->ps.sps = NULL;
 if (h1->ps.pps_ref) {
@@ -341,12 +340,7 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
 if (!h->ps.pps_ref)
 return 

[FFmpeg-devel] [PATCH 11/14] h264_sei: parse the picture timing SEIs correctly

2020-03-27 Thread Anton Khirnov
Those SEIs refer to the currently active SPS. However, since the SEI
NALUs precede the coded picture data in the bitstream, the active SPS is
in general not known when we are decoding the SEI.

Therefore, store the content of the picture timing SEIs and actually
parse it when the active SPS is known.
---
 libavcodec/h264_parser.c |  9 +
 libavcodec/h264_sei.c| 82 +++-
 libavcodec/h264_sei.h| 11 ++
 libavcodec/h264_slice.c  | 10 +
 4 files changed, 78 insertions(+), 34 deletions(-)

diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index 5f9a9c46ef..ec1cbc6a66 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -481,6 +481,15 @@ static inline int parse_nal_units(AVCodecParserContext *s,
 }
 }
 
+if (p->sei.picture_timing.present) {
+ret = 
ff_h264_sei_process_picture_timing(>sei.picture_timing,
+ sps, avctx);
+if (ret < 0) {
+av_log(avctx, AV_LOG_ERROR, "Error processing the picture 
timing SEI\n");
+p->sei.picture_timing.present = 0;
+}
+}
+
 if (sps->pic_struct_present_flag && p->sei.picture_timing.present) 
{
 switch (p->sei.picture_timing.pic_struct) {
 case H264_SEI_PIC_STRUCT_TOP_FIELD:
diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
index 32d13985f3..870dd90717 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -54,30 +54,22 @@ void ff_h264_sei_uninit(H264SEIContext *h)
 av_buffer_unref(>a53_caption.buf_ref);
 }
 
-static int decode_picture_timing(H264SEIPictureTiming *h, GetBitContext *gb,
- const H264ParamSets *ps, void *logctx)
+int ff_h264_sei_process_picture_timing(H264SEIPictureTiming *h, const SPS *sps,
+   void *logctx)
 {
-int i;
-const SPS *sps = ps->sps;
-
-for (i = 0; ilog2_max_frame_num) && ps->sps_list[i])
-sps = (const SPS *)ps->sps_list[i]->data;
+GetBitContext gb;
 
-if (!sps) {
-av_log(logctx, AV_LOG_ERROR, "SPS unavailable in 
decode_picture_timing\n");
-return AVERROR_PS_NOT_FOUND;
-}
+init_get_bits(, h->payload, h->payload_size_bits);
 
 if (sps->nal_hrd_parameters_present_flag ||
 sps->vcl_hrd_parameters_present_flag) {
-h->cpb_removal_delay = get_bits_long(gb, 
sps->cpb_removal_delay_length);
-h->dpb_output_delay  = get_bits_long(gb, sps->dpb_output_delay_length);
+h->cpb_removal_delay = get_bits_long(, 
sps->cpb_removal_delay_length);
+h->dpb_output_delay  = get_bits_long(, 
sps->dpb_output_delay_length);
 }
 if (sps->pic_struct_present_flag) {
 unsigned int i, num_clock_ts;
 
-h->pic_struct = get_bits(gb, 4);
+h->pic_struct = get_bits(, 4);
 h->ct_type= 0;
 
 if (h->pic_struct > H264_SEI_PIC_STRUCT_FRAME_TRIPLING)
@@ -86,38 +78,38 @@ static int decode_picture_timing(H264SEIPictureTiming *h, 
GetBitContext *gb,
 num_clock_ts = sei_num_clock_ts_table[h->pic_struct];
 h->timecode_cnt = 0;
 for (i = 0; i < num_clock_ts; i++) {
-if (get_bits(gb, 1)) {  /* 
clock_timestamp_flag */
+if (get_bits(, 1)) {  /* 
clock_timestamp_flag */
 H264SEITimeCode *tc = >timecode[h->timecode_cnt++];
 unsigned int full_timestamp_flag;
 unsigned int counting_type, cnt_dropped_flag;
-h->ct_type |= 1 << get_bits(gb, 2);
-skip_bits(gb, 1);   /* 
nuit_field_based_flag */
-counting_type = get_bits(gb, 5);/* counting_type */
-full_timestamp_flag = get_bits(gb, 1);
-skip_bits(gb, 1);   /* discontinuity_flag 
*/
-cnt_dropped_flag = get_bits(gb, 1);  /* cnt_dropped_flag */
+h->ct_type |= 1 << get_bits(, 2);
+skip_bits(, 1);   /* 
nuit_field_based_flag */
+counting_type = get_bits(, 5);/* counting_type */
+full_timestamp_flag = get_bits(, 1);
+skip_bits(, 1);   /* discontinuity_flag 
*/
+cnt_dropped_flag = get_bits(, 1);  /* cnt_dropped_flag 
*/
 if (cnt_dropped_flag && counting_type > 1 && counting_type < 7)
 tc->dropframe = 1;
-tc->frame = get_bits(gb, 8); /* n_frames */
+tc->frame = get_bits(, 8); /* n_frames */
 if (full_timestamp_flag) {
 tc->full = 1;
-tc->seconds = get_bits(gb, 6); /* seconds_value 0..59 */
-tc->minutes = get_bits(gb, 6); /* 

[FFmpeg-devel] [PATCH 09/14] h264dec: do not abort if decoding extradata fails

2020-03-27 Thread Anton Khirnov
Such errors are not necessarily fatal and decoding might still be
possible, e.g. it happens for MVC streams where we do not handle the
subset SPS thus failing to parse its corresponding PPS.
---
 libavcodec/h264dec.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index b6c51ed1e2..dba0634fa0 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -414,10 +414,14 @@ static av_cold int h264_decode_init(AVCodecContext *avctx)
 ret = ff_h264_decode_extradata(avctx->extradata, 
avctx->extradata_size,
>ps, >is_avc, 
>nal_length_size,
avctx->err_recognition, avctx);
-if (ret < 0) {
-h264_decode_end(avctx);
-return ret;
-}
+   if (ret < 0) {
+   av_log(avctx, AV_LOG_WARNING, "Error decoding the extradata\n");
+   if (avctx->err_recognition & AV_EF_EXPLODE) {
+   h264_decode_end(avctx);
+   return ret;
+   }
+   ret = 0;
+   }
 }
 }
 
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 05/14] pthread_frame: do not embed full AVFrame structs into per-thread contexts

2020-03-27 Thread Anton Khirnov
Use the AVFrame API to properly allocate and free frames for delayed
release.
---
 libavcodec/pthread_frame.c | 40 --
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 19073b1253..639c5ce574 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -93,9 +93,9 @@ typedef struct PerThreadContext {
  * Array of frames passed to ff_thread_release_buffer().
  * Frames are released after all threads referencing them are finished.
  */
-AVFrame *released_buffers;
-int  num_released_buffers;
-int  released_buffers_allocated;
+AVFrame **released_buffers;
+int   num_released_buffers;
+int   released_buffers_allocated;
 
 AVFrame *requested_frame;   ///< AVFrame the codec passed to 
get_buffer()
 int  requested_flags;   ///< flags passed to get_buffer() for 
requested_frame
@@ -370,7 +370,7 @@ static void release_delayed_buffers(PerThreadContext *p)
 // fix extended data in case the caller screwed it up
 av_assert0(p->avctx->codec_type == AVMEDIA_TYPE_VIDEO ||
p->avctx->codec_type == AVMEDIA_TYPE_AUDIO);
-f = >released_buffers[--p->num_released_buffers];
+f = p->released_buffers[--p->num_released_buffers];
 f->extended_data = f->data;
 av_frame_unref(f);
 
@@ -654,7 +654,7 @@ void ff_frame_thread_free(AVCodecContext *avctx, int 
thread_count)
 {
 FrameThreadContext *fctx = avctx->internal->thread_ctx;
 const AVCodec *codec = avctx->codec;
-int i;
+int i, j;
 
 park_frame_worker_threads(fctx, thread_count);
 
@@ -700,6 +700,9 @@ void ff_frame_thread_free(AVCodecContext *avctx, int 
thread_count)
 pthread_cond_destroy(>progress_cond);
 pthread_cond_destroy(>output_cond);
 av_packet_unref(>avpkt);
+
+for (j = 0; j < p->released_buffers_allocated; j++)
+av_frame_free(>released_buffers[j]);
 av_freep(>released_buffers);
 
 if (p->avctx) {
@@ -988,7 +991,7 @@ void ff_thread_release_buffer(AVCodecContext *avctx, 
ThreadFrame *f)
 {
 PerThreadContext *p = avctx->internal->thread_ctx;
 FrameThreadContext *fctx;
-AVFrame *dst, *tmp;
+AVFrame *dst;
 int can_direct_free = !(avctx->active_thread_type & FF_THREAD_FRAME) ||
   THREAD_SAFE_CALLBACKS(avctx);
 
@@ -1009,16 +1012,23 @@ void ff_thread_release_buffer(AVCodecContext *avctx, 
ThreadFrame *f)
 fctx = p->parent;
 pthread_mutex_lock(>buffer_mutex);
 
-if (p->num_released_buffers + 1 >= INT_MAX / sizeof(*p->released_buffers))
-goto fail;
-tmp = av_fast_realloc(p->released_buffers, >released_buffers_allocated,
-  (p->num_released_buffers + 1) *
-  sizeof(*p->released_buffers));
-if (!tmp)
-goto fail;
-p->released_buffers = tmp;
+if (p->num_released_buffers == p->released_buffers_allocated) {
+AVFrame **tmp = av_realloc_array(p->released_buffers, 
p->released_buffers_allocated + 1,
+ sizeof(*p->released_buffers));
+if (tmp) {
+tmp[p->released_buffers_allocated] = av_frame_alloc();
+p->released_buffers = tmp;
+}
+
+if (!tmp || !tmp[p->released_buffers_allocated]) {
+av_log(avctx, AV_LOG_ERROR, "Cannot queue a buffer for delayed "
+   "release. This will leak memory.\n");
+goto fail;
+}
+p->released_buffers_allocated++;
+}
 
-dst = >released_buffers[p->num_released_buffers];
+dst = p->released_buffers[p->num_released_buffers];
 av_frame_move_ref(dst, f->f);
 
 p->num_released_buffers++;
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 01/14] mpeg4videodec: do not copy a range of fields at once

2020-03-27 Thread Anton Khirnov
This is extremely fragile against reordering and hides what is actually
being copied. Copy all the fields manually instead.
---
Review comments applied and branch rebased against master.

13/14 has been acked and is only included for completeness.
---
 libavcodec/mpeg4videodec.c | 28 +++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index cc03486646..b57bfca943 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -3460,7 +3460,33 @@ static int mpeg4_update_thread_context(AVCodecContext 
*dst,
 if (ret < 0)
 return ret;
 
-memcpy(((uint8_t*)s) + sizeof(MpegEncContext), ((uint8_t*)s1) + 
sizeof(MpegEncContext), sizeof(Mpeg4DecContext) - sizeof(MpegEncContext));
+// copy all the necessary fields explicitly
+s->time_increment_bits   = s1->time_increment_bits;
+s->shape = s1->shape;
+s->vol_sprite_usage  = s1->vol_sprite_usage;
+s->sprite_brightness_change  = s1->sprite_brightness_change;
+s->num_sprite_warping_points = s1->num_sprite_warping_points;
+s->rvlc  = s1->rvlc;
+s->resync_marker = s1->resync_marker;
+s->t_frame   = s1->t_frame;
+s->new_pred  = s1->new_pred;
+s->enhancement_type  = s1->enhancement_type;
+s->scalability   = s1->scalability;
+s->use_intra_dc_vlc  = s1->use_intra_dc_vlc;
+s->intra_dc_threshold= s1->intra_dc_threshold;
+s->divx_version  = s1->divx_version;
+s->divx_build= s1->divx_build;
+s->xvid_build= s1->xvid_build;
+s->lavc_build= s1->lavc_build;
+s->showed_packed_warning = s1->showed_packed_warning;
+s->vol_control_parameters= s1->vol_control_parameters;
+s->cplx_estimation_trash_i   = s1->cplx_estimation_trash_i;
+s->cplx_estimation_trash_p   = s1->cplx_estimation_trash_p;
+s->cplx_estimation_trash_b   = s1->cplx_estimation_trash_b;
+s->rgb   = s1->rgb;
+
+memcpy(s->sprite_shift, s1->sprite_shift, sizeof(s1->sprite_shift));
+memcpy(s->sprite_traj,  s1->sprite_traj,  sizeof(s1->sprite_traj));
 
 if (CONFIG_MPEG4_DECODER && !init && s1->xvid_build >= 0)
 ff_xvid_idct_init(>m.idsp, dst);
-- 
2.25.1

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

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

[FFmpeg-devel] [PATCH 07/14] lavc: do not implicitly share the frame pool between threads

2020-03-27 Thread Anton Khirnov
Currently the frame pool used by the default get_buffer2()
implementation is a single struct, allocated when opening the decoder.
A pointer to it is simply copied to each frame thread and we assume that
no thread attempts to modify it at an unexpected time. This is rather
fragile and potentially dangerous.

With this commit, the frame pool is made refcounted, with the reference
being propagated across threads along with other context variables. The
frame pool is now also immutable - when the stream parameters change we
drop the old reference and create a new one.
---
 libavcodec/decode.c| 102 -
 libavcodec/internal.h  |  21 +---
 libavcodec/pthread_frame.c |  12 +
 libavcodec/utils.c |  13 +
 4 files changed, 94 insertions(+), 54 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index af6bb3f952..8925ce6edc 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -45,6 +45,25 @@
 #include "internal.h"
 #include "thread.h"
 
+typedef struct FramePool {
+/**
+ * Pools for each data plane. For audio all the planes have the same size,
+ * so only pools[0] is used.
+ */
+AVBufferPool *pools[4];
+
+/*
+ * Pool parameters
+ */
+int format;
+int width, height;
+int stride_align[AV_NUM_DATA_POINTERS];
+int linesize[4];
+int planes;
+int channels;
+int samples;
+} FramePool;
+
 static int apply_param_change(AVCodecContext *avctx, const AVPacket *avpkt)
 {
 int size = 0, ret;
@@ -1504,10 +1523,61 @@ int ff_get_format(AVCodecContext *avctx, const enum 
AVPixelFormat *fmt)
 return ret;
 }
 
+static void frame_pool_free(void *opaque, uint8_t *data)
+{
+FramePool *pool = (FramePool*)data;
+int i;
+
+for (i = 0; i < FF_ARRAY_ELEMS(pool->pools); i++)
+av_buffer_pool_uninit(>pools[i]);
+
+av_freep();
+}
+
+static AVBufferRef *frame_pool_alloc(void)
+{
+FramePool *pool = av_mallocz(sizeof(*pool));
+AVBufferRef *buf;
+
+if (!pool)
+return NULL;
+
+buf = av_buffer_create((uint8_t*)pool, sizeof(*pool),
+   frame_pool_free, NULL, 0);
+if (!buf) {
+av_freep();
+return NULL;
+}
+
+return buf;
+}
+
 static int update_frame_pool(AVCodecContext *avctx, AVFrame *frame)
 {
-FramePool *pool = avctx->internal->pool;
-int i, ret;
+FramePool *pool = avctx->internal->pool ?
+  (FramePool*)avctx->internal->pool->data : NULL;
+AVBufferRef *pool_buf;
+int i, ret, ch, planes;
+
+if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) {
+int planar = av_sample_fmt_is_planar(frame->format);
+ch = frame->channels;
+planes = planar ? ch : 1;
+}
+
+if (pool && pool->format == frame->format) {
+if (avctx->codec_type == AVMEDIA_TYPE_VIDEO &&
+pool->width == frame->width && pool->height == frame->height)
+return 0;
+if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && pool->planes == planes 
&&
+pool->channels == ch && frame->nb_samples == pool->samples)
+return 0;
+}
+
+pool_buf = frame_pool_alloc();
+if (!pool_buf)
+return AVERROR(ENOMEM);
+pool = (FramePool*)pool_buf->data;
 
 switch (avctx->codec_type) {
 case AVMEDIA_TYPE_VIDEO: {
@@ -1518,10 +1588,6 @@ static int update_frame_pool(AVCodecContext *avctx, 
AVFrame *frame)
 int h = frame->height;
 int tmpsize, unaligned;
 
-if (pool->format == frame->format &&
-pool->width == frame->width && pool->height == frame->height)
-return 0;
-
 avcodec_align_dimensions2(avctx, , , pool->stride_align);
 
 do {
@@ -1548,7 +1614,6 @@ static int update_frame_pool(AVCodecContext *avctx, 
AVFrame *frame)
 size[i] = tmpsize - (data[i] - data[0]);
 
 for (i = 0; i < 4; i++) {
-av_buffer_pool_uninit(>pools[i]);
 pool->linesize[i] = linesize[i];
 if (size[i]) {
 pool->pools[i] = av_buffer_pool_init(size[i] + 16 + 
STRIDE_ALIGN - 1,
@@ -1568,15 +1633,6 @@ static int update_frame_pool(AVCodecContext *avctx, 
AVFrame *frame)
 break;
 }
 case AVMEDIA_TYPE_AUDIO: {
-int ch = frame->channels; 
//av_get_channel_layout_nb_channels(frame->channel_layout);
-int planar = av_sample_fmt_is_planar(frame->format);
-int planes = planar ? ch : 1;
-
-if (pool->format == frame->format && pool->planes == planes &&
-pool->channels == ch && frame->nb_samples == pool->samples)
-return 0;
-
-av_buffer_pool_uninit(>pools[0]);
 ret = av_samples_get_buffer_size(>linesize[0], ch,
  frame->nb_samples, frame->format, 0);
 if (ret < 0)
@@ -1596,19 +1652,19 @@ static int update_frame_pool(AVCodecContext *avctx, 
AVFrame *frame)
 }
 default: av_assert0(0);

[FFmpeg-devel] [PATCH 02/14] lavc: replace AVCodecInternal.allocate_progress with an internal cap

2020-03-27 Thread Anton Khirnov
This is a constant codec property, so a capability flag is more appropriate.
---
 doc/multithreading.txt |  5 +++--
 libavcodec/ffv1dec.c   |  4 +---
 libavcodec/h264dec.c   |  5 ++---
 libavcodec/hevcdec.c   |  5 ++---
 libavcodec/internal.h  | 20 +---
 libavcodec/mimic.c |  3 +--
 libavcodec/mpeg4videodec.c |  4 ++--
 libavcodec/pngdec.c| 10 ++
 libavcodec/pthread_frame.c |  4 ++--
 libavcodec/rv30.c  |  1 +
 libavcodec/rv34.c  |  2 --
 libavcodec/rv40.c  |  1 +
 libavcodec/vp3.c   |  6 +++---
 libavcodec/vp8.c   |  2 +-
 libavcodec/vp9.c   |  4 ++--
 libavcodec/wavpack.c   |  5 ++---
 16 files changed, 34 insertions(+), 47 deletions(-)

diff --git a/doc/multithreading.txt b/doc/multithreading.txt
index 83849deacc..5b9dcb0bfc 100644
--- a/doc/multithreading.txt
+++ b/doc/multithreading.txt
@@ -58,9 +58,10 @@ Add AV_CODEC_CAP_FRAME_THREADS to the codec capabilities. 
There will be very lit
 speed gain at this point but it should work.
 
 If there are inter-frame dependencies, so the codec calls
-ff_thread_report/await_progress(), set AVCodecInternal.allocate_progress. The
+ff_thread_report/await_progress(), set FF_CODEC_CAP_ALLOCATE_PROGRESS in
+AVCodec.caps_internal and use ff_thread_get_buffer() to allocate frames. The
 frames must then be freed with ff_thread_release_buffer().
-Otherwise leave it at zero and decode directly into the user-supplied frames.
+Otherwise decode directly into the user-supplied frames.
 
 Call ff_thread_report_progress() after some part of the current picture has 
decoded.
 A good place to put this is where draw_horiz_band() is called - add this if it 
isn't
diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
index ca1286f413..2ffd3ef991 100644
--- a/libavcodec/ffv1dec.c
+++ b/libavcodec/ffv1dec.c
@@ -826,8 +826,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
 if ((ret = ff_ffv1_init_slice_contexts(f)) < 0)
 return ret;
 
-avctx->internal->allocate_progress = 1;
-
 return 0;
 }
 
@@ -1094,5 +1092,5 @@ AVCodec ff_ffv1_decoder = {
 .update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context),
 .capabilities   = AV_CODEC_CAP_DR1 /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/ |
   AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS,
-.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP | 
FF_CODEC_CAP_ALLOCATE_PROGRESS,
 };
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index fec1adfeed..defe514828 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -424,8 +424,6 @@ static av_cold int h264_decode_init(AVCodecContext *avctx)
 h->avctx->has_b_frames = h->ps.sps->num_reorder_frames;
 }
 
-avctx->internal->allocate_progress = 1;
-
 ff_h264_flush_change(h);
 
 if (h->enable_er < 0 && (avctx->active_thread_type & FF_THREAD_SLICE))
@@ -1080,7 +1078,8 @@ AVCodec ff_h264_decoder = {
 #endif
NULL
},
-.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | 
FF_CODEC_CAP_EXPORTS_CROPPING,
+.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | 
FF_CODEC_CAP_EXPORTS_CROPPING |
+ FF_CODEC_CAP_ALLOCATE_PROGRESS,
 .flush = flush_dpb,
 .init_thread_copy  = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
 .update_thread_context = 
ONLY_IF_THREADS_ENABLED(ff_h264_update_thread_context),
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 7448be482c..58689a4370 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -3491,8 +3491,6 @@ static av_cold int hevc_decode_init(AVCodecContext *avctx)
 HEVCContext *s = avctx->priv_data;
 int ret;
 
-avctx->internal->allocate_progress = 1;
-
 ret = hevc_init_context(avctx);
 if (ret < 0)
 return ret;
@@ -3582,7 +3580,8 @@ AVCodec ff_hevc_decoder = {
 .init_thread_copy  = ONLY_IF_THREADS_ENABLED(hevc_init_thread_copy),
 .capabilities  = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
  AV_CODEC_CAP_SLICE_THREADS | 
AV_CODEC_CAP_FRAME_THREADS,
-.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | 
FF_CODEC_CAP_EXPORTS_CROPPING,
+.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | 
FF_CODEC_CAP_EXPORTS_CROPPING |
+ FF_CODEC_CAP_ALLOCATE_PROGRESS,
 .profiles  = NULL_IF_CONFIG_SMALL(ff_hevc_profiles),
 .hw_configs= (const AVCodecHWConfigInternal*[]) {
 #if CONFIG_HEVC_DXVA2_HWACCEL
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index bccd9222d4..700807cd75 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -68,6 +68,11 @@
  * Codec initializes slice-based threading with a main function
  */
 #define FF_CODEC_CAP_SLICE_THREAD_HAS_MF(1 << 5)
+/*
+ * The codec supports frame threading 

[FFmpeg-devel] [PATCH 04/14] pthread_frame: do not share priv_data between multiple codec contexts

2020-03-27 Thread Anton Khirnov
Specifically, between the user-facing one and the first frame thread
one.

This is fragile and dangerous, allocate separate private data for each
per-thread context.
---
 libavcodec/pthread_frame.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 183d0f84f2..19073b1253 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -702,7 +702,7 @@ void ff_frame_thread_free(AVCodecContext *avctx, int 
thread_count)
 av_packet_unref(>avpkt);
 av_freep(>released_buffers);
 
-if (i && p->avctx) {
+if (p->avctx) {
 if (codec->priv_class)
 av_opt_free(p->avctx->priv_data);
 av_freep(>avctx->priv_data);
@@ -812,7 +812,7 @@ int ff_frame_thread_init(AVCodecContext *avctx)
 copy->internal->thread_ctx = p;
 copy->internal->last_pkt_props = >avpkt;
 
-if (i) {
+if (codec->priv_data_size) {
 copy->priv_data = av_mallocz(codec->priv_data_size);
 if (!copy->priv_data) {
 err = AVERROR(ENOMEM);
@@ -825,9 +825,11 @@ int ff_frame_thread_init(AVCodecContext *avctx)
 if (err < 0)
 goto error;
 }
-copy->internal->is_copy = 1;
 }
 
+if (i)
+copy->internal->is_copy = 1;
+
 if (codec->init)
 err = codec->init(copy);
 
-- 
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] avformat: Add Dynacolor MVC Demuxer

2020-03-27 Thread Tom Needham
Please See the updated patch below which applies as expected.

From 8f741899b7f6b3884d613f622a548b353af2489e Mon Sep 17 00:00:00 2001
From: Tom Needham <06needh...@gmail.com>
Date: Sun, 21 Jul 2019 21:11:19 +0100
Subject: [PATCH] avformat: Add Dynacolor MVC Demuxer

This demuxer adds support for demuxing files in the Dynacolor format
such as the sample located at:

http://samples.ffmpeg.org/camera-dvr/dynacolor/dynacolor-camera-sample

However some decode errors are showing on the resulting MPEG4 stream.
I don't know whether this is a bug with the demuxer or the file as there is
only one sample
but the output results in a 1 second mp4 file that is playable in VLC media
player.

Signed-off-by: Tom Needham <06needh...@gmail.com>
---
 Changelog|   1 +
 doc/general.texi |   1 +
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/dynacolor.c  | 497 +++
 libavformat/dynacolor.h  | 273 +
 libavformat/version.h|   2 +-
 7 files changed, 775 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/dynacolor.c
 create mode 100644 libavformat/dynacolor.h

diff --git a/Changelog b/Changelog
index 711861bda9..79d39494c9 100644
--- a/Changelog
+++ b/Changelog
@@ -54,6 +54,7 @@ version :
 - DERF demuxer
 - CRI HCA decoder
 - CRI HCA demuxer
+- Dynacolor MVC Demuxer


 version 4.2:
diff --git a/doc/general.texi b/doc/general.texi
index 752618a00b..4eb4716d87 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -452,6 +452,7 @@ library:
 @item DXA   @tab   @tab X
 @tab This format is used in the non-Windows version of the Feeble Files
  game and different game cutscenes repacked for use with ScummVM.
+@item Dynacolor MVC @tab   @tab X
 @item Electronic Arts cdata  @tab@tab X
 @item Electronic Arts Multimedia  @tab@tab X
 @tab Used in various EA games; files have extensions like WVE and UV2.
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 8fd0d43721..4d1ca8b7ed 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -169,6 +169,7 @@ OBJS-$(CONFIG_DV_MUXER)  += dvenc.o
 OBJS-$(CONFIG_DVBSUB_DEMUXER)+= dvbsub.o rawdec.o
 OBJS-$(CONFIG_DVBTXT_DEMUXER)+= dvbtxt.o rawdec.o
 OBJS-$(CONFIG_DXA_DEMUXER)   += dxa.o
+OBJS-$(CONFIG_DYNACOLOR_DEMUXER) += dynacolor.o
 OBJS-$(CONFIG_EA_CDATA_DEMUXER)  += eacdata.o
 OBJS-$(CONFIG_EA_DEMUXER)+= electronicarts.o
 OBJS-$(CONFIG_EAC3_DEMUXER)  += ac3dec.o rawdec.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 39d2c352f5..50f3926b05 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -131,6 +131,7 @@ extern AVOutputFormat ff_dv_muxer;
 extern AVInputFormat  ff_dvbsub_demuxer;
 extern AVInputFormat  ff_dvbtxt_demuxer;
 extern AVInputFormat  ff_dxa_demuxer;
+extern AVInputFormat  ff_dynacolor_demuxer;
 extern AVInputFormat  ff_ea_demuxer;
 extern AVInputFormat  ff_ea_cdata_demuxer;
 extern AVInputFormat  ff_eac3_demuxer;
diff --git a/libavformat/dynacolor.c b/libavformat/dynacolor.c
new file mode 100644
index 00..394e36adbe
--- /dev/null
+++ b/libavformat/dynacolor.c
@@ -0,0 +1,497 @@
+/*
+ * Dynacolor MVC Demuxer
+ * Copyright (c) 2020 Tom Needham
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
+ */
+
+#include 
+#include "avformat.h"
+#include "internal.h"
+#include "dynacolor.h"
+#include "libavutil/channel_layout.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/mathematics.h"
+#include "libavutil/timecode.h"
+#include "libavutil/avassert.h"
+
+//max total
size=sizeof(tHeader)+sizeof(tSuperExtraIdx1)+PENTAMICRO_PES_HEADER_SIZE+frame
size
+inline unsigned char ff_dyna_callback_checksum(tBasicIdx *header)
+{
+int i;
+unsigned char chksum = 0, *pHeader;
+pHeader = (unsigned char *)header;
+if (*pHeader == '@' && *(pHeader + 1) == '2') {
+for (i = 0; i < sizeof(tBasicIdx) - 1; ++i) {
+chksum ^= *(pHeader + i);
+}
+}
+return chksum;
+}
+
+inline unsigned char ff_dyna_extra_checksum(tBasicIdx *header)
+{
+int i;
+unsigned char chksum = 0, *pHeader;
+pHeader = (unsigned 

[FFmpeg-devel] [PATCH 4/4] avformat/avidec: Fix memleak with embedded GAB2 subtitles

2020-03-27 Thread Andreas Rheinhardt
The code for GAB2 subtitles predates refcounting AVPackets. So in order
to transfer the ownership of a packet's data pkt->data was simply stored
and the packet zeroed; in the end (i.e. in the read_close-function) this
data was then simply freed with av_freep(). This of course leads to a leak
of an AVBufferRef and an AVBuffer. It has been fixed by keeping and
eventually unreferencing the packet's buf instead.

Additionally, the packet is now reset via av_packet_unref().

Signed-off-by: Andreas Rheinhardt 
---
This is actually not the only thing wrong with these GAB2 subtitles; but
it is the only issue that exists on success.

(Actually, both the srt and ass demuxer read the whole file when reading
the header and store the result in a subtitles queue; so keeping the
data is actually unnecessary.)

 libavformat/avidec.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 87298513c2..5fc3e01aa9 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -60,7 +60,7 @@ typedef struct AVIStream {
 
 AVFormatContext *sub_ctx;
 AVPacket sub_pkt;
-uint8_t *sub_buffer;
+AVBufferRef *sub_buffer;
 
 int64_t seek_pos;
 } AVIStream;
@@ -1116,8 +1116,9 @@ static int read_gab2_sub(AVFormatContext *s, AVStream 
*st, AVPacket *pkt)
 time_base = ast->sub_ctx->streams[0]->time_base;
 avpriv_set_pts_info(st, 64, time_base.num, time_base.den);
 }
-ast->sub_buffer = pkt->data;
-memset(pkt, 0, sizeof(*pkt));
+ast->sub_buffer = pkt->buf;
+pkt->buf = NULL;
+av_packet_unref(pkt);
 return 1;
 
 error:
@@ -1909,7 +1910,7 @@ static int avi_read_close(AVFormatContext *s)
 av_freep(>sub_ctx->pb);
 avformat_close_input(>sub_ctx);
 }
-av_freep(>sub_buffer);
+av_buffer_unref(>sub_buffer);
 av_packet_unref(>sub_pkt);
 }
 }
-- 
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".

Re: [FFmpeg-devel] [PATCH 02/14] avformat/matroska: clean the structure formatting

2020-03-27 Thread Anton Khirnov
Quoting Moritz Barsnick (2020-03-24 09:47:14)
> On Sun, Mar 22, 2020 at 09:59:21 +0100, Steve Lhomme wrote:
> > Always use a comma at the end, order elements by value.
> 
> IIUC, this is strictly a C99(+) "feature", so should probably be
> mentioned here:
> https://ffmpeg.org/developer.html#C-language-features
> in case "all compilers we care about" support this.
> 
> (Yes, I am aware that many other enums in said file already are
> formatted thus.)
> 
> Deeply into nitpick country, ;-)

IMO we should stop picking specific C99 features we require and just
say we assume all of it, except some forbidden features (VLA, complex
numbers). We even borderline-depend on a C11 feature (atomics).

-- 
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 3/4] avformat/avidec: Fix memleak when allocating DVDemuxContext fails

2020-03-27 Thread Andreas Rheinhardt
An AVIStream (intended to be used as private data for an AVStream) would
leak in this scenario.

Also return a more fitting error code instead of AVERROR_INVALIDDATA.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/avidec.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 18402f0032..87298513c2 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -605,9 +605,12 @@ static int avi_read_header(AVFormatContext *s)
 ast = s->streams[0]->priv_data;
 st->priv_data = NULL;
 ff_free_stream(s, st);
-avi->dv_demux = avpriv_dv_init_demux(s);
-if (!avi->dv_demux)
-goto fail;
+
+avi->dv_demux = avpriv_dv_init_demux(s);
+if (!avi->dv_demux) {
+av_free(ast);
+return AVERROR(ENOMEM);
+}
 
 s->streams[0]->priv_data = ast;
 avio_skip(pb, 3 * 4);
-- 
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] [PATCH 2/4] avformat/avidec: Fix memleak when DV demuxer is disabled

2020-03-27 Thread Andreas Rheinhardt
If one uses a build without dv demuxer, an AVIStream struct that is
destined to be used as private data for an AVStream by the avi demuxer
would leak, because it has been moved from the AVStream (that is going
to be freed) and only stored in a local variable (in order to be used
for another AVStream), but if the dv demuxer is disabled, the earlier
code returned immediately instead.

Also return a better error code in this scenario (instead of
AVERROR_INVALIDDATA).

Signed-off-by: Andreas Rheinhardt 
---
Like lots of other parts of the code, this also relies on the compiler's
ability to eliminate dead code; otherwise linking would fail because
avpriv_dv_init_demux would not be available.

 libavformat/avidec.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index ae343e732a..18402f0032 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -599,15 +599,16 @@ static int avi_read_header(AVFormatContext *s)
 handler != MKTAG('d', 'v', 's', 'l'))
 goto fail;
 
+if (!CONFIG_DV_DEMUXER)
+return AVERROR_DEMUXER_NOT_FOUND;
+
 ast = s->streams[0]->priv_data;
 st->priv_data = NULL;
 ff_free_stream(s, st);
-if (CONFIG_DV_DEMUXER) {
 avi->dv_demux = avpriv_dv_init_demux(s);
 if (!avi->dv_demux)
 goto fail;
-} else
-goto fail;
+
 s->streams[0]->priv_data = ast;
 avio_skip(pb, 3 * 4);
 ast->scale = avio_rl32(pb);
-- 
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] [PATCH 1/4] avformat/avidec: Don't reimplement ff_free_stream()

2020-03-27 Thread Andreas Rheinhardt
Using ff_free_stream() makes the code more readable, more future-proof
(the old code freed AVCodecContexts and AVCodecParameters and its
substructures manually, so that there is a chance that there would be a
memleak for some time if new substructures were added) and reduces
code size.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/avidec.c | 17 ++---
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 00c3978b2d..ae343e732a 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -600,21 +600,8 @@ static int avi_read_header(AVFormatContext *s)
 goto fail;
 
 ast = s->streams[0]->priv_data;
-av_freep(>streams[0]->codecpar->extradata);
-av_freep(>streams[0]->codecpar);
-#if FF_API_LAVF_AVCTX
-FF_DISABLE_DEPRECATION_WARNINGS
-av_freep(>streams[0]->codec);
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-if (s->streams[0]->info)
-av_freep(>streams[0]->info->duration_error);
-av_freep(>streams[0]->info);
-if (s->streams[0]->internal)
-av_freep(>streams[0]->internal->avctx);
-av_freep(>streams[0]->internal);
-av_freep(>streams[0]);
-s->nb_streams = 0;
+st->priv_data = NULL;
+ff_free_stream(s, st);
 if (CONFIG_DV_DEMUXER) {
 avi->dv_demux = avpriv_dv_init_demux(s);
 if (!avi->dv_demux)
-- 
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".

Re: [FFmpeg-devel] [PATCH 1/3] avformat/avformat: Update av_read_frame() documentation

2020-03-27 Thread Andreas Rheinhardt
Anton Khirnov:
> Quoting Andreas Rheinhardt (2019-12-01 11:05:44)
>> This commit updates the documentation of av_read_frame() to match its
>> actual behaviour in several ways:
>>
>> 1. On success, av_read_frame() always returns refcounted packets.
>> 2. It can handle uninitialized packets.
>> 3. On error, it always returns clean packets.
>>
>> This will allow callers to not initialize or unref unnecessarily.
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
> 
> Looks ok, don't know if the version bump is necessary since there is no
> change in behaviour.
> 
I don't feel to strongly about it either. What do others think of it? If
there is no one in favour of it, I will remove it.

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

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

Re: [FFmpeg-devel] [PATCH 2/2] avcodec/avcodec, avpacket: Return blank packet on av_packet_ref() failure

2020-03-27 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2020-03-27 03:25:14)
> Up until now, it was completely unspecified what the content of the
> destination packet dst was on error. Depending upon where the error
> happened calling av_packet_unref() on dst might be dangerous.
> 
> This commit changes this by making sure that dst is blank on error, so
> unreferencing it again is safe (and still pointless). This behaviour is
> documented.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  doc/APIchanges| 4 
>  libavcodec/avcodec.h  | 3 ++-
>  libavcodec/avpacket.c | 7 ---
>  libavcodec/version.h  | 2 +-
>  4 files changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 8eeaec2028..f2bb2d242b 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,10 @@ libavutil: 2017-10-21
>  
>  API changes, most recent first:
>  
> +2020-03-27 - xx - lavc 58.77.100 - avcodec.h
> +  av_packet_ref() now guarantees to return the destination packet
> +  in a blank state on error.
> +
>  2020-03-10 - xx - lavc 58.75.100 - avcodec.h
>Add AV_PKT_DATA_ICC_PROFILE.
>  
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index f918d20a61..8fc0ad92c9 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -4651,7 +4651,8 @@ void av_packet_free_side_data(AVPacket *pkt);
>   * @param dst Destination packet. Will be completely overwritten.
>   * @param src Source packet
>   *
> - * @return 0 on success, a negative AVERROR on error.
> + * @return 0 on success, a negative AVERROR on error. On error, dst
> + * will be blank (as if returned by av_packet_alloc()).
>   */
>  int av_packet_ref(AVPacket *dst, const AVPacket *src);
>  
> diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
> index 132567bc2d..c622718a45 100644
> --- a/libavcodec/avpacket.c
> +++ b/libavcodec/avpacket.c
> @@ -610,12 +610,13 @@ int av_packet_ref(AVPacket *dst, const AVPacket *src)
>  {
>  int ret;
>  
> +dst->buf = NULL;
> +

I really think av_init_packet() would be more robust against future
changes. But I'm not going to push for that especially strongly, so feel
free to push whichever version you prefer.

-- 
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 v2 1/2] avcodec/avpacket: Always treat dst in av_packet_ref as uninitialized

2020-03-27 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2020-03-27 03:25:13)
> av_packet_ref() mostly treated the destination packet dst as uninitialized,
> i.e. the destination fields were simply overwritten. But if the source
> packet was not reference-counted, dst->buf was treated as if it pointed
> to an already allocated buffer (if != NULL) to be reallocated to the
> desired size.
> 
> The documentation did not explicitly state whether the dst will be treated
> as uninitialized, but it stated that if the source packet is not refcounted,
> a new buffer in dst will be allocated. This and the fact that the side-data
> as well as the codepath taken in case src is refcounted always treated the
> packet as uninitialized means that dst should always be treated as
> uninitialized for the sake of consistency. And this behaviour has been
> explicitly documented.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/avcodec.h  | 2 +-
>  libavcodec/avpacket.c | 1 +
>  2 files changed, 2 insertions(+), 1 deletion(-)

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 1/3] avformat/avformat: Update av_read_frame() documentation

2020-03-27 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2019-12-01 11:05:44)
> This commit updates the documentation of av_read_frame() to match its
> actual behaviour in several ways:
> 
> 1. On success, av_read_frame() always returns refcounted packets.
> 2. It can handle uninitialized packets.
> 3. On error, it always returns clean packets.
> 
> This will allow callers to not initialize or unref unnecessarily.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---

Looks ok, don't know if the version bump is necessary since there is no
change in behaviour.

-- 
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] about mediacodec encoder on android platform

2020-03-27 Thread aistoy
Hi, I want to know why ffmpeg do not include mediacodec encoder, just include 
mediacodec decoder. 
And why the decoder implemention don’t use mediacodec native api, but use jni 
call mediacodec java methods. 
If i plan to add the mediacodec encoder, what do you think i should pay 
attention to ?
thanks!
___
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".