[FFmpeg-cvslog] avcodec/av1dec: call ff_cbs_flush() on decoder flush

2020-09-29 Thread James Almer
ffmpeg | branch: master | James Almer  | Thu Sep 24 18:54:14 
2020 -0300| [aa5e49e46d3aa22cc805c85a982afac1405aede5] | committer: James Almer

avcodec/av1dec: call ff_cbs_flush() on decoder flush

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aa5e49e46d3aa22cc805c85a982afac1405aede5
---

 libavcodec/av1dec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index a30a496b4c..07026b7aeb 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -854,6 +854,8 @@ static void av1_decode_flush(AVCodecContext *avctx)
 av1_frame_unref(avctx, >cur_frame);
 s->raw_frame_header = NULL;
 s->raw_seq = NULL;
+
+ff_cbs_flush(s->cbc);
 }
 
 AVCodec ff_av1_decoder = {

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

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

[FFmpeg-cvslog] avcodec/av1dec: parse dimensions from the sequence header in extradata

2020-09-29 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Sep 25 11:20:41 
2020 -0300| [ea4b10249d1a9211fb050961d99aeb1725f4f783] | committer: James Almer

avcodec/av1dec: parse dimensions from the sequence header in extradata

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ea4b10249d1a9211fb050961d99aeb1725f4f783
---

 libavcodec/av1dec.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 0bb04a3e44..f6b9fbbac3 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -405,6 +405,9 @@ static av_cold int av1_decode_free(AVCodecContext *avctx)
 static int set_context_with_sequence(AVCodecContext *avctx,
  const AV1RawSequenceHeader *seq)
 {
+int width = seq->max_frame_width_minus_1 + 1;
+int height = seq->max_frame_height_minus_1 + 1;
+
 avctx->profile = seq->seq_profile;
 avctx->level = seq->seq_level_idx[0];
 
@@ -423,6 +426,13 @@ static int set_context_with_sequence(AVCodecContext *avctx,
 break;
 }
 
+if (avctx->width != width || avctx->height != height) {
+int ret = ff_set_dimensions(avctx, width, height);
+if (ret < 0)
+return ret;
+}
+avctx->sample_aspect_ratio = (AVRational) { 1, 1 };
+
 if (seq->timing_info.num_units_in_display_tick &&
 seq->timing_info.time_scale) {
 av_reduce(>framerate.den, >framerate.num,

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

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

[FFmpeg-cvslog] avcodec/cbs_h2645: implement CodedBitstreamType.flush() callbacks

2020-09-29 Thread James Almer
ffmpeg | branch: master | James Almer  | Thu Sep 24 18:19:05 
2020 -0300| [0c842533532aae9864db5527f6c321ff450f11a0] | committer: James Almer

avcodec/cbs_h2645: implement CodedBitstreamType.flush() callbacks

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0c842533532aae9864db5527f6c321ff450f11a0
---

 libavcodec/cbs_h2645.c | 42 ++
 1 file changed, 42 insertions(+)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index b9233f4df7..b6d77dd17f 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -1296,6 +1296,24 @@ static int 
cbs_h2645_assemble_fragment(CodedBitstreamContext *ctx,
 return 0;
 }
 
+static void cbs_h264_flush(CodedBitstreamContext *ctx)
+{
+CodedBitstreamH264Context *h264 = ctx->priv_data;
+
+for (int i = 0; i < FF_ARRAY_ELEMS(h264->sps); i++) {
+av_buffer_unref(>sps_ref[i]);
+h264->sps[i] = NULL;
+}
+for (int i = 0; i < FF_ARRAY_ELEMS(h264->pps); i++) {
+av_buffer_unref(>pps_ref[i]);
+h264->pps[i] = NULL;
+}
+
+h264->active_sps = NULL;
+h264->active_pps = NULL;
+h264->last_slice_nal_unit_type = 0;
+}
+
 static void cbs_h264_close(CodedBitstreamContext *ctx)
 {
 CodedBitstreamH264Context *h264 = ctx->priv_data;
@@ -1309,6 +1327,28 @@ static void cbs_h264_close(CodedBitstreamContext *ctx)
 av_buffer_unref(>pps_ref[i]);
 }
 
+static void cbs_h265_flush(CodedBitstreamContext *ctx)
+{
+CodedBitstreamH265Context *h265 = ctx->priv_data;
+
+for (int i = 0; i < FF_ARRAY_ELEMS(h265->vps); i++) {
+av_buffer_unref(>vps_ref[i]);
+h265->vps[i] = NULL;
+}
+for (int i = 0; i < FF_ARRAY_ELEMS(h265->sps); i++) {
+av_buffer_unref(>sps_ref[i]);
+h265->sps[i] = NULL;
+}
+for (int i = 0; i < FF_ARRAY_ELEMS(h265->pps); i++) {
+av_buffer_unref(>pps_ref[i]);
+h265->pps[i] = NULL;
+}
+
+h265->active_vps = NULL;
+h265->active_sps = NULL;
+h265->active_pps = NULL;
+}
+
 static void cbs_h265_close(CodedBitstreamContext *ctx)
 {
 CodedBitstreamH265Context *h265 = ctx->priv_data;
@@ -1480,6 +1520,7 @@ const CodedBitstreamType ff_cbs_type_h264 = {
 .write_unit= _h264_write_nal_unit,
 .assemble_fragment = _h2645_assemble_fragment,
 
+.flush = _h264_flush,
 .close = _h264_close,
 };
 
@@ -1495,6 +1536,7 @@ const CodedBitstreamType ff_cbs_type_h265 = {
 .write_unit= _h265_write_nal_unit,
 .assemble_fragment = _h2645_assemble_fragment,
 
+.flush = _h265_flush,
 .close = _h265_close,
 };
 

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

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

[FFmpeg-cvslog] avcodec/cbs: add a flush callback to CodedBitstreamType

2020-09-29 Thread James Almer
ffmpeg | branch: master | James Almer  | Thu Sep 24 17:57:42 
2020 -0300| [515b6419ca51f036a2d6dd42841a4be07147f865] | committer: James Almer

avcodec/cbs: add a flush callback to CodedBitstreamType

Used to reset the codec's private internal state.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=515b6419ca51f036a2d6dd42841a4be07147f865
---

 libavcodec/cbs.c  | 6 ++
 libavcodec/cbs.h  | 5 +
 libavcodec/cbs_internal.h | 3 +++
 3 files changed, 14 insertions(+)

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 7c1aa005c2..c8c526ab12 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -112,6 +112,12 @@ int ff_cbs_init(CodedBitstreamContext **ctx_ptr,
 return 0;
 }
 
+void ff_cbs_flush(CodedBitstreamContext *ctx)
+{
+if (ctx->codec && ctx->codec->flush)
+ctx->codec->flush(ctx);
+}
+
 void ff_cbs_close(CodedBitstreamContext **ctx_ptr)
 {
 CodedBitstreamContext *ctx = *ctx_ptr;
diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
index 3a054aa8f3..635921b11e 100644
--- a/libavcodec/cbs.h
+++ b/libavcodec/cbs.h
@@ -236,6 +236,11 @@ extern const enum AVCodecID ff_cbs_all_codec_ids[];
 int ff_cbs_init(CodedBitstreamContext **ctx,
 enum AVCodecID codec_id, void *log_ctx);
 
+/**
+ * Reset all internal state in a context.
+ */
+void ff_cbs_flush(CodedBitstreamContext *ctx);
+
 /**
  * Close a context and free all internal state.
  */
diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
index d991e1eedf..faa847aad3 100644
--- a/libavcodec/cbs_internal.h
+++ b/libavcodec/cbs_internal.h
@@ -117,6 +117,9 @@ typedef struct CodedBitstreamType {
 int (*assemble_fragment)(CodedBitstreamContext *ctx,
  CodedBitstreamFragment *frag);
 
+// Reset the codec internal state.
+void (*flush)(CodedBitstreamContext *ctx);
+
 // Free the codec internal state.
 void (*close)(CodedBitstreamContext *ctx);
 } CodedBitstreamType;

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

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

[FFmpeg-cvslog] avcodec/av1dec: fix check for active sequence header

2020-09-29 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Sep 25 11:05:30 
2020 -0300| [3392c1b05ea1a0b9a77bfb8075350af261cb0ab4] | committer: James Almer

avcodec/av1dec: fix check for active sequence header

We clear the AV1RawSequenceHeader pointer on flush, not the relevant 
AVBufferRef.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3392c1b05ea1a0b9a77bfb8075350af261cb0ab4
---

 libavcodec/av1dec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index f6b9fbbac3..a30a496b4c 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -713,7 +713,7 @@ static int av1_decode_frame(AVCodecContext *avctx, void 
*frame,
 // fall-through
 case AV1_OBU_FRAME:
 case AV1_OBU_FRAME_HEADER:
-if (!s->seq_ref) {
+if (!s->raw_seq) {
 av_log(avctx, AV_LOG_ERROR, "Missing Sequence Header.\n");
 ret = AVERROR_INVALIDDATA;
 goto end;

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

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

[FFmpeg-cvslog] avcodec/cbs_vp9: implement a CodedBitstreamType.flush() callback

2020-09-29 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Sep 25 00:04:15 
2020 -0300| [421906dddb631420fe82c6248f14100bae19b8b8] | committer: James Almer

avcodec/cbs_vp9: implement a CodedBitstreamType.flush() callback

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=421906dddb631420fe82c6248f14100bae19b8b8
---

 libavcodec/cbs_vp9.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/libavcodec/cbs_vp9.c b/libavcodec/cbs_vp9.c
index 6a480b4ce3..e0b8c02ac2 100644
--- a/libavcodec/cbs_vp9.c
+++ b/libavcodec/cbs_vp9.c
@@ -634,6 +634,13 @@ static int cbs_vp9_assemble_fragment(CodedBitstreamContext 
*ctx,
 return 0;
 }
 
+static void cbs_vp9_flush(CodedBitstreamContext *ctx)
+{
+CodedBitstreamVP9Context *vp9 = ctx->priv_data;
+
+memset(vp9->ref, 0, sizeof(vp9->ref));
+}
+
 static const CodedBitstreamUnitTypeDescriptor cbs_vp9_unit_types[] = {
 CBS_UNIT_TYPE_INTERNAL_REF(0, VP9RawFrame, data),
 CBS_UNIT_TYPE_END_OF_LIST
@@ -649,5 +656,8 @@ const CodedBitstreamType ff_cbs_type_vp9 = {
 .split_fragment= _vp9_split_fragment,
 .read_unit = _vp9_read_unit,
 .write_unit= _vp9_write_unit,
+
+.flush = _vp9_flush,
+
 .assemble_fragment = _vp9_assemble_fragment,
 };

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

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

[FFmpeg-cvslog] avcodec/cbs_av1: implement a CodedBitstreamType.flush() callback

2020-09-29 Thread James Almer
ffmpeg | branch: master | James Almer  | Thu Sep 24 18:06:35 
2020 -0300| [dfd184eed549d7cd8e9095f18a7da8e5b050db2c] | committer: James Almer

avcodec/cbs_av1: implement a CodedBitstreamType.flush() callback

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dfd184eed549d7cd8e9095f18a7da8e5b050db2c
---

 libavcodec/cbs_av1.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
index dcf6c140ae..65cf45fcfa 100644
--- a/libavcodec/cbs_av1.c
+++ b/libavcodec/cbs_av1.c
@@ -1194,6 +1194,19 @@ static int 
cbs_av1_assemble_fragment(CodedBitstreamContext *ctx,
 return 0;
 }
 
+static void cbs_av1_flush(CodedBitstreamContext *ctx)
+{
+CodedBitstreamAV1Context *priv = ctx->priv_data;
+
+av_buffer_unref(>frame_header_ref);
+priv->sequence_header = NULL;
+priv->frame_header = NULL;
+
+memset(priv->ref, 0, sizeof(priv->ref));
+priv->operating_point_idc = 0;
+priv->seen_frame_header = 0;
+}
+
 static void cbs_av1_close(CodedBitstreamContext *ctx)
 {
 CodedBitstreamAV1Context *priv = ctx->priv_data;
@@ -1250,5 +1263,6 @@ const CodedBitstreamType ff_cbs_type_av1 = {
 .write_unit= _av1_write_obu,
 .assemble_fragment = _av1_assemble_fragment,
 
+.flush = _av1_flush,
 .close = _av1_close,
 };

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

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

[FFmpeg-cvslog] avfilter/vf_v360: stop using floats variables in xyz_to_octahedron

2020-09-29 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Wed Sep 30 00:05:02 
2020 +0200| [23d075416544f55a605b1818a8491c818312a62d] | committer: Paul B Mahol

avfilter/vf_v360: stop using floats variables in xyz_to_octahedron

Use proper integer variables.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=23d075416544f55a605b1818a8491c818312a62d
---

 libavfilter/vf_v360.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c
index ed84c05fcc..1266ddc3b6 100644
--- a/libavfilter/vf_v360.c
+++ b/libavfilter/vf_v360.c
@@ -3725,10 +3725,10 @@ static int octahedron_to_xyz(const V360Context *s,
  int i, int j, int width, int height,
  float *vec)
 {
-float x = ((i + 0.5f) / width)  * 2.f - 1.f;
-float y = ((j + 0.5f) / height) * 2.f - 1.f;
-float ax = fabsf(x);
-float ay = fabsf(y);
+const float x = ((i + 0.5f) / width)  * 2.f - 1.f;
+const float y = ((j + 0.5f) / height) * 2.f - 1.f;
+const float ax = fabsf(x);
+const float ay = fabsf(y);
 
 vec[2] = 1.f - (ax + ay);
 if (ax + ay > 1.f) {
@@ -3788,8 +3788,8 @@ static int xyz_to_octahedron(const V360Context *s,
 
 for (int i = 0; i < 4; i++) {
 for (int j = 0; j < 4; j++) {
-us[i][j] = av_clip(uf + j - 1, 0, width  - 1);
-vs[i][j] = av_clip(vf + i - 1, 0, height - 1);
+us[i][j] = av_clip(ui + j - 1, 0, width  - 1);
+vs[i][j] = av_clip(vi + i - 1, 0, height - 1);
 }
 }
 

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

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

[FFmpeg-cvslog] avcodec/cuviddec: handle arbitrarily sized extradata

2020-09-29 Thread Timo Rothenpieler
ffmpeg | branch: master | Timo Rothenpieler  | Tue Sep 
29 23:19:23 2020 +0200| [a96743a05c544d0fc0a41f301eaf3a2a839b61ba] | committer: 
Timo Rothenpieler

avcodec/cuviddec: handle arbitrarily sized extradata

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a96743a05c544d0fc0a41f301eaf3a2a839b61ba
---

 libavcodec/cuviddec.c | 40 
 1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index bce584c9c6..a3d0bdd93c 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -88,7 +88,7 @@ typedef struct CuvidContext
 CUVIDDECODECAPS caps8, caps10, caps12;
 
 CUVIDPARSERPARAMS cuparseinfo;
-CUVIDEOFORMATEX cuparse_ext;
+CUVIDEOFORMATEX *cuparse_ext;
 
 CudaFunctions *cudl;
 CuvidFunctions *cvdl;
@@ -684,6 +684,7 @@ static av_cold int cuvid_decode_end(AVCodecContext *avctx)
 av_buffer_unref(>hwdevice);
 
 av_freep(>key_frame);
+av_freep(>cuparse_ext);
 
 cuvid_free_functions(>cvdl);
 
@@ -793,6 +794,8 @@ static av_cold int cuvid_decode_init(AVCodecContext *avctx)
 CUVIDSOURCEDATAPACKET seq_pkt;
 CUcontext cuda_ctx = NULL;
 CUcontext dummy;
+uint8_t *extradata;
+uint32_t extradata_size;
 int ret = 0;
 
 enum AVPixelFormat pix_fmts[3] = { AV_PIX_FMT_CUDA,
@@ -889,11 +892,8 @@ static av_cold int cuvid_decode_init(AVCodecContext *avctx)
 ctx->cudl = device_hwctx->internal->cuda_dl;
 
 memset(>cuparseinfo, 0, sizeof(ctx->cuparseinfo));
-memset(>cuparse_ext, 0, sizeof(ctx->cuparse_ext));
 memset(_pkt, 0, sizeof(seq_pkt));
 
-ctx->cuparseinfo.pExtVideoInfo = >cuparse_ext;
-
 switch (avctx->codec->id) {
 #if CONFIG_H264_CUVID_DECODER
 case AV_CODEC_ID_H264:
@@ -947,17 +947,25 @@ static av_cold int cuvid_decode_init(AVCodecContext 
*avctx)
 
 if (avctx->codec->bsfs) {
 const AVCodecParameters *par = avctx->internal->bsf->par_out;
-ctx->cuparse_ext.format.seqhdr_data_length = par->extradata_size;
-memcpy(ctx->cuparse_ext.raw_seqhdr_data,
-   par->extradata,
-   FFMIN(sizeof(ctx->cuparse_ext.raw_seqhdr_data), 
par->extradata_size));
+extradata = par->extradata;
+extradata_size = par->extradata_size;
 } else if (avctx->extradata_size > 0) {
-ctx->cuparse_ext.format.seqhdr_data_length = avctx->extradata_size;
-memcpy(ctx->cuparse_ext.raw_seqhdr_data,
-   avctx->extradata,
-   FFMIN(sizeof(ctx->cuparse_ext.raw_seqhdr_data), 
avctx->extradata_size));
+extradata = avctx->extradata;
+extradata_size = avctx->extradata_size;
 }
 
+ctx->cuparse_ext = av_mallocz(sizeof(*ctx->cuparse_ext)
++ FFMAX(extradata_size - 
sizeof(ctx->cuparse_ext->raw_seqhdr_data), 0));
+if (!ctx->cuparse_ext) {
+ret = AVERROR(ENOMEM);
+goto error;
+}
+
+ctx->cuparse_ext->format.seqhdr_data_length = avctx->extradata_size;
+memcpy(ctx->cuparse_ext->raw_seqhdr_data, extradata, extradata_size);
+
+ctx->cuparseinfo.pExtVideoInfo = ctx->cuparse_ext;
+
 ctx->key_frame = av_mallocz(ctx->nb_surfaces * sizeof(int));
 if (!ctx->key_frame) {
 ret = AVERROR(ENOMEM);
@@ -986,8 +994,8 @@ static av_cold int cuvid_decode_init(AVCodecContext *avctx)
 if (ret < 0)
 goto error;
 
-seq_pkt.payload = ctx->cuparse_ext.raw_seqhdr_data;
-seq_pkt.payload_size = ctx->cuparse_ext.format.seqhdr_data_length;
+seq_pkt.payload = ctx->cuparse_ext->raw_seqhdr_data;
+seq_pkt.payload_size = ctx->cuparse_ext->format.seqhdr_data_length;
 
 if (seq_pkt.payload && seq_pkt.payload_size) {
 ret = CHECK_CU(ctx->cvdl->cuvidParseVideoData(ctx->cuparser, 
_pkt));
@@ -1046,8 +1054,8 @@ static void cuvid_flush(AVCodecContext *avctx)
 if (ret < 0)
 goto error;
 
-seq_pkt.payload = ctx->cuparse_ext.raw_seqhdr_data;
-seq_pkt.payload_size = ctx->cuparse_ext.format.seqhdr_data_length;
+seq_pkt.payload = ctx->cuparse_ext->raw_seqhdr_data;
+seq_pkt.payload_size = ctx->cuparse_ext->format.seqhdr_data_length;
 
 if (seq_pkt.payload && seq_pkt.payload_size) {
 ret = CHECK_CU(ctx->cvdl->cuvidParseVideoData(ctx->cuparser, 
_pkt));

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

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

[FFmpeg-cvslog] avcodec/utils: Only call codec->close if init has been called

2020-09-29 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Sep 24 23:05:29 2020 +0200| [5bc74d06dad35d00b5925b1c76208aeaf40a2dbb] | 
committer: Andreas Rheinhardt

avcodec/utils: Only call codec->close if init has been called

avcodec_open2() also called the AVCodec's close function if an error
happened before init had ever been called if the AVCodec has the
FF_CODEC_CAP_INIT_CLEANUP flag set. This is against the documentation of
said flag: "The codec allows calling the close function for deallocation
even if the init function returned a failure."

E.g. the SVQ3 decoder is not ready to be closed if init has never been
called.

Fixes: NULL dereference
Fixes: 
25762/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SVQ3_fuzzer-5716279070294016

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg

Reviewed-by: Paul B Mahol 
Reviewed-by: Michael Niedermayer 
Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5bc74d06dad35d00b5925b1c76208aeaf40a2dbb
---

 libavcodec/utils.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index cf0a55f26d..94b9e94584 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -931,6 +931,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 || avci->frame_thread_encoder)) {
 ret = avctx->codec->init(avctx);
 if (ret < 0) {
+codec_init_ok = -1;
 goto free_and_end;
 }
 codec_init_ok = 1;
@@ -1022,8 +1023,8 @@ end:
 return ret;
 free_and_end:
 if (avctx->codec && avctx->codec->close &&
-(codec_init_ok ||
- (avctx->codec->caps_internal & FF_CODEC_CAP_INIT_CLEANUP)))
+(codec_init_ok > 0 || (codec_init_ok < 0 &&
+ avctx->codec->caps_internal & FF_CODEC_CAP_INIT_CLEANUP)))
 avctx->codec->close(avctx);
 
 if (HAVE_THREADS && avci->thread_ctx)

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

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

[FFmpeg-cvslog] Revert "avfilter/setparams: add FF_FILTER_FLAG_HWFRAME_AWARE"

2020-09-29 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Tue Sep 29 17:01:22 
2020 +0100| [4fceb2634e7a81e40c49df6478d924558bdc607c] | committer: Mark 
Thompson

Revert "avfilter/setparams: add FF_FILTER_FLAG_HWFRAME_AWARE"

This reverts commit 5bbf58ab876279ca1a5a2f30563f271c99b93e62.

The setparams filters are not hwframe aware, so the default context
passthrough behaviour is needed to allow using them with hardware frames.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4fceb2634e7a81e40c49df6478d924558bdc607c
---

 libavfilter/vf_setparams.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libavfilter/vf_setparams.c b/libavfilter/vf_setparams.c
index 72a69e3fc2..689097fac0 100644
--- a/libavfilter/vf_setparams.c
+++ b/libavfilter/vf_setparams.c
@@ -169,7 +169,6 @@ AVFilter ff_vf_setparams = {
 .priv_class  = _class,
 .inputs  = inputs,
 .outputs = outputs,
-.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
 };
 
 #if CONFIG_SETRANGE_FILTER
@@ -209,7 +208,6 @@ AVFilter ff_vf_setrange = {
 .priv_class  = _class,
 .inputs  = inputs,
 .outputs = outputs,
-.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
 };
 #endif /* CONFIG_SETRANGE_FILTER */
 
@@ -244,6 +242,5 @@ AVFilter ff_vf_setfield = {
 .priv_class  = _class,
 .inputs  = inputs,
 .outputs = outputs,
-.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
 };
 #endif /* CONFIG_SETFIELD_FILTER */

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

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

[FFmpeg-cvslog] avfilter/vf_v360: split maps into slices

2020-09-29 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Tue Sep 29 10:48:54 
2020 +0200| [86b29c0cd0d0e82179f655c1385afd1013e00eca] | committer: Paul B Mahol

avfilter/vf_v360: split maps into slices

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=86b29c0cd0d0e82179f655c1385afd1013e00eca
---

 libavfilter/v360.h| 11 --
 libavfilter/vf_v360.c | 97 ---
 2 files changed, 70 insertions(+), 38 deletions(-)

diff --git a/libavfilter/v360.h b/libavfilter/v360.h
index 851bbcb8d8..c0f700b62b 100644
--- a/libavfilter/v360.h
+++ b/libavfilter/v360.h
@@ -109,6 +109,12 @@ typedef struct XYRemap {
 float ker[4][4];
 } XYRemap;
 
+typedef struct SliceXYRemap {
+int16_t *u[2], *v[2];
+int16_t *ker[2];
+uint8_t *mask;
+} SliceXYRemap;
+
 typedef struct V360Context {
 const AVClass *class;
 int in, out;
@@ -164,10 +170,9 @@ typedef struct V360Context {
 int elements;
 int mask_size;
 int max_value;
+int nb_threads;
 
-int16_t *u[2], *v[2];
-int16_t *ker[2];
-uint8_t *mask;
+SliceXYRemap *slice_remap;
 unsigned map[4];
 
 int (*in_transform)(const struct V360Context *s,
diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c
index f3d269ecde..ffc23a27ce 100644
--- a/libavfilter/vf_v360.c
+++ b/libavfilter/vf_v360.c
@@ -279,6 +279,7 @@ static int remap##ws##_##bits##bit_slice(AVFilterContext 
*ctx, void *arg, int jo
 {  
\
 ThreadData *td = arg;  
\
 const V360Context *s = ctx->priv;  
\
+const SliceXYRemap *r = >slice_remap[jobnr];
\
 const AVFrame *in = td->in;
\
 AVFrame *out = td->out;
\

\
@@ -295,7 +296,7 @@ static int remap##ws##_##bits##bit_slice(AVFilterContext 
*ctx, void *arg, int jo
 const uint8_t *const src = in->data[plane] +   
\
in_offset_h * in_linesize + 
in_offset_w * (bits >> 3);  \
 uint8_t *dst = out->data[plane] + out_offset_h * out_linesize + 
out_offset_w * (bits >> 3);\
-const uint8_t *mask = plane == 3 ? s->mask : NULL; 
\
+const uint8_t *mask = plane == 3 ? r->mask : NULL; 
\
 const int width = s->pr_width[plane];  
\
 const int height = s->pr_height[plane];
\

\
@@ -303,15 +304,16 @@ static int remap##ws##_##bits##bit_slice(AVFilterContext 
*ctx, void *arg, int jo
 const int slice_end   = (height * (jobnr + 1)) / nb_jobs;  
\

\
 for (int y = slice_start; y < slice_end && !mask; y++) {   
\
-const int16_t *const u = s->u[map] + y * uv_linesize * ws * 
ws;\
-const int16_t *const v = s->v[map] + y * uv_linesize * ws * 
ws;\
-const int16_t *const ker = s->ker[map] + y * uv_linesize * ws 
* ws;\
+const int16_t *const u = r->u[map] + (y - slice_start) * 
uv_linesize * ws * ws;\
+const int16_t *const v = r->v[map] + (y - slice_start) * 
uv_linesize * ws * ws;\
+const int16_t *const ker = r->ker[map] + (y - slice_start) * 
uv_linesize * ws * ws;\

\
 s->remap_line(dst + y * out_linesize, width, src, in_linesize, 
u, v, ker); \
 }  
\

\
 for (int y = slice_start; y < slice_end && mask; y++) {
\
-memcpy(dst + y * out_linesize, mask + y * width * (bits >> 3), 
width * (bits >> 3));   \
+

[FFmpeg-cvslog] avfilter/vf_v360: simplify input flipping

2020-09-29 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Tue Sep 29 14:16:32 
2020 +0200| [12585c87e63302c59f5a1f5c30181695ef9aea6e] | committer: Paul B Mahol

avfilter/vf_v360: simplify input flipping

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=12585c87e63302c59f5a1f5c30181695ef9aea6e
---

 libavfilter/v360.h|   1 -
 libavfilter/vf_v360.c | 163 +-
 2 files changed, 69 insertions(+), 95 deletions(-)

diff --git a/libavfilter/v360.h b/libavfilter/v360.h
index c0f700b62b..9b52827bd1 100644
--- a/libavfilter/v360.h
+++ b/libavfilter/v360.h
@@ -151,7 +151,6 @@ typedef struct V360Context {
 
 float rot_mat[3][3];
 
-float input_mirror_modifier[2];
 float output_mirror_modifier[3];
 
 int in_width, in_height;
diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c
index ffc23a27ce..ed84c05fcc 100644
--- a/libavfilter/vf_v360.c
+++ b/libavfilter/vf_v360.c
@@ -,9 +,6 @@ static void xyz_to_cube(const V360Context *s,
 
 face = s->in_cubemap_face_order[*direction];
 rotate_cube_face(uf, vf, s->in_cubemap_face_rotation[face]);
-
-(*uf) *= s->input_mirror_modifier[0];
-(*vf) *= s->input_mirror_modifier[1];
 }
 
 /**
@@ -1804,8 +1801,8 @@ static int xyz_to_stereographic(const V360Context *s,
 const float theta = acosf(vec[2]);
 const float r = tanf(theta * 0.5f);
 const float c = r / hypotf(vec[0], vec[1]);
-const float x = vec[0] * c / s->iflat_range[0] * 
s->input_mirror_modifier[0];
-const float y = vec[1] * c / s->iflat_range[1] * 
s->input_mirror_modifier[1];
+const float x = vec[0] * c / s->iflat_range[0];
+const float y = vec[1] * c / s->iflat_range[1];
 
 const float uf = (x + 1.f) * width  / 2.f;
 const float vf = (y + 1.f) * height / 2.f;
@@ -1910,8 +1907,8 @@ static int xyz_to_equisolid(const V360Context *s,
 const float theta = acosf(vec[2]);
 const float r = sinf(theta * 0.5f);
 const float c = r / hypotf(vec[0], vec[1]);
-const float x = vec[0] * c / s->iflat_range[0] * 
s->input_mirror_modifier[0];
-const float y = vec[1] * c / s->iflat_range[1] * 
s->input_mirror_modifier[1];
+const float x = vec[0] * c / s->iflat_range[0];
+const float y = vec[1] * c / s->iflat_range[1];
 
 const float uf = (x + 1.f) * width  / 2.f;
 const float vf = (y + 1.f) * height / 2.f;
@@ -2015,8 +2012,8 @@ static int xyz_to_orthographic(const V360Context *s,
 const float theta = acosf(vec[2]);
 const float r = sinf(theta);
 const float c = r / hypotf(vec[0], vec[1]);
-const float x = vec[0] * c / s->iflat_range[0] * 
s->input_mirror_modifier[0];
-const float y = vec[1] * c / s->iflat_range[1] * 
s->input_mirror_modifier[1];
+const float x = vec[0] * c / s->iflat_range[0];
+const float y = vec[1] * c / s->iflat_range[1];
 
 const float uf = (x + 1.f) * width  / 2.f;
 const float vf = (y + 1.f) * height / 2.f;
@@ -2055,8 +2052,8 @@ static int xyz_to_equirect(const V360Context *s,
const float *vec, int width, int height,
int16_t us[4][4], int16_t vs[4][4], float *du, 
float *dv)
 {
-const float phi   = atan2f(vec[0], vec[2]) * s->input_mirror_modifier[0];
-const float theta = asinf(vec[1]) * s->input_mirror_modifier[1];
+const float phi   = atan2f(vec[0], vec[2]);
+const float theta = asinf(vec[1]);
 
 const float uf = (phi   / M_PI   + 1.f) * width  / 2.f;
 const float vf = (theta / M_PI_2 + 1.f) * height / 2.f;
@@ -2093,8 +2090,8 @@ static int xyz_to_hequirect(const V360Context *s,
 const float *vec, int width, int height,
 int16_t us[4][4], int16_t vs[4][4], float *du, 
float *dv)
 {
-const float phi   = atan2f(vec[0], vec[2]) * s->input_mirror_modifier[0];
-const float theta = asinf(vec[1]) * s->input_mirror_modifier[1];
+const float phi   = atan2f(vec[0], vec[2]);
+const float theta = asinf(vec[1]);
 
 const float uf = (phi   / M_PI_2 + 1.f) * width  / 2.f;
 const float vf = (theta / M_PI_2 + 1.f) * height / 2.f;
@@ -2156,8 +2153,8 @@ static int xyz_to_flat(const V360Context *s,
 const float zf = vec[2];
 const float h = hypotf(vec[0], vec[1]);
 const float c = h <= 1e-6f ? 1.f : rr / h;
-float uf = vec[0] * c / s->iflat_range[0] * s->input_mirror_modifier[0];
-float vf = vec[1] * c / s->iflat_range[1] * s->input_mirror_modifier[1];
+float uf = vec[0] * c / s->iflat_range[0];
+float vf = vec[1] * c / s->iflat_range[1];
 int visible, ui, vi;
 
 uf = zf >= 0.f ? (uf + 1.f) * width  / 2.f : 0.f;
@@ -2197,8 +2194,8 @@ static int xyz_to_mercator(const V360Context *s,
const float *vec, int width, int height,
int16_t us[4][4], int16_t vs[4][4], float *du, 
float *dv)
 {
-const float phi   = atan2f(vec[0], vec[2]) * s->input_mirror_modifier[0];
-const float theta = vec[1] * 

[FFmpeg-cvslog] dnn/native: add native support for dense

2020-09-29 Thread Mingyu Yin
ffmpeg | branch: master | Mingyu Yin  | Tue Sep 22 
15:11:09 2020 +0800| [ad2546e3b33eabed7d1b1f5e804181e819b7] | committer: 
Guo, Yejun

dnn/native: add native support for dense

Signed-off-by: Mingyu Yin 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ad2546e3b33eabed7d1b1f5e804181e819b7
---

 libavfilter/dnn/Makefile  |   1 +
 libavfilter/dnn/dnn_backend_native.h  |   2 +
 libavfilter/dnn/dnn_backend_native_layer_conv2d.h |   1 -
 libavfilter/dnn/dnn_backend_native_layer_dense.c  | 151 ++
 libavfilter/dnn/dnn_backend_native_layer_dense.h  |  37 ++
 libavfilter/dnn/dnn_backend_native_layers.c   |   2 +
 tests/dnn/.gitignore  |   1 +
 tests/dnn/dnn-layer-dense-test.c  | 131 +++
 tools/python/convert_from_tensorflow.py   | 126 --
 9 files changed, 443 insertions(+), 9 deletions(-)

diff --git a/libavfilter/dnn/Makefile b/libavfilter/dnn/Makefile
index ee08cc5243..b0b76301ec 100644
--- a/libavfilter/dnn/Makefile
+++ b/libavfilter/dnn/Makefile
@@ -3,6 +3,7 @@ OBJS-$(CONFIG_DNN)   += 
dnn/dnn_io_proc.o
 OBJS-$(CONFIG_DNN)   += dnn/dnn_backend_native.o
 OBJS-$(CONFIG_DNN)   += dnn/dnn_backend_native_layers.o
 OBJS-$(CONFIG_DNN)   += 
dnn/dnn_backend_native_layer_avgpool.o
+OBJS-$(CONFIG_DNN)   += 
dnn/dnn_backend_native_layer_dense.o
 OBJS-$(CONFIG_DNN)   += 
dnn/dnn_backend_native_layer_pad.o
 OBJS-$(CONFIG_DNN)   += 
dnn/dnn_backend_native_layer_conv2d.o
 OBJS-$(CONFIG_DNN)   += 
dnn/dnn_backend_native_layer_depth2space.o
diff --git a/libavfilter/dnn/dnn_backend_native.h 
b/libavfilter/dnn/dnn_backend_native.h
index 2f8d73fcf6..2d02c063d4 100644
--- a/libavfilter/dnn/dnn_backend_native.h
+++ b/libavfilter/dnn/dnn_backend_native.h
@@ -45,11 +45,13 @@ typedef enum {
 DLT_MATH_BINARY = 5,
 DLT_MATH_UNARY = 6,
 DLT_AVG_POOL = 7,
+DLT_DENSE = 8,
 DLT_COUNT
 } DNNLayerType;
 
 typedef enum {DOT_INPUT = 1, DOT_OUTPUT = 2, DOT_INTERMEDIATE = DOT_INPUT | 
DOT_OUTPUT} DNNOperandType;
 typedef enum {VALID, SAME, SAME_CLAMP_TO_EDGE} DNNPaddingParam;
+typedef enum {RELU, TANH, SIGMOID, NONE, LEAKY_RELU} DNNActivationFunc;
 
 typedef struct Layer{
 DNNLayerType type;
diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.h 
b/libavfilter/dnn/dnn_backend_native_layer_conv2d.h
index 72319f2ebe..1295028c46 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.h
+++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.h
@@ -23,7 +23,6 @@
 
 #include "dnn_backend_native.h"
 
-typedef enum {RELU, TANH, SIGMOID, NONE, LEAKY_RELU} DNNActivationFunc;
 
 typedef struct ConvolutionalParams{
 int32_t input_num, output_num, kernel_size;
diff --git a/libavfilter/dnn/dnn_backend_native_layer_dense.c 
b/libavfilter/dnn/dnn_backend_native_layer_dense.c
new file mode 100644
index 00..1029137792
--- /dev/null
+++ b/libavfilter/dnn/dnn_backend_native_layer_dense.c
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2020
+ *
+ * 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 "libavutil/avassert.h"
+#include "dnn_backend_native_layer_dense.h"
+
+int dnn_load_layer_dense(Layer *layer, AVIOContext *model_file_context, int 
file_size, int operands_num)
+{
+DenseParams *dense_params;
+int kernel_size;
+int dnn_size = 0;
+dense_params = av_malloc(sizeof(*dense_params));
+if (!dense_params)
+return 0;
+
+dense_params->activation = (int32_t)avio_rl32(model_file_context);
+dense_params->input_num = (int32_t)avio_rl32(model_file_context);
+dense_params->output_num = (int32_t)avio_rl32(model_file_context);
+dense_params->has_bias = (int32_t)avio_rl32(model_file_context);
+dnn_size += 16;
+
+kernel_size = dense_params->input_num * dense_params->output_num;
+dnn_size += kernel_size * 4;
+if (dense_params->has_bias)
+dnn_size += dense_params->output_num * 4;
+
+if (dnn_size > file_size || dense_params->input_num <= 0 ||
+dense_params->output_num <= 0){
+