[FFmpeg-cvslog] lavc/hevcdec: constify source frame in hevc_ref_frame()

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed Jun  5 
07:09:31 2024 +0200| [08ea7d6b8e1efaa613ec24bbc5310ce912e2490d] | committer: 
Anton Khirnov

lavc/hevcdec: constify source frame in hevc_ref_frame()

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

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

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 5fc55d5de9..88f2bcecad 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3449,7 +3449,7 @@ static int hevc_decode_frame(AVCodecContext *avctx, 
AVFrame *rframe,
 return avpkt->size;
 }
 
-static int hevc_ref_frame(HEVCFrame *dst, HEVCFrame *src)
+static int hevc_ref_frame(HEVCFrame *dst, const HEVCFrame *src)
 {
 int ret;
 

___
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] lavc/hevcdec: do not unref current frame on frame_end() failure

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Jun  3 
20:26:21 2024 +0200| [ccd391d6a3afaa2e47f01ac51789082f1a39f03e] | committer: 
Anton Khirnov

lavc/hevcdec: do not unref current frame on frame_end() failure

It's a race with frame threading.

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

 libavcodec/hevc/hevcdec.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index a8c2172674..5fc55d5de9 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3135,17 +3135,14 @@ static int hevc_frame_end(HEVCContext *s)
 if (ret < 0) {
 av_log(s->avctx, AV_LOG_ERROR,
"hardware accelerator failed to decode picture\n");
-ff_hevc_unref_frame(s->cur_frame, ~0);
 return ret;
 }
 } else {
 if (s->avctx->err_recognition & AV_EF_CRCCHECK &&
 s->sei.picture_hash.is_md5) {
 ret = verify_md5(s, s->cur_frame->f);
-if (ret < 0 && s->avctx->err_recognition & AV_EF_EXPLODE) {
-ff_hevc_unref_frame(s->cur_frame, ~0);
+if (ret < 0 && s->avctx->err_recognition & AV_EF_EXPLODE)
 return ret;
-}
 }
 }
 s->sei.picture_hash.is_md5 = 0;

___
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] lavc/hevcdec: move some frame-end code to hevc_frame_end()

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Jun  3 
14:37:25 2024 +0200| [d725c737fe2a19091b481d4d115fd939e0a674b2] | committer: 
Anton Khirnov

lavc/hevcdec: move some frame-end code to hevc_frame_end()

Specifically, calling hwaccel end_frame, verifying frame checksum,
and printing the frame-was-decoded message.

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

 libavcodec/hevc/hevcdec.c | 187 ++
 libavcodec/hevc/hevcdec.h |   1 -
 2 files changed, 91 insertions(+), 97 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 7263b80a24..a8c2172674 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -2942,7 +2942,6 @@ static int hevc_frame_start(HEVCContext *s)
 ff_hevc_clear_refs(s);
 }
 
-s->is_decoded= 0;
 s->slice_idx = 0;
 s->first_nal_type= s->nal_unit_type;
 s->poc   = s->sh.poc;
@@ -3038,6 +3037,75 @@ fail:
 return ret;
 }
 
+static int verify_md5(HEVCContext *s, AVFrame *frame)
+{
+const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
+char msg_buf[4 * (50 + 2 * 2 * 16 /* MD5-size */)];
+int pixel_shift;
+int err = 0;
+int i, j;
+
+if (!desc)
+return AVERROR(EINVAL);
+
+pixel_shift = desc->comp[0].depth > 8;
+
+/* the checksums are LE, so we have to byteswap for >8bpp formats
+ * on BE arches */
+#if HAVE_BIGENDIAN
+if (pixel_shift && !s->checksum_buf) {
+av_fast_malloc(>checksum_buf, >checksum_buf_size,
+   FFMAX3(frame->linesize[0], frame->linesize[1],
+  frame->linesize[2]));
+if (!s->checksum_buf)
+return AVERROR(ENOMEM);
+}
+#endif
+
+msg_buf[0] = '\0';
+for (i = 0; frame->data[i]; i++) {
+int width  = s->avctx->coded_width;
+int height = s->avctx->coded_height;
+int w = (i == 1 || i == 2) ? (width  >> desc->log2_chroma_w) : width;
+int h = (i == 1 || i == 2) ? (height >> desc->log2_chroma_h) : height;
+uint8_t md5[16];
+
+av_md5_init(s->md5_ctx);
+for (j = 0; j < h; j++) {
+const uint8_t *src = frame->data[i] + j * frame->linesize[i];
+#if HAVE_BIGENDIAN
+if (pixel_shift) {
+s->bdsp.bswap16_buf((uint16_t *) s->checksum_buf,
+(const uint16_t *) src, w);
+src = s->checksum_buf;
+}
+#endif
+av_md5_update(s->md5_ctx, src, w << pixel_shift);
+}
+av_md5_final(s->md5_ctx, md5);
+
+#define MD5_PRI "%016" PRIx64 "%016" PRIx64
+#define MD5_PRI_ARG(buf) AV_RB64(buf), AV_RB64((const uint8_t*)(buf) + 8)
+
+if (!memcmp(md5, s->sei.picture_hash.md5[i], 16)) {
+av_strlcatf(msg_buf, sizeof(msg_buf),
+"plane %d - correct " MD5_PRI "; ",
+i, MD5_PRI_ARG(md5));
+} else {
+av_strlcatf(msg_buf, sizeof(msg_buf),
+   "mismatching checksum of plane %d - " MD5_PRI " != " 
MD5_PRI "; ",
+i, MD5_PRI_ARG(md5), 
MD5_PRI_ARG(s->sei.picture_hash.md5[i]));
+err = AVERROR_INVALIDDATA;
+}
+}
+
+av_log(s->avctx, err < 0 ? AV_LOG_ERROR : AV_LOG_DEBUG,
+   "Verifying checksum for frame with POC %d: %s\n",
+   s->poc, msg_buf);
+
+return err;
+}
+
 static int hevc_frame_end(HEVCContext *s)
 {
 HEVCFrame *out = s->cur_frame;
@@ -3062,6 +3130,28 @@ static int hevc_frame_end(HEVCContext *s)
 av_assert1(ret >= 0);
 }
 
+if (s->avctx->hwaccel) {
+ret = FF_HW_SIMPLE_CALL(s->avctx, end_frame);
+if (ret < 0) {
+av_log(s->avctx, AV_LOG_ERROR,
+   "hardware accelerator failed to decode picture\n");
+ff_hevc_unref_frame(s->cur_frame, ~0);
+return ret;
+}
+} else {
+if (s->avctx->err_recognition & AV_EF_CRCCHECK &&
+s->sei.picture_hash.is_md5) {
+ret = verify_md5(s, s->cur_frame->f);
+if (ret < 0 && s->avctx->err_recognition & AV_EF_EXPLODE) {
+ff_hevc_unref_frame(s->cur_frame, ~0);
+return ret;
+}
+}
+}
+s->sei.picture_hash.is_md5 = 0;
+
+av_log(s->avctx, AV_LOG_DEBUG, "Decoded frame with POC %d.\n", s->poc);
+
 return 0;
 }
 
@@ -3109,7 +3199,6 @@ static int decode_slice(HEVCContext *s, const H2645NAL 
*nal, GetBitContext *gb)
 ret = hevc_frame_end(s);
 

[FFmpeg-cvslog] lavc/hevcdec: factor decoding a slice NALU out of decode_nal_unit()

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Jun  3 
11:41:23 2024 +0200| [edb6a471c4b3b96845c84772393b74f52e970f45] | committer: 
Anton Khirnov

lavc/hevcdec: factor decoding a slice NALU out of decode_nal_unit()

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

 libavcodec/hevc/hevcdec.c | 97 +--
 1 file changed, 52 insertions(+), 45 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index b9aea45edb..7263b80a24 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3065,10 +3065,60 @@ static int hevc_frame_end(HEVCContext *s)
 return 0;
 }
 
+static int decode_slice(HEVCContext *s, const H2645NAL *nal, GetBitContext *gb)
+{
+int ret;
+
+ret = hls_slice_header(>sh, s, gb);
+if (ret < 0)
+return ret;
+
+if ((s->avctx->skip_frame >= AVDISCARD_BIDIR && s->sh.slice_type == 
HEVC_SLICE_B) ||
+(s->avctx->skip_frame >= AVDISCARD_NONINTRA && s->sh.slice_type != 
HEVC_SLICE_I) ||
+(s->avctx->skip_frame >= AVDISCARD_NONKEY && !IS_IRAP(s)) ||
+((s->nal_unit_type == HEVC_NAL_RASL_R || s->nal_unit_type == 
HEVC_NAL_RASL_N) &&
+ s->no_rasl_output_flag)) {
+return 0;
+}
+
+if (s->sh.first_slice_in_pic_flag) {
+if (s->cur_frame) {
+av_log(s->avctx, AV_LOG_ERROR, "Two slices reporting being the 
first in the same frame.\n");
+return AVERROR_INVALIDDATA;
+}
+
+ret = hevc_frame_start(s);
+if (ret < 0)
+return ret;
+} else if (!s->cur_frame) {
+av_log(s->avctx, AV_LOG_ERROR, "First slice in a frame missing.\n");
+return AVERROR_INVALIDDATA;
+}
+
+if (s->nal_unit_type != s->first_nal_type) {
+av_log(s->avctx, AV_LOG_ERROR,
+   "Non-matching NAL types of the VCL NALUs: %d %d\n",
+   s->first_nal_type, s->nal_unit_type);
+return AVERROR_INVALIDDATA;
+}
+
+ret = decode_slice_data(s, nal, gb);
+if (ret < 0)
+return ret;
+if (ret >= s->cur_frame->ctb_count) {
+ret = hevc_frame_end(s);
+if (ret < 0)
+return ret;
+s->is_decoded = 1;
+}
+
+return 0;
+}
+
 static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
 {
 GetBitContext gb = nal->gb;
-int ctb_addr_ts, ret;
+int ret;
 
 s->nal_unit_type = nal->type;
 s->temporal_id   = nal->temporal_id;
@@ -3124,52 +3174,9 @@ static int decode_nal_unit(HEVCContext *s, const 
H2645NAL *nal)
 case HEVC_NAL_RADL_R:
 case HEVC_NAL_RASL_N:
 case HEVC_NAL_RASL_R:
-ret = hls_slice_header(>sh, s, );
+ret = decode_slice(s, nal, );
 if (ret < 0)
-return ret;
-
-if ((s->avctx->skip_frame >= AVDISCARD_BIDIR && s->sh.slice_type == 
HEVC_SLICE_B) ||
-(s->avctx->skip_frame >= AVDISCARD_NONINTRA && s->sh.slice_type != 
HEVC_SLICE_I) ||
-(s->avctx->skip_frame >= AVDISCARD_NONKEY && !IS_IRAP(s)) ||
-((s->nal_unit_type == HEVC_NAL_RASL_R || s->nal_unit_type == 
HEVC_NAL_RASL_N) &&
- s->no_rasl_output_flag)) {
-break;
-}
-
-if (s->sh.first_slice_in_pic_flag) {
-if (s->cur_frame) {
-av_log(s->avctx, AV_LOG_ERROR, "Two slices reporting being the 
first in the same frame.\n");
-ret = AVERROR_INVALIDDATA;
-goto fail;
-}
-
-ret = hevc_frame_start(s);
-if (ret < 0)
-return ret;
-} else if (!s->cur_frame) {
-av_log(s->avctx, AV_LOG_ERROR, "First slice in a frame 
missing.\n");
 goto fail;
-}
-
-if (s->nal_unit_type != s->first_nal_type) {
-av_log(s->avctx, AV_LOG_ERROR,
-   "Non-matching NAL types of the VCL NALUs: %d %d\n",
-   s->first_nal_type, s->nal_unit_type);
-return AVERROR_INVALIDDATA;
-}
-
-ctb_addr_ts = decode_slice_data(s, nal, );
-if (ctb_addr_ts >= s->cur_frame->ctb_count) {
-ret = hevc_frame_end(s);
-if (ret < 0)
-goto fail;
-s->is_decoded = 1;
-}
-
-if (ctb_addr_ts < 0) {
-ret = ctb_addr_ts;
-goto fail;
-}
 break;
 case HEVC_NAL_EOS_NUT:
 case HEVC_NAL_EOB_NUT:

___
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] lavc/hevcdec: drop a redundant multiple-frame-per-packet check

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Jun  3 
11:35:39 2024 +0200| [90e75c4ec9b0886a7b96482d2a4dc5e693ca15d1] | committer: 
Anton Khirnov

lavc/hevcdec: drop a redundant multiple-frame-per-packet check

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

 libavcodec/hevc/hevcdec.c | 4 
 libavcodec/hevc/hevcdec.h | 1 -
 2 files changed, 5 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index a241e25196..b9aea45edb 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3143,7 +3143,6 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL 
*nal)
 goto fail;
 }
 
-s->overlap ++;
 ret = hevc_frame_start(s);
 if (ret < 0)
 return ret;
@@ -3204,7 +3203,6 @@ static int decode_nal_units(HEVCContext *s, const uint8_t 
*buf, int length)
 s->cur_frame = s->collocated_ref = NULL;
 s->last_eos = s->eos;
 s->eos = 0;
-s->overlap = 0;
 s->slice_initialized = 0;
 
 /* split the input packet into NAL units, so we know the upper bound on the
@@ -3271,8 +3269,6 @@ static int decode_nal_units(HEVCContext *s, const uint8_t 
*buf, int length)
 continue;
 
 ret = decode_nal_unit(s, nal);
-if (ret >= 0 && s->overlap > 2)
-ret = AVERROR_INVALIDDATA;
 if (ret < 0) {
 av_log(s->avctx, AV_LOG_WARNING,
"Error parsing NAL unit #%d.\n", i);
diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h
index e47a7107c8..f0443b3ab9 100644
--- a/libavcodec/hevc/hevcdec.h
+++ b/libavcodec/hevc/hevcdec.h
@@ -487,7 +487,6 @@ typedef struct HEVCContext {
 int last_eos;  ///< last packet contains an EOS/EOB NAL
 int bs_width;
 int bs_height;
-int overlap;
 
 int is_decoded;
 // NoRaslOutputFlag associated with the last IRAP frame

___
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] lavc/hevcdec: move the check for multiple frames in a packet

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Jun  3 
11:31:24 2024 +0200| [3cd6492fb5e7bb4b6e0fdada2d2277b405b1236a] | committer: 
Anton Khirnov

lavc/hevcdec: move the check for multiple frames in a packet

Do not do it in hls_slice_header(), which is the wrong place for it.
Avoids special magic return value of 1 in that function. The comment
mentioning potential corrupted state is no longer relevant, as
hls_slice_header() modifies no state beyond SliceHeader, which will only
get used for a valid frame.

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

 libavcodec/hevc/hevcdec.c | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 2809e1e61d..a241e25196 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -598,10 +598,6 @@ static int hls_slice_header(SliceHeader *sh, const 
HEVCContext *s, GetBitContext
 
 // Coded parameters
 sh->first_slice_in_pic_flag = get_bits1(gb);
-if (s->cur_frame && sh->first_slice_in_pic_flag) {
-av_log(s->avctx, AV_LOG_ERROR, "Two slices reporting being the first 
in the same frame.\n");
-return 1; // This slice will be skipped later, do not corrupt state
-}
 
 sh->no_output_of_prior_pics_flag = 0;
 if (IS_IRAP(s))
@@ -3131,10 +3127,6 @@ static int decode_nal_unit(HEVCContext *s, const 
H2645NAL *nal)
 ret = hls_slice_header(>sh, s, );
 if (ret < 0)
 return ret;
-if (ret == 1) {
-ret = AVERROR_INVALIDDATA;
-goto fail;
-}
 
 if ((s->avctx->skip_frame >= AVDISCARD_BIDIR && s->sh.slice_type == 
HEVC_SLICE_B) ||
 (s->avctx->skip_frame >= AVDISCARD_NONINTRA && s->sh.slice_type != 
HEVC_SLICE_I) ||
@@ -3145,6 +3137,12 @@ static int decode_nal_unit(HEVCContext *s, const 
H2645NAL *nal)
 }
 
 if (s->sh.first_slice_in_pic_flag) {
+if (s->cur_frame) {
+av_log(s->avctx, AV_LOG_ERROR, "Two slices reporting being the 
first in the same frame.\n");
+ret = AVERROR_INVALIDDATA;
+goto fail;
+}
+
 s->overlap ++;
 ret = hevc_frame_start(s);
 if (ret < 0)

___
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] lavc/hevcdec: move setting slice_initialized out of hls_slice_header()

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Jun  3 
11:09:26 2024 +0200| [a8f9d52c227841929959cd414398cfa426b6024e] | committer: 
Anton Khirnov

lavc/hevcdec: move setting slice_initialized out of hls_slice_header()

hls_slice_header() no longer modifies anything in HEVCContext besides
SliceHeader.

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

 libavcodec/hevc/hevcdec.c | 15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index b13e3e06a3..2809e1e61d 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -589,9 +589,8 @@ fail:
 return ret;
 }
 
-static int hls_slice_header(HEVCContext *s, GetBitContext *gb)
+static int hls_slice_header(SliceHeader *sh, const HEVCContext *s, 
GetBitContext *gb)
 {
-SliceHeader *sh   = >sh;
 const HEVCPPS *pps;
 const HEVCSPS *sps;
 unsigned pps_id;
@@ -647,12 +646,9 @@ static int hls_slice_header(HEVCContext *s, GetBitContext 
*gb)
 }
 } else {
 sh->slice_segment_addr = sh->slice_addr = 0;
-s->slice_initialized   = 0;
 }
 
 if (!sh->dependent_slice_segment_flag) {
-s->slice_initialized = 0;
-
 for (i = 0; i < pps->num_extra_slice_header_bits; i++)
 skip_bits(gb, 1);  // slice_reserved_undetermined_flag[]
 
@@ -991,8 +987,6 @@ static int hls_slice_header(HEVCContext *s, GetBitContext 
*gb)
 return AVERROR_INVALIDDATA;
 }
 
-s->slice_initialized = 1;
-
 return 0;
 }
 
@@ -2798,6 +2792,8 @@ static int decode_slice_data(HEVCContext *s, const 
H2645NAL *nal, GetBitContext
 }
 }
 
+s->slice_initialized = 1;
+
 if (s->avctx->hwaccel)
 return FF_HW_CALL(s->avctx, decode_slice, nal->raw_data, 
nal->raw_size);
 
@@ -3042,6 +3038,7 @@ fail:
 if (s->cur_frame)
 ff_hevc_unref_frame(s->cur_frame, ~0);
 s->cur_frame = s->collocated_ref = NULL;
+s->slice_initialized = 0;
 return ret;
 }
 
@@ -3131,7 +3128,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL 
*nal)
 case HEVC_NAL_RADL_R:
 case HEVC_NAL_RASL_N:
 case HEVC_NAL_RASL_R:
-ret = hls_slice_header(s, );
+ret = hls_slice_header(>sh, s, );
 if (ret < 0)
 return ret;
 if (ret == 1) {
@@ -3139,7 +3136,6 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL 
*nal)
 goto fail;
 }
 
-
 if ((s->avctx->skip_frame >= AVDISCARD_BIDIR && s->sh.slice_type == 
HEVC_SLICE_B) ||
 (s->avctx->skip_frame >= AVDISCARD_NONINTRA && s->sh.slice_type != 
HEVC_SLICE_I) ||
 (s->avctx->skip_frame >= AVDISCARD_NONKEY && !IS_IRAP(s)) ||
@@ -3211,6 +3207,7 @@ static int decode_nal_units(HEVCContext *s, const uint8_t 
*buf, int length)
 s->last_eos = s->eos;
 s->eos = 0;
 s->overlap = 0;
+s->slice_initialized = 0;
 
 /* split the input packet into NAL units, so we know the upper bound on the
  * number of slices in the frame */

___
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] lavc/hevcdec: move calling hwaccel decode_slice to decode_slice_data()

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sun Jun  2 
14:02:52 2024 +0200| [fe171a3b51a1f20ff34159fe75ec44ed0c256348] | committer: 
Anton Khirnov

lavc/hevcdec: move calling hwaccel decode_slice to decode_slice_data()

>From decode_nal_unit(), as that is a more appropriate place for it.

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

 libavcodec/hevc/hevcdec.c | 38 +-
 1 file changed, 17 insertions(+), 21 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 0bf68ea45c..c148244361 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -2811,6 +2811,15 @@ static int decode_slice_data(HEVCContext *s, const 
H2645NAL *nal, GetBitContext
 }
 }
 
+if (s->avctx->hwaccel)
+return FF_HW_CALL(s->avctx, decode_slice, nal->raw_data, 
nal->raw_size);
+
+if (s->avctx->profile == AV_PROFILE_HEVC_SCC) {
+av_log(s->avctx, AV_LOG_ERROR,
+   "SCC profile is not yet implemented in hevc native decoder.\n");
+return AVERROR_PATCHWELCOME;
+}
+
 s->local_ctx[0].first_qp_group = !s->sh.dependent_slice_segment_flag;
 
 if (!pps->cu_qp_delta_enabled_flag)
@@ -3152,30 +3161,17 @@ static int decode_nal_unit(HEVCContext *s, const 
H2645NAL *nal)
 }
 }
 
-if (s->avctx->hwaccel) {
-ret = FF_HW_CALL(s->avctx, decode_slice, nal->raw_data, 
nal->raw_size);
+ctb_addr_ts = decode_slice_data(s, nal, );
+if (ctb_addr_ts >= s->cur_frame->ctb_count) {
+ret = hevc_frame_end(s);
 if (ret < 0)
 goto fail;
-} else {
-if (s->avctx->profile == AV_PROFILE_HEVC_SCC) {
-av_log(s->avctx, AV_LOG_ERROR,
-   "SCC profile is not yet implemented in hevc native 
decoder.\n");
-ret = AVERROR_PATCHWELCOME;
-goto fail;
-}
-
-ctb_addr_ts = decode_slice_data(s, nal, );
-if (ctb_addr_ts >= s->cur_frame->ctb_count) {
-ret = hevc_frame_end(s);
-if (ret < 0)
-goto fail;
-s->is_decoded = 1;
-}
+s->is_decoded = 1;
+}
 
-if (ctb_addr_ts < 0) {
-ret = ctb_addr_ts;
-goto fail;
-}
+if (ctb_addr_ts < 0) {
+ret = ctb_addr_ts;
+goto fail;
 }
 break;
 case HEVC_NAL_EOS_NUT:

___
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] lavc/hevcdec: move sequence increment/IDR handling to hevc_frame_start()

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Jun  3 
10:21:42 2024 +0200| [82ded1ad3a79ad453e82ec317dc58dba91f900a0] | committer: 
Anton Khirnov

lavc/hevcdec: move sequence increment/IDR handling to hevc_frame_start()

>From hls_slice_header(). It is only done once per frame, so that is a
more appropriate place for this code.

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

 libavcodec/hevc/hevcdec.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 9abae3260d..b13e3e06a3 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -604,11 +604,6 @@ static int hls_slice_header(HEVCContext *s, GetBitContext 
*gb)
 return 1; // This slice will be skipped later, do not corrupt state
 }
 
-if ((IS_IDR(s) || IS_BLA(s)) && sh->first_slice_in_pic_flag) {
-s->seq_decode = (s->seq_decode + 1) & HEVC_SEQUENCE_COUNTER_MASK;
-if (IS_IDR(s))
-ff_hevc_clear_refs(s);
-}
 sh->no_output_of_prior_pics_flag = 0;
 if (IS_IRAP(s))
 sh->no_output_of_prior_pics_flag = get_bits1(gb);
@@ -2949,6 +2944,12 @@ static int hevc_frame_start(HEVCContext *s)
 memset(s->is_pcm,0, (sps->min_pu_width + 1) * (sps->min_pu_height 
+ 1));
 memset(s->tab_slice_address, -1, pic_size_in_ctb * 
sizeof(*s->tab_slice_address));
 
+if ((IS_IDR(s) || IS_BLA(s))) {
+s->seq_decode = (s->seq_decode + 1) & HEVC_SEQUENCE_COUNTER_MASK;
+if (IS_IDR(s))
+ff_hevc_clear_refs(s);
+}
+
 s->is_decoded= 0;
 s->slice_idx = 0;
 s->first_nal_type= s->nal_unit_type;

___
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] lavc/hevcdec: move calling hwaccel start_frame to hevc_frame_start()

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sun Jun  2 
14:02:52 2024 +0200| [6ee550d83d155225c3f57b49b22a992c9d4e59f8] | committer: 
Anton Khirnov

lavc/hevcdec: move calling hwaccel start_frame to hevc_frame_start()

>From decode_nal_unit(), as that is a more appropriate place for it.

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

 libavcodec/hevc/hevcdec.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index cda52e05ef..0bf68ea45c 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3006,7 +3006,11 @@ static int hevc_frame_start(HEVCContext *s)
 if (ret < 0)
 goto fail;
 
-if (!s->avctx->hwaccel)
+if (s->avctx->hwaccel) {
+ret = FF_HW_CALL(s->avctx, start_frame, NULL, 0);
+if (ret < 0)
+goto fail;
+} else
 ff_thread_finish_setup(s->avctx);
 
 return 0;
@@ -3148,12 +3152,6 @@ static int decode_nal_unit(HEVCContext *s, const 
H2645NAL *nal)
 }
 }
 
-if (s->sh.first_slice_in_pic_flag && s->avctx->hwaccel) {
-ret = FF_HW_CALL(s->avctx, start_frame, NULL, 0);
-if (ret < 0)
-goto fail;
-}
-
 if (s->avctx->hwaccel) {
 ret = FF_HW_CALL(s->avctx, decode_slice, nal->raw_data, 
nal->raw_size);
 if (ret < 0)

___
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] lavc/hevcdec: set active PPS/SPS in hevc_frame_start()

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Jun  3 
09:56:09 2024 +0200| [a2e77caf37c90837eb543a268ec5cc3ba5465ca4] | committer: 
Anton Khirnov

lavc/hevcdec: set active PPS/SPS in hevc_frame_start()

Not in hls_slice_header(), as it should only be done once per frame.

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

 libavcodec/hevc/hevcdec.c | 52 ---
 1 file changed, 27 insertions(+), 25 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 804cceac3e..9abae3260d 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -594,6 +594,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext 
*gb)
 SliceHeader *sh   = >sh;
 const HEVCPPS *pps;
 const HEVCSPS *sps;
+unsigned pps_id;
 int i, ret;
 
 // Coded parameters
@@ -612,40 +613,23 @@ static int hls_slice_header(HEVCContext *s, GetBitContext 
*gb)
 if (IS_IRAP(s))
 sh->no_output_of_prior_pics_flag = get_bits1(gb);
 
-sh->pps_id = get_ue_golomb_long(gb);
-if (sh->pps_id >= HEVC_MAX_PPS_COUNT || !s->ps.pps_list[sh->pps_id]) {
-av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", 
sh->pps_id);
+pps_id = get_ue_golomb_long(gb);
+if (pps_id >= HEVC_MAX_PPS_COUNT || !s->ps.pps_list[pps_id]) {
+av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id);
 return AVERROR_INVALIDDATA;
 }
-if (!sh->first_slice_in_pic_flag &&
-s->pps != s->ps.pps_list[sh->pps_id]) {
+if (!sh->first_slice_in_pic_flag && pps_id != sh->pps_id) {
 av_log(s->avctx, AV_LOG_ERROR, "PPS changed between slices.\n");
 return AVERROR_INVALIDDATA;
 }
-ff_refstruct_replace(>pps, s->ps.pps_list[sh->pps_id]);
-pps = s->pps;
+sh->pps_id = pps_id;
+
+pps = s->ps.pps_list[pps_id];
 sps = pps->sps;
 
 if (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos == 1)
 sh->no_output_of_prior_pics_flag = 1;
 
-if (s->ps.sps != sps) {
-enum AVPixelFormat pix_fmt;
-
-ff_hevc_clear_refs(s);
-
-ret = set_sps(s, sps, sps->pix_fmt);
-if (ret < 0)
-return ret;
-
-pix_fmt = get_format(s, sps);
-if (pix_fmt < 0)
-return pix_fmt;
-s->avctx->pix_fmt = pix_fmt;
-
-s->seq_decode = (s->seq_decode + 1) & HEVC_SEQUENCE_COUNTER_MASK;
-}
-
 sh->dependent_slice_segment_flag = 0;
 if (!sh->first_slice_in_pic_flag) {
 int slice_address_length;
@@ -2935,12 +2919,30 @@ static int set_side_data(HEVCContext *s)
 
 static int hevc_frame_start(HEVCContext *s)
 {
-const HEVCPPS *const pps = s->pps;
+const HEVCPPS *const pps = s->ps.pps_list[s->sh.pps_id];
 const HEVCSPS *const sps = pps->sps;
 int pic_size_in_ctb  = ((sps->width  >> sps->log2_min_cb_size) + 1) *
((sps->height >> sps->log2_min_cb_size) + 1);
 int ret;
 
+ff_refstruct_replace(>pps, pps);
+if (s->ps.sps != sps) {
+enum AVPixelFormat pix_fmt;
+
+ff_hevc_clear_refs(s);
+
+ret = set_sps(s, sps, sps->pix_fmt);
+if (ret < 0)
+return ret;
+
+pix_fmt = get_format(s, sps);
+if (pix_fmt < 0)
+return pix_fmt;
+s->avctx->pix_fmt = pix_fmt;
+
+s->seq_decode = (s->seq_decode + 1) & HEVC_SEQUENCE_COUNTER_MASK;
+}
+
 memset(s->horizontal_bs, 0, s->bs_width * s->bs_height);
 memset(s->vertical_bs,   0, s->bs_width * s->bs_height);
 memset(s->cbf_luma,  0, sps->min_tb_width * sps->min_tb_height);

___
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] lavc/hevcdec: move constructing slice RPL to decode_slice_data()

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sun Jun  2 
19:55:01 2024 +0200| [47d34ba7fbb811e23ea4485cf8066e3a045e74f8] | committer: 
Anton Khirnov

lavc/hevcdec: move constructing slice RPL to decode_slice_data()

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

 libavcodec/hevc/hevcdec.c | 25 +
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index c148244361..804cceac3e 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -665,11 +665,9 @@ static int hls_slice_header(HEVCContext *s, GetBitContext 
*gb)
 
 if (!sh->dependent_slice_segment_flag) {
 sh->slice_addr = sh->slice_segment_addr;
-s->slice_idx++;
 }
 } else {
 sh->slice_segment_addr = sh->slice_addr = 0;
-s->slice_idx   = 0;
 s->slice_initialized   = 0;
 }
 
@@ -2801,6 +2799,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const 
H2645NAL *nal)
 static int decode_slice_data(HEVCContext *s, const H2645NAL *nal, 
GetBitContext *gb)
 {
 const HEVCPPS *pps = s->pps;
+int ret;
 
 if (s->sh.dependent_slice_segment_flag) {
 int ctb_addr_ts = pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs];
@@ -2811,6 +2810,15 @@ static int decode_slice_data(HEVCContext *s, const 
H2645NAL *nal, GetBitContext
 }
 }
 
+if (!s->sh.dependent_slice_segment_flag && s->sh.slice_type != 
HEVC_SLICE_I) {
+ret = ff_hevc_slice_rpl(s);
+if (ret < 0) {
+av_log(s->avctx, AV_LOG_WARNING,
+   "Error constructing the reference lists for the current 
slice.\n");
+return ret;
+}
+}
+
 if (s->avctx->hwaccel)
 return FF_HW_CALL(s->avctx, decode_slice, nal->raw_data, 
nal->raw_size);
 
@@ -2828,6 +2836,8 @@ static int decode_slice_data(HEVCContext *s, const 
H2645NAL *nal, GetBitContext
 s->local_ctx[0].tu.cu_qp_offset_cb = 0;
 s->local_ctx[0].tu.cu_qp_offset_cr = 0;
 
+s->slice_idx += !s->sh.dependent_slice_segment_flag;
+
 if (s->avctx->active_thread_type == FF_THREAD_SLICE  &&
 s->sh.num_entry_point_offsets > 0&&
 pps->num_tile_rows == 1 && pps->num_tile_columns == 1)
@@ -2938,6 +2948,7 @@ static int hevc_frame_start(HEVCContext *s)
 memset(s->tab_slice_address, -1, pic_size_in_ctb * 
sizeof(*s->tab_slice_address));
 
 s->is_decoded= 0;
+s->slice_idx = 0;
 s->first_nal_type= s->nal_unit_type;
 s->poc   = s->sh.poc;
 
@@ -3151,16 +3162,6 @@ static int decode_nal_unit(HEVCContext *s, const 
H2645NAL *nal)
 return AVERROR_INVALIDDATA;
 }
 
-if (!s->sh.dependent_slice_segment_flag &&
-s->sh.slice_type != HEVC_SLICE_I) {
-ret = ff_hevc_slice_rpl(s);
-if (ret < 0) {
-av_log(s->avctx, AV_LOG_WARNING,
-   "Error constructing the reference lists for the current 
slice.\n");
-goto fail;
-}
-}
-
 ctb_addr_ts = decode_slice_data(s, nal, );
 if (ctb_addr_ts >= s->cur_frame->ctb_count) {
 ret = hevc_frame_end(s);

___
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] lavc/hevcdec: move per-slice local_ctx setup out of hls_slice_header()

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sun Jun  2 
13:47:13 2024 +0200| [3bbb5d78c74ab24cc5ea30120ebae454a875a454] | committer: 
Anton Khirnov

lavc/hevcdec: move per-slice local_ctx setup out of hls_slice_header()

Into decode_slice_data(). This is a step towards constifying
HEVCContext in hls_slice_header().

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

 libavcodec/hevc/hevcdec.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index bbcaa350c7..cda52e05ef 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -1014,14 +1014,7 @@ static int hls_slice_header(HEVCContext *s, 
GetBitContext *gb)
 return AVERROR_INVALIDDATA;
 }
 
-s->local_ctx[0].first_qp_group = !s->sh.dependent_slice_segment_flag;
-
-if (!pps->cu_qp_delta_enabled_flag)
-s->local_ctx[0].qp_y = s->sh.slice_qp;
-
 s->slice_initialized = 1;
-s->local_ctx[0].tu.cu_qp_offset_cb = 0;
-s->local_ctx[0].tu.cu_qp_offset_cr = 0;
 
 return 0;
 }
@@ -2818,6 +2811,14 @@ static int decode_slice_data(HEVCContext *s, const 
H2645NAL *nal, GetBitContext
 }
 }
 
+s->local_ctx[0].first_qp_group = !s->sh.dependent_slice_segment_flag;
+
+if (!pps->cu_qp_delta_enabled_flag)
+s->local_ctx[0].qp_y = s->sh.slice_qp;
+
+s->local_ctx[0].tu.cu_qp_offset_cb = 0;
+s->local_ctx[0].tu.cu_qp_offset_cr = 0;
+
 if (s->avctx->active_thread_type == FF_THREAD_SLICE  &&
 s->sh.num_entry_point_offsets > 0&&
 pps->num_tile_rows == 1 && pps->num_tile_columns == 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] lavc/hevcdec: move slice decoding dispatch to its own function

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sun Jun  2 
09:12:06 2024 +0200| [efc827bf6fdcb046e215547e8c3edfee9b22d5db] | committer: 
Anton Khirnov

lavc/hevcdec: move slice decoding dispatch to its own function

Also move there a sanity check from hls_decode_entry() that should also
be performed when WPP is active (note that the check is not moved to
hls_slice_header() because it requires the HEVCContext.tab_slice_address
to be set up).

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

 libavcodec/hevc/hevcdec.c | 36 ++--
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 9c1d879953..bbcaa350c7 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -2578,14 +2578,6 @@ static int hls_decode_entry(HEVCContext *s, 
GetBitContext *gb)
 int ctb_addr_ts = pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs];
 int ret;
 
-if (s->sh.dependent_slice_segment_flag) {
-int prev_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1];
-if (s->tab_slice_address[prev_rs] != s->sh.slice_addr) {
-av_log(s->avctx, AV_LOG_ERROR, "Previous slice segment missing\n");
-return AVERROR_INVALIDDATA;
-}
-}
-
 while (more_data && ctb_addr_ts < sps->ctb_size) {
 int ctb_addr_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts];
 
@@ -2813,6 +2805,27 @@ static int hls_slice_data_wpp(HEVCContext *s, const 
H2645NAL *nal)
 return res;
 }
 
+static int decode_slice_data(HEVCContext *s, const H2645NAL *nal, 
GetBitContext *gb)
+{
+const HEVCPPS *pps = s->pps;
+
+if (s->sh.dependent_slice_segment_flag) {
+int ctb_addr_ts = pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs];
+int prev_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1];
+if (s->tab_slice_address[prev_rs] != s->sh.slice_addr) {
+av_log(s->avctx, AV_LOG_ERROR, "Previous slice segment missing\n");
+return AVERROR_INVALIDDATA;
+}
+}
+
+if (s->avctx->active_thread_type == FF_THREAD_SLICE  &&
+s->sh.num_entry_point_offsets > 0&&
+pps->num_tile_rows == 1 && pps->num_tile_columns == 1)
+return hls_slice_data_wpp(s, nal);
+
+return hls_decode_entry(s, gb);
+}
+
 static int set_side_data(HEVCContext *s)
 {
 AVFrame *out = s->cur_frame->f;
@@ -3152,12 +3165,7 @@ static int decode_nal_unit(HEVCContext *s, const 
H2645NAL *nal)
 goto fail;
 }
 
-if (s->avctx->active_thread_type == FF_THREAD_SLICE  &&
-s->sh.num_entry_point_offsets > 0&&
-s->pps->num_tile_rows == 1 && s->pps->num_tile_columns == 1)
-ctb_addr_ts = hls_slice_data_wpp(s, nal);
-else
-ctb_addr_ts = hls_decode_entry(s, );
+ctb_addr_ts = decode_slice_data(s, nal, );
 if (ctb_addr_ts >= s->cur_frame->ctb_count) {
 ret = hevc_frame_end(s);
 if (ret < 0)

___
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] lavc/hevcdec: move a slice segment sanity check to hls_slice_header()

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sun Jun  2 
09:00:43 2024 +0200| [7cce612a26c3bd750b4a64db6e31ce370b067993] | committer: 
Anton Khirnov

lavc/hevcdec: move a slice segment sanity check to hls_slice_header()

Combine it with an existing similar check.

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

 libavcodec/hevc/hevcdec.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index df6d1565bc..9c1d879953 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -1002,7 +1002,8 @@ static int hls_slice_header(HEVCContext *s, GetBitContext 
*gb)
 
 sh->slice_ctb_addr_rs = sh->slice_segment_addr;
 
-if (!s->sh.slice_ctb_addr_rs && s->sh.dependent_slice_segment_flag) {
+if (sh->dependent_slice_segment_flag &&
+(!sh->slice_ctb_addr_rs || 
!pps->ctb_addr_rs_to_ts[sh->slice_ctb_addr_rs])) {
 av_log(s->avctx, AV_LOG_ERROR, "Impossible slice segment.\n");
 return AVERROR_INVALIDDATA;
 }
@@ -2577,11 +2578,6 @@ static int hls_decode_entry(HEVCContext *s, 
GetBitContext *gb)
 int ctb_addr_ts = pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs];
 int ret;
 
-if (!ctb_addr_ts && s->sh.dependent_slice_segment_flag) {
-av_log(s->avctx, AV_LOG_ERROR, "Impossible initial tile.\n");
-return AVERROR_INVALIDDATA;
-}
-
 if (s->sh.dependent_slice_segment_flag) {
 int prev_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1];
 if (s->tab_slice_address[prev_rs] != s->sh.slice_addr) {

___
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] lavc/hevcdec: store slice header POC in SliceHeader

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Jun  1 
20:29:50 2024 +0200| [d43527a1a0f5760a5c18468cb9f5305d1e6ac93a] | committer: 
Anton Khirnov

lavc/hevcdec: store slice header POC in SliceHeader

Rather than decoding directly into HEVCContext.poc.

This is a step towards constifying HEVCContext in hls_slice_header().

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

 libavcodec/hevc/hevcdec.c | 13 +++--
 libavcodec/hevc/hevcdec.h |  1 +
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index f867fdbea5..df6d1565bc 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -706,14 +706,14 @@ static int hls_slice_header(HEVCContext *s, GetBitContext 
*gb)
 
 sh->pic_order_cnt_lsb = get_bits(gb, sps->log2_max_poc_lsb);
 poc = ff_hevc_compute_poc(sps, s->poc_tid0, sh->pic_order_cnt_lsb, 
s->nal_unit_type);
-if (!sh->first_slice_in_pic_flag && poc != s->poc) {
+if (!sh->first_slice_in_pic_flag && poc != sh->poc) {
 av_log(s->avctx, AV_LOG_WARNING,
-   "Ignoring POC change between slices: %d -> %d\n", 
s->poc, poc);
+   "Ignoring POC change between slices: %d -> %d\n", poc, 
sh->poc);
 if (s->avctx->err_recognition & AV_EF_EXPLODE)
 return AVERROR_INVALIDDATA;
-poc = s->poc;
+poc = sh->poc;
 }
-s->poc = poc;
+sh->poc = poc;
 
 sh->short_term_ref_pic_set_sps_flag = get_bits1(gb);
 pos = get_bits_left(gb);
@@ -738,7 +738,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext 
*gb)
 sh->short_term_ref_pic_set_size = pos - get_bits_left(gb);
 
 pos = get_bits_left(gb);
-ret = decode_lt_rps(sps, >long_term_rps, gb, s->poc, 
sh->pic_order_cnt_lsb);
+ret = decode_lt_rps(sps, >long_term_rps, gb, sh->poc, 
sh->pic_order_cnt_lsb);
 if (ret < 0) {
 av_log(s->avctx, AV_LOG_WARNING, "Invalid long term RPS.\n");
 if (s->avctx->err_recognition & AV_EF_EXPLODE)
@@ -751,7 +751,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext 
*gb)
 else
 sh->slice_temporal_mvp_enabled_flag = 0;
 } else {
-s->poc  = 0;
+sh->poc = 0;
 sh->pic_order_cnt_lsb   = 0;
 sh->short_term_ref_pic_set_sps_flag = 0;
 sh->short_term_ref_pic_set_size = 0;
@@ -2920,6 +2920,7 @@ static int hevc_frame_start(HEVCContext *s)
 
 s->is_decoded= 0;
 s->first_nal_type= s->nal_unit_type;
+s->poc   = s->sh.poc;
 
 if (IS_IRAP(s))
 s->no_rasl_output_flag = IS_IDR(s) || IS_BLA(s) ||
diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h
index 75026a8deb..e47a7107c8 100644
--- a/libavcodec/hevc/hevcdec.h
+++ b/libavcodec/hevc/hevcdec.h
@@ -209,6 +209,7 @@ typedef struct SliceHeader {
 enum HEVCSliceType slice_type;
 
 int pic_order_cnt_lsb;
+int poc;
 
 uint8_t first_slice_in_pic_flag;
 uint8_t dependent_slice_segment_flag;

___
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] lavc/hevcdec: drop redundant HEVCContext.threads_{type,number}

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Jun  1 
20:21:06 2024 +0200| [e4e9e1da15a228688b97489b4e6d89d092a4229b] | committer: 
Anton Khirnov

lavc/hevcdec: drop redundant HEVCContext.threads_{type,number}

They are useless duplicates of corresponding AVCodecContext fields.

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

 libavcodec/hevc/filter.c  |  6 +++---
 libavcodec/hevc/hevcdec.c | 36 +---
 libavcodec/hevc/hevcdec.h |  3 ---
 libavcodec/hevc/mvs.c |  4 ++--
 libavcodec/hevc/refs.c|  2 +-
 5 files changed, 19 insertions(+), 32 deletions(-)

diff --git a/libavcodec/hevc/filter.c b/libavcodec/hevc/filter.c
index 081b3a3898..56e354b486 100644
--- a/libavcodec/hevc/filter.c
+++ b/libavcodec/hevc/filter.c
@@ -892,15 +892,15 @@ void ff_hevc_hls_filter(HEVCLocalContext *lc, const 
HEVCPPS *pps,
 sao_filter_CTB(lc, s, pps, sps, x - ctb_size, y);
 if (y && x_end) {
 sao_filter_CTB(lc, s, pps, sps, x, y - ctb_size);
-if (s->threads_type & FF_THREAD_FRAME )
+if (s->avctx->active_thread_type & FF_THREAD_FRAME )
 ff_progress_frame_report(>cur_frame->tf, y);
 }
 if (x_end && y_end) {
 sao_filter_CTB(lc, s, pps, sps, x , y);
-if (s->threads_type & FF_THREAD_FRAME )
+if (s->avctx->active_thread_type & FF_THREAD_FRAME )
 ff_progress_frame_report(>cur_frame->tf, y + ctb_size);
 }
-} else if (s->threads_type & FF_THREAD_FRAME && x_end)
+} else if (s->avctx->active_thread_type & FF_THREAD_FRAME && x_end)
 ff_progress_frame_report(>cur_frame->tf, y + ctb_size - 4);
 }
 
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index e3773a6147..f867fdbea5 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -968,8 +968,6 @@ static int hls_slice_header(HEVCContext *s, GetBitContext 
*gb)
 unsigned val = get_bits_long(gb, offset_len);
 sh->entry_point_offset[i] = val + 1; // +1; // +1 to get the 
size
 }
-if (s->threads_number > 1 && (pps->num_tile_rows > 1 || 
pps->num_tile_columns > 1))
-s->threads_number = 1;
 }
 }
 
@@ -1870,7 +1868,7 @@ static void chroma_mc_bi(HEVCLocalContext *lc,
 static void hevc_await_progress(const HEVCContext *s, const HEVCFrame *ref,
 const Mv *mv, int y0, int height)
 {
-if (s->threads_type == FF_THREAD_FRAME ) {
+if (s->avctx->active_thread_type == FF_THREAD_FRAME ) {
 int y = FFMAX(0, (mv->y >> 2) + y0 + height + 9);
 
 ff_progress_frame_await(>tf, y);
@@ -2631,7 +2629,7 @@ static int hls_decode_entry(HEVCContext *s, GetBitContext 
*gb)
 return ctb_addr_ts;
 }
 
-static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist,
+static int hls_decode_entry_wpp(AVCodecContext *avctx, void *hevc_lclist,
 int job, int self_id)
 {
 HEVCLocalContext *lc = &((HEVCLocalContext*)hevc_lclist)[self_id];
@@ -2643,7 +2641,7 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, 
void *hevc_lclist,
 int ctb_row = job;
 int ctb_addr_rs = s->sh.slice_ctb_addr_rs + ctb_row * ((sps->width + 
ctb_size - 1) >> sps->log2_ctb_size);
 int ctb_addr_ts = pps->ctb_addr_rs_to_ts[ctb_addr_rs];
-int thread = ctb_row % s->threads_number;
+int thread = ctb_row % avctx->thread_count;
 
 const uint8_t *data  = s->data + s->sh.offset[ctb_row];
 const size_t   data_size = s->sh.size[ctb_row];
@@ -2736,8 +2734,8 @@ static int hls_slice_data_wpp(HEVCContext *s, const 
H2645NAL *nal)
 return AVERROR_INVALIDDATA;
 }
 
-if (s->threads_number > s->nb_local_ctx) {
-HEVCLocalContext *tmp = av_malloc_array(s->threads_number, 
sizeof(*s->local_ctx));
+if (s->avctx->thread_count > s->nb_local_ctx) {
+HEVCLocalContext *tmp = av_malloc_array(s->avctx->thread_count, 
sizeof(*s->local_ctx));
 
 if (!tmp)
 return AVERROR(ENOMEM);
@@ -2746,7 +2744,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const 
H2645NAL *nal)
 av_free(s->local_ctx);
 s->local_ctx = tmp;
 
-for (unsigned i = s->nb_local_ctx; i < s->threads_number; i++) {
+for (unsigned i = s->nb_local_ctx; i < s->avctx->thread_count; i++) {
 tmp = >local_ctx[i];
 
 memset(tmp, 0, sizeof(*tmp));
@@ -2756,7 +2754,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const 
H2645NAL *nal)
 tmp->common_cabac_state = >cabac;
 }
 
-s->nb_local_ctx = s->threads_number;
+

[FFmpeg-cvslog] lavc/hevc/cabac: do not infer WPP use based on HEVCContext.threads_number

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Jun  1 
20:05:36 2024 +0200| [b0c29a45dc3c42eb0c32eb78a850b3c3f581459c] | committer: 
Anton Khirnov

lavc/hevc/cabac: do not infer WPP use based on HEVCContext.threads_number

Pass this information explicitly instead.

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

 libavcodec/hevc/cabac.c   | 7 ---
 libavcodec/hevc/hevcdec.c | 4 ++--
 libavcodec/hevc/hevcdec.h | 3 ++-
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/libavcodec/hevc/cabac.c b/libavcodec/hevc/cabac.c
index 8708efc248..39ca7c0135 100644
--- a/libavcodec/hevc/cabac.c
+++ b/libavcodec/hevc/cabac.c
@@ -452,7 +452,8 @@ static void cabac_init_state(HEVCLocalContext *lc, const 
HEVCContext *s)
 }
 
 int ff_hevc_cabac_init(HEVCLocalContext *lc, const HEVCPPS *pps,
-   int ctb_addr_ts, const uint8_t *data, size_t size)
+   int ctb_addr_ts, const uint8_t *data, size_t size,
+   int is_wpp)
 {
 const HEVCContext *const s = lc->parent;
 const HEVCSPS   *const sps = pps->sps;
@@ -479,7 +480,7 @@ int ff_hevc_cabac_init(HEVCLocalContext *lc, const HEVCPPS 
*pps,
 if (pps->tiles_enabled_flag &&
 pps->tile_id[ctb_addr_ts] != pps->tile_id[ctb_addr_ts - 1]) {
 int ret;
-if (s->threads_number == 1)
+if (!is_wpp)
 ret = cabac_reinit(lc);
 else {
 ret = ff_init_cabac_decoder(>cc, data, size);
@@ -492,7 +493,7 @@ int ff_hevc_cabac_init(HEVCLocalContext *lc, const HEVCPPS 
*pps,
 if (ctb_addr_ts % sps->ctb_width == 0) {
 int ret;
 get_cabac_terminate(>cc);
-if (s->threads_number == 1)
+if (!is_wpp)
 ret = cabac_reinit(lc);
 else {
 ret = ff_init_cabac_decoder(>cc, data, size);
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index a57fa4e539..e3773a6147 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -2599,7 +2599,7 @@ static int hls_decode_entry(HEVCContext *s, GetBitContext 
*gb)
 y_ctb = (ctb_addr_rs / ((sps->width + ctb_size - 1) >> 
sps->log2_ctb_size)) << sps->log2_ctb_size;
 hls_decode_neighbour(lc, pps, sps, x_ctb, y_ctb, ctb_addr_ts);
 
-ret = ff_hevc_cabac_init(lc, pps, ctb_addr_ts, slice_data, slice_size);
+ret = ff_hevc_cabac_init(lc, pps, ctb_addr_ts, slice_data, slice_size, 
0);
 if (ret < 0) {
 s->tab_slice_address[ctb_addr_rs] = -1;
 return ret;
@@ -2669,7 +2669,7 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, 
void *hevc_lclist,
 return 0;
 }
 
-ret = ff_hevc_cabac_init(lc, pps, ctb_addr_ts, data, data_size);
+ret = ff_hevc_cabac_init(lc, pps, ctb_addr_ts, data, data_size, 1);
 if (ret < 0)
 goto error;
 hls_sao_param(lc, pps, sps,
diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h
index 04eacca76d..22367602aa 100644
--- a/libavcodec/hevc/hevcdec.h
+++ b/libavcodec/hevc/hevcdec.h
@@ -579,7 +579,8 @@ int ff_hevc_slice_rpl(HEVCContext *s);
 void ff_hevc_save_states(HEVCLocalContext *lc, const HEVCPPS *pps,
  int ctb_addr_ts);
 int ff_hevc_cabac_init(HEVCLocalContext *lc, const HEVCPPS *pps,
-   int ctb_addr_ts, const uint8_t *data, size_t size);
+   int ctb_addr_ts, const uint8_t *data, size_t size,
+   int is_wpp);
 int ff_hevc_sao_merge_flag_decode(HEVCLocalContext *lc);
 int ff_hevc_sao_type_idx_decode(HEVCLocalContext *lc);
 int ff_hevc_sao_band_position_decode(HEVCLocalContext *lc);

___
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] lavc/hevcdec: output RASL frames based on the value of no_rasl_output_flag

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Jun  1 
18:49:55 2024 +0200| [d86ac94df24dbaacab995442713bfe81253fb004] | committer: 
Anton Khirnov

lavc/hevcdec: output RASL frames based on the value of no_rasl_output_flag

Instead of an ad-hoc scheme. Also, combine skipping RASL frames with
skip_frame handling - current code seems flawed as it only executes for
the first slice of a RASL frame and unnecessarily unsets is_decoded,
which should not be set at this point anyway..

Some RASL frames in fate-hevc-afd-tc-sei that were previously discarded
are now output.

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

 libavcodec/hevc/hevcdec.c  | 33 -
 libavcodec/hevc/hevcdec.h  |  1 -
 tests/ref/fate/hevc-afd-tc-sei | 36 
 3 files changed, 40 insertions(+), 30 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index d444ea93f7..a57fa4e539 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -605,7 +605,6 @@ static int hls_slice_header(HEVCContext *s, GetBitContext 
*gb)
 
 if ((IS_IDR(s) || IS_BLA(s)) && sh->first_slice_in_pic_flag) {
 s->seq_decode = (s->seq_decode + 1) & HEVC_SEQUENCE_COUNTER_MASK;
-s->max_ra = INT_MAX;
 if (IS_IDR(s))
 ff_hevc_clear_refs(s);
 }
@@ -645,7 +644,6 @@ static int hls_slice_header(HEVCContext *s, GetBitContext 
*gb)
 s->avctx->pix_fmt = pix_fmt;
 
 s->seq_decode = (s->seq_decode + 1) & HEVC_SEQUENCE_COUNTER_MASK;
-s->max_ra = INT_MAX;
 }
 
 sh->dependent_slice_segment_flag = 0;
@@ -3106,32 +3104,15 @@ static int decode_nal_unit(HEVCContext *s, const 
H2645NAL *nal)
 }
 
 
-if (
-(s->avctx->skip_frame >= AVDISCARD_BIDIR && s->sh.slice_type == 
HEVC_SLICE_B) ||
+if ((s->avctx->skip_frame >= AVDISCARD_BIDIR && s->sh.slice_type == 
HEVC_SLICE_B) ||
 (s->avctx->skip_frame >= AVDISCARD_NONINTRA && s->sh.slice_type != 
HEVC_SLICE_I) ||
-(s->avctx->skip_frame >= AVDISCARD_NONKEY && !IS_IRAP(s))) {
+(s->avctx->skip_frame >= AVDISCARD_NONKEY && !IS_IRAP(s)) ||
+((s->nal_unit_type == HEVC_NAL_RASL_R || s->nal_unit_type == 
HEVC_NAL_RASL_N) &&
+ s->no_rasl_output_flag)) {
 break;
 }
 
 if (s->sh.first_slice_in_pic_flag) {
-if (s->max_ra == INT_MAX) {
-if (s->nal_unit_type == HEVC_NAL_CRA_NUT || IS_BLA(s)) {
-s->max_ra = s->poc;
-} else {
-if (IS_IDR(s))
-s->max_ra = INT_MIN;
-}
-}
-
-if ((s->nal_unit_type == HEVC_NAL_RASL_R || s->nal_unit_type == 
HEVC_NAL_RASL_N) &&
-s->poc <= s->max_ra) {
-s->is_decoded = 0;
-break;
-} else {
-if (s->nal_unit_type == HEVC_NAL_RASL_R && s->poc > s->max_ra)
-s->max_ra = INT_MIN;
-}
-
 s->overlap ++;
 ret = hevc_frame_start(s);
 if (ret < 0)
@@ -3196,7 +3177,6 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL 
*nal)
 case HEVC_NAL_EOS_NUT:
 case HEVC_NAL_EOB_NUT:
 s->seq_decode = (s->seq_decode + 1) & HEVC_SEQUENCE_COUNTER_MASK;
-s->max_ra = INT_MAX;
 break;
 case HEVC_NAL_AUD:
 case HEVC_NAL_FD_NUT:
@@ -3572,8 +3552,6 @@ static av_cold int hevc_init_context(AVCodecContext 
*avctx)
 return AVERROR(ENOMEM);
 }
 
-s->max_ra = INT_MAX;
-
 s->md5_ctx = av_md5_alloc();
 if (!s->md5_ctx)
 return AVERROR(ENOMEM);
@@ -3626,7 +3604,6 @@ static int hevc_update_thread_context(AVCodecContext *dst,
 s->seq_decode = s0->seq_decode;
 s->seq_output = s0->seq_output;
 s->poc_tid0   = s0->poc_tid0;
-s->max_ra = s0->max_ra;
 s->eos= s0->eos;
 s->no_rasl_output_flag = s0->no_rasl_output_flag;
 
@@ -3640,7 +3617,6 @@ static int hevc_update_thread_context(AVCodecContext *dst,
 
 if (s0->eos) {
 s->seq_decode = (s->seq_decode + 1) & HEVC_SEQUENCE_COUNTER_MASK;
-s->max_ra = INT_MAX;
 }
 
 ret = ff_h2645_sei_ctx_replace(>sei.common, >sei.common);
@@ -3734,7 +3710,6 @@ static void hevc_decode_flush(AVCodecContext *avctx)
 ff_hevc_reset_sei(>sei);
 ff_dovi_ctx_flush(>dovi_ctx);
 av_buffer_unref(>rpu_buf);
-s->max_ra = INT_MAX;
 s->eos = 1;
 
 if (FF_HW_HAS_CB(avctx, flush))
diff --git a/libavcodec/hevc/hevcdec.h

[FFmpeg-cvslog] lavc/hevcdec: only set no_rasl_output_flag for IRAP frames

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Jun  1 
18:38:57 2024 +0200| [3115c84015d8cc86262844d9a2435d2c5423de0e] | committer: 
Anton Khirnov

lavc/hevcdec: only set no_rasl_output_flag for IRAP frames

Its meaning is only specified for IRAP frames.

As it's currently never used otherwise, this should not change decoder
behaviour, but will be useful in future commits.

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

 libavcodec/hevc/hevcdec.c | 4 +++-
 libavcodec/hevc/hevcdec.h | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 585a066426..d444ea93f7 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -2925,7 +2925,9 @@ static int hevc_frame_start(HEVCContext *s)
 s->is_decoded= 0;
 s->first_nal_type= s->nal_unit_type;
 
-s->no_rasl_output_flag = IS_IDR(s) || IS_BLA(s) || (s->nal_unit_type == 
HEVC_NAL_CRA_NUT && s->last_eos);
+if (IS_IRAP(s))
+s->no_rasl_output_flag = IS_IDR(s) || IS_BLA(s) ||
+ (s->nal_unit_type == HEVC_NAL_CRA_NUT && 
s->last_eos);
 
 /* 8.3.1 */
 if (s->temporal_id == 0 &&
diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h
index 5eaebd3584..fa7caf9cf7 100644
--- a/libavcodec/hevc/hevcdec.h
+++ b/libavcodec/hevc/hevcdec.h
@@ -493,6 +493,7 @@ typedef struct HEVCContext {
 int overlap;
 
 int is_decoded;
+// NoRaslOutputFlag associated with the last IRAP frame
 int no_rasl_output_flag;
 
 HEVCPredContext hpc;

___
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] lavc/hevcdec: do not pass HEVCContext to ff_hevc_frame_nb_refs()

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Jun  1 
16:36:16 2024 +0200| [381b70e173f9d55a05ef7174f1a3709951dc3ba3] | committer: 
Anton Khirnov

lavc/hevcdec: do not pass HEVCContext to ff_hevc_frame_nb_refs()

Pass the only things required from it - slice header and PPS -
explicitly.

Will be useful in the following commits to avoid mofiying HEVCContext in
hls_slice_header().

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

 libavcodec/hevc/hevcdec.c | 2 +-
 libavcodec/hevc/hevcdec.h | 2 +-
 libavcodec/hevc/refs.c| 8 
 libavcodec/nvdec_hevc.c   | 2 +-
 libavcodec/vdpau_hevc.c   | 2 +-
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index bf6e93ba1b..585a066426 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -795,7 +795,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext 
*gb)
 
 sh->rpl_modification_flag[0] = 0;
 sh->rpl_modification_flag[1] = 0;
-nb_refs = ff_hevc_frame_nb_refs(s);
+nb_refs = ff_hevc_frame_nb_refs(sh, pps);
 if (!nb_refs) {
 av_log(s->avctx, AV_LOG_ERROR, "Zero refs for a frame with P 
or B slices.\n");
 return AVERROR_INVALIDDATA;
diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h
index 4b28494366..5eaebd3584 100644
--- a/libavcodec/hevc/hevcdec.h
+++ b/libavcodec/hevc/hevcdec.h
@@ -614,7 +614,7 @@ int ff_hevc_res_scale_sign_flag(HEVCLocalContext *lc, int 
idx);
 /**
  * Get the number of candidate references for the current frame.
  */
-int ff_hevc_frame_nb_refs(const HEVCContext *s);
+int ff_hevc_frame_nb_refs(const SliceHeader *sh, const HEVCPPS *pps);
 
 int ff_hevc_set_new_ref(HEVCContext *s, int poc);
 
diff --git a/libavcodec/hevc/refs.c b/libavcodec/hevc/refs.c
index 31fcd49d69..5bd5eab9f1 100644
--- a/libavcodec/hevc/refs.c
+++ b/libavcodec/hevc/refs.c
@@ -526,12 +526,12 @@ fail:
 return ret;
 }
 
-int ff_hevc_frame_nb_refs(const HEVCContext *s)
+int ff_hevc_frame_nb_refs(const SliceHeader *sh, const HEVCPPS *pps)
 {
 int ret = 0;
 int i;
-const ShortTermRPS *rps = s->sh.short_term_rps;
-const LongTermRPS *long_rps = >sh.long_term_rps;
+const ShortTermRPS *rps = sh->short_term_rps;
+const LongTermRPS *long_rps = >long_term_rps;
 
 if (rps) {
 for (i = 0; i < rps->num_negative_pics; i++)
@@ -545,7 +545,7 @@ int ff_hevc_frame_nb_refs(const HEVCContext *s)
 ret += !!long_rps->used[i];
 }
 
-if (s->pps->pps_curr_pic_ref_enabled_flag)
+if (pps->pps_curr_pic_ref_enabled_flag)
 ret++;
 
 return ret;
diff --git a/libavcodec/nvdec_hevc.c b/libavcodec/nvdec_hevc.c
index 0bebca7568..ce66ddcfb7 100644
--- a/libavcodec/nvdec_hevc.c
+++ b/libavcodec/nvdec_hevc.c
@@ -187,7 +187,7 @@ static int nvdec_hevc_start_frame(AVCodecContext *avctx,
 
 .NumBitsForShortTermRPSInSlice= 
s->sh.short_term_rps ? s->sh.short_term_ref_pic_set_size : 0,
 .NumDeltaPocsOfRefRpsIdx  = 
s->sh.short_term_rps ? s->sh.short_term_rps->rps_idx_num_delta_pocs : 0,
-.NumPocTotalCurr  = 
ff_hevc_frame_nb_refs(s),
+.NumPocTotalCurr  = 
ff_hevc_frame_nb_refs(>sh, pps),
 .NumPocStCurrBefore   = 
s->rps[ST_CURR_BEF].nb_refs,
 .NumPocStCurrAfter= 
s->rps[ST_CURR_AFT].nb_refs,
 .NumPocLtCurr = 
s->rps[LT_CURR].nb_refs,
diff --git a/libavcodec/vdpau_hevc.c b/libavcodec/vdpau_hevc.c
index 3db7ec156a..b9e922ecfc 100644
--- a/libavcodec/vdpau_hevc.c
+++ b/libavcodec/vdpau_hevc.c
@@ -205,7 +205,7 @@ static int vdpau_hevc_start_frame(AVCodecContext *avctx,
 }
 }
 /* See section 7.4.7.2 of the specification. */
-info->NumPocTotalCurr = ff_hevc_frame_nb_refs(h);
+info->NumPocTotalCurr = ff_hevc_frame_nb_refs(>sh, pps);
 if (sh->short_term_ref_pic_set_sps_flag == 0 && sh->short_term_rps) {
 /* Corresponds to specification field, NumDeltaPocs[RefRpsIdx].
Only applicable when short_term_ref_pic_set_sps_flag == 0.

___
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] lavc/hevcdec: only call export_stream_params_from_sei() once per frame

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Jun  1 
16:24:00 2024 +0200| [07eb60c0da34d146b72064ec1f316d64a6ac7ebb] | committer: 
Anton Khirnov

lavc/hevcdec: only call export_stream_params_from_sei() once per frame

Not once per each slice header, as it makes no sense and may cause races
with frame threading.

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

 libavcodec/hevc/hevcdec.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index dd3c188418..bf6e93ba1b 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -648,10 +648,6 @@ static int hls_slice_header(HEVCContext *s, GetBitContext 
*gb)
 s->max_ra = INT_MAX;
 }
 
-ret = export_stream_params_from_sei(s);
-if (ret < 0)
-return ret;
-
 sh->dependent_slice_segment_flag = 0;
 if (!sh->first_slice_in_pic_flag) {
 int slice_address_length;
@@ -2965,6 +2961,10 @@ static int hevc_frame_start(HEVCContext *s)
 !(s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) &&
 !s->avctx->hwaccel;
 
+ret = export_stream_params_from_sei(s);
+if (ret < 0)
+return ret;
+
 ret = set_side_data(s);
 if (ret < 0)
 goto fail;

___
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] lavc/hevcdec: stop accessing parameter sets through HEVCParamSets

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri May 31 
13:55:39 2024 +0200| [0f47342c12dc21be2ae64db21eeefefa893641c7] | committer: 
Anton Khirnov

lavc/hevcdec: stop accessing parameter sets through HEVCParamSets

Instead, accept PPS/SPS as function arguments.

Makes the code shorter and significantly reduces diff in future commits.

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

 libavcodec/hevc/hevcdec.c | 878 +-
 1 file changed, 470 insertions(+), 408 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 5e4e5776e0..14b9a2a844 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -143,7 +143,7 @@ fail:
 return AVERROR(ENOMEM);
 }
 
-static int pred_weight_table(HEVCContext *s, GetBitContext *gb)
+static int pred_weight_table(HEVCContext *s, const HEVCSPS *sps, GetBitContext 
*gb)
 {
 int i = 0;
 int j = 0;
@@ -159,7 +159,7 @@ static int pred_weight_table(HEVCContext *s, GetBitContext 
*gb)
 return AVERROR_INVALIDDATA;
 }
 s->sh.luma_log2_weight_denom = av_clip_uintp2(luma_log2_weight_denom, 3);
-if (s->ps.sps->chroma_format_idc != 0) {
+if (sps->chroma_format_idc != 0) {
 int64_t chroma_log2_weight_denom = luma_log2_weight_denom + 
(int64_t)get_se_golomb(gb);
 if (chroma_log2_weight_denom < 0 || chroma_log2_weight_denom > 7) {
 av_log(s->avctx, AV_LOG_ERROR, "chroma_log2_weight_denom %"PRId64" 
is invalid\n", chroma_log2_weight_denom);
@@ -175,7 +175,7 @@ static int pred_weight_table(HEVCContext *s, GetBitContext 
*gb)
 s->sh.luma_offset_l0[i] = 0;
 }
 }
-if (s->ps.sps->chroma_format_idc != 0) {
+if (sps->chroma_format_idc != 0) {
 for (i = 0; i < s->sh.nb_refs[L0]; i++)
 chroma_weight_l0_flag[i] = get_bits1(gb);
 } else {
@@ -219,7 +219,7 @@ static int pred_weight_table(HEVCContext *s, GetBitContext 
*gb)
 s->sh.luma_offset_l1[i] = 0;
 }
 }
-if (s->ps.sps->chroma_format_idc != 0) {
+if (sps->chroma_format_idc != 0) {
 for (i = 0; i < s->sh.nb_refs[L1]; i++)
 chroma_weight_l1_flag[i] = get_bits1(gb);
 } else {
@@ -259,9 +259,9 @@ static int pred_weight_table(HEVCContext *s, GetBitContext 
*gb)
 return 0;
 }
 
-static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb)
+static int decode_lt_rps(HEVCContext *s, const HEVCSPS *sps, LongTermRPS *rps,
+ GetBitContext *gb)
 {
-const HEVCSPS *sps = s->ps.sps;
 int max_poc_lsb= 1 << sps->log2_max_poc_lsb;
 int prev_delta_msb = 0;
 unsigned int nb_sps = 0, nb_sh;
@@ -591,6 +591,8 @@ fail:
 static int hls_slice_header(HEVCContext *s, GetBitContext *gb)
 {
 SliceHeader *sh   = >sh;
+const HEVCPPS *pps;
+const HEVCSPS *sps;
 int i, ret;
 
 // Coded parameters
@@ -621,11 +623,13 @@ static int hls_slice_header(HEVCContext *s, GetBitContext 
*gb)
 return AVERROR_INVALIDDATA;
 }
 s->ps.pps = s->ps.pps_list[sh->pps_id];
+pps = s->ps.pps;
+sps = pps->sps;
+
 if (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos == 1)
 sh->no_output_of_prior_pics_flag = 1;
 
-if (s->ps.sps != s->ps.pps->sps) {
-const HEVCSPS *sps = s->ps.pps->sps;
+if (s->ps.sps != sps) {
 enum AVPixelFormat pix_fmt;
 
 ff_hevc_clear_refs(s);
@@ -651,13 +655,13 @@ static int hls_slice_header(HEVCContext *s, GetBitContext 
*gb)
 if (!sh->first_slice_in_pic_flag) {
 int slice_address_length;
 
-if (s->ps.pps->dependent_slice_segments_enabled_flag)
+if (pps->dependent_slice_segments_enabled_flag)
 sh->dependent_slice_segment_flag = get_bits1(gb);
 
-slice_address_length = av_ceil_log2(s->ps.sps->ctb_width *
-s->ps.sps->ctb_height);
+slice_address_length = av_ceil_log2(sps->ctb_width *
+sps->ctb_height);
 sh->slice_segment_addr = get_bitsz(gb, slice_address_length);
-if (sh->slice_segment_addr >= s->ps.sps->ctb_width * 
s->ps.sps->ctb_height) {
+if (sh->slice_segment_addr >= sps->ctb_width * sps->ctb_height) {
 av_log(s->avctx, AV_LOG_ERROR,
"Invalid slice segment address: %u.\n",
sh->slice_segment_addr);
@@ -677,7 +681,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext 
*gb)
 if (!sh->dependent_slice_segment_flag) {
 s->slice_initialized = 0;
 
-for (i = 0; i < s->ps.pps->num_extra_slice_header_bits; i++)
+

[FFmpeg-cvslog] lavc/hevcdec: drop an always-zero variable

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Jun  1 
12:43:42 2024 +0200| [8eb134f4f9449fef6f1a992361e46a7f321f3b1d] | committer: 
Anton Khirnov

lavc/hevcdec: drop an always-zero variable

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

 libavcodec/hevc/hevcdec.c | 9 ++---
 libavcodec/hevc/hevcdec.h | 1 -
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 6dda923df5..d599373c9d 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -984,13 +984,9 @@ static int hls_slice_header(HEVCContext *s, GetBitContext 
*gb)
 unsigned val = get_bits_long(gb, offset_len);
 sh->entry_point_offset[i] = val + 1; // +1; // +1 to get the 
size
 }
-if (s->threads_number > 1 && (pps->num_tile_rows > 1 || 
pps->num_tile_columns > 1)) {
-s->enable_parallel_tiles = 0; // TODO: you can enable tiles in 
parallel here
+if (s->threads_number > 1 && (pps->num_tile_rows > 1 || 
pps->num_tile_columns > 1))
 s->threads_number = 1;
-} else
-s->enable_parallel_tiles = 0;
-} else
-s->enable_parallel_tiles = 0;
+}
 }
 
 if (pps->slice_header_extension_present_flag) {
@@ -3697,7 +3693,6 @@ static av_cold int hevc_decode_init(AVCodecContext *avctx)
 if (ret < 0)
 return ret;
 
-s->enable_parallel_tiles = 0;
 s->sei.picture_timing.picture_struct = 0;
 s->eos = 1;
 
diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h
index 3b7442e5c1..c58ce05639 100644
--- a/libavcodec/hevc/hevcdec.h
+++ b/libavcodec/hevc/hevcdec.h
@@ -532,7 +532,6 @@ typedef struct HEVCContext {
 /** The target for the common_cabac_state of the local contexts. */
 HEVCCABACState cabac;
 
-int enable_parallel_tiles;
 atomic_int wpp_err;
 
 const uint8_t *data;

___
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] lavc/hevcdec: move pocTid0 computation to hevc_frame_start()

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Jun  1 
16:17:57 2024 +0200| [01b379a93e05d86f7d889a848741f7e235560630] | committer: 
Anton Khirnov

lavc/hevcdec: move pocTid0 computation to hevc_frame_start()

It is only done once per frame. Also, rename the variable to poc_tid0 to
be consistent with our naming conventions.

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

 libavcodec/hevc/hevcdec.c | 26 +-
 libavcodec/hevc/hevcdec.h |  2 +-
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 960a06c773..dd3c188418 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -711,7 +711,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext 
*gb)
 int poc, pos;
 
 sh->pic_order_cnt_lsb = get_bits(gb, sps->log2_max_poc_lsb);
-poc = ff_hevc_compute_poc(sps, s->pocTid0, sh->pic_order_cnt_lsb, 
s->nal_unit_type);
+poc = ff_hevc_compute_poc(sps, s->poc_tid0, sh->pic_order_cnt_lsb, 
s->nal_unit_type);
 if (!sh->first_slice_in_pic_flag && poc != s->poc) {
 av_log(s->avctx, AV_LOG_WARNING,
"Ignoring POC change between slices: %d -> %d\n", 
s->poc, poc);
@@ -766,17 +766,6 @@ static int hls_slice_header(HEVCContext *s, GetBitContext 
*gb)
 sh->slice_temporal_mvp_enabled_flag = 0;
 }
 
-/* 8.3.1 */
-if (sh->first_slice_in_pic_flag && s->temporal_id == 0 &&
-s->nal_unit_type != HEVC_NAL_TRAIL_N &&
-s->nal_unit_type != HEVC_NAL_TSA_N   &&
-s->nal_unit_type != HEVC_NAL_STSA_N  &&
-s->nal_unit_type != HEVC_NAL_RADL_N  &&
-s->nal_unit_type != HEVC_NAL_RADL_R  &&
-s->nal_unit_type != HEVC_NAL_RASL_N  &&
-s->nal_unit_type != HEVC_NAL_RASL_R)
-s->pocTid0 = s->poc;
-
 if (sps->sao_enabled) {
 sh->slice_sample_adaptive_offset_flag[0] = get_bits1(gb);
 if (sps->chroma_format_idc) {
@@ -2942,6 +2931,17 @@ static int hevc_frame_start(HEVCContext *s)
 
 s->no_rasl_output_flag = IS_IDR(s) || IS_BLA(s) || (s->nal_unit_type == 
HEVC_NAL_CRA_NUT && s->last_eos);
 
+/* 8.3.1 */
+if (s->temporal_id == 0 &&
+s->nal_unit_type != HEVC_NAL_TRAIL_N &&
+s->nal_unit_type != HEVC_NAL_TSA_N   &&
+s->nal_unit_type != HEVC_NAL_STSA_N  &&
+s->nal_unit_type != HEVC_NAL_RADL_N  &&
+s->nal_unit_type != HEVC_NAL_RADL_R  &&
+s->nal_unit_type != HEVC_NAL_RASL_N  &&
+s->nal_unit_type != HEVC_NAL_RASL_R)
+s->poc_tid0 = s->poc;
+
 if (pps->tiles_enabled_flag)
 s->local_ctx[0].end_of_tiles_x = pps->column_width[0] << 
sps->log2_ctb_size;
 
@@ -3623,7 +3623,7 @@ static int hevc_update_thread_context(AVCodecContext *dst,
 
 s->seq_decode = s0->seq_decode;
 s->seq_output = s0->seq_output;
-s->pocTid0= s0->pocTid0;
+s->poc_tid0   = s0->poc_tid0;
 s->max_ra = s0->max_ra;
 s->eos= s0->eos;
 s->no_rasl_output_flag = s0->no_rasl_output_flag;
diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h
index c58ce05639..4b28494366 100644
--- a/libavcodec/hevc/hevcdec.h
+++ b/libavcodec/hevc/hevcdec.h
@@ -483,7 +483,7 @@ typedef struct HEVCContext {
 HEVCFrame *collocated_ref;
 HEVCFrame DPB[32];
 int poc;
-int pocTid0;
+int poc_tid0;
 int slice_idx; ///< number of the slice being currently decoded
 int eos;   ///< current packet contains an EOS/EOB NAL
 int last_eos;  ///< last packet contains an EOS/EOB NAL

___
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] lavc/hevcdec: pass SliceHeader explicitly to pred_weight_table()

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Jun  1 
16:04:14 2024 +0200| [0892ec947c7fa488b8806e3711e174969fc77b1b] | committer: 
Anton Khirnov

lavc/hevcdec: pass SliceHeader explicitly to pred_weight_table()

And replace the HEVCContext* parameter by void *logctx.

Makes it clear that only SliceHeader is modified by this function.

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

 libavcodec/hevc/hevcdec.c | 75 ---
 1 file changed, 38 insertions(+), 37 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 2c26d397df..6a9de79dcd 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -143,7 +143,8 @@ fail:
 return AVERROR(ENOMEM);
 }
 
-static int pred_weight_table(HEVCContext *s, const HEVCSPS *sps, GetBitContext 
*gb)
+static int pred_weight_table(SliceHeader *sh, void *logctx,
+ const HEVCSPS *sps, GetBitContext *gb)
 {
 int i = 0;
 int j = 0;
@@ -155,40 +156,40 @@ static int pred_weight_table(HEVCContext *s, const 
HEVCSPS *sps, GetBitContext *
 
 luma_log2_weight_denom = get_ue_golomb_long(gb);
 if (luma_log2_weight_denom < 0 || luma_log2_weight_denom > 7) {
-av_log(s->avctx, AV_LOG_ERROR, "luma_log2_weight_denom %d is 
invalid\n", luma_log2_weight_denom);
+av_log(logctx, AV_LOG_ERROR, "luma_log2_weight_denom %d is invalid\n", 
luma_log2_weight_denom);
 return AVERROR_INVALIDDATA;
 }
-s->sh.luma_log2_weight_denom = av_clip_uintp2(luma_log2_weight_denom, 3);
+sh->luma_log2_weight_denom = av_clip_uintp2(luma_log2_weight_denom, 3);
 if (sps->chroma_format_idc != 0) {
 int64_t chroma_log2_weight_denom = luma_log2_weight_denom + 
(int64_t)get_se_golomb(gb);
 if (chroma_log2_weight_denom < 0 || chroma_log2_weight_denom > 7) {
-av_log(s->avctx, AV_LOG_ERROR, "chroma_log2_weight_denom %"PRId64" 
is invalid\n", chroma_log2_weight_denom);
+av_log(logctx, AV_LOG_ERROR, "chroma_log2_weight_denom %"PRId64" 
is invalid\n", chroma_log2_weight_denom);
 return AVERROR_INVALIDDATA;
 }
-s->sh.chroma_log2_weight_denom = chroma_log2_weight_denom;
+sh->chroma_log2_weight_denom = chroma_log2_weight_denom;
 }
 
-for (i = 0; i < s->sh.nb_refs[L0]; i++) {
+for (i = 0; i < sh->nb_refs[L0]; i++) {
 luma_weight_l0_flag[i] = get_bits1(gb);
 if (!luma_weight_l0_flag[i]) {
-s->sh.luma_weight_l0[i] = 1 << s->sh.luma_log2_weight_denom;
-s->sh.luma_offset_l0[i] = 0;
+sh->luma_weight_l0[i] = 1 << sh->luma_log2_weight_denom;
+sh->luma_offset_l0[i] = 0;
 }
 }
 if (sps->chroma_format_idc != 0) {
-for (i = 0; i < s->sh.nb_refs[L0]; i++)
+for (i = 0; i < sh->nb_refs[L0]; i++)
 chroma_weight_l0_flag[i] = get_bits1(gb);
 } else {
-for (i = 0; i < s->sh.nb_refs[L0]; i++)
+for (i = 0; i < sh->nb_refs[L0]; i++)
 chroma_weight_l0_flag[i] = 0;
 }
-for (i = 0; i < s->sh.nb_refs[L0]; i++) {
+for (i = 0; i < sh->nb_refs[L0]; i++) {
 if (luma_weight_l0_flag[i]) {
 int delta_luma_weight_l0 = get_se_golomb(gb);
 if ((int8_t)delta_luma_weight_l0 != delta_luma_weight_l0)
 return AVERROR_INVALIDDATA;
-s->sh.luma_weight_l0[i] = (1 << s->sh.luma_log2_weight_denom) + 
delta_luma_weight_l0;
-s->sh.luma_offset_l0[i] = get_se_golomb(gb);
+sh->luma_weight_l0[i] = (1 << sh->luma_log2_weight_denom) + 
delta_luma_weight_l0;
+sh->luma_offset_l0[i] = get_se_golomb(gb);
 }
 if (chroma_weight_l0_flag[i]) {
 for (j = 0; j < 2; j++) {
@@ -200,39 +201,39 @@ static int pred_weight_table(HEVCContext *s, const 
HEVCSPS *sps, GetBitContext *
 return AVERROR_INVALIDDATA;
 }
 
-s->sh.chroma_weight_l0[i][j] = (1 << 
s->sh.chroma_log2_weight_denom) + delta_chroma_weight_l0;
-s->sh.chroma_offset_l0[i][j] = av_clip((delta_chroma_offset_l0 
- ((128 * s->sh.chroma_weight_l0[i][j])
-   
 >> s->sh.chroma_log2_weight_denom) + 128), -128, 127);
+sh->chroma_weight_l0[i][j] = (1 << 
sh->chroma_log2_weight_denom) + delta_chroma_weight_l0;
+sh->chroma_offset_l0[i][j] = av_clip((delta_chroma_offset_l0 - 
((128 * sh->chroma_weight_l0[i][j])
+   
 >> sh->chroma_log2_weight_den

[FFmpeg-cvslog] lavc/hevcdec: do not pass HEVCContext to decode_lt_rps()

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Jun  1 
16:04:14 2024 +0200| [5e438511abb28097e73ac8d5c4dd97a8ad6d9908] | committer: 
Anton Khirnov

lavc/hevcdec: do not pass HEVCContext to decode_lt_rps()

Pass the two numbers needed from it explicitly.

Makes it clear that HEVCContext is not modified by this function.

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

 libavcodec/hevc/hevcdec.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 6a9de79dcd..960a06c773 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -260,8 +260,8 @@ static int pred_weight_table(SliceHeader *sh, void *logctx,
 return 0;
 }
 
-static int decode_lt_rps(HEVCContext *s, const HEVCSPS *sps, LongTermRPS *rps,
- GetBitContext *gb)
+static int decode_lt_rps(const HEVCSPS *sps, LongTermRPS *rps,
+ GetBitContext *gb, int cur_poc, int poc_lsb)
 {
 int max_poc_lsb= 1 << sps->log2_max_poc_lsb;
 int prev_delta_msb = 0;
@@ -306,7 +306,7 @@ static int decode_lt_rps(HEVCContext *s, const HEVCSPS 
*sps, LongTermRPS *rps,
 if (i && i != nb_sps)
 delta += prev_delta_msb;
 
-poc = rps->poc[i] + s->poc - delta * max_poc_lsb - 
s->sh.pic_order_cnt_lsb;
+poc = rps->poc[i] + cur_poc - delta * max_poc_lsb - poc_lsb;
 if (poc != (int32_t)poc)
 return AVERROR_INVALIDDATA;
 rps->poc[i] = poc;
@@ -744,7 +744,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext 
*gb)
 sh->short_term_ref_pic_set_size = pos - get_bits_left(gb);
 
 pos = get_bits_left(gb);
-ret = decode_lt_rps(s, sps, >long_term_rps, gb);
+ret = decode_lt_rps(sps, >long_term_rps, gb, s->poc, 
sh->pic_order_cnt_lsb);
 if (ret < 0) {
 av_log(s->avctx, AV_LOG_WARNING, "Invalid long term RPS.\n");
 if (s->avctx->err_recognition & AV_EF_EXPLODE)

___
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] lavc/hevcdec: only ignore INVALIDDATA in decode_nal_unit()

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Jun  1 
13:49:32 2024 +0200| [90fc331b0fc6f7d9c31f9e6d543102ba7fe02daf] | committer: 
Anton Khirnov

lavc/hevcdec: only ignore INVALIDDATA in decode_nal_unit()

All other errors should cause a failure, regardless of the value of
err_recognition. Also, print a warning message when skipping invalid NAL
units.

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

 libavcodec/hevc/hevcdec.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index d599373c9d..2c26d397df 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3206,9 +3206,13 @@ static int decode_nal_unit(HEVCContext *s, const 
H2645NAL *nal)
 
 return 0;
 fail:
-if (s->avctx->err_recognition & AV_EF_EXPLODE)
-return ret;
-return 0;
+if (ret == AVERROR_INVALIDDATA &&
+!(s->avctx->err_recognition & AV_EF_EXPLODE)) {
+av_log(s->avctx, AV_LOG_WARNING,
+   "Skipping invalid undecodable NALU: %d\n", s->nal_unit_type);
+return 0;
+}
+return ret;
 }
 
 static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)

___
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] lavc/hevcdec: move active PPS from HEVCParamSets to HEVCContext

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Jun  1 
10:36:00 2024 +0200| [8c8072c29c9712615c571a2de733cf49fa5a27ed] | committer: 
Anton Khirnov

lavc/hevcdec: move active PPS from HEVCParamSets to HEVCContext

"Currently active PPS" is a property of the decoding process, not of the
list of available parameter sets.

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

 libavcodec/dxva2_hevc.c   |  8 
 libavcodec/hevc/hevcdec.c | 19 ---
 libavcodec/hevc/hevcdec.h |  1 +
 libavcodec/hevc/ps.c  | 12 ++--
 libavcodec/hevc/ps.h  |  1 -
 libavcodec/hevc/refs.c| 12 ++--
 libavcodec/nvdec_hevc.c   | 10 +-
 libavcodec/vaapi_hevc.c   | 12 ++--
 libavcodec/vdpau_hevc.c   |  4 ++--
 libavcodec/videotoolbox.c |  6 +++---
 libavcodec/vulkan_hevc.c  |  8 
 11 files changed, 45 insertions(+), 48 deletions(-)

diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c
index 2f4073edd6..bd2c6f72a4 100644
--- a/libavcodec/dxva2_hevc.c
+++ b/libavcodec/dxva2_hevc.c
@@ -62,8 +62,8 @@ void ff_dxva2_hevc_fill_picture_parameters(const 
AVCodecContext *avctx, AVDXVACo
 {
 const HEVCContext *h = avctx->priv_data;
 const HEVCFrame *current_picture = h->cur_frame;
-const HEVCSPS *sps = h->ps.sps;
-const HEVCPPS *pps = h->ps.pps;
+const HEVCPPS *pps = h->pps;
+const HEVCSPS *sps = pps->sps;
 int i, j;
 
 memset(pp, 0, sizeof(*pp));
@@ -205,8 +205,8 @@ void ff_dxva2_hevc_fill_scaling_lists(const AVCodecContext 
*avctx, AVDXVAContext
 {
 const HEVCContext *h = avctx->priv_data;
 unsigned i, j, pos;
-const ScalingList *sl = h->ps.pps->scaling_list_data_present_flag ?
->ps.pps->scaling_list : 
>ps.sps->scaling_list;
+const ScalingList *sl = h->pps->scaling_list_data_present_flag ?
+>pps->scaling_list : >pps->sps->scaling_list;
 
 memset(qm, 0, sizeof(*qm));
 for (i = 0; i < 6; i++) {
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 14b9a2a844..6dda923df5 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -618,12 +618,12 @@ static int hls_slice_header(HEVCContext *s, GetBitContext 
*gb)
 return AVERROR_INVALIDDATA;
 }
 if (!sh->first_slice_in_pic_flag &&
-s->ps.pps != s->ps.pps_list[sh->pps_id]) {
+s->pps != s->ps.pps_list[sh->pps_id]) {
 av_log(s->avctx, AV_LOG_ERROR, "PPS changed between slices.\n");
 return AVERROR_INVALIDDATA;
 }
-s->ps.pps = s->ps.pps_list[sh->pps_id];
-pps = s->ps.pps;
+ff_refstruct_replace(>pps, s->ps.pps_list[sh->pps_id]);
+pps = s->pps;
 sps = pps->sps;
 
 if (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos == 1)
@@ -2588,7 +2588,7 @@ static void hls_decode_neighbour(HEVCLocalContext *lc,
 static int hls_decode_entry(HEVCContext *s, GetBitContext *gb)
 {
 HEVCLocalContext *const lc = >local_ctx[0];
-const HEVCPPS   *const pps = s->ps.pps;
+const HEVCPPS   *const pps = s->pps;
 const HEVCSPS   *const sps = pps->sps;
 const uint8_t *slice_data = gb->buffer + s->sh.data_offset;
 const size_t   slice_size = gb->buffer_end - gb->buffer - 
s->sh.data_offset;
@@ -2656,7 +2656,7 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, 
void *hevc_lclist,
 {
 HEVCLocalContext *lc = &((HEVCLocalContext*)hevc_lclist)[self_id];
 const HEVCContext *const s = lc->parent;
-const HEVCPPS   *const pps = s->ps.pps;
+const HEVCPPS   *const pps = s->pps;
 const HEVCSPS   *const sps = pps->sps;
 int ctb_size= 1 << sps->log2_ctb_size;
 int more_data   = 1;
@@ -2739,7 +2739,7 @@ error:
 
 static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal)
 {
-const HEVCPPS *const pps = s->ps.pps;
+const HEVCPPS *const pps = s->pps;
 const HEVCSPS *const sps = pps->sps;
 const uint8_t *data = nal->data;
 int length  = nal->size;
@@ -2928,7 +2928,7 @@ static int set_side_data(HEVCContext *s)
 
 static int hevc_frame_start(HEVCContext *s)
 {
-const HEVCPPS *const pps = s->ps.pps;
+const HEVCPPS *const pps = s->pps;
 const HEVCSPS *const sps = pps->sps;
 int pic_size_in_ctb  = ((sps->width  >> sps->log2_min_cb_size) + 1) *
((sps->height >> sps->log2_min_cb_size) + 1);
@@ -3510,6 +3510,8 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)
 
 pic_arrays_free(s);
 
+ff_refstruct_unref(>pps);
+
 ff_dovi_ctx_unref(>dovi_ctx);
 av_buffer_unref(>rpu_buf);
 
@@ -3611,6 +3613,9 @@ static int hevc_update_thread_context(AVCodecContext *dst,
 for (int i = 0

[FFmpeg-cvslog] lavc/hevc/filter: stop accessing parameter sets through HEVCParamSets

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri May 31 
13:55:39 2024 +0200| [b38aecffecea5682d34b1295d1e146f1283160cb] | committer: 
Anton Khirnov

lavc/hevc/filter: stop accessing parameter sets through HEVCParamSets

Instead, accept PPS as a function argument and retrieve SPS through it.

Makes the code shorter and significantly reduces diff in future commits.

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

 libavcodec/hevc/filter.c  | 315 +-
 libavcodec/hevc/hevcdec.c |  20 +--
 libavcodec/hevc/hevcdec.h |  14 ++-
 3 files changed, 188 insertions(+), 161 deletions(-)

diff --git a/libavcodec/hevc/filter.c b/libavcodec/hevc/filter.c
index db7525170d..081b3a3898 100644
--- a/libavcodec/hevc/filter.c
+++ b/libavcodec/hevc/filter.c
@@ -44,7 +44,8 @@ static const uint8_t betatable[52] = {
 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64 
 // QP 38...51
 };
 
-static int chroma_tc(const HEVCContext *s, int qp_y, int c_idx, int tc_offset)
+static int chroma_tc(const HEVCPPS *pps, const HEVCSPS *sps,
+ int qp_y, int c_idx, int tc_offset)
 {
 static const int qp_c[] = {
 29, 30, 31, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37
@@ -53,12 +54,12 @@ static int chroma_tc(const HEVCContext *s, int qp_y, int 
c_idx, int tc_offset)
 
 // slice qp offset is not used for deblocking
 if (c_idx == 1)
-offset = s->ps.pps->cb_qp_offset;
+offset = pps->cb_qp_offset;
 else
-offset = s->ps.pps->cr_qp_offset;
+offset = pps->cr_qp_offset;
 
 qp_i = av_clip(qp_y + offset, 0, 57);
-if (s->ps.sps->chroma_format_idc == 1) {
+if (sps->chroma_format_idc == 1) {
 if (qp_i < 30)
 qp = qp_i;
 else if (qp_i > 43)
@@ -74,16 +75,17 @@ static int chroma_tc(const HEVCContext *s, int qp_y, int 
c_idx, int tc_offset)
 }
 
 static int get_qPy_pred(HEVCLocalContext *lc, const HEVCContext *s,
+const HEVCPPS *pps, const HEVCSPS *sps,
 int xBase, int yBase, int log2_cb_size)
 {
-int ctb_size_mask= (1 << s->ps.sps->log2_ctb_size) - 1;
-int MinCuQpDeltaSizeMask = (1 << (s->ps.sps->log2_ctb_size -
-  s->ps.pps->diff_cu_qp_delta_depth)) - 1;
+int ctb_size_mask= (1 << sps->log2_ctb_size) - 1;
+int MinCuQpDeltaSizeMask = (1 << (sps->log2_ctb_size -
+  pps->diff_cu_qp_delta_depth)) - 1;
 int xQgBase  = xBase - (xBase & MinCuQpDeltaSizeMask);
 int yQgBase  = yBase - (yBase & MinCuQpDeltaSizeMask);
-int min_cb_width = s->ps.sps->min_cb_width;
-int x_cb = xQgBase >> s->ps.sps->log2_min_cb_size;
-int y_cb = yQgBase >> s->ps.sps->log2_min_cb_size;
+int min_cb_width = sps->min_cb_width;
+int x_cb = xQgBase >> sps->log2_min_cb_size;
+int y_cb = yQgBase >> sps->log2_min_cb_size;
 int availableA   = (xBase   & ctb_size_mask) &&
(xQgBase & ctb_size_mask);
 int availableB   = (yBase   & ctb_size_mask) &&
@@ -110,31 +112,33 @@ static int get_qPy_pred(HEVCLocalContext *lc, const 
HEVCContext *s,
 else
 qPy_b = s->qp_y_tab[x_cb + (y_cb - 1) * min_cb_width];
 
-av_assert2(qPy_a >= -s->ps.sps->qp_bd_offset && qPy_a < 52);
-av_assert2(qPy_b >= -s->ps.sps->qp_bd_offset && qPy_b < 52);
+av_assert2(qPy_a >= -sps->qp_bd_offset && qPy_a < 52);
+av_assert2(qPy_b >= -sps->qp_bd_offset && qPy_b < 52);
 
 return (qPy_a + qPy_b + 1) >> 1;
 }
 
-void ff_hevc_set_qPy(HEVCLocalContext *lc, int xBase, int yBase, int 
log2_cb_size)
+void ff_hevc_set_qPy(HEVCLocalContext *lc, const HEVCPPS *pps,
+ int xBase, int yBase, int log2_cb_size)
 {
+const HEVCSPS   *const sps = pps->sps;
 const HEVCContext *const s = lc->parent;
-int qp_y = get_qPy_pred(lc, s, xBase, yBase, log2_cb_size);
+int qp_y = get_qPy_pred(lc, s, pps, sps, xBase, yBase, log2_cb_size);
 
 if (lc->tu.cu_qp_delta != 0) {
-int off = s->ps.sps->qp_bd_offset;
+int off = sps->qp_bd_offset;
 lc->qp_y = FFUMOD(qp_y + lc->tu.cu_qp_delta + 52 + 2 * off,
  52 + off) - off;
 } else
 lc->qp_y = qp_y;
 }
 
-static int get_qPy(const HEVCContext *s, int xC, int yC)
+static int get_qPy(const HEVCSPS *sps, const int8_t *qp_y_tab, int xC, int yC)
 {
-int log2_min_cb_size  = s->ps.sps->log2_min_cb_size;
+int log2_min_cb_size  = sps-&

[FFmpeg-cvslog] lavc/hevc/pred: stop accessing parameter sets through HEVCParamSets

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri May 31 
13:55:39 2024 +0200| [38b8ae4112684c3415ab2f7d717605759d764d27] | committer: 
Anton Khirnov

lavc/hevc/pred: stop accessing parameter sets through HEVCParamSets

Instead, accept PPS/SPS as function arguments.

Makes the code shorter and significantly reduces diff in future commits.

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

 libavcodec/hevc/hevcdec.c   |  26 ++--
 libavcodec/hevc/pred.h  |   4 +-
 libavcodec/hevc/pred_template.c |  74 +-
 libavcodec/mips/hevcpred_mips.h |   4 +-
 libavcodec/mips/hevcpred_msa.c  | 291 
 5 files changed, 202 insertions(+), 197 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index cf972ed560..5e4e5776e0 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -1160,7 +1160,7 @@ static int hls_transform_unit(HEVCLocalContext *lc, int 
x0, int y0,
 int trafo_size = 1 << log2_trafo_size;
 ff_hevc_set_neighbour_available(lc, x0, y0, trafo_size, trafo_size, 
s->ps.sps->log2_ctb_size);
 
-s->hpc.intra_pred[log2_trafo_size - 2](lc, x0, y0, 0);
+s->hpc.intra_pred[log2_trafo_size - 2](lc, s->ps.pps, x0, y0, 0);
 }
 
 if (cbf_luma || cbf_cb[0] || cbf_cr[0] ||
@@ -1247,7 +1247,7 @@ static int hls_transform_unit(HEVCLocalContext *lc, int 
x0, int y0,
 if (lc->cu.pred_mode == MODE_INTRA) {
 ff_hevc_set_neighbour_available(lc, x0, y0 + (i << 
log2_trafo_size_c),
 trafo_size_h, 
trafo_size_v, s->ps.sps->log2_ctb_size);
-s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0 + (i 
<< log2_trafo_size_c), 1);
+s->hpc.intra_pred[log2_trafo_size_c - 2](lc, s->ps.pps, 
x0, y0 + (i << log2_trafo_size_c), 1);
 }
 if (cbf_cb[i])
 ff_hevc_hls_residual_coding(lc, s->ps.pps, x0, y0 + (i << 
log2_trafo_size_c),
@@ -1277,7 +1277,7 @@ static int hls_transform_unit(HEVCLocalContext *lc, int 
x0, int y0,
 if (lc->cu.pred_mode == MODE_INTRA) {
 ff_hevc_set_neighbour_available(lc, x0, y0 + (i << 
log2_trafo_size_c),
 trafo_size_h, 
trafo_size_v, s->ps.sps->log2_ctb_size);
-s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0 + (i 
<< log2_trafo_size_c), 2);
+s->hpc.intra_pred[log2_trafo_size_c - 2](lc, s->ps.pps, 
x0, y0 + (i << log2_trafo_size_c), 2);
 }
 if (cbf_cr[i])
 ff_hevc_hls_residual_coding(lc, s->ps.pps, x0, y0 + (i << 
log2_trafo_size_c),
@@ -1306,7 +1306,7 @@ static int hls_transform_unit(HEVCLocalContext *lc, int 
x0, int y0,
 if (lc->cu.pred_mode == MODE_INTRA) {
 ff_hevc_set_neighbour_available(lc, xBase, yBase + (i << 
log2_trafo_size),
 trafo_size_h, 
trafo_size_v, s->ps.sps->log2_ctb_size);
-s->hpc.intra_pred[log2_trafo_size - 2](lc, xBase, yBase + 
(i << log2_trafo_size), 1);
+s->hpc.intra_pred[log2_trafo_size - 2](lc, s->ps.pps, 
xBase, yBase + (i << log2_trafo_size), 1);
 }
 if (cbf_cb[i])
 ff_hevc_hls_residual_coding(lc, s->ps.pps, xBase, yBase + 
(i << log2_trafo_size),
@@ -1316,7 +1316,7 @@ static int hls_transform_unit(HEVCLocalContext *lc, int 
x0, int y0,
 if (lc->cu.pred_mode == MODE_INTRA) {
 ff_hevc_set_neighbour_available(lc, xBase, yBase + (i << 
log2_trafo_size),
 trafo_size_h, trafo_size_v, 
s->ps.sps->log2_ctb_size);
-s->hpc.intra_pred[log2_trafo_size - 2](lc, xBase, yBase + 
(i << log2_trafo_size), 2);
+s->hpc.intra_pred[log2_trafo_size - 2](lc, s->ps.pps, 
xBase, yBase + (i << log2_trafo_size), 2);
 }
 if (cbf_cr[i])
 ff_hevc_hls_residual_coding(lc, s->ps.pps, xBase, yBase + 
(i << log2_trafo_size),
@@ -1329,26 +1329,26 @@ static int hls_transform_unit(HEVCLocalContext *lc, int 
x0, int y0,
 int trafo_size_v = 1 << (log2_trafo_size_c + s->ps.sps->vshift[1]);
 ff_hevc_set_neighbour_available(lc, x0, y0, trafo_size_h, 
trafo_size_v,
 s->ps.sps->log2_ctb_size);
-s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0, 1);
-s->hpc.intra_pred[log2_trafo_size_c - 2](

[FFmpeg-cvslog] lavc/hevc/mvs: stop accessing parameter sets through HEVCParamSets

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri May 31 
13:55:39 2024 +0200| [fb873a05b3439c32b362285557a8b1fcb9947dd2] | committer: 
Anton Khirnov

lavc/hevc/mvs: stop accessing parameter sets through HEVCParamSets

Instead, accept PPS as a function argument and retrieve SPS through it.

Makes the code shorter and significantly reduces diff in future commits.

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

 libavcodec/hevc/hevcdec.c |  28 ++-
 libavcodec/hevc/hevcdec.h |   8 +--
 libavcodec/hevc/mvs.c | 126 --
 3 files changed, 87 insertions(+), 75 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 16c46997a8..5de229f78d 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -1158,7 +1158,7 @@ static int hls_transform_unit(HEVCLocalContext *lc, int 
x0, int y0,
 
 if (lc->cu.pred_mode == MODE_INTRA) {
 int trafo_size = 1 << log2_trafo_size;
-ff_hevc_set_neighbour_available(lc, x0, y0, trafo_size, trafo_size);
+ff_hevc_set_neighbour_available(lc, x0, y0, trafo_size, trafo_size, 
s->ps.sps->log2_ctb_size);
 
 s->hpc.intra_pred[log2_trafo_size - 2](lc, x0, y0, 0);
 }
@@ -1245,7 +1245,8 @@ static int hls_transform_unit(HEVCLocalContext *lc, int 
x0, int y0,
 }
 for (i = 0; i < (s->ps.sps->chroma_format_idc == 2 ? 2 : 1); i++) {
 if (lc->cu.pred_mode == MODE_INTRA) {
-ff_hevc_set_neighbour_available(lc, x0, y0 + (i << 
log2_trafo_size_c), trafo_size_h, trafo_size_v);
+ff_hevc_set_neighbour_available(lc, x0, y0 + (i << 
log2_trafo_size_c),
+trafo_size_h, 
trafo_size_v, s->ps.sps->log2_ctb_size);
 s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0 + (i 
<< log2_trafo_size_c), 1);
 }
 if (cbf_cb[i])
@@ -1275,7 +1276,7 @@ static int hls_transform_unit(HEVCLocalContext *lc, int 
x0, int y0,
 for (i = 0; i < (s->ps.sps->chroma_format_idc == 2 ? 2 : 1); i++) {
 if (lc->cu.pred_mode == MODE_INTRA) {
 ff_hevc_set_neighbour_available(lc, x0, y0 + (i << 
log2_trafo_size_c),
-trafo_size_h, 
trafo_size_v);
+trafo_size_h, 
trafo_size_v, s->ps.sps->log2_ctb_size);
 s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0 + (i 
<< log2_trafo_size_c), 2);
 }
 if (cbf_cr[i])
@@ -1304,7 +1305,7 @@ static int hls_transform_unit(HEVCLocalContext *lc, int 
x0, int y0,
 for (i = 0; i < (s->ps.sps->chroma_format_idc == 2 ? 2 : 1); i++) {
 if (lc->cu.pred_mode == MODE_INTRA) {
 ff_hevc_set_neighbour_available(lc, xBase, yBase + (i << 
log2_trafo_size),
-trafo_size_h, 
trafo_size_v);
+trafo_size_h, 
trafo_size_v, s->ps.sps->log2_ctb_size);
 s->hpc.intra_pred[log2_trafo_size - 2](lc, xBase, yBase + 
(i << log2_trafo_size), 1);
 }
 if (cbf_cb[i])
@@ -1314,7 +1315,7 @@ static int hls_transform_unit(HEVCLocalContext *lc, int 
x0, int y0,
 for (i = 0; i < (s->ps.sps->chroma_format_idc == 2 ? 2 : 1); i++) {
 if (lc->cu.pred_mode == MODE_INTRA) {
 ff_hevc_set_neighbour_available(lc, xBase, yBase + (i << 
log2_trafo_size),
-trafo_size_h, trafo_size_v);
+trafo_size_h, trafo_size_v, 
s->ps.sps->log2_ctb_size);
 s->hpc.intra_pred[log2_trafo_size - 2](lc, xBase, yBase + 
(i << log2_trafo_size), 2);
 }
 if (cbf_cr[i])
@@ -1326,12 +1327,13 @@ static int hls_transform_unit(HEVCLocalContext *lc, int 
x0, int y0,
 if (log2_trafo_size > 2 || s->ps.sps->chroma_format_idc == 3) {
 int trafo_size_h = 1 << (log2_trafo_size_c + s->ps.sps->hshift[1]);
 int trafo_size_v = 1 << (log2_trafo_size_c + s->ps.sps->vshift[1]);
-ff_hevc_set_neighbour_available(lc, x0, y0, trafo_size_h, 
trafo_size_v);
+ff_hevc_set_neighbour_available(lc, x0, y0, trafo_size_h, 
trafo_size_v,
+s->ps.sps->log2_ctb_size);
 s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0, 1);
 s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0, 2);
 i

[FFmpeg-cvslog] lavc/hevc/cabac: stop accessing parameter sets through HEVCParamSets

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri May 31 
13:55:39 2024 +0200| [d0868d70eaa19b6ae118f16a770738e801fa7be7] | committer: 
Anton Khirnov

lavc/hevc/cabac: stop accessing parameter sets through HEVCParamSets

Instead, accept PPS/SPS as function arguments.

Makes the code shorter and significantly reduces diff in future commits.

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

 libavcodec/hevc/cabac.c   | 145 +++---
 libavcodec/hevc/hevcdec.c |  31 +-
 libavcodec/hevc/hevcdec.h |  22 +++
 3 files changed, 102 insertions(+), 96 deletions(-)

diff --git a/libavcodec/hevc/cabac.c b/libavcodec/hevc/cabac.c
index 37f144758a..8708efc248 100644
--- a/libavcodec/hevc/cabac.c
+++ b/libavcodec/hevc/cabac.c
@@ -399,25 +399,25 @@ static const uint8_t diag_scan8x8_inv[8][8] = {
 { 28, 36, 43, 49, 54, 58, 61, 63, },
 };
 
-void ff_hevc_save_states(HEVCLocalContext *lc, int ctb_addr_ts)
+void ff_hevc_save_states(HEVCLocalContext *lc, const HEVCPPS *pps,
+ int ctb_addr_ts)
 {
-const HEVCContext *const s = lc->parent;
-
-if (s->ps.pps->entropy_coding_sync_enabled_flag &&
-(ctb_addr_ts % s->ps.sps->ctb_width == 2 ||
- (s->ps.sps->ctb_width == 2 &&
-  ctb_addr_ts % s->ps.sps->ctb_width == 0))) {
+const HEVCSPS *const sps = pps->sps;
+if (pps->entropy_coding_sync_enabled_flag &&
+(ctb_addr_ts % sps->ctb_width == 2 ||
+ (sps->ctb_width == 2 &&
+  ctb_addr_ts % sps->ctb_width == 0))) {
 memcpy(lc->common_cabac_state->state, lc->cabac_state, HEVC_CONTEXTS);
-if (s->ps.sps->persistent_rice_adaptation_enabled) {
+if (sps->persistent_rice_adaptation_enabled) {
 memcpy(lc->common_cabac_state->stat_coeff, lc->stat_coeff, 
HEVC_STAT_COEFFS);
 }
 }
 }
 
-static void load_states(HEVCLocalContext *lc, const HEVCContext *s)
+static void load_states(HEVCLocalContext *lc, const HEVCSPS *sps)
 {
 memcpy(lc->cabac_state, lc->common_cabac_state->state, HEVC_CONTEXTS);
-if (s->ps.sps->persistent_rice_adaptation_enabled) {
+if (sps->persistent_rice_adaptation_enabled) {
 memcpy(lc->stat_coeff, lc->common_cabac_state->stat_coeff, 
HEVC_STAT_COEFFS);
 }
 }
@@ -451,32 +451,33 @@ static void cabac_init_state(HEVCLocalContext *lc, const 
HEVCContext *s)
 lc->stat_coeff[i] = 0;
 }
 
-int ff_hevc_cabac_init(HEVCLocalContext *lc, int ctb_addr_ts,
-   const uint8_t *data, size_t size)
+int ff_hevc_cabac_init(HEVCLocalContext *lc, const HEVCPPS *pps,
+   int ctb_addr_ts, const uint8_t *data, size_t size)
 {
 const HEVCContext *const s = lc->parent;
+const HEVCSPS   *const sps = pps->sps;
 
-if (ctb_addr_ts == s->ps.pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]) {
+if (ctb_addr_ts == pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]) {
 int ret = ff_init_cabac_decoder(>cc, data, size);
 if (ret < 0)
 return ret;
 if (s->sh.dependent_slice_segment_flag == 0 ||
-(s->ps.pps->tiles_enabled_flag &&
- s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[ctb_addr_ts 
- 1]))
+(pps->tiles_enabled_flag &&
+ pps->tile_id[ctb_addr_ts] != pps->tile_id[ctb_addr_ts - 1]))
 cabac_init_state(lc, s);
 
 if (!s->sh.first_slice_in_pic_flag &&
-s->ps.pps->entropy_coding_sync_enabled_flag) {
-if (ctb_addr_ts % s->ps.sps->ctb_width == 0) {
-if (s->ps.sps->ctb_width == 1)
+pps->entropy_coding_sync_enabled_flag) {
+if (ctb_addr_ts % sps->ctb_width == 0) {
+if (sps->ctb_width == 1)
 cabac_init_state(lc, s);
 else if (s->sh.dependent_slice_segment_flag == 1)
-load_states(lc, s);
+load_states(lc, sps);
 }
 }
 } else {
-if (s->ps.pps->tiles_enabled_flag &&
-s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[ctb_addr_ts 
- 1]) {
+if (pps->tiles_enabled_flag &&
+pps->tile_id[ctb_addr_ts] != pps->tile_id[ctb_addr_ts - 1]) {
 int ret;
 if (s->threads_number == 1)
 ret = cabac_reinit(lc);
@@ -487,8 +488,8 @@ int ff_hevc_cabac_init(HEVCLocalContext *lc, int 
ctb_addr_ts,
 return ret;
 cabac_init_state(lc, s);
 }
-if (s->ps.pps->entropy_coding_sync_enabled_flag) {
-if (ctb_addr_ts % s->ps.sps->ctb_width == 0) {

[FFmpeg-cvslog] lavc/hevc/parser: stop using HEVCParamSets.[psv]ps

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri May 31 
10:55:19 2024 +0200| [6ddba110eb1dcb7c05368f85759a70a5645ca4ca] | committer: 
Anton Khirnov

lavc/hevc/parser: stop using HEVCParamSets.[psv]ps

The parser does not need to preserve these between frames.

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

 libavcodec/hevc/parser.c | 61 
 1 file changed, 30 insertions(+), 31 deletions(-)

diff --git a/libavcodec/hevc/parser.c b/libavcodec/hevc/parser.c
index 49f7bccdfa..f4e6e3c36d 100644
--- a/libavcodec/hevc/parser.c
+++ b/libavcodec/hevc/parser.c
@@ -58,6 +58,8 @@ static int hevc_parse_slice_header(AVCodecParserContext *s, 
H2645NAL *nal,
 HEVCParamSets *ps = >ps;
 HEVCSEI *sei = >sei;
 GetBitContext *gb = >gb;
+const HEVCPPS *pps;
+const HEVCSPS *sps;
 const HEVCWindow *ow;
 int i, num = 0, den = 0;
 
@@ -78,28 +80,25 @@ static int hevc_parse_slice_header(AVCodecParserContext *s, 
H2645NAL *nal,
 av_log(avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id);
 return AVERROR_INVALIDDATA;
 }
-ps->pps = ps->pps_list[pps_id];
-
-if (ps->sps != ps->pps->sps) {
-ps->sps  = ps->pps->sps;
-ps->vps  = ps->sps->vps;
-}
-ow  = >sps->output_window;
-
-s->coded_width  = ps->sps->width;
-s->coded_height = ps->sps->height;
-s->width= ps->sps->width  - ow->left_offset - ow->right_offset;
-s->height   = ps->sps->height - ow->top_offset  - ow->bottom_offset;
-s->format   = ps->sps->pix_fmt;
-avctx->profile  = ps->sps->ptl.general_ptl.profile_idc;
-avctx->level= ps->sps->ptl.general_ptl.level_idc;
-
-if (ps->vps->vps_timing_info_present_flag) {
-num = ps->vps->vps_num_units_in_tick;
-den = ps->vps->vps_time_scale;
-} else if (ps->sps->vui.vui_timing_info_present_flag) {
-num = ps->sps->vui.vui_num_units_in_tick;
-den = ps->sps->vui.vui_time_scale;
+pps = ps->pps_list[pps_id];
+sps = pps->sps;
+
+ow  = >output_window;
+
+s->coded_width  = sps->width;
+s->coded_height = sps->height;
+s->width= sps->width  - ow->left_offset - ow->right_offset;
+s->height   = sps->height - ow->top_offset  - ow->bottom_offset;
+s->format   = sps->pix_fmt;
+avctx->profile  = sps->ptl.general_ptl.profile_idc;
+avctx->level= sps->ptl.general_ptl.level_idc;
+
+if (sps->vps->vps_timing_info_present_flag) {
+num = sps->vps->vps_num_units_in_tick;
+den = sps->vps->vps_time_scale;
+} else if (sps->vui.vui_timing_info_present_flag) {
+num = sps->vui.vui_num_units_in_tick;
+den = sps->vui.vui_time_scale;
 }
 
 if (num != 0 && den != 0)
@@ -110,15 +109,15 @@ static int hevc_parse_slice_header(AVCodecParserContext 
*s, H2645NAL *nal,
 unsigned int slice_segment_addr;
 int slice_address_length;
 
-if (ps->pps->dependent_slice_segments_enabled_flag)
+if (pps->dependent_slice_segments_enabled_flag)
 dependent_slice_segment_flag = get_bits1(gb);
 else
 dependent_slice_segment_flag = 0;
 
-slice_address_length = av_ceil_log2_c(ps->sps->ctb_width *
-  ps->sps->ctb_height);
+slice_address_length = av_ceil_log2_c(sps->ctb_width *
+  sps->ctb_height);
 slice_segment_addr = get_bitsz(gb, slice_address_length);
-if (slice_segment_addr >= ps->sps->ctb_width * ps->sps->ctb_height) {
+if (slice_segment_addr >= sps->ctb_width * sps->ctb_height) {
 av_log(avctx, AV_LOG_ERROR, "Invalid slice segment address: %u.\n",
slice_segment_addr);
 return AVERROR_INVALIDDATA;
@@ -129,7 +128,7 @@ static int hevc_parse_slice_header(AVCodecParserContext *s, 
H2645NAL *nal,
 if (dependent_slice_segment_flag)
 return 0; /* break; */
 
-for (i = 0; i < ps->pps->num_extra_slice_header_bits; i++)
+for (i = 0; i < pps->num_extra_slice_header_bits; i++)
 skip_bits(gb, 1); // slice_reserved_undetermined_flag[]
 
 slice_type = get_ue_golomb_31(gb);
@@ -143,16 +142,16 @@ static int hevc_parse_slice_header(AVCodecParserContext 
*s, H2645NAL *nal,
slice_type == HEVC_SLICE_P ? AV_PICTURE_TYPE_P :
 AV_PICTURE_TYPE_I;
 
-if (ps->pps->output_flag_present_flag)
+if (pps->output_flag_present_flag)
 skip_bits1(gb); // pic_outp

[FFmpeg-cvslog] lavc/hevcdec: drop a redundant assignment in hevc_decode_frame()

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Jun  1 
12:19:33 2024 +0200| [e12fd62d1dd4a8f129f33015e22e270e871fc4ce] | committer: 
Anton Khirnov

lavc/hevcdec: drop a redundant assignment in hevc_decode_frame()

The exact same code is executed at the beginning of decode_nal_units()

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

 libavcodec/hevc/hevcdec.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 43cbc45062..46db7923fe 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3369,7 +3369,6 @@ static int hevc_decode_frame(AVCodecContext *avctx, 
AVFrame *rframe,
old, s->dovi_ctx.cfg.dv_profile);
 }
 
-s->cur_frame = s->collocated_ref = NULL;
 ret= decode_nal_units(s, avpkt->data, avpkt->size);
 if (ret < 0)
 return ret;

___
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] lavc/hevc_ps: make SPS hold a reference to its VPS

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri May 31 
09:53:28 2024 +0200| [2e46d68f553c36f61e46f1db5c5adce84b60f175] | committer: 
Anton Khirnov

lavc/hevc_ps: make SPS hold a reference to its VPS

SPS and its dependent PPSes depend on, and are parsed for, specific VPS data.

This will be useful in following commits.

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

 libavcodec/hevc/hevcdec.c |  5 ++---
 libavcodec/hevc/parser.c  |  2 +-
 libavcodec/hevc/ps.c  | 13 +
 libavcodec/hevc/ps.h  |  2 ++
 4 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index ae4a5888e5..16c46997a8 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -319,8 +319,7 @@ static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, 
GetBitContext *gb)
 static void export_stream_params(HEVCContext *s, const HEVCSPS *sps)
 {
 AVCodecContext *avctx = s->avctx;
-const HEVCParamSets *ps = >ps;
-const HEVCVPS *vps = ps->vps_list[sps->vps_id];
+const HEVCVPS*vps = sps->vps;
 const HEVCWindow *ow = >output_window;
 unsigned int num = 0, den = 0;
 
@@ -575,7 +574,7 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps,
 }
 
 s->ps.sps = sps;
-s->ps.vps = s->ps.vps_list[s->ps.sps->vps_id];
+s->ps.vps = sps->vps;
 
 return 0;
 
diff --git a/libavcodec/hevc/parser.c b/libavcodec/hevc/parser.c
index d0d5e7fbc2..49f7bccdfa 100644
--- a/libavcodec/hevc/parser.c
+++ b/libavcodec/hevc/parser.c
@@ -82,7 +82,7 @@ static int hevc_parse_slice_header(AVCodecParserContext *s, 
H2645NAL *nal,
 
 if (ps->sps != ps->pps->sps) {
 ps->sps  = ps->pps->sps;
-ps->vps  = ps->vps_list[ps->sps->vps_id];
+ps->vps  = ps->sps->vps;
 }
 ow  = >sps->output_window;
 
diff --git a/libavcodec/hevc/ps.c b/libavcodec/hevc/ps.c
index 98217e337b..eabed69b94 100644
--- a/libavcodec/hevc/ps.c
+++ b/libavcodec/hevc/ps.c
@@ -889,10 +889,13 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
unsigned int *sps_id,
 
 sps->vps_id = get_bits(gb, 4);
 
-if (vps_list && !vps_list[sps->vps_id]) {
-av_log(avctx, AV_LOG_ERROR, "VPS %d does not exist\n",
-   sps->vps_id);
-return AVERROR_INVALIDDATA;
+if (vps_list) {
+if (!vps_list[sps->vps_id]) {
+av_log(avctx, AV_LOG_ERROR, "VPS %d does not exist\n",
+   sps->vps_id);
+return AVERROR_INVALIDDATA;
+}
+sps->vps = ff_refstruct_ref_c(vps_list[sps->vps_id]);
 }
 
 sps->max_sub_layers = get_bits(gb, 3) + 1;
@@ -1298,6 +1301,8 @@ static void hevc_sps_free(FFRefStructOpaque opaque, void 
*obj)
 {
 HEVCSPS *sps = obj;
 
+ff_refstruct_unref(>vps);
+
 av_freep(>data);
 }
 
diff --git a/libavcodec/hevc/ps.h b/libavcodec/hevc/ps.h
index 7c9aacf057..fc10876756 100644
--- a/libavcodec/hevc/ps.h
+++ b/libavcodec/hevc/ps.h
@@ -302,6 +302,8 @@ typedef struct HEVCSPS {
 
 uint8_t *data;
 int data_size;
+
+const HEVCVPS *vps; ///< RefStruct reference
 } HEVCSPS;
 
 typedef struct HEVCPPS {

___
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] lavc/hevc_ps: make PPS hold a reference to its SPS

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri May 31 
09:53:28 2024 +0200| [c879165b393dee62ecd7c3b51d0e15964425bf5d] | committer: 
Anton Khirnov

lavc/hevc_ps: make PPS hold a reference to its SPS

PPS depends on, and is parsed for, specific SPS data.

This will be useful in following commits.

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

 libavcodec/hevc/hevcdec.c | 4 ++--
 libavcodec/hevc/parser.c  | 8 ++--
 libavcodec/hevc/ps.c  | 4 
 libavcodec/hevc/ps.h  | 2 ++
 4 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 46db7923fe..ae4a5888e5 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -625,8 +625,8 @@ static int hls_slice_header(HEVCContext *s, GetBitContext 
*gb)
 if (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos == 1)
 sh->no_output_of_prior_pics_flag = 1;
 
-if (s->ps.sps != s->ps.sps_list[s->ps.pps->sps_id]) {
-const HEVCSPS *sps = s->ps.sps_list[s->ps.pps->sps_id];
+if (s->ps.sps != s->ps.pps->sps) {
+const HEVCSPS *sps = s->ps.pps->sps;
 enum AVPixelFormat pix_fmt;
 
 ff_hevc_clear_refs(s);
diff --git a/libavcodec/hevc/parser.c b/libavcodec/hevc/parser.c
index 056e1b4aa4..d0d5e7fbc2 100644
--- a/libavcodec/hevc/parser.c
+++ b/libavcodec/hevc/parser.c
@@ -80,12 +80,8 @@ static int hevc_parse_slice_header(AVCodecParserContext *s, 
H2645NAL *nal,
 }
 ps->pps = ps->pps_list[pps_id];
 
-if (ps->pps->sps_id >= HEVC_MAX_SPS_COUNT || 
!ps->sps_list[ps->pps->sps_id]) {
-av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", 
ps->pps->sps_id);
-return AVERROR_INVALIDDATA;
-}
-if (ps->sps != ps->sps_list[ps->pps->sps_id]) {
-ps->sps  = ps->sps_list[ps->pps->sps_id];
+if (ps->sps != ps->pps->sps) {
+ps->sps  = ps->pps->sps;
 ps->vps  = ps->vps_list[ps->sps->vps_id];
 }
 ow  = >sps->output_window;
diff --git a/libavcodec/hevc/ps.c b/libavcodec/hevc/ps.c
index 2dd4f834a4..98217e337b 100644
--- a/libavcodec/hevc/ps.c
+++ b/libavcodec/hevc/ps.c
@@ -1363,6 +1363,8 @@ static void hevc_pps_free(FFRefStructOpaque unused, void 
*obj)
 {
 HEVCPPS *pps = obj;
 
+ff_refstruct_unref(>sps);
+
 av_freep(>column_width);
 av_freep(>row_height);
 av_freep(>col_bd);
@@ -1828,6 +1830,8 @@ int ff_hevc_decode_nal_pps(GetBitContext *gb, 
AVCodecContext *avctx,
 sps = ps->sps_list[pps->sps_id];
 vps = ps->vps_list[sps->vps_id];
 
+pps->sps = ff_refstruct_ref_c(sps);
+
 pps->dependent_slice_segments_enabled_flag = get_bits1(gb);
 pps->output_flag_present_flag  = get_bits1(gb);
 pps->num_extra_slice_header_bits   = get_bits(gb, 3);
diff --git a/libavcodec/hevc/ps.h b/libavcodec/hevc/ps.h
index 99d70cefd2..7c9aacf057 100644
--- a/libavcodec/hevc/ps.h
+++ b/libavcodec/hevc/ps.h
@@ -437,6 +437,8 @@ typedef struct HEVCPPS {
 
 uint8_t *data;
 int data_size;
+
+const HEVCSPS *sps; ///< RefStruct reference
 } HEVCPPS;
 
 typedef struct HEVCParamSets {

___
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] lavc/hevcdec: simplify condition

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sat Jun  1 
10:04:44 2024 +0200| [a82f2b092430db8284bf91147f718d09f3ee592c] | committer: 
Anton Khirnov

lavc/hevcdec: simplify condition

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

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

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index d317c1471a..43cbc45062 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3115,7 +3115,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL 
*nal)
 ctb_addr_ts = hls_slice_data_wpp(s, nal);
 else
 ctb_addr_ts = hls_decode_entry(s, );
-if (ctb_addr_ts >= (s->ps.sps->ctb_width * s->ps.sps->ctb_height)) 
{
+if (ctb_addr_ts >= s->cur_frame->ctb_count) {
 ret = hevc_frame_end(s);
 if (ret < 0)
 goto fail;

___
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] lavc/hevcdec: do not free SliceHeader arrays in pic_arrays_free()

2024-06-11 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sun Jun  2 
20:23:07 2024 +0200| [04075567163290eb8b85d106b3e53bdc13d8515b] | committer: 
Anton Khirnov

lavc/hevcdec: do not free SliceHeader arrays in pic_arrays_free()

SliceHeader.{entry_point_offset,size,offset} are not derived from frame
size and do not need to be freed here.

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

 libavcodec/hevc/hevcdec.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 4e0df4d033..d317c1471a 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -84,10 +84,6 @@ static void pic_arrays_free(HEVCContext *s)
 av_freep(>horizontal_bs);
 av_freep(>vertical_bs);
 
-av_freep(>sh.entry_point_offset);
-av_freep(>sh.size);
-av_freep(>sh.offset);
-
 ff_refstruct_pool_uninit(>tab_mvf_pool);
 ff_refstruct_pool_uninit(>rpl_tab_pool);
 }

___
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] lavc/hevcdec: drop unused HEVCContext.width/height

2024-06-04 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed May 29 
17:03:28 2024 +0200| [9576a005271e5a20572b5c581dbf15ad77b373bb] | committer: 
Anton Khirnov

lavc/hevcdec: drop unused HEVCContext.width/height

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

 libavcodec/hevc/hevcdec.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h
index 8208268460..33ad4ac0aa 100644
--- a/libavcodec/hevc/hevcdec.h
+++ b/libavcodec/hevc/hevcdec.h
@@ -456,9 +456,6 @@ typedef struct HEVCContext {
 uint8_t threads_type;
 uint8_t threads_number;
 
-int width;
-int height;
-
 /** 1 if the independent slice segment header was successfully parsed */
 uint8_t slice_initialized;
 

___
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] lavc/hevcdec: rename HEVCContext.ref to cur_frame

2024-06-04 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed May 29 
08:38:27 2024 +0200| [9226514cededdfe0244fbe8fe5c8fcfa3a9c75cb] | committer: 
Anton Khirnov

lavc/hevcdec: rename HEVCContext.ref to cur_frame

Since it stores a pointer to the current frame.

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

 libavcodec/d3d12va_hevc.c  | 10 +++
 libavcodec/dxva2_hevc.c| 12 
 libavcodec/hevc_filter.c   | 34 ++---
 libavcodec/hevc_mvs.c  | 20 ++---
 libavcodec/hevc_refs.c | 18 +--
 libavcodec/hevcdec.c   | 68 +-
 libavcodec/hevcdec.h   |  2 +-
 libavcodec/hevcpred_template.c |  2 +-
 libavcodec/mips/hevcpred_msa.c | 68 +-
 libavcodec/nvdec_hevc.c|  6 ++--
 libavcodec/vaapi_hevc.c| 18 +--
 libavcodec/vdpau_hevc.c| 10 +++
 libavcodec/videotoolbox.c  |  2 +-
 libavcodec/vulkan_hevc.c   |  6 ++--
 14 files changed, 138 insertions(+), 138 deletions(-)

diff --git a/libavcodec/d3d12va_hevc.c b/libavcodec/d3d12va_hevc.c
index a4964a05c6..323ade7d83 100644
--- a/libavcodec/d3d12va_hevc.c
+++ b/libavcodec/d3d12va_hevc.c
@@ -53,7 +53,7 @@ static int d3d12va_hevc_start_frame(AVCodecContext *avctx, 
av_unused const uint8
 {
 const HEVCContext*h   = avctx->priv_data;
 D3D12VADecodeContext *ctx = D3D12VA_DECODE_CONTEXT(avctx);
-HEVCDecodePictureContext *ctx_pic = h->ref->hwaccel_picture_private;
+HEVCDecodePictureContext *ctx_pic = h->cur_frame->hwaccel_picture_private;
 
 if (!ctx)
 return -1;
@@ -76,7 +76,7 @@ static int d3d12va_hevc_start_frame(AVCodecContext *avctx, 
av_unused const uint8
 static int d3d12va_hevc_decode_slice(AVCodecContext *avctx, const uint8_t 
*buffer, uint32_t size)
 {
 const HEVCContext*h   = avctx->priv_data;
-const HEVCFrame  *current_picture = h->ref;
+const HEVCFrame  *current_picture = h->cur_frame;
 HEVCDecodePictureContext *ctx_pic = 
current_picture->hwaccel_picture_private;
 unsigned position;
 
@@ -99,7 +99,7 @@ static int d3d12va_hevc_decode_slice(AVCodecContext *avctx, 
const uint8_t *buffe
 static int update_input_arguments(AVCodecContext *avctx, 
D3D12_VIDEO_DECODE_INPUT_STREAM_ARGUMENTS *input_args, ID3D12Resource *buffer)
 {
 const HEVCContext*h   = avctx->priv_data;
-const HEVCFrame  *current_picture = h->ref;
+const HEVCFrame  *current_picture = h->cur_frame;
 HEVCDecodePictureContext *ctx_pic = 
current_picture->hwaccel_picture_private;
 
 int i;
@@ -149,14 +149,14 @@ static int update_input_arguments(AVCodecContext *avctx, 
D3D12_VIDEO_DECODE_INPU
 static int d3d12va_hevc_end_frame(AVCodecContext *avctx)
 {
 HEVCContext  *h   = avctx->priv_data;
-HEVCDecodePictureContext *ctx_pic = h->ref->hwaccel_picture_private;
+HEVCDecodePictureContext *ctx_pic = h->cur_frame->hwaccel_picture_private;
 
 int scale = ctx_pic->pp.dwCodingParamToolFlags & 1;
 
 if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
 return -1;
 
-return ff_d3d12va_common_end_frame(avctx, h->ref->frame, _pic->pp, 
sizeof(ctx_pic->pp),
+return ff_d3d12va_common_end_frame(avctx, h->cur_frame->frame, 
_pic->pp, sizeof(ctx_pic->pp),
scale ? _pic->qm : NULL, scale ? sizeof(ctx_pic->qm) : 0, 
update_input_arguments);
 }
 
diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c
index b500d7917a..2d6c2f812f 100644
--- a/libavcodec/dxva2_hevc.c
+++ b/libavcodec/dxva2_hevc.c
@@ -61,7 +61,7 @@ void ff_dxva2_hevc_fill_picture_parameters(const 
AVCodecContext *avctx, AVDXVACo
 DXVA_PicParams_HEVC *pp)
 {
 const HEVCContext *h = avctx->priv_data;
-const HEVCFrame *current_picture = h->ref;
+const HEVCFrame *current_picture = h->cur_frame;
 const HEVCSPS *sps = h->ps.sps;
 const HEVCPPS *pps = h->ps.pps;
 int i, j;
@@ -245,7 +245,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext 
*avctx,
 {
 const HEVCContext *h = avctx->priv_data;
 AVDXVAContext *ctx = DXVA_CONTEXT(avctx);
-const HEVCFrame *current_picture = h->ref;
+const HEVCFrame *current_picture = h->cur_frame;
 struct hevc_dxva2_picture_context *ctx_pic = 
current_picture->hwaccel_picture_private;
 DXVA_Slice_HEVC_Short *slice = NULL;
 void *dxva_data_ptr;
@@ -364,7 +364,7 @@ static int dxva2_hevc_start_frame(AVCodecContext *avctx,
 {
 const HEVCContext *h = avctx->priv_data;
 AVDXVAContext *ctx = DXVA_CONTEXT(avctx);
-struct hevc_dxva2_picture_context *ctx_pic = 
h->ref->hwaccel_pictur

[FFmpeg-cvslog] lavc/hevcdec: drop HEVCContext.HEVClc

2024-06-04 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed May 29 
08:23:54 2024 +0200| [7ad9400952c0e2827def7a461ff7a8f7b911945b] | committer: 
Anton Khirnov

lavc/hevcdec: drop HEVCContext.HEVClc

It is merely a pointer to local_ctx[0], which we can just as well use
directly.

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

 libavcodec/hevcdec.c | 24 ++--
 libavcodec/hevcdec.h |  2 --
 2 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 0a9443505a..75d0ed613a 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -1036,14 +1036,14 @@ static int hls_slice_header(HEVCContext *s, 
GetBitContext *gb)
 return AVERROR_INVALIDDATA;
 }
 
-s->HEVClc->first_qp_group = !s->sh.dependent_slice_segment_flag;
+s->local_ctx[0].first_qp_group = !s->sh.dependent_slice_segment_flag;
 
 if (!s->ps.pps->cu_qp_delta_enabled_flag)
-s->HEVClc->qp_y = s->sh.slice_qp;
+s->local_ctx[0].qp_y = s->sh.slice_qp;
 
 s->slice_initialized = 1;
-s->HEVClc->tu.cu_qp_offset_cb = 0;
-s->HEVClc->tu.cu_qp_offset_cr = 0;
+s->local_ctx[0].tu.cu_qp_offset_cb = 0;
+s->local_ctx[0].tu.cu_qp_offset_cr = 0;
 
 return 0;
 }
@@ -2534,7 +2534,7 @@ static void hls_decode_neighbour(HEVCLocalContext *lc, 
int x_ctb, int y_ctb,
 
 static int hls_decode_entry(HEVCContext *s, GetBitContext *gb)
 {
-HEVCLocalContext *const lc = s->HEVClc;
+HEVCLocalContext *const lc = >local_ctx[0];
 const uint8_t *slice_data = gb->buffer + s->sh.data_offset;
 const size_t   slice_size = gb->buffer_end - gb->buffer - 
s->sh.data_offset;
 int ctb_size= 1 << s->ps.sps->log2_ctb_size;
@@ -2704,7 +2704,6 @@ static int hls_slice_data_wpp(HEVCContext *s, const 
H2645NAL *nal)
 memcpy(tmp, s->local_ctx, sizeof(*s->local_ctx) * s->nb_local_ctx);
 av_free(s->local_ctx);
 s->local_ctx = tmp;
-s->HEVClc= >local_ctx[0];
 
 for (unsigned i = s->nb_local_ctx; i < s->threads_number; i++) {
 tmp = >local_ctx[i];
@@ -2757,7 +2756,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const 
H2645NAL *nal)
 
 for (i = 1; i < s->threads_number; i++) {
 s->local_ctx[i].first_qp_group = 1;
-s->local_ctx[i].qp_y = s->HEVClc->qp_y;
+s->local_ctx[i].qp_y = s->local_ctx[0].qp_y;
 }
 
 atomic_store(>wpp_err, 0);
@@ -2868,7 +2867,6 @@ static int set_side_data(HEVCContext *s)
 
 static int hevc_frame_start(HEVCContext *s)
 {
-HEVCLocalContext *lc = s->HEVClc;
 int pic_size_in_ctb  = ((s->ps.sps->width  >> s->ps.sps->log2_min_cb_size) 
+ 1) *
((s->ps.sps->height >> s->ps.sps->log2_min_cb_size) 
+ 1);
 int ret;
@@ -2885,7 +2883,7 @@ static int hevc_frame_start(HEVCContext *s)
 s->no_rasl_output_flag = IS_IDR(s) || IS_BLA(s) || (s->nal_unit_type == 
HEVC_NAL_CRA_NUT && s->last_eos);
 
 if (s->ps.pps->tiles_enabled_flag)
-lc->end_of_tiles_x = s->ps.pps->column_width[0] << 
s->ps.sps->log2_ctb_size;
+s->local_ctx[0].end_of_tiles_x = s->ps.pps->column_width[0] << 
s->ps.sps->log2_ctb_size;
 
 ret = ff_hevc_set_new_ref(s, >frame, s->poc);
 if (ret < 0)
@@ -3505,11 +3503,9 @@ static av_cold int hevc_init_context(AVCodecContext 
*avctx)
 return AVERROR(ENOMEM);
 s->nb_local_ctx = 1;
 
-s->HEVClc = >local_ctx[0];
-
-s->HEVClc->parent = s;
-s->HEVClc->logctx = avctx;
-s->HEVClc->common_cabac_state = >cabac;
+s->local_ctx[0].parent = s;
+s->local_ctx[0].logctx = avctx;
+s->local_ctx[0].common_cabac_state = >cabac;
 
 s->output_frame = av_frame_alloc();
 if (!s->output_frame)
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index 0ed51a5392..6957cd1091 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -452,8 +452,6 @@ typedef struct HEVCContext {
 HEVCLocalContext *local_ctx;
 unsigned   nb_local_ctx;
 
-HEVCLocalContext*HEVClc;
-
 uint8_t threads_type;
 uint8_t threads_number;
 

___
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] lavc/hevcdec: drop HEVCContext.frame

2024-06-04 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed May 29 
09:00:19 2024 +0200| [ba56a300a94bdf5520ac1324a8e7fbaeea430904] | committer: 
Anton Khirnov

lavc/hevcdec: drop HEVCContext.frame

It is merely a redundant pointer to cur_frame->f

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

 libavcodec/hevc_cabac.c|  4 ++--
 libavcodec/hevc_filter.c   | 39 ++-
 libavcodec/hevc_refs.c |  3 +--
 libavcodec/hevcdec.c   | 53 +-
 libavcodec/hevcdec.h   |  3 +--
 libavcodec/hevcpred_template.c |  4 ++--
 6 files changed, 50 insertions(+), 56 deletions(-)

diff --git a/libavcodec/hevc_cabac.c b/libavcodec/hevc_cabac.c
index 71bd678972..c9da4d7fc1 100644
--- a/libavcodec/hevc_cabac.c
+++ b/libavcodec/hevc_cabac.c
@@ -1002,10 +1002,10 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, 
int x0, int y0,
 
 const uint8_t *scan_x_cg, *scan_y_cg, *scan_x_off, *scan_y_off;
 
-ptrdiff_t stride = s->frame->linesize[c_idx];
+ptrdiff_t stride = s->cur_frame->f->linesize[c_idx];
 int hshift = s->ps.sps->hshift[c_idx];
 int vshift = s->ps.sps->vshift[c_idx];
-uint8_t *dst = >frame->data[c_idx][(y0 >> vshift) * stride +
+uint8_t *dst = >cur_frame->f->data[c_idx][(y0 >> vshift) * stride +
   ((x0 >> hshift) << 
s->ps.sps->pixel_shift)];
 int16_t *coeffs = (int16_t*)(c_idx ? lc->edge_emu_buffer2 : 
lc->edge_emu_buffer);
 uint8_t significant_coeff_group_flag[8][8] = {{0}};
diff --git a/libavcodec/hevc_filter.c b/libavcodec/hevc_filter.c
index 0ba419a7b8..db7525170d 100644
--- a/libavcodec/hevc_filter.c
+++ b/libavcodec/hevc_filter.c
@@ -315,13 +315,13 @@ static void sao_filter_CTB(HEVCLocalContext *lc, const 
HEVCContext *s, int x, in
 for (c_idx = 0; c_idx < (s->ps.sps->chroma_format_idc ? 3 : 1); c_idx++) {
 int x0   = x >> s->ps.sps->hshift[c_idx];
 int y0   = y >> s->ps.sps->vshift[c_idx];
-ptrdiff_t stride_src = s->frame->linesize[c_idx];
+ptrdiff_t stride_src = s->cur_frame->f->linesize[c_idx];
 int ctb_size_h = (1 << (s->ps.sps->log2_ctb_size)) >> 
s->ps.sps->hshift[c_idx];
 int ctb_size_v = (1 << (s->ps.sps->log2_ctb_size)) >> 
s->ps.sps->vshift[c_idx];
 int width= FFMIN(ctb_size_h, (s->ps.sps->width  >> 
s->ps.sps->hshift[c_idx]) - x0);
 int height   = FFMIN(ctb_size_v, (s->ps.sps->height >> 
s->ps.sps->vshift[c_idx]) - y0);
 int tab  = sao_tab[(FFALIGN(width, 8) >> 3) - 1];
-uint8_t *src = >frame->data[c_idx][y0 * stride_src + (x0 << 
s->ps.sps->pixel_shift)];
+uint8_t *src = >cur_frame->f->data[c_idx][y0 * stride_src + (x0 << 
s->ps.sps->pixel_shift)];
 ptrdiff_t stride_dst;
 uint8_t *dst;
 
@@ -484,6 +484,9 @@ static int get_pcm(const HEVCContext *s, int x, int y)
 
 static void deblocking_filter_CTB(const HEVCContext *s, int x0, int y0)
 {
+uint8_t **data = s->cur_frame->f->data;
+int  *linesize = s->cur_frame->f->linesize;
+
 uint8_t *src;
 int x, y;
 int chroma, beta;
@@ -537,18 +540,16 @@ static void deblocking_filter_CTB(const HEVCContext *s, 
int x0, int y0)
 
 tc[0]   = bs0 ? TC_CALC(qp, bs0) : 0;
 tc[1]   = bs1 ? TC_CALC(qp, bs1) : 0;
-src = >frame->data[LUMA][y * s->frame->linesize[LUMA] + 
(x << s->ps.sps->pixel_shift)];
+src = [LUMA][y * linesize[LUMA] + (x << 
s->ps.sps->pixel_shift)];
 if (pcmf) {
 no_p[0] = get_pcm(s, x - 1, y);
 no_p[1] = get_pcm(s, x - 1, y + 4);
 no_q[0] = get_pcm(s, x, y);
 no_q[1] = get_pcm(s, x, y + 4);
-s->hevcdsp.hevc_v_loop_filter_luma_c(src,
- 
s->frame->linesize[LUMA],
+s->hevcdsp.hevc_v_loop_filter_luma_c(src, linesize[LUMA],
  beta, tc, no_p, no_q);
 } else
-s->hevcdsp.hevc_v_loop_filter_luma(src,
-   
s->frame->linesize[LUMA],
+s->hevcdsp.hevc_v_loop_filter_luma(src, linesize[LUMA],
beta, tc, no_p, no_q);
 }
 }
@@ -569,18 +570,16 @@ static void deblocking_filter_CTB(const HEVCContext *s, 
int x0, int y0)
 beta = betatable[av_c

[FFmpeg-cvslog] lavc/hevcdec: rename HEVCFrame.frame to just f

2024-06-04 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed May 29 
08:38:27 2024 +0200| [db84c1c6eff955150ec2a1a5211c15c9101fcbf1] | committer: 
Anton Khirnov

lavc/hevcdec: rename HEVCFrame.frame to just f

This is shorter, loses no information, and is consistent with other
similar structs.

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

 libavcodec/d3d12va_hevc.c |  2 +-
 libavcodec/dxva2_hevc.c   |  8 
 libavcodec/hevc_refs.c| 34 
 libavcodec/hevcdec.c  | 50 +++
 libavcodec/hevcdec.h  |  2 +-
 libavcodec/nvdec_hevc.c   |  6 +++---
 libavcodec/vaapi_hevc.c   | 18 -
 libavcodec/vdpau_hevc.c   | 10 +-
 libavcodec/videotoolbox.c |  2 +-
 libavcodec/vulkan_hevc.c  | 10 +-
 10 files changed, 71 insertions(+), 71 deletions(-)

diff --git a/libavcodec/d3d12va_hevc.c b/libavcodec/d3d12va_hevc.c
index 323ade7d83..3a886f3bc1 100644
--- a/libavcodec/d3d12va_hevc.c
+++ b/libavcodec/d3d12va_hevc.c
@@ -156,7 +156,7 @@ static int d3d12va_hevc_end_frame(AVCodecContext *avctx)
 if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
 return -1;
 
-return ff_d3d12va_common_end_frame(avctx, h->cur_frame->frame, 
_pic->pp, sizeof(ctx_pic->pp),
+return ff_d3d12va_common_end_frame(avctx, h->cur_frame->f, _pic->pp, 
sizeof(ctx_pic->pp),
scale ? _pic->qm : NULL, scale ? sizeof(ctx_pic->qm) : 0, 
update_input_arguments);
 }
 
diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c
index 2d6c2f812f..08b3b1e785 100644
--- a/libavcodec/dxva2_hevc.c
+++ b/libavcodec/dxva2_hevc.c
@@ -170,7 +170,7 @@ void ff_dxva2_hevc_fill_picture_parameters(const 
AVCodecContext *avctx, AVDXVACo
 }
 
 if (frame) {
-fill_picture_entry(>RefPicList[i], 
ff_dxva2_get_surface_index(avctx, ctx, frame->frame, 0), !!(frame->flags & 
HEVC_FRAME_FLAG_LONG_REF));
+fill_picture_entry(>RefPicList[i], 
ff_dxva2_get_surface_index(avctx, ctx, frame->f, 0), !!(frame->flags & 
HEVC_FRAME_FLAG_LONG_REF));
 pp->PicOrderCntValList[i] = frame->poc;
 } else {
 pp->RefPicList[i].bPicEntry = 0xff;
@@ -178,7 +178,7 @@ void ff_dxva2_hevc_fill_picture_parameters(const 
AVCodecContext *avctx, AVDXVACo
 }
 }
 
-fill_picture_entry(>CurrPic, ff_dxva2_get_surface_index(avctx, ctx, 
current_picture->frame, 1), 0);
+fill_picture_entry(>CurrPic, ff_dxva2_get_surface_index(avctx, ctx, 
current_picture->f, 1), 0);
 
 #define DO_REF_LIST(ref_idx, ref_list) { \
 const RefPicList *rpl = >rps[ref_idx]; \
@@ -187,7 +187,7 @@ void ff_dxva2_hevc_fill_picture_parameters(const 
AVCodecContext *avctx, AVDXVACo
 while (!frame && j < rpl->nb_refs) \
 frame = rpl->ref[j++]; \
 if (frame && frame->flags & (HEVC_FRAME_FLAG_LONG_REF | 
HEVC_FRAME_FLAG_SHORT_REF)) \
-pp->ref_list[i] = get_refpic_index(pp, 
ff_dxva2_get_surface_index(avctx, ctx, frame->frame, 0)); \
+pp->ref_list[i] = get_refpic_index(pp, 
ff_dxva2_get_surface_index(avctx, ctx, frame->f, 0)); \
 else \
 pp->ref_list[i] = 0xff; \
 } \
@@ -415,7 +415,7 @@ static int dxva2_hevc_end_frame(AVCodecContext *avctx)
 if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
 return -1;
 
-ret = ff_dxva2_common_end_frame(avctx, h->cur_frame->frame,
+ret = ff_dxva2_common_end_frame(avctx, h->cur_frame->f,
 _pic->pp, sizeof(ctx_pic->pp),
 scale ? _pic->qm : NULL, scale ? 
sizeof(ctx_pic->qm) : 0,
 commit_bitstream_and_slice_buffer);
diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index ca4b2b8bfd..6019818cf0 100644
--- a/libavcodec/hevc_refs.c
+++ b/libavcodec/hevc_refs.c
@@ -79,7 +79,7 @@ static HEVCFrame *alloc_frame(HEVCContext *s)
 int i, j, ret;
 for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
 HEVCFrame *frame = >DPB[i];
-if (frame->frame)
+if (frame->f)
 continue;
 
 ret = ff_progress_frame_get_buffer(s->avctx, >tf,
@@ -104,10 +104,10 @@ static HEVCFrame *alloc_frame(HEVCContext *s)
 frame->rpl_tab[j] = frame->rpl;
 
 if (s->sei.picture_timing.picture_struct == 
AV_PICTURE_STRUCTURE_TOP_FIELD)
-frame->frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
+frame->f->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
 if ((s->sei.picture_timing.picture_struct == 
AV_PICTURE_STRUCTURE_TOP_FIELD) ||
 (s->sei.picture_timing.picture_struct == 
AV_PICTURE

[FFmpeg-cvslog] lavc/hevcdec: deduplicate calling hwaccel decode_params()

2024-06-04 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed May 29 
13:44:04 2024 +0200| [a13b892080811345c9b5ae74ed1a9dbbccd5af52] | committer: 
Anton Khirnov

lavc/hevcdec: deduplicate calling hwaccel decode_params()

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

 libavcodec/hevc/hevcdec.c | 36 
 1 file changed, 12 insertions(+), 24 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 4a07fa6612..4e0df4d033 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -2985,49 +2985,37 @@ static int decode_nal_unit(HEVCContext *s, const 
H2645NAL *nal)
 s->nal_unit_type = nal->type;
 s->temporal_id   = nal->temporal_id;
 
+if (FF_HW_HAS_CB(s->avctx, decode_params) &&
+(s->nal_unit_type == HEVC_NAL_VPS ||
+ s->nal_unit_type == HEVC_NAL_SPS ||
+ s->nal_unit_type == HEVC_NAL_PPS ||
+ s->nal_unit_type == HEVC_NAL_SEI_PREFIX ||
+ s->nal_unit_type == HEVC_NAL_SEI_SUFFIX)) {
+ret = FF_HW_CALL(s->avctx, decode_params,
+ nal->type, nal->raw_data, nal->raw_size);
+if (ret < 0)
+goto fail;
+}
+
 switch (s->nal_unit_type) {
 case HEVC_NAL_VPS:
-if (FF_HW_HAS_CB(s->avctx, decode_params)) {
-ret = FF_HW_CALL(s->avctx, decode_params,
- nal->type, nal->raw_data, nal->raw_size);
-if (ret < 0)
-goto fail;
-}
 ret = ff_hevc_decode_nal_vps(, s->avctx, >ps);
 if (ret < 0)
 goto fail;
 break;
 case HEVC_NAL_SPS:
-if (FF_HW_HAS_CB(s->avctx, decode_params)) {
-ret = FF_HW_CALL(s->avctx, decode_params,
- nal->type, nal->raw_data, nal->raw_size);
-if (ret < 0)
-goto fail;
-}
 ret = ff_hevc_decode_nal_sps(, s->avctx, >ps,
  s->apply_defdispwin);
 if (ret < 0)
 goto fail;
 break;
 case HEVC_NAL_PPS:
-if (FF_HW_HAS_CB(s->avctx, decode_params)) {
-ret = FF_HW_CALL(s->avctx, decode_params,
- nal->type, nal->raw_data, nal->raw_size);
-if (ret < 0)
-goto fail;
-}
 ret = ff_hevc_decode_nal_pps(, s->avctx, >ps);
 if (ret < 0)
 goto fail;
 break;
 case HEVC_NAL_SEI_PREFIX:
 case HEVC_NAL_SEI_SUFFIX:
-if (FF_HW_HAS_CB(s->avctx, decode_params)) {
-ret = FF_HW_CALL(s->avctx, decode_params,
- nal->type, nal->raw_data, nal->raw_size);
-if (ret < 0)
-goto fail;
-}
 ret = ff_hevc_decode_nal_sei(, s->avctx, >sei, >ps, 
s->nal_unit_type);
 if (ret < 0)
 goto fail;

___
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] lavc/hevc*: move to hevc/ subdir

2024-06-04 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed May 29 
09:50:48 2024 +0200| [e4601cc3390eec6ccbfc1139bdd102b4e801ae80] | committer: 
Anton Khirnov

lavc/hevc*: move to hevc/ subdir

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

 libavcodec/Makefile| 12 ++--
 libavcodec/aarch64/hevcdsp_init_aarch64.c  |  2 +-
 libavcodec/arm/hevcdsp_arm.h   |  2 +-
 libavcodec/arm/hevcdsp_init_arm.c  |  2 +-
 libavcodec/arm/hevcdsp_init_neon.c |  2 +-
 libavcodec/bsf/extract_extradata.c |  3 +-
 libavcodec/bsf/h265_metadata.c |  3 +-
 libavcodec/bsf/hevc_mp4toannexb.c  |  3 +-
 libavcodec/bsf/remove_extradata.c  |  3 +-
 libavcodec/cbs_h2645.c |  2 +-
 libavcodec/cbs_h265.h  |  3 +-
 libavcodec/d3d12va_hevc.c  |  4 +--
 libavcodec/dxva2_hevc.c|  4 +--
 libavcodec/h2645_parse.c   |  3 +-
 libavcodec/hevc/Makefile   | 36 ++
 libavcodec/{hevc_cabac.c => hevc/cabac.c}  |  2 +-
 libavcodec/{hevc_data.c => hevc/data.c}|  2 +-
 libavcodec/{hevc_data.h => hevc/data.h}|  0
 libavcodec/{hevcdsp.c => hevc/dsp.c}   | 10 +++---
 libavcodec/{hevcdsp.h => hevc/dsp.h}   |  8 ++---
 .../{hevcdsp_template.c => hevc/dsp_template.c}|  2 +-
 libavcodec/{hevc_filter.c => hevc/filter.c}|  0
 libavcodec/{ => hevc}/hevc.h   |  6 ++--
 libavcodec/{ => hevc}/hevcdec.c|  2 +-
 libavcodec/{ => hevc}/hevcdec.h| 33 ++--
 libavcodec/{hevc_mvs.c => hevc/mvs.c}  |  0
 libavcodec/{hevc_parse.c => hevc/parse.c}  |  2 +-
 libavcodec/{hevc_parse.h => hevc/parse.h}  |  4 +--
 libavcodec/{hevc_parser.c => hevc/parser.c}|  6 ++--
 libavcodec/{hevcpred.c => hevc/pred.c} | 10 +++---
 libavcodec/{hevcpred.h => hevc/pred.h} |  6 ++--
 .../{hevcpred_template.c => hevc/pred_template.c}  |  2 +-
 libavcodec/{hevc_ps.c => hevc/ps.c}|  4 +--
 libavcodec/{hevc_ps.h => hevc/ps.h}|  7 +++--
 libavcodec/{hevc_ps_enc.c => hevc/ps_enc.c}|  2 +-
 libavcodec/{hevc_refs.c => hevc/refs.c}|  0
 libavcodec/{hevc_sei.c => hevc/sei.c}  |  4 +--
 libavcodec/{hevc_sei.h => hevc/sei.h}  |  7 +++--
 libavcodec/loongarch/hevcdsp_lasx.h|  2 +-
 libavcodec/loongarch/hevcdsp_lsx.h |  2 +-
 libavcodec/mediacodecdec.c |  2 +-
 libavcodec/mips/hevcdsp_mips.h |  2 +-
 libavcodec/mips/hevcdsp_mmi.c  |  2 +-
 libavcodec/mips/hevcpred_mips.h|  2 +-
 libavcodec/mips/hevcpred_msa.c |  2 +-
 libavcodec/nvdec_hevc.c|  4 +--
 libavcodec/nvenc.c |  2 +-
 libavcodec/ppc/hevcdsp.c   |  2 +-
 libavcodec/qsvenc_hevc.c   |  5 +--
 libavcodec/vaapi_encode_h265.c |  3 +-
 libavcodec/vaapi_hevc.c|  3 +-
 libavcodec/vdpau_hevc.c|  4 +--
 libavcodec/videotoolbox.c  |  2 +-
 libavcodec/vulkan_hevc.c   |  6 ++--
 libavcodec/x86/hevcdsp_init.c  |  2 +-
 libavformat/hevc.c |  2 +-
 libavformat/hevcdec.c  |  2 +-
 libavformat/mov.c  |  2 +-
 libavformat/mpegtsenc.c|  2 +-
 tests/checkasm/hevc_add_res.c  |  2 +-
 tests/checkasm/hevc_deblock.c  |  2 +-
 tests/checkasm/hevc_idct.c |  2 +-
 tests/checkasm/hevc_pel.c  |  2 +-
 tests/checkasm/hevc_sao.c  |  2 +-
 64 files changed, 154 insertions(+), 114 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 2443d2c6fd..8ab4398b6c 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -65,6 +65,7 @@ OBJS = ac3_parser.o   
  \
 
 # subsystems
 include $(SRC_PATH)/libavcodec/aac/Makefile
+include $(SRC_PATH)/libavcodec/hevc/Makefile
 include $(SRC_PATH)/libavcodec/vvc/Makefile
 -include $(SRC_PATH)/libavcodec/$(ARCH)/vvc/Makefile
 OBJS-$(CONFIG_AANDCTTABLES)+= aandcttab.o
@@ -105,10 +106,6 @@ OBJS-$(CONFIG_H264PARSE)   += h264_parse.o 
h264_ps.o h264data.o \
 OBJS-$(CONFIG_H264PRED)+= h264pred.o
 OBJS

[FFmpeg-cvslog] lavc/hevcdec: drop HEVCLocalContext.gb

2024-06-04 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Tue May 28 
18:43:13 2024 +0200| [67ca18dd56956892a097388a160bb70f10539d77] | committer: 
Anton Khirnov

lavc/hevcdec: drop HEVCLocalContext.gb

In all HEVCLocalContext instances except the first one, the bitreader is
never used for actually reading bits, but merely for passing the buffer
to ff_init_cabac_decoder(), which is better done directly.

The instance that actually is used for bitreading gets moved to stack in
decode_nal_unit(), which makes its lifetime clearer.

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

 libavcodec/hevc_cabac.c | 17 +
 libavcodec/hevcdec.c| 43 ---
 libavcodec/hevcdec.h|  4 ++--
 3 files changed, 27 insertions(+), 37 deletions(-)

diff --git a/libavcodec/hevc_cabac.c b/libavcodec/hevc_cabac.c
index 3f95c9ca05..71bd678972 100644
--- a/libavcodec/hevc_cabac.c
+++ b/libavcodec/hevc_cabac.c
@@ -427,14 +427,6 @@ static int cabac_reinit(HEVCLocalContext *lc)
 return skip_bytes(>cc, 0) == NULL ? AVERROR_INVALIDDATA : 0;
 }
 
-static int cabac_init_decoder(HEVCLocalContext *lc)
-{
-GetBitContext *gb = >gb;
-return ff_init_cabac_decoder(>cc,
-  gb->buffer + get_bits_count(gb) / 8,
-  (get_bits_left(gb) + 7) / 8);
-}
-
 static void cabac_init_state(HEVCLocalContext *lc, const HEVCContext *s)
 {
 int init_type = 2 - s->sh.slice_type;
@@ -459,12 +451,13 @@ static void cabac_init_state(HEVCLocalContext *lc, const 
HEVCContext *s)
 lc->stat_coeff[i] = 0;
 }
 
-int ff_hevc_cabac_init(HEVCLocalContext *lc, int ctb_addr_ts)
+int ff_hevc_cabac_init(HEVCLocalContext *lc, int ctb_addr_ts,
+   const uint8_t *data, size_t size)
 {
 const HEVCContext *const s = lc->parent;
 
 if (ctb_addr_ts == s->ps.pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]) {
-int ret = cabac_init_decoder(lc);
+int ret = ff_init_cabac_decoder(>cc, data, size);
 if (ret < 0)
 return ret;
 if (s->sh.dependent_slice_segment_flag == 0 ||
@@ -488,7 +481,7 @@ int ff_hevc_cabac_init(HEVCLocalContext *lc, int 
ctb_addr_ts)
 if (s->threads_number == 1)
 ret = cabac_reinit(lc);
 else {
-ret = cabac_init_decoder(lc);
+ret = ff_init_cabac_decoder(>cc, data, size);
 }
 if (ret < 0)
 return ret;
@@ -501,7 +494,7 @@ int ff_hevc_cabac_init(HEVCLocalContext *lc, int 
ctb_addr_ts)
 if (s->threads_number == 1)
 ret = cabac_reinit(lc);
 else {
-ret = cabac_init_decoder(lc);
+ret = ff_init_cabac_decoder(>cc, data, size);
 }
 if (ret < 0)
 return ret;
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 42fd33961b..0a9443505a 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -593,9 +593,8 @@ fail:
 return ret;
 }
 
-static int hls_slice_header(HEVCContext *s)
+static int hls_slice_header(HEVCContext *s, GetBitContext *gb)
 {
-GetBitContext *gb = >HEVClc->gb;
 SliceHeader *sh   = >sh;
 int i, ret;
 
@@ -2533,9 +2532,11 @@ static void hls_decode_neighbour(HEVCLocalContext *lc, 
int x_ctb, int y_ctb,
 lc->ctb_up_left_flag = ((x_ctb > 0) && (y_ctb > 0)  && 
(ctb_addr_in_slice-1 >= s->ps.sps->ctb_width) && 
(s->ps.pps->tile_id[ctb_addr_ts] == 
s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs-1 - 
s->ps.sps->ctb_width]]));
 }
 
-static int hls_decode_entry(HEVCContext *s)
+static int hls_decode_entry(HEVCContext *s, GetBitContext *gb)
 {
 HEVCLocalContext *const lc = s->HEVClc;
+const uint8_t *slice_data = gb->buffer + s->sh.data_offset;
+const size_t   slice_size = gb->buffer_end - gb->buffer - 
s->sh.data_offset;
 int ctb_size= 1 << s->ps.sps->log2_ctb_size;
 int more_data   = 1;
 int x_ctb   = 0;
@@ -2563,7 +2564,7 @@ static int hls_decode_entry(HEVCContext *s)
 y_ctb = (ctb_addr_rs / ((s->ps.sps->width + ctb_size - 1) >> 
s->ps.sps->log2_ctb_size)) << s->ps.sps->log2_ctb_size;
 hls_decode_neighbour(lc, x_ctb, y_ctb, ctb_addr_ts);
 
-ret = ff_hevc_cabac_init(lc, ctb_addr_ts);
+ret = ff_hevc_cabac_init(lc, ctb_addr_ts, slice_data, slice_size);
 if (ret < 0) {
 s->tab_slice_address[ctb_addr_rs] = -1;
 return ret;
@@ -2605,14 +2606,14 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, 
void *hevc_lclist,
 int ctb_addr_rs = s->sh.slice_ctb_addr_rs + ctb_row * ((s->ps.sps->width + 
ctb_size - 1) >> s->ps.sps->log2_ct

[FFmpeg-cvslog] lavc/hevcdec: include first row in SliceHeader.offset/size

2024-06-04 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Tue May 28 
18:40:22 2024 +0200| [ac69e6caf6d9b74a215c7fc170574e7bcc4f9fda] | committer: 
Anton Khirnov

lavc/hevcdec: include first row in SliceHeader.offset/size

Will be useful in the following commit.

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

 libavcodec/hevcdec.c | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index d3715f9de7..42fd33961b 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -975,8 +975,8 @@ static int hls_slice_header(HEVCContext *s)
 av_freep(>offset);
 av_freep(>size);
 sh->entry_point_offset = 
av_malloc_array(sh->num_entry_point_offsets, sizeof(unsigned));
-sh->offset = av_malloc_array(sh->num_entry_point_offsets, 
sizeof(int));
-sh->size = av_malloc_array(sh->num_entry_point_offsets, 
sizeof(int));
+sh->offset = 
av_malloc_array(sh->num_entry_point_offsets + 1, sizeof(int));
+sh->size   = 
av_malloc_array(sh->num_entry_point_offsets + 1, sizeof(int));
 if (!sh->entry_point_offset || !sh->offset || !sh->size) {
 sh->num_entry_point_offsets = 0;
 av_log(s->avctx, AV_LOG_ERROR, "Failed to allocate memory\n");
@@ -2608,10 +2608,10 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, 
void *hevc_lclist,
 int ret;
 
 if(ctb_row) {
-ret = init_get_bits8(>gb, s->data + s->sh.offset[ctb_row - 1], 
s->sh.size[ctb_row - 1]);
+ret = init_get_bits8(>gb, s->data + s->sh.offset[ctb_row], 
s->sh.size[ctb_row]);
 if (ret < 0)
 goto error;
-ff_init_cabac_decoder(>cc, s->data + s->sh.offset[(ctb_row)-1], 
s->sh.size[ctb_row - 1]);
+ff_init_cabac_decoder(>cc, s->data + s->sh.offset[ctb_row], 
s->sh.size[ctb_row]);
 }
 
 while(more_data && ctb_addr_ts < s->ps.sps->ctb_size) {
@@ -2738,8 +2738,8 @@ static int hls_slice_data_wpp(HEVCContext *s, const 
H2645NAL *nal)
 cmpt++;
 }
 }
-s->sh.size[i - 1] = s->sh.entry_point_offset[i] - cmpt;
-s->sh.offset[i - 1] = offset;
+s->sh.size[i]   = s->sh.entry_point_offset[i] - cmpt;
+s->sh.offset[i] = offset;
 
 }
 
@@ -2748,8 +2748,11 @@ static int hls_slice_data_wpp(HEVCContext *s, const 
H2645NAL *nal)
 av_log(s->avctx, AV_LOG_ERROR, "entry_point_offset table is 
corrupted\n");
 return AVERROR_INVALIDDATA;
 }
-s->sh.size[s->sh.num_entry_point_offsets - 1] = length - offset;
-s->sh.offset[s->sh.num_entry_point_offsets - 1] = offset;
+s->sh.size  [s->sh.num_entry_point_offsets] = length - offset;
+s->sh.offset[s->sh.num_entry_point_offsets] = offset;
+
+s->sh.offset[0] = s->sh.data_offset;
+s->sh.size[0]   = s->sh.offset[1] - s->sh.offset[0];
 
 s->data = data;
 

___
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] lavc/hevcdec: drop a useless condition

2024-06-04 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Tue May 28 
18:33:54 2024 +0200| [79c0310acaf3b638cea2258b5b18b575668f250c] | committer: 
Anton Khirnov

lavc/hevcdec: drop a useless condition

hls_slice_data_wpp() is only called when num_entry_point_offsets>0

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

 libavcodec/hevcdec.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index ad2cbd7ece..d3715f9de7 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2742,16 +2742,15 @@ static int hls_slice_data_wpp(HEVCContext *s, const 
H2645NAL *nal)
 s->sh.offset[i - 1] = offset;
 
 }
-if (s->sh.num_entry_point_offsets != 0) {
-offset += s->sh.entry_point_offset[s->sh.num_entry_point_offsets - 1] 
- cmpt;
-if (length < offset) {
-av_log(s->avctx, AV_LOG_ERROR, "entry_point_offset table is 
corrupted\n");
-return AVERROR_INVALIDDATA;
-}
-s->sh.size[s->sh.num_entry_point_offsets - 1] = length - offset;
-s->sh.offset[s->sh.num_entry_point_offsets - 1] = offset;
 
+offset += s->sh.entry_point_offset[s->sh.num_entry_point_offsets - 1] - 
cmpt;
+if (length < offset) {
+av_log(s->avctx, AV_LOG_ERROR, "entry_point_offset table is 
corrupted\n");
+return AVERROR_INVALIDDATA;
 }
+s->sh.size[s->sh.num_entry_point_offsets - 1] = length - offset;
+s->sh.offset[s->sh.num_entry_point_offsets - 1] = offset;
+
 s->data = data;
 
 for (i = 1; i < s->threads_number; i++) {

___
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] lavc/hevcdec: move handling of byte alignment at the end of slice header

2024-06-04 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Tue May 28 
16:59:23 2024 +0200| [74159cbfc30a0202b3c3d6f770143d0e1c30fa5a] | committer: 
Anton Khirnov

lavc/hevcdec: move handling of byte alignment at the end of slice header

Do it in hls_slice_header() rather than cabac_init_decoder() - the
former is a more logical place as according the spec the byte alignment
is a part of the slice header, not slice data. Avoids a second instance
of alignment handling in vaapi_hevc.

Also, check that alignment_bit_equal_to_one is, in fact, equal to one.

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

 libavcodec/hevc_cabac.c | 2 --
 libavcodec/hevcdec.c| 7 +++
 libavcodec/hevcdec.h| 1 +
 libavcodec/vaapi_hevc.c | 4 +---
 4 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/libavcodec/hevc_cabac.c b/libavcodec/hevc_cabac.c
index 2e639a7e41..3f95c9ca05 100644
--- a/libavcodec/hevc_cabac.c
+++ b/libavcodec/hevc_cabac.c
@@ -430,8 +430,6 @@ static int cabac_reinit(HEVCLocalContext *lc)
 static int cabac_init_decoder(HEVCLocalContext *lc)
 {
 GetBitContext *gb = >gb;
-skip_bits(gb, 1);
-align_get_bits(gb);
 return ff_init_cabac_decoder(>cc,
   gb->buffer + get_bits_count(gb) / 8,
   (get_bits_left(gb) + 7) / 8);
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index ff9a418926..ad2cbd7ece 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -1005,6 +1005,13 @@ static int hls_slice_header(HEVCContext *s)
 skip_bits(gb, 8);  // slice_header_extension_data_byte
 }
 
+ret = get_bits1(gb);
+if (!ret) {
+av_log(s->avctx, AV_LOG_ERROR, "alignment_bit_equal_to_one=0\n");
+return AVERROR_INVALIDDATA;
+}
+sh->data_offset = align_get_bits(gb) - gb->buffer;
+
 // Inferred parameters
 sh->slice_qp = 26U + s->ps.pps->pic_init_qp_minus26 + sh->slice_qp_delta;
 if (sh->slice_qp > 51 ||
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index 5aa3d40450..3824bf621b 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -277,6 +277,7 @@ typedef struct SliceHeader {
 int16_t chroma_offset_l1[16][2];
 
 int slice_ctb_addr_rs;
+unsigned data_offset;
 } SliceHeader;
 
 typedef struct CodingUnit {
diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index 0f5dd50351..f0a0f295d9 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -485,9 +485,7 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
 .slice_data_size   = size,
 .slice_data_offset = 0,
 .slice_data_flag   = VA_SLICE_DATA_FLAG_ALL,
-/* Add 1 to the bits count here to account for the byte_alignment bit, 
which
- * always is at least one bit and not accounted for otherwise. */
-.slice_data_byte_offset= (get_bits_count(>HEVClc->gb) + 1 + 
7) / 8,
+.slice_data_byte_offset= sh->data_offset,
 .slice_segment_address = sh->slice_segment_addr,
 .slice_qp_delta= sh->slice_qp_delta,
 .slice_cb_qp_offset= sh->slice_cb_qp_offset,

___
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] lavc/hevc_ps: fix variable signedness in ff_hevc_decode_short_term_rps()

2024-05-31 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed Apr 10 
13:36:50 2024 +0200| [4264e4056c41e0dfc01a27d95f600ac91fb5a04f] | committer: 
Anton Khirnov

lavc/hevc_ps: fix variable signedness in ff_hevc_decode_short_term_rps()

It is actually supposed to go negative in the loop over num_negative
pics, but underflow does not break anything as the result is then
assigned to a signed int.

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

 libavcodec/hevc_ps.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 1af691414e..d90f172c46 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -197,7 +197,8 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, 
AVCodecContext *avctx,
 }
 }
 } else {
-unsigned int prev, nb_positive_pics;
+unsigned int nb_positive_pics;
+
 rps->num_negative_pics = get_ue_golomb_long(gb);
 nb_positive_pics   = get_ue_golomb_long(gb);
 
@@ -209,7 +210,8 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, 
AVCodecContext *avctx,
 
 rps->num_delta_pocs = rps->num_negative_pics + nb_positive_pics;
 if (rps->num_delta_pocs) {
-prev = 0;
+int prev = 0;
+
 for (i = 0; i < rps->num_negative_pics; i++) {
 delta_poc = rps->delta_poc_s0[i] = get_ue_golomb_long(gb) + 1;
 if (delta_poc < 1 || delta_poc > 32768) {

___
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] lavc/hevc_ps: reduce the size of ShortTermRPS.used

2024-05-31 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed Apr 10 
11:27:51 2024 +0200| [9127819d514a3a82031f7448b40714f2880d7804] | committer: 
Anton Khirnov

lavc/hevc_ps: reduce the size of ShortTermRPS.used

It is currently an array of 32 uint8_t, each storing a single flag. A
single uint32_t is sufficient.

Reduces sizeof(HEVCSPS) by 1792 bytes.

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

 libavcodec/hevc_ps.c | 33 +++--
 libavcodec/hevc_ps.h |  2 +-
 libavcodec/hevc_refs.c   |  6 +++---
 libavcodec/vulkan_hevc.c | 13 +
 4 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index a6b0021bc3..76fe507e7b 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -107,6 +107,7 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, 
AVCodecContext *avctx,
 int k  = 0;
 int i;
 
+rps->used= 0;
 rps->rps_predict = 0;
 
 if (rps != sps->st_rps && sps->nb_st_rps)
@@ -114,6 +115,7 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, 
AVCodecContext *avctx,
 
 if (rps->rps_predict) {
 const ShortTermRPS *rps_ridx;
+uint8_t used[32] = { 0 };
 int delta_rps;
 
 if (is_slice_header) {
@@ -139,13 +141,13 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, 
AVCodecContext *avctx,
 }
 delta_rps  = (1 - (rps->delta_rps_sign << 1)) * rps->abs_delta_rps;
 for (i = 0; i <= rps_ridx->num_delta_pocs; i++) {
-int used = rps->used[k] = get_bits1(gb);
+used[k] = get_bits1(gb);
 
 rps->use_delta_flag = 0;
-if (!used)
+if (!used[k])
 rps->use_delta_flag = get_bits1(gb);
 
-if (used || rps->use_delta_flag) {
+if (used[k] || rps->use_delta_flag) {
 if (i < rps_ridx->num_delta_pocs)
 delta_poc = delta_rps + rps_ridx->delta_poc[i];
 else
@@ -157,7 +159,7 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, 
AVCodecContext *avctx,
 }
 }
 
-if (k >= FF_ARRAY_ELEMS(rps->used)) {
+if (k >= FF_ARRAY_ELEMS(used)) {
 av_log(avctx, AV_LOG_ERROR,
"Invalid num_delta_pocs: %d\n", k);
 return AVERROR_INVALIDDATA;
@@ -167,35 +169,38 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, 
AVCodecContext *avctx,
 rps->num_negative_pics = k0;
 // sort in increasing order (smallest first)
 if (rps->num_delta_pocs != 0) {
-int used, tmp;
+int u, tmp;
 for (i = 1; i < rps->num_delta_pocs; i++) {
 delta_poc = rps->delta_poc[i];
-used  = rps->used[i];
+u = used[i];
 for (k = i - 1; k >= 0; k--) {
 tmp = rps->delta_poc[k];
 if (delta_poc < tmp) {
 rps->delta_poc[k + 1] = tmp;
-rps->used[k + 1]  = rps->used[k];
+used[k + 1]   = used[k];
 rps->delta_poc[k] = delta_poc;
-rps->used[k]  = used;
+used[k]   = u;
 }
 }
 }
 }
 if ((rps->num_negative_pics >> 1) != 0) {
-int used;
+int u;
 k = rps->num_negative_pics - 1;
 // flip the negative values to largest first
 for (i = 0; i < rps->num_negative_pics >> 1; i++) {
 delta_poc = rps->delta_poc[i];
-used  = rps->used[i];
+u = used[i];
 rps->delta_poc[i] = rps->delta_poc[k];
-rps->used[i]  = rps->used[k];
+used[i]   = used[k];
 rps->delta_poc[k] = delta_poc;
-rps->used[k]  = used;
+used[k]   = u;
 k--;
 }
 }
+
+for (unsigned i = 0; i < FF_ARRAY_ELEMS(used); i++)
+rps->used |= used[i] * (1 << i);
 } else {
 unsigned int nb_positive_pics;
 
@@ -222,7 +227,7 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, 
AVCodecContext *avctx,
 }
 prev -= delta_poc;
 rps->delta_poc[i] = prev;
-rps->used[i]  = get_bits1(gb);
+rps->used|= get_bits1(gb) * (1 << i);
 }
 prev = 0;
 for (i = 0; i < nb_positive_pics; i++) {
@@ -235,7 +240,7 @@ int ff_hevc_decode_shor

[FFmpeg-cvslog] lavc/hevc_ps/HEVCSPS: change flags into uint8_t

2024-05-31 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed Apr 10 
12:28:09 2024 +0200| [6fed1841a1f5dd3cdcf343f77925af0781ebe83a] | committer: 
Anton Khirnov

lavc/hevc_ps/HEVCSPS: change flags into uint8_t

Reduces sizeof(HEVCSPS) by 64 bytes.

Also improve flag names: drop redundant suffixes and prefixes, and
consistently use disabled/enabled.

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

 libavcodec/dxva2_hevc.c| 24 +--
 libavcodec/hevc_cabac.c| 36 
 libavcodec/hevc_filter.c   |  8 ++--
 libavcodec/hevc_parser.c   |  2 +-
 libavcodec/hevc_ps.c   | 95 +-
 libavcodec/hevc_ps.h   | 66 ++---
 libavcodec/hevcdec.c   | 10 ++---
 libavcodec/hevcpred_template.c |  4 +-
 libavcodec/mips/hevcpred_msa.c |  6 +--
 libavcodec/nvdec_hevc.c| 42 +--
 libavcodec/qsvenc_hevc.c   |  2 +-
 libavcodec/vaapi_hevc.c| 42 +--
 libavcodec/vdpau_hevc.c| 36 
 libavcodec/vulkan_hevc.c   | 56 -
 14 files changed, 214 insertions(+), 215 deletions(-)

diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c
index 31d74a7164..b500d7917a 100644
--- a/libavcodec/dxva2_hevc.c
+++ b/libavcodec/dxva2_hevc.c
@@ -72,7 +72,7 @@ void ff_dxva2_hevc_fill_picture_parameters(const 
AVCodecContext *avctx, AVDXVACo
 pp->PicHeightInMinCbsY = sps->min_cb_height;
 
 pp->wFormatAndSequenceInfoFlags = (sps->chroma_format_idc <<  
0) |
-  (sps->separate_colour_plane_flag<<  
2) |
+  (sps->separate_colour_plane <<  
2) |
   ((sps->bit_depth - 8)   <<  
3) |
   ((sps->bit_depth - 8)   <<  
6) |
   ((sps->log2_max_poc_lsb - 4)<<  
9) |
@@ -99,18 +99,18 @@ void ff_dxva2_hevc_fill_picture_parameters(const 
AVCodecContext *avctx, AVDXVACo
 pp->wNumBitsForShortTermRPSInSlice   = 
h->sh.short_term_ref_pic_set_size;
 }
 
-pp->dwCodingParamToolFlags = (sps->scaling_list_enable_flag
  <<  0) |
- (sps->amp_enabled_flag
  <<  1) |
+pp->dwCodingParamToolFlags = (sps->scaling_list_enabled
  <<  0) |
+ (sps->amp_enabled 
  <<  1) |
  (sps->sao_enabled 
  <<  2) |
- (sps->pcm_enabled_flag
  <<  3) |
- ((sps->pcm_enabled_flag ? (sps->pcm.bit_depth 
- 1) : 0)<<  4) |
- ((sps->pcm_enabled_flag ? 
(sps->pcm.bit_depth_chroma - 1) : 0) <<  8) |
- ((sps->pcm_enabled_flag ? 
(sps->pcm.log2_min_pcm_cb_size - 3) : 0) << 12) |
- ((sps->pcm_enabled_flag ? 
(sps->pcm.log2_max_pcm_cb_size - sps->pcm.log2_min_pcm_cb_size) : 0) << 14) |
- (sps->pcm.loop_filter_disable_flag
  << 16) |
- (sps->long_term_ref_pics_present_flag 
  << 17) |
- (sps->sps_temporal_mvp_enabled_flag   
  << 18) |
- (sps->sps_strong_intra_smoothing_enable_flag  
  << 19) |
+ (sps->pcm_enabled 
  <<  3) |
+ ((sps->pcm_enabled  ? (sps->pcm.bit_depth 
- 1) : 0)<<  4) |
+ ((sps->pcm_enabled  ? 
(sps->pcm.bit_depth_chroma - 1) : 0) <<  8) |
+ ((sps->pcm_enabled  ? 
(sps->pcm.log2_min_pcm_cb_size - 3) : 0) << 12) |
+ ((sps->pcm_enabled  ? 
(sps->pcm.log2_max_pcm_cb_size - sps->pcm.log2_min_pcm_cb_size) : 0) << 14) |
+ (sps->pcm_loop_filter_disabled
  << 16) |
+ (sps->long_term_ref_pics_present  
  << 17) |
+ (sps->temporal_mvp_enabled
  << 18) |
+ (sps->strong_intra_smoothing_enabled  
  << 19) |
  (pps->dependent_slice_segments_enabled_flag   
  << 20) |
 

[FFmpeg-cvslog] lavc/hevc_ps: do not store delta_poc_s[01] in ShortTermRPS

2024-05-31 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed Apr 10 
13:46:20 2024 +0200| [d8936678673d05410b3462c41dba190cc5e23705] | committer: 
Anton Khirnov

lavc/hevc_ps: do not store delta_poc_s[01] in ShortTermRPS

They are only used in vulkan_hevc and are not actually needed, as they
can be computed from delta_poc.

Reduces sizeof(HEVCSPS) by 16kB.

Also, fix a typo (s0->s1) in the code being touched.

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

 libavcodec/hevc_ps.c | 4 ++--
 libavcodec/hevc_ps.h | 2 --
 libavcodec/vulkan_hevc.c | 9 ++---
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index d90f172c46..a6b0021bc3 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -213,7 +213,7 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, 
AVCodecContext *avctx,
 int prev = 0;
 
 for (i = 0; i < rps->num_negative_pics; i++) {
-delta_poc = rps->delta_poc_s0[i] = get_ue_golomb_long(gb) + 1;
+delta_poc = get_ue_golomb_long(gb) + 1;
 if (delta_poc < 1 || delta_poc > 32768) {
 av_log(avctx, AV_LOG_ERROR,
 "Invalid value of delta_poc: %d\n",
@@ -226,7 +226,7 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, 
AVCodecContext *avctx,
 }
 prev = 0;
 for (i = 0; i < nb_positive_pics; i++) {
-delta_poc = rps->delta_poc_s1[i] = get_ue_golomb_long(gb) + 1;
+delta_poc = get_ue_golomb_long(gb) + 1;
 if (delta_poc < 1 || delta_poc > 32768) {
 av_log(avctx, AV_LOG_ERROR,
 "Invalid value of delta_poc: %d\n",
diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
index 3cd2eac923..1d3bdca4c6 100644
--- a/libavcodec/hevc_ps.h
+++ b/libavcodec/hevc_ps.h
@@ -78,8 +78,6 @@ typedef struct ShortTermRPS {
 unsigned int num_negative_pics;
 int num_delta_pocs;
 int rps_idx_num_delta_pocs;
-int32_t delta_poc_s0[32];
-int32_t delta_poc_s1[32];
 int32_t delta_poc[32];
 uint8_t used[32];
 } ShortTermRPS;
diff --git a/libavcodec/vulkan_hevc.c b/libavcodec/vulkan_hevc.c
index df86049d22..21cf49c0ec 100644
--- a/libavcodec/vulkan_hevc.c
+++ b/libavcodec/vulkan_hevc.c
@@ -351,6 +351,8 @@ static void set_sps(const HEVCSPS *sps, int sps_idx,
 pal->PredictorPaletteEntries[i][j] = 
sps->sps_palette_predictor_initializer[i][j];
 
 for (int i = 0; i < sps->nb_st_rps; i++) {
+const ShortTermRPS *st_rps = >st_rps[i];
+
 str[i] = (StdVideoH265ShortTermRefPicSet) {
 .flags = (StdVideoH265ShortTermRefPicSetFlags) {
 .inter_ref_pic_set_prediction_flag = 
sps->st_rps[i].rps_predict,
@@ -375,13 +377,14 @@ static void set_sps(const HEVCSPS *sps, int sps_idx,
 str[i].used_by_curr_pic_flag |= sps->st_rps[i].used[j] << j;
 
 for (int j = 0; j < str[i].num_negative_pics; j++) {
-str[i].delta_poc_s0_minus1[j] = sps->st_rps[i].delta_poc_s0[j] - 1;
+str[i].delta_poc_s0_minus1[j] = st_rps->delta_poc[j] - (j ? 
st_rps->delta_poc[j - 1] : 0) - 1;
 str[i].used_by_curr_pic_s0_flag |= sps->st_rps[i].used[j] << j;
 }
 
 for (int j = 0; j < str[i].num_positive_pics; j++) {
-str[i].delta_poc_s1_minus1[j] = sps->st_rps[i].delta_poc_s1[j] - 1;
-str[i].used_by_curr_pic_s0_flag |= 
sps->st_rps[i].used[str[i].num_negative_pics + j] << j;
+str[i].delta_poc_s1_minus1[j] = 
st_rps->delta_poc[st_rps->num_negative_pics + j] -
+(j ? 
st_rps->delta_poc[st_rps->num_negative_pics + j - 1] : 0) - 1;
+str[i].used_by_curr_pic_s1_flag |= 
sps->st_rps[i].used[str[i].num_negative_pics + j] << j;
 }
 }
 

___
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] lavc/hevc_ps: compactify ShortTermRPS

2024-05-31 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed Apr 10 
14:42:37 2024 +0200| [63a96dbcced2a67e96ee7306874dd2574e2d7d74] | committer: 
Anton Khirnov

lavc/hevc_ps: compactify ShortTermRPS

Do not use larger fields than needed, use size-1 bitfields for flags.

Reduces sizeof(HEVCSPS) by 1280 bytes.

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

 libavcodec/hevc_ps.c |  6 +++---
 libavcodec/hevc_ps.h | 19 +++
 libavcodec/vulkan_hevc.c |  2 +-
 3 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 76fe507e7b..7b486ce0af 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -143,11 +143,11 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, 
AVCodecContext *avctx,
 for (i = 0; i <= rps_ridx->num_delta_pocs; i++) {
 used[k] = get_bits1(gb);
 
-rps->use_delta_flag = 0;
+rps->use_delta = 0;
 if (!used[k])
-rps->use_delta_flag = get_bits1(gb);
+rps->use_delta = get_bits1(gb);
 
-if (used[k] || rps->use_delta_flag) {
+if (used[k] || rps->use_delta) {
 if (i < rps_ridx->num_delta_pocs)
 delta_poc = delta_rps + rps_ridx->delta_poc[i];
 else
diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
index ed6372c747..d06d7cf1d4 100644
--- a/libavcodec/hevc_ps.h
+++ b/libavcodec/hevc_ps.h
@@ -70,16 +70,19 @@ typedef struct HEVCHdrParams {
 } HEVCHdrParams;
 
 typedef struct ShortTermRPS {
-uint8_t rps_predict;
-unsigned int delta_idx;
-uint8_t use_delta_flag;
-uint8_t delta_rps_sign;
-unsigned int abs_delta_rps;
-unsigned int num_negative_pics;
-int num_delta_pocs;
-int rps_idx_num_delta_pocs;
 int32_t delta_poc[32];
 uint32_t used;
+
+uint8_t delta_idx;
+uint8_t num_negative_pics;
+uint8_t num_delta_pocs;
+uint8_t rps_idx_num_delta_pocs;
+
+uint16_t abs_delta_rps;
+unsigned delta_rps_sign:1;
+
+unsigned rps_predict:1;
+unsigned use_delta:1;
 } ShortTermRPS;
 
 typedef struct HEVCWindow {
diff --git a/libavcodec/vulkan_hevc.c b/libavcodec/vulkan_hevc.c
index a35f3d992d..5583f56285 100644
--- a/libavcodec/vulkan_hevc.c
+++ b/libavcodec/vulkan_hevc.c
@@ -359,7 +359,7 @@ static void set_sps(const HEVCSPS *sps, int sps_idx,
 .delta_rps_sign = sps->st_rps[i].delta_rps_sign,
 },
 .delta_idx_minus1 = sps->st_rps[i].delta_idx - 1,
-.use_delta_flag = sps->st_rps[i].use_delta_flag,
+.use_delta_flag = sps->st_rps[i].use_delta,
 .abs_delta_rps_minus1 = sps->st_rps[i].abs_delta_rps - 1,
 .used_by_curr_pic_flag= 0x0,
 .used_by_curr_pic_s0_flag = 0x0,

___
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] lavc/hevc_ps: reduce the size of used_by_curr_pic_lt_sps_flag

2024-05-31 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed Apr 10 
11:27:51 2024 +0200| [bd1a06dc439403d7e16a220629165e34791016d7] | committer: 
Anton Khirnov

lavc/hevc_ps: reduce the size of used_by_curr_pic_lt_sps_flag

It is currently an array of 32 uint8_t, each storing a single flag. A
single uint32_t is sufficient.

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

 libavcodec/hevc_ps.c | 4 +++-
 libavcodec/hevc_ps.h | 2 +-
 libavcodec/hevcdec.c | 2 +-
 libavcodec/vulkan_hevc.c | 3 +--
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 25f087ed75..8d5fc0d0ca 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -1094,9 +1094,11 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, 
unsigned int *sps_id,
sps->num_long_term_ref_pics_sps);
 return AVERROR_INVALIDDATA;
 }
+
+sps->used_by_curr_pic_lt = 0;
 for (i = 0; i < sps->num_long_term_ref_pics_sps; i++) {
 sps->lt_ref_pic_poc_lsb_sps[i]   = get_bits(gb, 
sps->log2_max_poc_lsb);
-sps->used_by_curr_pic_lt_sps_flag[i] = get_bits1(gb);
+sps->used_by_curr_pic_lt|= get_bits1(gb) * (1 << i);
 }
 }
 
diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
index 61a0fe2219..b2f3a8dbd1 100644
--- a/libavcodec/hevc_ps.h
+++ b/libavcodec/hevc_ps.h
@@ -230,7 +230,7 @@ typedef struct HEVCSPS {
 
 uint8_t long_term_ref_pics_present_flag;
 uint16_t lt_ref_pic_poc_lsb_sps[HEVC_MAX_LONG_TERM_REF_PICS];
-uint8_t used_by_curr_pic_lt_sps_flag[HEVC_MAX_LONG_TERM_REF_PICS];
+uint32_t used_by_curr_pic_lt;
 uint8_t num_long_term_ref_pics_sps;
 
 struct {
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index b8ab34d710..ef3ed75c8a 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -295,7 +295,7 @@ static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, 
GetBitContext *gb)
 lt_idx_sps = get_bits(gb, 
av_ceil_log2(sps->num_long_term_ref_pics_sps));
 
 rps->poc[i]  = sps->lt_ref_pic_poc_lsb_sps[lt_idx_sps];
-rps->used[i] = sps->used_by_curr_pic_lt_sps_flag[lt_idx_sps];
+rps->used[i] = !!(sps->used_by_curr_pic_lt & (1 << lt_idx_sps));
 } else {
 rps->poc[i]  = get_bits(gb, sps->log2_max_poc_lsb);
 rps->used[i] = get_bits1(gb);
diff --git a/libavcodec/vulkan_hevc.c b/libavcodec/vulkan_hevc.c
index 2705a965b9..9b40f5ad58 100644
--- a/libavcodec/vulkan_hevc.c
+++ b/libavcodec/vulkan_hevc.c
@@ -386,11 +386,10 @@ static void set_sps(const HEVCSPS *sps, int sps_idx,
 }
 
 *ltr = (StdVideoH265LongTermRefPicsSps) {
-.used_by_curr_pic_lt_sps_flag = 0x0,
+.used_by_curr_pic_lt_sps_flag = sps->used_by_curr_pic_lt,
 };
 
 for (int i = 0; i < sps->num_long_term_ref_pics_sps; i++) {
-ltr->used_by_curr_pic_lt_sps_flag |= 
sps->used_by_curr_pic_lt_sps_flag[i] << i;
 ltr->lt_ref_pic_poc_lsb_sps[i] = sps->lt_ref_pic_poc_lsb_sps[i];
 }
 

___
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] lavc/hevcdec: allocate local_ctx as array of structs rather than pointers

2024-05-31 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sun Apr  7 
11:23:48 2024 +0200| [f0aece90d99ce7ceacc8ef947d01cfdeedae1d6c] | committer: 
Anton Khirnov

lavc/hevcdec: allocate local_ctx as array of structs rather than pointers

It is more efficient and easier to manage.

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

 libavcodec/hevcdec.c | 55 +---
 libavcodec/hevcdec.h |  6 +-
 2 files changed, 36 insertions(+), 25 deletions(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index e84f45e3f8..88a481c043 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2598,7 +2598,7 @@ static int hls_slice_data(HEVCContext *s)
 static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist,
 int job, int self_id)
 {
-HEVCLocalContext *lc = ((HEVCLocalContext**)hevc_lclist)[self_id];
+HEVCLocalContext *lc = &((HEVCLocalContext*)hevc_lclist)[self_id];
 const HEVCContext *const s = lc->parent;
 int ctb_size= 1 << s->ps.sps->log2_ctb_size;
 int more_data   = 1;
@@ -2682,7 +2682,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const 
H2645NAL *nal)
 {
 const uint8_t *data = nal->data;
 int length  = nal->size;
-HEVCLocalContext *lc = s->HEVClc;
+HEVCLocalContext *lc;
 int *ret;
 int64_t offset;
 int64_t startheader, cmpt = 0;
@@ -2696,19 +2696,31 @@ static int hls_slice_data_wpp(HEVCContext *s, const 
H2645NAL *nal)
 return AVERROR_INVALIDDATA;
 }
 
-for (i = 1; i < s->threads_number; i++) {
-if (i < s->nb_local_ctx)
-continue;
-s->local_ctx[i] = av_mallocz(sizeof(HEVCLocalContext));
-if (!s->local_ctx[i])
+if (s->threads_number > s->nb_local_ctx) {
+HEVCLocalContext *tmp = av_malloc_array(s->threads_number, 
sizeof(*s->local_ctx));
+
+if (!tmp)
 return AVERROR(ENOMEM);
-s->nb_local_ctx++;
 
-s->local_ctx[i]->logctx = s->avctx;
-s->local_ctx[i]->parent = s;
-s->local_ctx[i]->common_cabac_state = >cabac;
+memcpy(tmp, s->local_ctx, sizeof(*s->local_ctx) * s->nb_local_ctx);
+av_free(s->local_ctx);
+s->local_ctx = tmp;
+s->HEVClc= >local_ctx[0];
+
+for (unsigned i = s->nb_local_ctx; i < s->threads_number; i++) {
+tmp = >local_ctx[i];
+
+memset(tmp, 0, sizeof(*tmp));
+
+tmp->logctx = s->avctx;
+tmp->parent = s;
+tmp->common_cabac_state = >cabac;
+}
+
+s->nb_local_ctx = s->threads_number;
 }
 
+lc = >local_ctx[0];
 offset = (lc->gb.index >> 3);
 
 for (j = 0, cmpt = 0, startheader = offset + s->sh.entry_point_offset[0]; 
j < nal->skipped_bytes; j++) {
@@ -2744,8 +2756,8 @@ static int hls_slice_data_wpp(HEVCContext *s, const 
H2645NAL *nal)
 s->data = data;
 
 for (i = 1; i < s->threads_number; i++) {
-s->local_ctx[i]->first_qp_group = 1;
-s->local_ctx[i]->qp_y = s->HEVClc->qp_y;
+s->local_ctx[i].first_qp_group = 1;
+s->local_ctx[i].qp_y = s->HEVClc->qp_y;
 }
 
 atomic_store(>wpp_err, 0);
@@ -3474,12 +3486,6 @@ static av_cold int hevc_decode_free(AVCodecContext 
*avctx)
 av_freep(>sh.offset);
 av_freep(>sh.size);
 
-if (s->local_ctx) {
-for (i = 1; i < s->nb_local_ctx; i++) {
-av_freep(>local_ctx[i]);
-}
-}
-av_freep(>HEVClc);
 av_freep(>local_ctx);
 
 ff_h2645_packet_uninit(>pkt);
@@ -3496,15 +3502,16 @@ static av_cold int hevc_init_context(AVCodecContext 
*avctx)
 
 s->avctx = avctx;
 
-s->HEVClc = av_mallocz(sizeof(HEVCLocalContext));
-s->local_ctx = av_mallocz(sizeof(HEVCLocalContext*) * s->threads_number);
-if (!s->HEVClc || !s->local_ctx)
+s->local_ctx = av_mallocz(sizeof(*s->local_ctx));
+if (!s->local_ctx)
 return AVERROR(ENOMEM);
+s->nb_local_ctx = 1;
+
+s->HEVClc = >local_ctx[0];
+
 s->HEVClc->parent = s;
 s->HEVClc->logctx = avctx;
 s->HEVClc->common_cabac_state = >cabac;
-s->local_ctx[0] = s->HEVClc;
-s->nb_local_ctx = 1;
 
 s->output_frame = av_frame_alloc();
 if (!s->output_frame)
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index ca68fb54a7..5aa3d40450 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -439,13 +439,17 @@ typedef struct HEVCLocalContext {
 /* properties of the boundary of the current CTB for the purposes
  * of the deblocking filter */
 int boundary_flags;
+
+// an array of the

[FFmpeg-cvslog] lavc/hevcdec: track local context count separately from WPP thread count

2024-05-31 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sun Apr  7 
11:49:04 2024 +0200| [25ce44efa5f199e4ee0ed47985801077c203e7d8] | committer: 
Anton Khirnov

lavc/hevcdec: track local context count separately from WPP thread count

The latter can be lowered while decoding, which would lead to memleaks.

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

 libavcodec/hevcdec.c | 7 +--
 libavcodec/hevcdec.h | 2 ++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 79dc1c98de..e84f45e3f8 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2697,11 +2697,13 @@ static int hls_slice_data_wpp(HEVCContext *s, const 
H2645NAL *nal)
 }
 
 for (i = 1; i < s->threads_number; i++) {
-if (s->local_ctx[i])
+if (i < s->nb_local_ctx)
 continue;
 s->local_ctx[i] = av_mallocz(sizeof(HEVCLocalContext));
 if (!s->local_ctx[i])
 return AVERROR(ENOMEM);
+s->nb_local_ctx++;
+
 s->local_ctx[i]->logctx = s->avctx;
 s->local_ctx[i]->parent = s;
 s->local_ctx[i]->common_cabac_state = >cabac;
@@ -3473,7 +3475,7 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)
 av_freep(>sh.size);
 
 if (s->local_ctx) {
-for (i = 1; i < s->threads_number; i++) {
+for (i = 1; i < s->nb_local_ctx; i++) {
 av_freep(>local_ctx[i]);
 }
 }
@@ -3502,6 +3504,7 @@ static av_cold int hevc_init_context(AVCodecContext 
*avctx)
 s->HEVClc->logctx = avctx;
 s->HEVClc->common_cabac_state = >cabac;
 s->local_ctx[0] = s->HEVClc;
+s->nb_local_ctx = 1;
 
 s->output_frame = av_frame_alloc();
 if (!s->output_frame)
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index 663f42a7ff..ca68fb54a7 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -446,6 +446,8 @@ typedef struct HEVCContext {
 AVCodecContext *avctx;
 
 HEVCLocalContext**local_ctx;
+unsigned   nb_local_ctx;
+
 HEVCLocalContext*HEVClc;
 
 uint8_t threads_type;

___
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] lavc/hevcdec: rename HEVCContext.HEVClcList to local_ctx

2024-05-31 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sun Apr  7 
11:11:07 2024 +0200| [a1471ec8ada0a2f5a8c0064ef7103cda5db691f8] | committer: 
Anton Khirnov

lavc/hevcdec: rename HEVCContext.HEVClcList to local_ctx

It is more consistent with our naming conventions.

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

 libavcodec/hevcdec.c | 30 +++---
 libavcodec/hevcdec.h |  2 +-
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index b41dc46053..79dc1c98de 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2697,14 +2697,14 @@ static int hls_slice_data_wpp(HEVCContext *s, const 
H2645NAL *nal)
 }
 
 for (i = 1; i < s->threads_number; i++) {
-if (s->HEVClcList[i])
+if (s->local_ctx[i])
 continue;
-s->HEVClcList[i] = av_mallocz(sizeof(HEVCLocalContext));
-if (!s->HEVClcList[i])
+s->local_ctx[i] = av_mallocz(sizeof(HEVCLocalContext));
+if (!s->local_ctx[i])
 return AVERROR(ENOMEM);
-s->HEVClcList[i]->logctx = s->avctx;
-s->HEVClcList[i]->parent = s;
-s->HEVClcList[i]->common_cabac_state = >cabac;
+s->local_ctx[i]->logctx = s->avctx;
+s->local_ctx[i]->parent = s;
+s->local_ctx[i]->common_cabac_state = >cabac;
 }
 
 offset = (lc->gb.index >> 3);
@@ -2742,8 +2742,8 @@ static int hls_slice_data_wpp(HEVCContext *s, const 
H2645NAL *nal)
 s->data = data;
 
 for (i = 1; i < s->threads_number; i++) {
-s->HEVClcList[i]->first_qp_group = 1;
-s->HEVClcList[i]->qp_y = s->HEVClc->qp_y;
+s->local_ctx[i]->first_qp_group = 1;
+s->local_ctx[i]->qp_y = s->HEVClc->qp_y;
 }
 
 atomic_store(>wpp_err, 0);
@@ -2756,7 +2756,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const 
H2645NAL *nal)
 return AVERROR(ENOMEM);
 
 if (s->ps.pps->entropy_coding_sync_enabled_flag)
-s->avctx->execute2(s->avctx, hls_decode_entry_wpp, s->HEVClcList, ret, 
s->sh.num_entry_point_offsets + 1);
+s->avctx->execute2(s->avctx, hls_decode_entry_wpp, s->local_ctx, ret, 
s->sh.num_entry_point_offsets + 1);
 
 for (i = 0; i <= s->sh.num_entry_point_offsets; i++)
 res += ret[i];
@@ -3472,13 +3472,13 @@ static av_cold int hevc_decode_free(AVCodecContext 
*avctx)
 av_freep(>sh.offset);
 av_freep(>sh.size);
 
-if (s->HEVClcList) {
+if (s->local_ctx) {
 for (i = 1; i < s->threads_number; i++) {
-av_freep(>HEVClcList[i]);
+av_freep(>local_ctx[i]);
 }
 }
 av_freep(>HEVClc);
-av_freep(>HEVClcList);
+av_freep(>local_ctx);
 
 ff_h2645_packet_uninit(>pkt);
 
@@ -3495,13 +3495,13 @@ static av_cold int hevc_init_context(AVCodecContext 
*avctx)
 s->avctx = avctx;
 
 s->HEVClc = av_mallocz(sizeof(HEVCLocalContext));
-s->HEVClcList = av_mallocz(sizeof(HEVCLocalContext*) * s->threads_number);
-if (!s->HEVClc || !s->HEVClcList)
+s->local_ctx = av_mallocz(sizeof(HEVCLocalContext*) * s->threads_number);
+if (!s->HEVClc || !s->local_ctx)
 return AVERROR(ENOMEM);
 s->HEVClc->parent = s;
 s->HEVClc->logctx = avctx;
 s->HEVClc->common_cabac_state = >cabac;
-s->HEVClcList[0] = s->HEVClc;
+s->local_ctx[0] = s->HEVClc;
 
 s->output_frame = av_frame_alloc();
 if (!s->output_frame)
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index e82daf6679..663f42a7ff 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -445,7 +445,7 @@ typedef struct HEVCContext {
 const AVClass *c;  // needed by private avoptions
 AVCodecContext *avctx;
 
-HEVCLocalContext**HEVClcList;
+HEVCLocalContext**local_ctx;
 HEVCLocalContext*HEVClc;
 
 uint8_t threads_type;

___
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] lavc/hevcdec: drop a useless execute() call with 1 job

2024-05-31 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Sun Apr  7 
17:35:22 2024 +0200| [72bdbce00d4d84008c40f5aa7a655f7dddafa5b1] | committer: 
Anton Khirnov

lavc/hevcdec: drop a useless execute() call with 1 job

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

 libavcodec/hevcdec.c | 12 ++--
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 88a481c043..b8ab34d710 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2526,9 +2526,8 @@ static void hls_decode_neighbour(HEVCLocalContext *lc, 
int x_ctb, int y_ctb,
 lc->ctb_up_left_flag = ((x_ctb > 0) && (y_ctb > 0)  && 
(ctb_addr_in_slice-1 >= s->ps.sps->ctb_width) && 
(s->ps.pps->tile_id[ctb_addr_ts] == 
s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs-1 - 
s->ps.sps->ctb_width]]));
 }
 
-static int hls_decode_entry(AVCodecContext *avctxt, void *arg)
+static int hls_decode_entry(HEVCContext *s)
 {
-HEVCContext *s  = avctxt->priv_data;
 HEVCLocalContext *const lc = s->HEVClc;
 int ctb_size= 1 << s->ps.sps->log2_ctb_size;
 int more_data   = 1;
@@ -2588,13 +2587,6 @@ static int hls_decode_entry(AVCodecContext *avctxt, void 
*arg)
 return ctb_addr_ts;
 }
 
-static int hls_slice_data(HEVCContext *s)
-{
-int ret = 0;
-
-s->avctx->execute(s->avctx, hls_decode_entry, NULL,  , 1, 0);
-return ret;
-}
 static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist,
 int job, int self_id)
 {
@@ -3133,7 +3125,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL 
*nal)
 if (s->threads_number > 1 && s->sh.num_entry_point_offsets > 0)
 ctb_addr_ts = hls_slice_data_wpp(s, nal);
 else
-ctb_addr_ts = hls_slice_data(s);
+ctb_addr_ts = hls_decode_entry(s);
 if (ctb_addr_ts >= (s->ps.sps->ctb_width * s->ps.sps->ctb_height)) 
{
 ret = hevc_frame_end(s);
 if (ret < 0)

___
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 "bsf: use standard include paths"

2024-04-10 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed Apr 10 
15:17:54 2024 +0200| [0e4dfa470958a6bc6c6a673491dda5adf758c6c2] | committer: 
Anton Khirnov

Revert "bsf: use standard include paths"

This reverts commit 41b73ae883ec2a70c814e394de0e5ae5f1f13e87.

This patch was pushed extremely quickly, without giving developers the
time to object.

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

 libavcodec/bsf/Makefile   |  2 ++
 libavcodec/bsf/aac_adtstoasc.c| 16 
 libavcodec/bsf/av1_frame_merge.c  |  8 
 libavcodec/bsf/av1_frame_split.c  |  8 
 libavcodec/bsf/av1_metadata.c | 10 +-
 libavcodec/bsf/chomp.c|  4 ++--
 libavcodec/bsf/dca_core.c |  8 
 libavcodec/bsf/dts2pts.c  | 12 ++--
 libavcodec/bsf/dump_extradata.c   |  4 ++--
 libavcodec/bsf/dv_error_marker.c  |  4 ++--
 libavcodec/bsf/eac3_core.c|  8 
 libavcodec/bsf/evc_frame_merge.c  | 12 ++--
 libavcodec/bsf/extract_extradata.c| 22 +++---
 libavcodec/bsf/filter_units.c |  6 +++---
 libavcodec/bsf/h264_metadata.c| 20 ++--
 libavcodec/bsf/h264_mp4toannexb.c | 10 +-
 libavcodec/bsf/h264_redundant_pps.c   | 16 
 libavcodec/bsf/h265_metadata.c| 16 
 libavcodec/bsf/h266_metadata.c| 12 ++--
 libavcodec/bsf/hapqa_extract.c|  8 
 libavcodec/bsf/hevc_mp4toannexb.c | 10 +-
 libavcodec/bsf/imx_dump_header.c  |  6 +++---
 libavcodec/bsf/media100_to_mjpegb.c   |  6 +++---
 libavcodec/bsf/mjpeg2jpeg.c   |  8 
 libavcodec/bsf/mjpega_dump_header.c   |  8 
 libavcodec/bsf/movsub.c   |  4 ++--
 libavcodec/bsf/mpeg2_metadata.c   | 12 ++--
 libavcodec/bsf/mpeg4_unpack_bframes.c |  8 
 libavcodec/bsf/noise.c|  4 ++--
 libavcodec/bsf/null.c |  2 +-
 libavcodec/bsf/opus_metadata.c|  4 ++--
 libavcodec/bsf/pcm_rechunk.c  |  4 ++--
 libavcodec/bsf/pgs_frame_merge.c  |  4 ++--
 libavcodec/bsf/prores_metadata.c  |  4 ++--
 libavcodec/bsf/remove_extradata.c | 14 +++---
 libavcodec/bsf/setts.c|  4 ++--
 libavcodec/bsf/showinfo.c |  4 ++--
 libavcodec/bsf/trace_headers.c|  6 +++---
 libavcodec/bsf/truehd_core.c  | 10 +-
 libavcodec/bsf/vp9_metadata.c | 10 +-
 libavcodec/bsf/vp9_raw_reorder.c  |  8 
 libavcodec/bsf/vp9_superframe.c   |  6 +++---
 libavcodec/bsf/vp9_superframe_split.c |  8 
 libavcodec/bsf/vvc_mp4toannexb.c  | 10 +-
 44 files changed, 186 insertions(+), 184 deletions(-)

diff --git a/libavcodec/bsf/Makefile b/libavcodec/bsf/Makefile
index e506ac61fd..fb70ad0c21 100644
--- a/libavcodec/bsf/Makefile
+++ b/libavcodec/bsf/Makefile
@@ -45,3 +45,5 @@ OBJS-$(CONFIG_VP9_SUPERFRAME_BSF) += 
bsf/vp9_superframe.o
 OBJS-$(CONFIG_VP9_SUPERFRAME_SPLIT_BSF)   += bsf/vp9_superframe_split.o
 OBJS-$(CONFIG_VVC_METADATA_BSF)   += bsf/h266_metadata.o
 OBJS-$(CONFIG_VVC_MP4TOANNEXB_BSF)+= bsf/vvc_mp4toannexb.o
+
+libavcodec/bsf/%.o: CPPFLAGS += -I$(SRC_PATH)/libavcodec/
diff --git a/libavcodec/bsf/aac_adtstoasc.c b/libavcodec/bsf/aac_adtstoasc.c
index 08373fc3b2..dd5e8b2a31 100644
--- a/libavcodec/bsf/aac_adtstoasc.c
+++ b/libavcodec/bsf/aac_adtstoasc.c
@@ -19,14 +19,14 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavcodec/adts_header.h"
-#include "libavcodec/adts_parser.h"
-#include "libavcodec/bsf.h"
-#include "libavcodec/bsf_internal.h"
-#include "libavcodec/put_bits.h"
-#include "libavcodec/get_bits.h"
-#include "libavcodec/mpeg4audio.h"
-#include "libavcodec/mpeg4audio_copy_pce.h"
+#include "adts_header.h"
+#include "adts_parser.h"
+#include "bsf.h"
+#include "bsf_internal.h"
+#include "put_bits.h"
+#include "get_bits.h"
+#include "mpeg4audio.h"
+#include "mpeg4audio_copy_pce.h"
 
 typedef struct AACBSFContext {
 int first_frame_done;
diff --git a/libavcodec/bsf/av1_frame_merge.c b/libavcodec/bsf/av1_frame_merge.c
index 12d53fba7c..4c54f2167e 100644
--- a/libavcodec/bsf/av1_frame_merge.c
+++ b/libavcodec/bsf/av1_frame_merge.c
@@ -18,10 +18,10 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavcodec/bsf.h"
-#include "libavcodec/bsf_internal.h"
-#include "libavcodec/cbs.h"
-#include "libavcodec/cbs_av1.h"
+#include "bsf.h"
+#include "bsf_internal.h"
+#include "cbs.h"
+#include "cbs_av1.h"
 
 typedef st

[FFmpeg-cvslog] fftools/ffmpeg_sched: allow filtergraphs to send to filtergraphs

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri Apr  5 
11:42:10 2024 +0200| [255ae036012177e1c0419e28bc4b9ab10d848d0a] | committer: 
Anton Khirnov

fftools/ffmpeg_sched: allow filtergraphs to send to filtergraphs

Will be useful for filtergraph chaining that will be added in following
commits.

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

 fftools/ffmpeg_sched.c | 94 +++---
 fftools/ffmpeg_sched.h |  6 +++-
 2 files changed, 63 insertions(+), 37 deletions(-)

diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c
index f8485db30b..e58b00ea97 100644
--- a/fftools/ffmpeg_sched.c
+++ b/fftools/ffmpeg_sched.c
@@ -983,20 +983,40 @@ int sch_connect(Scheduler *sch, SchedulerNode src, 
SchedulerNode dst)
 }
 case SCH_NODE_TYPE_FILTER_OUT: {
 SchFilterOut *fo;
-SchEnc  *enc;
 
 av_assert0(src.idx < sch->nb_filters &&
src.idx_stream < sch->filters[src.idx].nb_outputs);
-// filtered frames go to encoding
-av_assert0(dst.type == SCH_NODE_TYPE_ENC &&
-   dst.idx < sch->nb_enc);
+fo = >filters[src.idx].outputs[src.idx_stream];
 
-fo  = >filters[src.idx].outputs[src.idx_stream];
-enc = >enc[dst.idx];
+av_assert0(!fo->dst.type);
+fo->dst = dst;
+
+// filtered frames go to encoding or another filtergraph
+switch (dst.type) {
+case SCH_NODE_TYPE_ENC: {
+SchEnc *enc;
+
+av_assert0(dst.idx < sch->nb_enc);
+enc = >enc[dst.idx];
+
+av_assert0(!enc->src.type);
+enc->src = src;
+break;
+}
+case SCH_NODE_TYPE_FILTER_IN: {
+SchFilterIn *fi;
+
+av_assert0(dst.idx < sch->nb_filters &&
+   dst.idx_stream < sch->filters[dst.idx].nb_inputs);
+fi = >filters[dst.idx].inputs[dst.idx_stream];
+
+av_assert0(!fi->src.type);
+fi->src = src;
+break;
+}
+default: av_assert0(0);
+}
 
-av_assert0(!fo->dst.type && !enc->src.type);
-fo->dst  = dst;
-enc->src = src;
 
 break;
 }
@@ -1351,24 +1371,13 @@ static int check_acyclic(Scheduler *sch)
 goto fail;
 }
 
-// trace the transcoding graph upstream from every output stream
-// fed by a filtergraph
-for (unsigned i = 0; i < sch->nb_mux; i++) {
-SchMux *mux = >mux[i];
-
-for (unsigned j = 0; j < mux->nb_streams; j++) {
-SchMuxStream  *ms = >streams[j];
-SchedulerNode src = ms->src_sched;
-
-if (src.type != SCH_NODE_TYPE_FILTER_OUT)
-continue;
-src.idx_stream = 0;
-
-ret = check_acyclic_for_output(sch, src, filters_visited, 
filters_stack);
-if (ret < 0) {
-av_log(mux, AV_LOG_ERROR, "Transcoding graph has a cycle\n");
-goto fail;
-}
+// trace the transcoding graph upstream from every filtegraph
+for (unsigned i = 0; i < sch->nb_filters; i++) {
+ret = check_acyclic_for_output(sch, (SchedulerNode){ .idx = i },
+   filters_visited, filters_stack);
+if (ret < 0) {
+av_log(>filters[i], AV_LOG_ERROR, "Transcoding graph has a 
cycle\n");
+goto fail;
 }
 }
 
@@ -1484,13 +1493,18 @@ static int start_prepare(Scheduler *sch)
"Filtergraph input %u not connected to a source\n", j);
 return AVERROR(EINVAL);
 }
-av_assert0(fi->src.type == SCH_NODE_TYPE_DEC);
-dec = >dec[fi->src.idx];
 
-switch (dec->src.type) {
-case SCH_NODE_TYPE_DEMUX: fi->src_sched = dec->src;
   break;
-case SCH_NODE_TYPE_ENC:   fi->src_sched = 
sch->enc[dec->src.idx].src; break;
-default: av_assert0(0);
+if (fi->src.type == SCH_NODE_TYPE_FILTER_OUT)
+fi->src_sched = fi->src;
+else {
+av_assert0(fi->src.type == SCH_NODE_TYPE_DEC);
+dec = >dec[fi->src.idx];
+
+switch (dec->src.type) {
+case SCH_NODE_TYPE_DEMUX: fi->src_sched = dec->src;
   break;
+case SCH_NODE_TYPE_ENC:   fi->src_sched = 
sch->enc[dec->src.idx].src; break;
+default: av_assert0(0);
+}
 }
 }
 
@@ -2379,12 +2393,17 @@ void sch_filter_receive_finish(Scheduler *sch, unsigned 
fg_idx, unsigned in_idx)
 int sch_filter_send(Scheduler *sch, unsigned fg

[FFmpeg-cvslog] fftools/ffmpeg_filter: change processing order in fg_finalise_bindings()

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri Apr  5 
12:10:21 2024 +0200| [3d01996b242ee588bcb27d61d6351439b8849260] | committer: 
Anton Khirnov

fftools/ffmpeg_filter: change processing order in fg_finalise_bindings()

First bind all inputs in all filtergraphs, only then check that all
outputs are bound.

Needed by the following commit.

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

 fftools/ffmpeg.h|  2 +-
 fftools/ffmpeg_filter.c | 33 ++---
 fftools/ffmpeg_opt.c| 10 --
 3 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 882d241bdb..885a7c0c10 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -724,7 +724,7 @@ int init_simple_filtergraph(InputStream *ist, OutputStream 
*ost,
 char *graph_desc,
 Scheduler *sch, unsigned sch_idx_enc,
 const OutputFilterOptions *opts);
-int fg_finalise_bindings(FilterGraph *fg);
+int fg_finalise_bindings(void);
 
 /**
  * Get our axiliary frame data attached to the frame, allocating it
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 388c8919fd..1e14962f41 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1272,7 +1272,7 @@ static int fg_complex_bind_input(FilterGraph *fg, 
InputFilter *ifilter)
 return 0;
 }
 
-int fg_finalise_bindings(FilterGraph *fg)
+static int bind_inputs(FilterGraph *fg)
 {
 // bind filtergraph inputs to input streams
 for (int i = 0; i < fg->nb_inputs; i++) {
@@ -1287,14 +1287,33 @@ int fg_finalise_bindings(FilterGraph *fg)
 return ret;
 }
 
-for (int i = 0; i < fg->nb_outputs; i++) {
-OutputFilter *output = fg->outputs[i];
-if (!output->bound) {
-av_log(filtergraphs[i], AV_LOG_FATAL,
-   "Filter %s has an unconnected output\n", output->name);
-return AVERROR(EINVAL);
+return 0;
+}
+
+int fg_finalise_bindings(void)
+{
+int ret;
+
+for (int i = 0; i < nb_filtergraphs; i++) {
+ret = bind_inputs(filtergraphs[i]);
+if (ret < 0)
+return ret;
+}
+
+// check that all outputs were bound
+for (int i = 0; i < nb_filtergraphs; i++) {
+FilterGraph *fg = filtergraphs[i];
+
+for (int j = 0; j < fg->nb_outputs; j++) {
+OutputFilter *output = fg->outputs[j];
+if (!output->bound) {
+av_log(filtergraphs[j], AV_LOG_FATAL,
+   "Filter %s has an unconnected output\n", output->name);
+return AVERROR(EINVAL);
+}
 }
 }
+
 return 0;
 }
 
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index f764da1ed4..6526e8e3e8 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1264,12 +1264,10 @@ int ffmpeg_parse_options(int argc, char **argv, 
Scheduler *sch)
 }
 
 // bind unbound filtegraph inputs/outputs and check consistency
-for (int i = 0; i < nb_filtergraphs; i++) {
-ret = fg_finalise_bindings(filtergraphs[i]);
-if (ret < 0) {
-errmsg = "binding filtergraph inputs/outputs";
-goto fail;
-}
+ret = fg_finalise_bindings();
+if (ret < 0) {
+errmsg = "binding filtergraph inputs/outputs";
+goto fail;
 }
 
 correct_input_start_times();

___
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] doc/ffmpeg: document that there can be multiple complex filtergraphs

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri Apr  5 
15:06:54 2024 +0200| [baf17c15bec6eab97d9d67acd0a18cc0f4f45309] | committer: 
Anton Khirnov

doc/ffmpeg: document that there can be multiple complex filtergraphs

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

 doc/ffmpeg.texi | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 9bd548ce4e..e996ab945f 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -2143,7 +2143,8 @@ Define a complex filtergraph, i.e. one with arbitrary 
number of inputs and/or
 outputs. For simple graphs -- those with one input and one output of the same
 type -- see the @option{-filter} options. @var{filtergraph} is a description of
 the filtergraph, as described in the ``Filtergraph syntax'' section of the
-ffmpeg-filters manual.
+ffmpeg-filters manual. This option may be specified multiple times - each use
+creates a new complex filtergraph.
 
 Inputs to a complex filtergraph may come from different source types,
 distinguished by the format of the corresponding link label:

___
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] fftools/ffmpeg_filter: only store complex filtergraphs in global array

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Thu Apr  4 
12:49:55 2024 +0200| [243a51490a85923c29ea9c276786e7b7d29cff0d] | committer: 
Anton Khirnov

fftools/ffmpeg_filter: only store complex filtergraphs in global array

Store simple filtergraphs in the stream they feed. Keeping the two
separate will be useful in following commits.

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

 fftools/ffmpeg.c|  5 +
 fftools/ffmpeg.h|  3 +++
 fftools/ffmpeg_filter.c | 16 +---
 fftools/ffmpeg_mux.c|  1 +
 4 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 0ee76d69b5..1f50ed6805 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -787,6 +787,11 @@ static int check_keyboard_interaction(int64_t cur_time)
 (n = sscanf(buf, "%63[^ ] %lf %255[^ ] %255[^\n]", target, , 
command, arg)) >= 3) {
 av_log(NULL, AV_LOG_DEBUG, "Processing command target:%s time:%f 
command:%s arg:%s",
target, time, command, arg);
+for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) 
{
+if (ost->fg_simple)
+fg_send_command(ost->fg_simple, time, target, command, arg,
+key == 'C');
+}
 for (i = 0; i < nb_filtergraphs; i++)
 fg_send_command(filtergraphs[i], time, target, command, arg,
 key == 'C');
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 6446a141b5..882d241bdb 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -582,6 +582,8 @@ typedef struct OutputStream {
 char *logfile_prefix;
 FILE *logfile;
 
+// simple filtergraph feeding this stream, if any
+FilterGraph  *fg_simple;
 OutputFilter *filter;
 
 AVDictionary *encoder_opts;
@@ -653,6 +655,7 @@ extern intnb_input_files;
 extern OutputFile   **output_files;
 extern int nb_output_files;
 
+// complex filtergraphs
 extern FilterGraph **filtergraphs;
 extern intnb_filtergraphs;
 
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 3988cf5fc2..388c8919fd 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1009,16 +1009,25 @@ int fg_create(FilterGraph **pfg, char *graph_desc, 
Scheduler *sch)
 AVFilterGraph *graph;
 int ret = 0;
 
-fgp = allocate_array_elem(, sizeof(*fgp), _filtergraphs);
+fgp = av_mallocz(sizeof(*fgp));
 if (!fgp)
 return AVERROR(ENOMEM);
 fg = >fg;
 
-if (pfg)
+if (pfg) {
 *pfg = fg;
+fg->index = -1;
+} else {
+ret = av_dynarray_add_nofree(, _filtergraphs, fgp);
+if (ret < 0) {
+av_freep();
+return ret;
+}
+
+fg->index = nb_filtergraphs - 1;
+}
 
 fg->class   = _class;
-fg->index  = nb_filtergraphs - 1;
 fgp->graph_desc = graph_desc;
 fgp->disable_conversions = !auto_conversion_filters;
 fgp->sch = sch;
@@ -1135,6 +1144,7 @@ int init_simple_filtergraph(InputStream *ist, 
OutputStream *ost,
 ret = fg_create(, graph_desc, sch);
 if (ret < 0)
 return ret;
+ost->fg_simple = fg;
 fgp = fgp_from_fg(fg);
 
 fgp->is_simple = 1;
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 2b7a733501..a1583edd61 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -797,6 +797,7 @@ static void ost_free(OutputStream **post)
 ms = ms_from_ost(ost);
 
 enc_free(>enc);
+fg_free(>fg_simple);
 
 if (ost->logfile) {
 if (fclose(ost->logfile))

___
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] fftools/ffmpeg_filter: implement filtergraph chaining

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Thu Apr  4 
11:46:52 2024 +0200| [3bd7c571257474b9b6f813a09a49b78056edd9bc] | committer: 
Anton Khirnov

fftools/ffmpeg_filter: implement filtergraph chaining

This allows one complex filtergraph's output to be sent as input to
another one, which is useful in certain situations (one is described in
the docs).

Chaining filtergraphs was already effectively possible by using a
wrapped_avframe encoder connected to a loopback decoder, but it is ugly,
non-obvious and inefficient.

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

 Changelog   |  1 +
 doc/ffmpeg.texi | 58 +---
 fftools/ffmpeg_filter.c | 89 +++--
 3 files changed, 140 insertions(+), 8 deletions(-)

diff --git a/Changelog b/Changelog
index 18e83b99a1..b7a1af4083 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
 version :
 - Raw Captions with Time (RCWT) closed caption demuxer
 - LC3/LC3plus decoding/encoding using external library liblc3
+- ffmpeg CLI filtergraph chaining
 
 
 version 7.0:
diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 801c083705..9bd548ce4e 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -2145,14 +2145,62 @@ type -- see the @option{-filter} options. 
@var{filtergraph} is a description of
 the filtergraph, as described in the ``Filtergraph syntax'' section of the
 ffmpeg-filters manual.
 
-Input link labels must refer to either input streams or loopback decoders. For
-input streams, use the @code{[file_index:stream_specifier]} syntax (i.e. the
-same as @option{-map} uses). If @var{stream_specifier} matches multiple 
streams,
-the first one will be used.
+Inputs to a complex filtergraph may come from different source types,
+distinguished by the format of the corresponding link label:
+@itemize
+@item
+To connect an input stream, use @code{[file_index:stream_specifier]} (i.e. the
+same syntax as @option{-map}). If @var{stream_specifier} matches multiple
+streams, the first one will be used.
 
-For decoders, the link label must be [dec:@var{dec_idx}], where @var{dec_idx} 
is
+@item
+To connect a loopback decoder use [dec:@var{dec_idx}], where @var{dec_idx} is
 the index of the loopback decoder to be connected to given input.
 
+@item
+To connect an output from another complex filtergraph, use its link label. E.g
+the following example:
+
+@example
+ffmpeg -i input.mkv \
+  -filter_complex 
'[0:v]scale=size=hd1080,split=outputs=2[for_enc][orig_scaled]' \
+  -c:v libx264 -map '[for_enc]' output.mkv \
+  -dec 0:0 \
+  -filter_complex '[dec:0][orig_scaled]hstack[stacked]' \
+  -map '[stacked]' -c:v ffv1 comparison.mkv
+@end example
+
+reads an input video and
+@itemize
+@item
+(line 2) uses a complex filtergraph with one input and two outputs
+to scale the video to 1920x1080 and duplicate the result to both
+outputs;
+
+@item
+(line 3) encodes one scaled output with @code{libx264} and writes the result to
+@file{output.mkv};
+
+@item
+(line 4) decodes this encoded stream with a loopback decoder;
+
+@item
+(line 5) places the output of the loopback decoder (i.e. the
+@code{libx264}-encoded video) side by side with the scaled original input;
+
+@item
+(line 6) combined video is then losslessly encoded and written into
+@file{comparison.mkv}.
+
+@end itemize
+
+Note that the two filtergraphs cannot be combined into one, because then there
+would be a cycle in the transcoding pipeline (filtergraph output goes to
+encoding, from there to decoding, then back to the same graph), and such cycles
+are not allowed.
+
+@end itemize
+
 An unlabeled input will be connected to the first unused input stream of the
 matching type.
 
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 1e14962f41..f108f8daf9 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -902,6 +902,63 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream 
*ost,
 return 0;
 }
 
+static int ofilter_bind_ifilter(OutputFilter *ofilter, InputFilterPriv *ifp,
+const OutputFilterOptions *opts)
+{
+OutputFilterPriv *ofp = ofp_from_ofilter(ofilter);
+
+av_assert0(!ofilter->bound);
+av_assert0(ofilter->type == ifp->type);
+
+ofilter->bound = 1;
+av_freep(>linklabel);
+
+ofp->name = av_strdup(opts->name);
+if (!ofp->name)
+return AVERROR(EINVAL);
+
+av_strlcatf(ofp->log_name, sizeof(ofp->log_name), "->%s", ofp->name);
+
+return 0;
+}
+
+static int ifilter_bind_fg(InputFilterPriv *ifp, FilterGraph *fg_src, int 
out_idx)
+{
+FilterGraphPriv  *fgp = fgp_from_fg(ifp->ifilter.graph);
+OutputFilter *ofilter_src = fg_src->outputs[out_idx];
+OutputFilterOptions opts;
+char name[32];
+int ret;
+
+av_assert0(!ifp->bound);
+ifp->bound = 1;
+
+

[FFmpeg-cvslog] fftools/ffmpeg_filter: drop OutputFilter.ost

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Thu Apr  4 
11:35:26 2024 +0200| [d74cbcb9635f1c94f990dae4988a060ec6494f34] | committer: 
Anton Khirnov

fftools/ffmpeg_filter: drop OutputFilter.ost

All remaining code accessing it only needs to know whether this
filtergraph output has been bound or not.

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

 fftools/ffmpeg.h  | 2 +-
 fftools/ffmpeg_filter.c   | 6 +++---
 fftools/ffmpeg_mux_init.c | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index f77ec956b3..6446a141b5 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -314,12 +314,12 @@ typedef struct InputFilter {
 typedef struct OutputFilter {
 const AVClass   *class;
 
-struct OutputStream *ost;
 struct FilterGraph  *graph;
 uint8_t *name;
 
 /* for filters that are not yet bound to an output stream,
  * this stores the output linklabel, if any */
+int  bound;
 uint8_t *linklabel;
 
 char*apad;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 9fc6e32960..3988cf5fc2 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -806,10 +806,10 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream 
*ost,
 FilterGraphPriv *fgp = fgp_from_fg(fg);
 int ret;
 
-av_assert0(!ofilter->ost);
+av_assert0(!ofilter->bound);
 av_assert0(ofilter->type == ost->type);
 
-ofilter->ost = ost;
+ofilter->bound = 1;
 av_freep(>linklabel);
 
 ofp->flags= opts->flags;
@@ -1279,7 +1279,7 @@ int fg_finalise_bindings(FilterGraph *fg)
 
 for (int i = 0; i < fg->nb_outputs; i++) {
 OutputFilter *output = fg->outputs[i];
-if (!output->ost) {
+if (!output->bound) {
 av_log(filtergraphs[i], AV_LOG_FATAL,
"Filter %s has an unconnected output\n", output->name);
 return AVERROR(EINVAL);
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 10421ae1b0..6d8bd5bcdf 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1827,7 +1827,7 @@ static int create_streams(Muxer *mux, const 
OptionsContext *o)
 for (int j = 0; j < fg->nb_outputs; j++) {
 OutputFilter *ofilter = fg->outputs[j];
 
-if (ofilter->linklabel || ofilter->ost)
+if (ofilter->linklabel || ofilter->bound)
 continue;
 
 auto_disable |= 1 << ofilter->type;

___
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] fftools/ffmpeg_filter: accept encoder thread count through OutputFilterOptions

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Thu Apr  4 
11:30:18 2024 +0200| [f2c919252da460f89f7281c769d3005e35d95b85] | committer: 
Anton Khirnov

fftools/ffmpeg_filter: accept encoder thread count through OutputFilterOptions

Stop digging through encoder options manually.

Will allow decoupling filtering from encoding in future commits.

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

 fftools/ffmpeg.h  |  2 ++
 fftools/ffmpeg_filter.c   | 20 ++--
 fftools/ffmpeg_mux_init.c |  5 +
 3 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 7135d9563c..f77ec956b3 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -291,6 +291,8 @@ typedef struct OutputFilterOptions {
 AVDictionary   *sws_opts;
 AVDictionary   *swr_opts;
 
+const char *nb_threads;
+
 // A combination of OFilterFlags.
 unsignedflags;
 
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index ec17e99494..9fc6e32960 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -59,6 +59,8 @@ typedef struct FilterGraphPriv {
 
 const char  *graph_desc;
 
+char*nb_threads;
+
 // frame for temporarily holding output from the filtergraph
 AVFrame *frame;
 // frame for sending output to the encoder
@@ -976,6 +978,7 @@ void fg_free(FilterGraph **pfg)
 }
 av_freep(>outputs);
 av_freep(>graph_desc);
+av_freep(>nb_threads);
 
 av_frame_free(>frame);
 av_frame_free(>frame_enc);
@@ -1165,6 +1168,13 @@ int init_simple_filtergraph(InputStream *ist, 
OutputStream *ost,
 if (ret < 0)
 return ret;
 
+if (opts->nb_threads) {
+av_freep(>nb_threads);
+fgp->nb_threads = av_strdup(opts->nb_threads);
+if (!fgp->nb_threads)
+return AVERROR(ENOMEM);
+}
+
 return 0;
 }
 
@@ -1735,17 +1745,15 @@ static int configure_filtergraph(FilterGraph *fg, 
FilterGraphThread *fgt)
 
 if (simple) {
 OutputFilterPriv *ofp = ofp_from_ofilter(fg->outputs[0]);
-OutputStream *ost = fg->outputs[0]->ost;
 
 if (filter_nbthreads) {
 ret = av_opt_set(fgt->graph, "threads", filter_nbthreads, 0);
 if (ret < 0)
 goto fail;
-} else {
-const AVDictionaryEntry *e = NULL;
-e = av_dict_get(ost->encoder_opts, "threads", NULL, 0);
-if (e)
-av_opt_set(fgt->graph, "threads", e->value, 0);
+} else if (fgp->nb_threads) {
+ret = av_opt_set(fgt->graph, "threads", fgp->nb_threads, 0);
+if (ret < 0)
+return ret;
 }
 
 if (av_dict_count(ofp->sws_opts)) {
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index ffcc20a504..10421ae1b0 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1370,6 +1370,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
 
 if (ost->enc &&
 (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) {
+const AVDictionaryEntry *e;
 char name[16];
 OutputFilterOptions opts = {
 .enc = enc,
@@ -1395,6 +1396,10 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
 
 snprintf(name, sizeof(name), "#%d:%d", mux->of.index, ost->index);
 
+e = av_dict_get(ost->encoder_opts, "threads", NULL, 0);
+if (e)
+opts.nb_threads = e->value;
+
 // MJPEG encoder exports a full list of supported pixel formats,
 // but the full-range ones are experimental-only.
 // Restrict the auto-conversion list unless -strict experimental

___
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] fftools/ffmpeg_filter: pass trim parameters through OutputFilterOptions

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Tue Apr  2 
13:58:59 2024 +0200| [a2892dbe06161452ec6592bc0cbe8b0f6780] | committer: 
Anton Khirnov

fftools/ffmpeg_filter: pass trim parameters through OutputFilterOptions

Do not read them from OutputStream directly.

Will allow decoupling filtering from encoding in future commits.

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

 fftools/ffmpeg.h  |  2 ++
 fftools/ffmpeg_filter.c   | 11 +++
 fftools/ffmpeg_mux_init.c |  2 ++
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 4059b1dcc3..8e773165da 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -279,6 +279,8 @@ typedef struct OutputFilterOptions {
 // Overrides encoder pixel formats when set.
 const enum AVPixelFormat *pix_fmts;
 
+int64_t trim_start_us;
+int64_t trim_duration_us;
 int64_t ts_offset;
 
 /* Desired output timebase.
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index dc9556bbc1..225fa4bda2 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -220,6 +220,8 @@ typedef struct OutputFilterPriv {
 const int  *sample_rates;
 
 AVRational  enc_timebase;
+int64_t trim_start_us;
+int64_t trim_duration_us;
 // offset for output timestamps, in AV_TIME_BASE_Q
 int64_t ts_offset;
 int64_t next_pts;
@@ -812,6 +814,9 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream 
*ost,
 ofp->ts_offset= opts->ts_offset;
 ofp->enc_timebase = opts->output_tb;
 
+ofp->trim_start_us= opts->trim_start_us;
+ofp->trim_duration_us = opts->trim_duration_us;
+
 ofp->name = av_strdup(opts->name);
 if (!ofp->name)
 return AVERROR(EINVAL);
@@ -1349,8 +1354,6 @@ static int configure_output_video_filter(FilterGraph *fg, 
AVFilterGraph *graph,
  OutputFilter *ofilter, AVFilterInOut 
*out)
 {
 OutputFilterPriv *ofp = ofp_from_ofilter(ofilter);
-OutputStream *ost = ofilter->ost;
-OutputFile*of = ost->file;
 AVFilterContext *last_filter = out->filter_ctx;
 AVBPrint bprint;
 int pad_idx = out->pad_idx;
@@ -1411,7 +1414,7 @@ static int configure_output_video_filter(FilterGraph *fg, 
AVFilterGraph *graph,
 }
 
 snprintf(name, sizeof(name), "trim_out_%s", ofp->name);
-ret = insert_trim(of->start_time, of->recording_time,
+ret = insert_trim(ofp->trim_start_us, ofp->trim_duration_us,
   _filter, _idx, name);
 if (ret < 0)
 return ret;
@@ -1503,7 +1506,7 @@ static int configure_output_audio_filter(FilterGraph *fg, 
AVFilterGraph *graph,
 }
 
 snprintf(name, sizeof(name), "trim for output %s", ofp->name);
-ret = insert_trim(of->start_time, of->recording_time,
+ret = insert_trim(ofp->trim_start_us, ofp->trim_duration_us,
   _filter, _idx, name);
 if (ret < 0)
 goto fail;
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 51c31eeb72..6e19b98abd 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1389,6 +1389,8 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
 .sws_opts= o->g->sws_dict,
 .swr_opts= o->g->swr_opts,
 .output_tb = enc_tb,
+.trim_start_us= mux->of.start_time,
+.trim_duration_us = mux->of.recording_time,
 .ts_offset = mux->of.start_time == AV_NOPTS_VALUE ?
  0 : mux->of.start_time,
 .flags = OFILTER_FLAG_DISABLE_CONVERT * !!keep_pix_fmt |

___
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] fftools/ffmpeg_mux: drop OutputFile.shortest

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Thu Apr  4 
10:56:29 2024 +0200| [5b0589c8c37bc77df0e895d31135867e59b8cc90] | committer: 
Anton Khirnov

fftools/ffmpeg_mux: drop OutputFile.shortest

It is no longer needed outside of of_open() and its children.

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

 fftools/ffmpeg.h  |  1 -
 fftools/ffmpeg_mux_init.c | 17 +
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 26b42a3fcd..1d32009f90 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -620,7 +620,6 @@ typedef struct OutputFile {
 int64_t recording_time;  ///< desired length of the resulting file in 
microseconds == AV_TIME_BASE units
 int64_t start_time;  ///< start time in microseconds == AV_TIME_BASE 
units
 
-int shortest;
 int bitexact;
 } OutputFile;
 
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index a483fffa6e..9aad19a85d 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1886,7 +1886,7 @@ static int create_streams(Muxer *mux, const 
OptionsContext *o)
 }
 
 // handle -apad
-if (mux->of.shortest) {
+if (o->shortest) {
 int have_video = 0;
 
 for (unsigned i = 0; i < mux->of.nb_streams; i++)
@@ -1921,7 +1921,8 @@ static int create_streams(Muxer *mux, const 
OptionsContext *o)
 return 0;
 }
 
-static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t 
buf_size_us)
+static int setup_sync_queues(Muxer *mux, AVFormatContext *oc,
+ int64_t buf_size_us, int shortest)
 {
 OutputFile *of = >of;
 int nb_av_enc = 0, nb_audio_fs = 0, nb_interleaved = 0;
@@ -1947,7 +1948,7 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext 
*oc, int64_t buf_size_u
 limit_frames_av_enc |= (ms->max_frames < INT64_MAX) && IS_AV_ENC(ost, 
type);
 }
 
-if (!((nb_interleaved > 1 && of->shortest) ||
+if (!((nb_interleaved > 1 && shortest) ||
   (nb_interleaved > 0 && limit_frames) ||
   nb_audio_fs))
 return 0;
@@ -1963,7 +1964,7 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext 
*oc, int64_t buf_size_u
  * different encoders run in different threads and need external
  * synchronization, while muxer sync queues can be handled inside the muxer
  */
-if ((of->shortest && nb_av_enc > 1) || limit_frames_av_enc || nb_audio_fs) 
{
+if ((shortest && nb_av_enc > 1) || limit_frames_av_enc || nb_audio_fs) {
 int sq_idx, ret;
 
 sq_idx = sch_add_sq_enc(mux->sch, buf_size_us, mux);
@@ -1979,7 +1980,7 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext 
*oc, int64_t buf_size_u
 continue;
 
 ret = sch_sq_add_enc(mux->sch, sq_idx, ms->sch_idx_enc,
- of->shortest || ms->max_frames < INT64_MAX,
+ shortest || ms->max_frames < INT64_MAX,
  ms->max_frames);
 if (ret < 0)
 return ret;
@@ -2006,7 +2007,7 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext 
*oc, int64_t buf_size_u
 continue;
 
 ms->sq_idx_mux = sq_add_stream(mux->sq_mux,
-   of->shortest || ms->max_frames < 
INT64_MAX);
+   shortest || ms->max_frames < 
INT64_MAX);
 if (ms->sq_idx_mux < 0)
 return ms->sq_idx_mux;
 
@@ -3043,7 +3044,6 @@ int of_open(const OptionsContext *o, const char 
*filename, Scheduler *sch)
 
 of->recording_time = recording_time;
 of->start_time = o->start_time;
-of->shortest   = o->shortest;
 
 mux->limit_filesize= o->limit_filesize;
 av_dict_copy(>opts, o->g->format_opts, 0);
@@ -3159,7 +3159,8 @@ int of_open(const OptionsContext *o, const char 
*filename, Scheduler *sch)
 return err;
 }
 
-err = setup_sync_queues(mux, oc, o->shortest_buf_duration * AV_TIME_BASE);
+err = setup_sync_queues(mux, oc, o->shortest_buf_duration * AV_TIME_BASE,
+o->shortest);
 if (err < 0) {
 av_log(mux, AV_LOG_FATAL, "Error setting up output sync queues\n");
 return err;

___
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] fftools/ffmpeg_filter: move most of -apad logic to the muxer

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Thu Apr  4 
10:51:53 2024 +0200| [a4c940c86a46e817eea16d8535db383f9e19c25c] | committer: 
Anton Khirnov

fftools/ffmpeg_filter: move most of -apad logic to the muxer

The decision whether -apad actually does anything is made based on muxer
properties, and so more properly belongs there. Filtering code only
receives the result.

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

 fftools/ffmpeg.h  |  3 ++-
 fftools/ffmpeg_filter.c   | 16 +++-
 fftools/ffmpeg_mux.c  |  1 -
 fftools/ffmpeg_mux.h  |  2 ++
 fftools/ffmpeg_mux_init.c | 36 +---
 5 files changed, 36 insertions(+), 22 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 8e773165da..26b42a3fcd 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -320,6 +320,8 @@ typedef struct OutputFilter {
  * this stores the output linklabel, if any */
 uint8_t *linklabel;
 
+char*apad;
+
 enum AVMediaType type;
 
 atomic_uint_least64_t nb_frames_dup;
@@ -581,7 +583,6 @@ typedef struct OutputStream {
 OutputFilter *filter;
 
 AVDictionary *encoder_opts;
-char *apad;
 
 char *attachment_filename;
 
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 225fa4bda2..ec17e99494 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -969,6 +969,7 @@ void fg_free(FilterGraph **pfg)
 
 av_freep(>linklabel);
 av_freep(>name);
+av_freep(>apad);
 av_freep(>name);
 av_channel_layout_uninit(>ch_layout);
 av_freep(>outputs[j]);
@@ -1430,8 +1431,6 @@ static int configure_output_audio_filter(FilterGraph *fg, 
AVFilterGraph *graph,
  OutputFilter *ofilter, AVFilterInOut 
*out)
 {
 OutputFilterPriv *ofp = ofp_from_ofilter(ofilter);
-OutputStream *ost = ofilter->ost;
-OutputFile*of = ost->file;
 AVFilterContext *last_filter = out->filter_ctx;
 int pad_idx = out->pad_idx;
 AVBPrint args;
@@ -1493,17 +1492,8 @@ static int configure_output_audio_filter(FilterGraph 
*fg, AVFilterGraph *graph,
 pad_idx = 0;
 }
 
-if (ost->apad && of->shortest) {
-int i;
-
-for (i = 0; i < of->nb_streams; i++)
-if (of->streams[i]->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
-break;
-
-if (i < of->nb_streams) {
-AUTO_INSERT_FILTER("-apad", "apad", ost->apad);
-}
-}
+if (ofilter->apad)
+AUTO_INSERT_FILTER("-apad", "apad", ofilter->apad);
 
 snprintf(name, sizeof(name), "trim for output %s", ofp->name);
 ret = insert_trim(ofp->trim_start_us, ofp->trim_duration_us,
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 557f08b3a5..6a64cba72d 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -815,7 +815,6 @@ static void ost_free(OutputStream **post)
 av_expr_free(ost->kf.pexpr);
 
 av_freep(>logfile_prefix);
-av_freep(>apad);
 
 av_freep(>attachment_filename);
 
diff --git a/fftools/ffmpeg_mux.h b/fftools/ffmpeg_mux.h
index f8b6f7a790..1e9ea35412 100644
--- a/fftools/ffmpeg_mux.h
+++ b/fftools/ffmpeg_mux.h
@@ -78,6 +78,8 @@ typedef struct MuxStream {
 #if FFMPEG_OPT_VSYNC_DROP
 int ts_drop;
 #endif
+
+char   *apad;
 } MuxStream;
 
 typedef struct Muxer {
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 6e19b98abd..a483fffa6e 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -828,6 +828,7 @@ static int new_stream_video(Muxer *mux, const 
OptionsContext *o,
 static int new_stream_audio(Muxer *mux, const OptionsContext *o,
 OutputStream *ost)
 {
+MuxStream *ms = ms_from_ost(ost);
 AVFormatContext *oc = mux->fc;
 AVStream *st = ost->st;
 
@@ -836,7 +837,6 @@ static int new_stream_audio(Muxer *mux, const 
OptionsContext *o,
 int channels = 0;
 char *layout = NULL;
 char *sample_fmt = NULL;
-const char *apad = NULL;
 
 MATCH_PER_STREAM_OPT(audio_channels, i, channels, oc, st);
 if (channels) {
@@ -859,12 +859,7 @@ static int new_stream_audio(Muxer *mux, const 
OptionsContext *o,
 
 MATCH_PER_STREAM_OPT(audio_sample_rate, i, audio_enc->sample_rate, oc, 
st);
 
-MATCH_PER_STREAM_OPT(apad, str, apad, oc, st);
-if (apad) {
-ost->apad = av_strdup(apad);
-if (!ost->apad)
-return AVERROR(ENOMEM);
-}
+MATCH_PER_STREAM_OPT(apad, str, ms->apad, oc, st);
 }
 
 return 0;
@@ -1890,6 +1885,33 @@ static int create_streams(Muxer *mux, const 
OptionsContext *o)
 }

[FFmpeg-cvslog] fftools/ffmpeg_mux: drop OutputFile.format

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Thu Apr  4 
11:05:33 2024 +0200| [bfeb751171c87e81fa940f4152b1e72eb9b0a1c0] | committer: 
Anton Khirnov

fftools/ffmpeg_mux: drop OutputFile.format

It is no longer used outside of the muxing code (where we can access the
muxer directly).

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

 fftools/ffmpeg.h  |  1 -
 fftools/ffmpeg_mux.c  | 15 +--
 fftools/ffmpeg_mux_init.c |  1 -
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 1d32009f90..7135d9563c 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -611,7 +611,6 @@ typedef struct OutputFile {
 
 int index;
 
-const AVOutputFormat *format;
 const char   *url;
 
 OutputStream **streams;
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 6a64cba72d..2b7a733501 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -370,10 +370,11 @@ fail:
 return ret;
 }
 
-static void thread_set_name(OutputFile *of)
+static void thread_set_name(Muxer *mux)
 {
 char name[16];
-snprintf(name, sizeof(name), "mux%d:%s", of->index, of->format->name);
+snprintf(name, sizeof(name), "mux%d:%s",
+ mux->of.index, mux->fc->oformat->name);
 ff_thread_setname(name);
 }
 
@@ -417,7 +418,7 @@ int muxer_thread(void *arg)
 if (ret < 0)
 goto finish;
 
-thread_set_name(of);
+thread_set_name(mux);
 
 while (1) {
 OutputStream *ost;
@@ -515,8 +516,10 @@ int print_sdp(const char *filename)
 if (!avc)
 return AVERROR(ENOMEM);
 for (int i = 0; i < nb_output_files; i++) {
-if (!strcmp(output_files[i]->format->name, "rtp")) {
-avc[j] = mux_from_of(output_files[i])->fc;
+Muxer *mux = mux_from_of(output_files[i]);
+
+if (!strcmp(mux->fc->oformat->name, "rtp")) {
+avc[j] = mux->fc;
 j++;
 }
 }
@@ -756,7 +759,7 @@ int of_write_trailer(OutputFile *of)
 
 mux->last_filesize = filesize(fc->pb);
 
-if (!(of->format->flags & AVFMT_NOFILE)) {
+if (!(fc->oformat->flags & AVFMT_NOFILE)) {
 ret = avio_closep(>pb);
 if (ret < 0) {
 av_log(mux, AV_LOG_ERROR, "Error closing file: %s\n", 
av_err2str(ret));
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 9aad19a85d..ffcc20a504 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -3063,7 +3063,6 @@ int of_open(const OptionsContext *o, const char 
*filename, Scheduler *sch)
 av_strlcat(mux->log_name, oc->oformat->name, sizeof(mux->log_name));
 
 
-of->format = oc->oformat;
 if (recording_time != INT64_MAX)
 oc->duration = recording_time;
 

___
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] fftools/ffmpeg_filter: pass sws/swr opts through OutputFilterOptions

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Tue Apr  2 
13:58:59 2024 +0200| [b8e6802023a5e687c40b6565745a225f8e069657] | committer: 
Anton Khirnov

fftools/ffmpeg_filter: pass sws/swr opts through OutputFilterOptions

Do not read them from OutputStream directly.

Will allow decoupling filtering from encoding in future commits.

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

 fftools/ffmpeg.h  |  7 +--
 fftools/ffmpeg_filter.c   | 27 ++-
 fftools/ffmpeg_mux.c  |  3 ---
 fftools/ffmpeg_mux_init.c | 11 ---
 4 files changed, 31 insertions(+), 17 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 786f925bc6..c61a670103 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -265,6 +265,8 @@ typedef struct InputFilterOptions {
 
 enum OFilterFlags {
 OFILTER_FLAG_DISABLE_CONVERT= (1 << 0),
+// produce 24-bit audio
+OFILTER_FLAG_AUDIO_24BIT= (1 << 1),
 };
 
 typedef struct OutputFilterOptions {
@@ -283,6 +285,9 @@ typedef struct OutputFilterOptions {
  */
 AVRational  output_tb;
 
+AVDictionary   *sws_opts;
+AVDictionary   *swr_opts;
+
 // A combination of OFilterFlags.
 unsignedflags;
 
@@ -574,8 +579,6 @@ typedef struct OutputStream {
 OutputFilter *filter;
 
 AVDictionary *encoder_opts;
-AVDictionary *sws_dict;
-AVDictionary *swr_opts;
 char *apad;
 
 char *attachment_filename;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index d2fd26af7e..8aa4053716 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -210,6 +210,9 @@ typedef struct OutputFilterPriv {
 
 AVRational  sample_aspect_ratio;
 
+AVDictionary   *sws_opts;
+AVDictionary   *swr_opts;
+
 // those are only set if no format is specified and the encoder gives us 
multiple options
 // They point directly to the relevant lists of the encoder.
 const int  *formats;
@@ -813,6 +816,17 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream 
*ost,
 if (!ofp->name)
 return AVERROR(EINVAL);
 
+ret = av_dict_copy(>sws_opts, opts->sws_opts, 0);
+if (ret < 0)
+return ret;
+
+ret = av_dict_copy(>swr_opts, opts->swr_opts, 0);
+if (ret < 0)
+return ret;
+
+if (opts->flags & OFILTER_FLAG_AUDIO_24BIT)
+av_dict_set(>swr_opts, "output_sample_bits", "24", 0);
+
 if (fgp->is_simple) {
 // for simple filtergraph there is just one output,
 // so use only graph-level information for logging
@@ -945,6 +959,8 @@ void fg_free(FilterGraph **pfg)
 OutputFilterPriv *ofp = ofp_from_ofilter(ofilter);
 
 av_frame_free(>fps.last_frame);
+av_dict_free(>sws_opts);
+av_dict_free(>swr_opts);
 
 av_freep(>linklabel);
 av_freep(>name);
@@ -1358,7 +1374,7 @@ static int configure_output_video_filter(FilterGraph *fg, 
AVFilterGraph *graph,
 snprintf(args, sizeof(args), "%d:%d",
  ofp->width, ofp->height);
 
-while ((e = av_dict_iterate(ost->sws_dict, e))) {
+while ((e = av_dict_iterate(ofp->sws_opts, e))) {
 av_strlcatf(args, sizeof(args), ":%s=%s", e->key, e->value);
 }
 
@@ -1725,6 +1741,7 @@ static int configure_filtergraph(FilterGraph *fg, 
FilterGraphThread *fgt)
 return AVERROR(ENOMEM);
 
 if (simple) {
+OutputFilterPriv *ofp = ofp_from_ofilter(fg->outputs[0]);
 OutputStream *ost = fg->outputs[0]->ost;
 
 if (filter_nbthreads) {
@@ -1738,17 +1755,17 @@ static int configure_filtergraph(FilterGraph *fg, 
FilterGraphThread *fgt)
 av_opt_set(fgt->graph, "threads", e->value, 0);
 }
 
-if (av_dict_count(ost->sws_dict)) {
-ret = av_dict_get_string(ost->sws_dict,
+if (av_dict_count(ofp->sws_opts)) {
+ret = av_dict_get_string(ofp->sws_opts,
  >graph->scale_sws_opts,
  '=', ':');
 if (ret < 0)
 goto fail;
 }
 
-if (av_dict_count(ost->swr_opts)) {
+if (av_dict_count(ofp->swr_opts)) {
 char *args;
-ret = av_dict_get_string(ost->swr_opts, , '=', ':');
+ret = av_dict_get_string(ofp->swr_opts, , '=', ':');
 if (ret < 0)
 goto fail;
 av_opt_set(fgt->graph, "aresample_swr_opts", args, 0);
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 253c2e58d4..557f08b3a5 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -819,9 +819,6 @@ static void ost_free(OutputStream **post)
 
 av_freep(

[FFmpeg-cvslog] fftools/ffmpeg_filter: pass autoscale through OutputFilterOptions

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Tue Apr  2 
13:58:59 2024 +0200| [83304f7c1f26ef12880115ad9b0c82b399759a46] | committer: 
Anton Khirnov

fftools/ffmpeg_filter: pass autoscale through OutputFilterOptions

Do not read it from OutputStream directly.

Will allow decoupling filtering from encoding in future commits.

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

 fftools/ffmpeg.h  | 2 +-
 fftools/ffmpeg_filter.c   | 2 +-
 fftools/ffmpeg_mux_init.c | 7 ---
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index c61a670103..4059b1dcc3 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -267,6 +267,7 @@ enum OFilterFlags {
 OFILTER_FLAG_DISABLE_CONVERT= (1 << 0),
 // produce 24-bit audio
 OFILTER_FLAG_AUDIO_24BIT= (1 << 1),
+OFILTER_FLAG_AUTOSCALE  = (1 << 2),
 };
 
 typedef struct OutputFilterOptions {
@@ -565,7 +566,6 @@ typedef struct OutputStream {
 #if FFMPEG_OPT_TOP
 int top_field_first;
 #endif
-int autoscale;
 int bitexact;
 int bits_per_raw_sample;
 
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 8aa4053716..dc9556bbc1 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1366,7 +1366,7 @@ static int configure_output_video_filter(FilterGraph *fg, 
AVFilterGraph *graph,
 if (ret < 0)
 return ret;
 
-if ((ofp->width || ofp->height) && ofilter->ost->autoscale) {
+if ((ofp->width || ofp->height) && (ofp->flags & OFILTER_FLAG_AUTOSCALE)) {
 char args[255];
 AVFilterContext *filter;
 const AVDictionaryEntry *e = NULL;
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 8f4b73f8a7..51c31eeb72 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1045,7 +1045,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
 OutputStream *ost;
 const AVCodec *enc;
 AVStream *st;
-int ret = 0, keep_pix_fmt = 0;
+int ret = 0, keep_pix_fmt = 0, autoscale = 1;
 AVRational enc_tb = { 0, 0 };
 enum VideoSyncMethod vsync_method = VSYNC_AUTO;
 const char *bsfs = NULL, *time_base = NULL;
@@ -1170,8 +1170,8 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
 return ret;
 
 MATCH_PER_STREAM_OPT(presets, str, preset, oc, st);
-ost->autoscale = 1;
-MATCH_PER_STREAM_OPT(autoscale, i, ost->autoscale, oc, st);
+
+MATCH_PER_STREAM_OPT(autoscale, i, autoscale, oc, st);
 if (preset && (!(ret = get_preset_file_2(preset, enc->codec->name, 
 {
 AVBPrint bprint;
 av_bprint_init(, 0, AV_BPRINT_SIZE_UNLIMITED);
@@ -1392,6 +1392,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
 .ts_offset = mux->of.start_time == AV_NOPTS_VALUE ?
  0 : mux->of.start_time,
 .flags = OFILTER_FLAG_DISABLE_CONVERT * !!keep_pix_fmt |
+ OFILTER_FLAG_AUTOSCALE   * !!autoscale|
  OFILTER_FLAG_AUDIO_24BIT * 
!!(av_get_exact_bits_per_sample(ost->enc_ctx->codec_id) == 24),
 };
 

___
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] fftools/ffmpeg_filter: drop an unnecessary use of OutputStream

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Tue Apr  2 
13:44:22 2024 +0200| [23c23077fc79f27022f56855080debdba7a00274] | committer: 
Anton Khirnov

fftools/ffmpeg_filter: drop an unnecessary use of OutputStream

OutputFilter.type contains the same information.

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

 fftools/ffmpeg_filter.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 840502bd62..d2fd26af7e 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -2325,7 +2325,6 @@ static int fg_output_step(OutputFilterPriv *ofp, 
FilterGraphThread *fgt,
   AVFrame *frame)
 {
 FilterGraphPriv*fgp = fgp_from_fg(ofp->ofilter.graph);
-OutputStream   *ost = ofp->ofilter.ost;
 AVFilterContext *filter = ofp->filter;
 FrameData *fd;
 int ret;
@@ -2379,7 +2378,7 @@ static int fg_output_step(OutputFilterPriv *ofp, 
FilterGraphThread *fgt,
 if (!fgp->is_meta)
 fd->bits_per_raw_sample = 0;
 
-if (ost->type == AVMEDIA_TYPE_VIDEO) {
+if (ofp->ofilter.type == AVMEDIA_TYPE_VIDEO) {
 if (!frame->duration) {
 AVRational fr = av_buffersink_get_frame_rate(filter);
 if (fr.num > 0 && fr.den > 0)

___
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] fftools/ffmpeg_filter: simplify retrieving filter type

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Tue Apr  2 
12:25:33 2024 +0200| [3c3e04c8a3fc93ab5b18277d59db8990ab6ec943] | committer: 
Anton Khirnov

fftools/ffmpeg_filter: simplify retrieving filter type

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

 fftools/ffmpeg_filter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 41d96267bc..ffbc13eb70 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1472,7 +1472,7 @@ fail:
 static int configure_output_filter(FilterGraph *fg, AVFilterGraph *graph,
OutputFilter *ofilter, AVFilterInOut *out)
 {
-switch (avfilter_pad_get_type(out->filter_ctx->output_pads, out->pad_idx)) 
{
+switch (ofilter->type) {
 case AVMEDIA_TYPE_VIDEO: return configure_output_video_filter(fg, graph, 
ofilter, out);
 case AVMEDIA_TYPE_AUDIO: return configure_output_audio_filter(fg, graph, 
ofilter, out);
 default: av_assert0(0); return 0;

___
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] fftools/ffmpeg_filter: add an AVClass to OutputFilter

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Tue Apr  2 
13:40:42 2024 +0200| [fc6354c39cb06df6b5fcd83364e34b0ef27884f1] | committer: 
Anton Khirnov

fftools/ffmpeg_filter: add an AVClass to OutputFilter

Use it for logging where appropriate, avoid logging to OutputStream as
we do not own it.

This is a step towards decoupling filtering from encoding.

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

 fftools/ffmpeg.h|  2 ++
 fftools/ffmpeg_filter.c | 68 +++--
 2 files changed, 51 insertions(+), 19 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 3c196c25e5..786f925bc6 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -302,6 +302,8 @@ typedef struct InputFilter {
 } InputFilter;
 
 typedef struct OutputFilter {
+const AVClass   *class;
+
 struct OutputStream *ost;
 struct FilterGraph  *graph;
 uint8_t *name;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index ffbc13eb70..840502bd62 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -188,6 +188,9 @@ typedef struct OutputFilterPriv {
 
 int index;
 
+void   *log_parent;
+charlog_name[32];
+
 char   *name;
 
 AVFilterContext*filter;
@@ -629,7 +632,21 @@ static char *describe_filter_link(FilterGraph *fg, 
AVFilterInOut *inout, int in)
avfilter_pad_get_name(pads, inout->pad_idx));
 }
 
-static OutputFilter *ofilter_alloc(FilterGraph *fg)
+static const char *ofilter_item_name(void *obj)
+{
+OutputFilterPriv *ofp = obj;
+return ofp->log_name;
+}
+
+static const AVClass ofilter_class = {
+.class_name= "OutputFilter",
+.version   = LIBAVUTIL_VERSION_INT,
+.item_name = ofilter_item_name,
+.parent_log_context_offset = offsetof(OutputFilterPriv, log_parent),
+.category  = AV_CLASS_CATEGORY_FILTER,
+};
+
+static OutputFilter *ofilter_alloc(FilterGraph *fg, enum AVMediaType type)
 {
 OutputFilterPriv *ofp;
 OutputFilter *ofilter;
@@ -639,10 +656,16 @@ static OutputFilter *ofilter_alloc(FilterGraph *fg)
 return NULL;
 
 ofilter   = >ofilter;
+ofilter->class= _class;
+ofp->log_parent   = fg;
 ofilter->graph= fg;
+ofilter->type = type;
 ofp->format   = -1;
 ofp->index= fg->nb_outputs - 1;
 
+snprintf(ofp->log_name, sizeof(ofp->log_name), "%co%d",
+ av_get_media_type_string(type)[0], ofp->index);
+
 return ofilter;
 }
 
@@ -790,6 +813,14 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream 
*ost,
 if (!ofp->name)
 return AVERROR(EINVAL);
 
+if (fgp->is_simple) {
+// for simple filtergraph there is just one output,
+// so use only graph-level information for logging
+ofp->log_parent = NULL;
+av_strlcpy(ofp->log_name, fgp->log_name, sizeof(ofp->log_name));
+} else
+av_strlcatf(ofp->log_name, sizeof(ofp->log_name), "->%s", ofp->name);
+
 switch (ofilter->type) {
 case AVMEDIA_TYPE_VIDEO:
 ofp->width  = opts->width;
@@ -1025,7 +1056,9 @@ int fg_create(FilterGraph **pfg, char *graph_desc, 
Scheduler *sch)
 }
 
 for (AVFilterInOut *cur = outputs; cur; cur = cur->next) {
-OutputFilter *const ofilter = ofilter_alloc(fg);
+const enum AVMediaType type = 
avfilter_pad_get_type(cur->filter_ctx->output_pads,
+cur->pad_idx);
+OutputFilter *const ofilter = ofilter_alloc(fg, type);
 
 if (!ofilter) {
 ret = AVERROR(ENOMEM);
@@ -1035,8 +1068,6 @@ int fg_create(FilterGraph **pfg, char *graph_desc, 
Scheduler *sch)
 ofilter->linklabel = cur->name;
 cur->name  = NULL;
 
-ofilter->type  = 
avfilter_pad_get_type(cur->filter_ctx->output_pads,
-   cur->pad_idx);
 ofilter->name  = describe_filter_link(fg, cur, 0);
 if (!ofilter->name) {
 ret = AVERROR(ENOMEM);
@@ -1400,7 +1431,7 @@ static int configure_output_audio_filter(FilterGraph *fg, 
AVFilterGraph *graph,
 #define AUTO_INSERT_FILTER(opt_name, filter_name, arg) do { \
 AVFilterContext *filt_ctx;  \
 \
-av_log(fg, AV_LOG_INFO, opt_name " is forwarded to lavfi "  \
+av_log(ofilter, AV_LOG_INFO, opt_name " is forwarded to lavfi " \
"similarly to -

[FFmpeg-cvslog] fftools/ffmpeg_filter: accept a caller-provided output name

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Tue Apr  2 
11:40:41 2024 +0200| [da80e0b077552d1fbd591805705e47931427ea8f] | committer: 
Anton Khirnov

fftools/ffmpeg_filter: accept a caller-provided output name

Do not construct it from OutputStream manually.

Will allow decoupling filtering from encoding in future commits.

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

 fftools/ffmpeg.h  |  3 +++
 fftools/ffmpeg_filter.c   | 36 +++-
 fftools/ffmpeg_mux_init.c |  4 
 3 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 16497105e1..3c196c25e5 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -268,6 +268,9 @@ enum OFilterFlags {
 };
 
 typedef struct OutputFilterOptions {
+// Caller-provided name for this output
+char   *name;
+
 // Codec used for encoding, may be NULL
 const AVCodec  *enc;
 // Overrides encoder pixel formats when set.
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 022c42e9c7..ceab58da19 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -188,6 +188,8 @@ typedef struct OutputFilterPriv {
 
 int index;
 
+char   *name;
+
 AVFilterContext*filter;
 
 /* desired output stream properties */
@@ -784,6 +786,10 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream 
*ost,
 ofp->ts_offset= opts->ts_offset;
 ofp->enc_timebase = opts->output_tb;
 
+ofp->name = av_strdup(opts->name);
+if (!ofp->name)
+return AVERROR(EINVAL);
+
 switch (ofilter->type) {
 case AVMEDIA_TYPE_VIDEO:
 ofp->width  = opts->width;
@@ -911,6 +917,7 @@ void fg_free(FilterGraph **pfg)
 
 av_freep(>linklabel);
 av_freep(>name);
+av_freep(>name);
 av_channel_layout_uninit(>ch_layout);
 av_freep(>outputs[j]);
 }
@@ -1076,9 +1083,8 @@ int init_simple_filtergraph(InputStream *ist, 
OutputStream *ost,
 
 fgp->is_simple = 1;
 
-snprintf(fgp->log_name, sizeof(fgp->log_name), "%cf#%d:%d",
- av_get_media_type_string(ost->type)[0],
- ost->file->index, ost->index);
+snprintf(fgp->log_name, sizeof(fgp->log_name), "%cf%s",
+ av_get_media_type_string(ost->type)[0], opts->name);
 
 if (fg->nb_inputs != 1 || fg->nb_outputs != 1) {
 av_log(fg, AV_LOG_ERROR, "Simple filtergraph '%s' was expected "
@@ -1305,7 +1311,7 @@ static int configure_output_video_filter(FilterGraph *fg, 
AVFilterGraph *graph,
 const char *pix_fmts;
 char name[255];
 
-snprintf(name, sizeof(name), "out_%d_%d", ost->file->index, ost->index);
+snprintf(name, sizeof(name), "out_%s", ofp->name);
 ret = avfilter_graph_create_filter(>filter,
avfilter_get_by_name("buffersink"),
name, NULL, NULL, graph);
@@ -1325,8 +1331,7 @@ static int configure_output_video_filter(FilterGraph *fg, 
AVFilterGraph *graph,
 av_strlcatf(args, sizeof(args), ":%s=%s", e->key, e->value);
 }
 
-snprintf(name, sizeof(name), "scaler_out_%d_%d",
- ost->file->index, ost->index);
+snprintf(name, sizeof(name), "scaler_out_%s", ofp->name);
 if ((ret = avfilter_graph_create_filter(, 
avfilter_get_by_name("scale"),
 name, args, NULL, graph)) < 0)
 return ret;
@@ -1358,8 +1363,7 @@ static int configure_output_video_filter(FilterGraph *fg, 
AVFilterGraph *graph,
 pad_idx = 0;
 }
 
-snprintf(name, sizeof(name), "trim_out_%d_%d",
- ost->file->index, ost->index);
+snprintf(name, sizeof(name), "trim_out_%s", ofp->name);
 ret = insert_trim(of->start_time, of->recording_time,
   _filter, _idx, name);
 if (ret < 0)
@@ -1384,7 +1388,7 @@ static int configure_output_audio_filter(FilterGraph *fg, 
AVFilterGraph *graph,
 char name[255];
 int ret;
 
-snprintf(name, sizeof(name), "out_%d_%d", ost->file->index, ost->index);
+snprintf(name, sizeof(name), "out_%s", ofp->name);
 ret = avfilter_graph_create_filter(>filter,
avfilter_get_by_name("abuffersink"),
name, NULL, NULL, graph);
@@ -1424,8 +1428,7 @@ static int configure_output_audio_filter(FilterGraph *fg, 
AVFilterGraph *graph,
 if (args.len) {
 AVFilterContext *format;
 
-snprintf(name, sizeof(name), "format_out_%d_%

[FFmpeg-cvslog] fftools/ffmpeg_filter: drop a redundant check

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Tue Apr  2 
12:23:05 2024 +0200| [114cbaa316d7d71d942229cd665e76a0a5e3c24b] | committer: 
Anton Khirnov

fftools/ffmpeg_filter: drop a redundant check

fg_finalise_bindings() already checks that all filtergraph outputs are
connected.

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

 fftools/ffmpeg_filter.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index ceab58da19..41d96267bc 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1472,11 +1472,6 @@ fail:
 static int configure_output_filter(FilterGraph *fg, AVFilterGraph *graph,
OutputFilter *ofilter, AVFilterInOut *out)
 {
-if (!ofilter->ost) {
-av_log(fg, AV_LOG_FATAL, "Filter %s has an unconnected output\n", 
ofilter->name);
-return AVERROR(EINVAL);
-}
-
 switch (avfilter_pad_get_type(out->filter_ctx->output_pads, out->pad_idx)) 
{
 case AVMEDIA_TYPE_VIDEO: return configure_output_video_filter(fg, graph, 
ofilter, out);
 case AVMEDIA_TYPE_AUDIO: return configure_output_audio_filter(fg, graph, 
ofilter, out);

___
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] fftools/ffmpeg: drop OutputStream.is_cfr

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Apr  1 
06:29:16 2024 +0200| [82c7c21b1812928f8507a8c91a2070d41cac49ea] | committer: 
Anton Khirnov

fftools/ffmpeg: drop OutputStream.is_cfr

It is used in a single place in the filtering code, so it is better to
inline it there.

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

 fftools/ffmpeg.h  | 1 -
 fftools/ffmpeg_filter.c   | 2 +-
 fftools/ffmpeg_mux_init.c | 1 -
 3 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index fa8f7d8324..16497105e1 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -551,7 +551,6 @@ typedef struct OutputStream {
 /* video only */
 AVRational frame_rate;
 AVRational max_frame_rate;
-int is_cfr;
 int force_fps;
 #if FFMPEG_OPT_TOP
 int top_field_first;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index d906b72576..022c42e9c7 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1956,7 +1956,7 @@ static int choose_out_timebase(OutputFilterPriv *ofp, 
AVFrame *frame)
 fr = fr_sink;
 }
 
-if (ofilter->ost->is_cfr) {
+if (fps->vsync_method == VSYNC_CFR || fps->vsync_method == VSYNC_VSCFR) {
 if (!fr.num && !fps->framerate_max.num) {
 fr = (AVRational){25, 1};
 av_log(ofilter->ost, AV_LOG_WARNING,
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 6ffa4b7491..1791905d7e 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -816,7 +816,6 @@ static int new_stream_video(Muxer *mux, const 
OptionsContext *o,
 *vsync_method = VSYNC_VSCFR;
 }
 }
-ost->is_cfr = (*vsync_method == VSYNC_CFR || *vsync_method == 
VSYNC_VSCFR);
 #if FFMPEG_OPT_VSYNC_DROP
 if (*vsync_method == VSYNC_DROP)
 ms->ts_drop = 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] fftools/ffmpeg_filter: stop accessing encoder AVCodecContext

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Apr  1 
06:29:16 2024 +0200| [bc206ed1b3631801869b1bd4ddb3d3e4dd5f7aef] | committer: 
Anton Khirnov

fftools/ffmpeg_filter: stop accessing encoder AVCodecContext

Pass all the necessary value through OutputFilterOptions.

Will allow decoupling filtering from encoding in future commits.

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

 fftools/ffmpeg.h  |  7 +++
 fftools/ffmpeg_filter.c   | 22 +++---
 fftools/ffmpeg_mux_init.c |  6 ++
 3 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index d0e896dbe7..598ca2fa96 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -282,6 +282,13 @@ typedef struct OutputFilterOptions {
 
 // A combination of OFilterFlags.
 unsignedflags;
+
+int format;
+int width;
+int height;
+
+int sample_rate;
+AVChannelLayout ch_layout;
 } OutputFilterOptions;
 
 typedef struct InputFilter {
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 5661dc960a..3c25d2ed65 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -782,12 +782,12 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream 
*ost,
 ofp->ts_offset= opts->ts_offset;
 ofp->enc_timebase = opts->output_tb;
 
-switch (ost->enc_ctx->codec_type) {
+switch (ofilter->type) {
 case AVMEDIA_TYPE_VIDEO:
-ofp->width  = ost->enc_ctx->width;
-ofp->height = ost->enc_ctx->height;
-if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) {
-ofp->format = ost->enc_ctx->pix_fmt;
+ofp->width  = opts->width;
+ofp->height = opts->height;
+if (opts->format != AV_PIX_FMT_NONE) {
+ofp->format = opts->format;
 } else if (opts->pix_fmts)
 ofp->formats = opts->pix_fmts;
 else if (opts->enc)
@@ -812,19 +812,19 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream 
*ost,
 
 break;
 case AVMEDIA_TYPE_AUDIO:
-if (ost->enc_ctx->sample_fmt != AV_SAMPLE_FMT_NONE) {
-ofp->format = ost->enc_ctx->sample_fmt;
+if (opts->format != AV_SAMPLE_FMT_NONE) {
+ofp->format = opts->format;
 } else if (opts->enc) {
 ofp->formats = opts->enc->sample_fmts;
 }
-if (ost->enc_ctx->sample_rate) {
-ofp->sample_rate = ost->enc_ctx->sample_rate;
+if (opts->sample_rate) {
+ofp->sample_rate = opts->sample_rate;
 } else if (opts->enc) {
 ofp->sample_rates = opts->enc->supported_samplerates;
 }
-if (ost->enc_ctx->ch_layout.nb_channels) {
+if (opts->ch_layout.nb_channels) {
 int ret = set_channel_layout(ofp, opts->enc ? 
opts->enc->ch_layouts : NULL,
- >enc_ctx->ch_layout);
+ >ch_layout);
 if (ret < 0)
 return ret;
 } else if (opts->enc) {
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 04642f5c8b..b031cc59d2 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1378,6 +1378,12 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
 (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) {
 OutputFilterOptions opts = {
 .enc = enc,
+.format  = (type == AVMEDIA_TYPE_VIDEO) ?
+   ost->enc_ctx->pix_fmt : ost->enc_ctx->sample_fmt,
+.width   = ost->enc_ctx->width,
+.height  = ost->enc_ctx->height,
+.sample_rate = ost->enc_ctx->sample_rate,
+.ch_layout   = ost->enc_ctx->ch_layout,
 .output_tb = enc_tb,
 .ts_offset = mux->of.start_time == AV_NOPTS_VALUE ?
  0 : mux->of.start_time,

___
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] fftools/ffmpeg_filter: pass enc_timebase through OutputFilterOptions

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Apr  1 
06:29:16 2024 +0200| [9d5bf2d69e6ad85adbf8a673929192e0b07bc080] | committer: 
Anton Khirnov

fftools/ffmpeg_filter: pass enc_timebase through OutputFilterOptions

Reduces the need to access OutputStream, which will allow decoupling
filtering from encoding in future commits.

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

 fftools/ffmpeg.h  | 7 +--
 fftools/ffmpeg_filter.c   | 2 +-
 fftools/ffmpeg_mux_init.c | 4 +++-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 300ad8a987..56c2fedcc4 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -273,6 +273,11 @@ typedef struct OutputFilterOptions {
 
 int64_t ts_offset;
 
+/* Desired output timebase.
+ * Numerator can be one of EncTimeBase values, or 0 when no preference.
+ */
+AVRational  output_tb;
+
 // A combination of OFilterFlags.
 unsignedflags;
 } OutputFilterOptions;
@@ -529,8 +534,6 @@ typedef struct OutputStream {
 
 AVStream *st;/* stream in the output file */
 
-AVRational enc_timebase;
-
 Encoder *enc;
 AVCodecContext *enc_ctx;
 
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 5f2dbc387e..0b78898af0 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -780,7 +780,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream 
*ost,
 
 ofp->flags= opts->flags;
 ofp->ts_offset= opts->ts_offset;
-ofp->enc_timebase = ost->enc_timebase;
+ofp->enc_timebase = opts->output_tb;
 
 switch (ost->enc_ctx->codec_type) {
 case AVMEDIA_TYPE_VIDEO:
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 8b03d3b108..28090423c6 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1042,6 +1042,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
 const AVCodec *enc;
 AVStream *st;
 int ret = 0, keep_pix_fmt = 0;
+AVRational enc_tb = { 0, 0 };
 const char *bsfs = NULL, *time_base = NULL;
 char *filters = NULL, *next, *codec_tag = NULL;
 double qscale = -1;
@@ -1260,7 +1261,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
 #endif
 }
 
-ost->enc_timebase = q;
+enc_tb = q;
 }
 } else {
 ret = filter_codec_opts(o->g->codec_opts, AV_CODEC_ID_NONE, oc, st,
@@ -1377,6 +1378,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
 (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) {
 OutputFilterOptions opts = {
 .enc = enc,
+.output_tb = enc_tb,
 .ts_offset = mux->of.start_time == AV_NOPTS_VALUE ?
  0 : mux->of.start_time,
 .flags = OFILTER_FLAG_DISABLE_CONVERT * !!keep_pix_fmt,

___
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] fftools/ffmpeg_filter: pass keep_pix_fmt through OutputFilterOptions

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Apr  1 
06:29:16 2024 +0200| [e903c31fd159a48bd6bbc8cb9cdd45fd67727650] | committer: 
Anton Khirnov

fftools/ffmpeg_filter: pass keep_pix_fmt through OutputFilterOptions

Reduces the need to access OutputStream, which will allow decoupling
filtering from encoding in future commits.

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

 fftools/ffmpeg.h  | 9 +++--
 fftools/ffmpeg_filter.c   | 8 +---
 fftools/ffmpeg_mux_init.c | 9 +
 3 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 7288a48aa1..300ad8a987 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -263,11 +263,18 @@ typedef struct InputFilterOptions {
 AVFrame*fallback;
 } InputFilterOptions;
 
+enum OFilterFlags {
+OFILTER_FLAG_DISABLE_CONVERT= (1 << 0),
+};
+
 typedef struct OutputFilterOptions {
 // Codec used for encoding, may be NULL
 const AVCodec  *enc;
 
 int64_t ts_offset;
+
+// A combination of OFilterFlags.
+unsignedflags;
 } OutputFilterOptions;
 
 typedef struct InputFilter {
@@ -556,8 +563,6 @@ typedef struct OutputStream {
 
 char *attachment_filename;
 
-int keep_pix_fmt;
-
 /* stats */
 // number of packets send to the muxer
 atomic_uint_least64_t packets_written;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 8b05262622..5f2dbc387e 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -214,6 +214,8 @@ typedef struct OutputFilterPriv {
 int64_t ts_offset;
 int64_t next_pts;
 FPSConvContext  fps;
+
+unsignedflags;
 } OutputFilterPriv;
 
 static OutputFilterPriv *ofp_from_ofilter(OutputFilter *ofilter)
@@ -355,11 +357,10 @@ static int choose_pix_fmts(OutputFilter *ofilter, 
AVBPrint *bprint,
const char **dst)
 {
 OutputFilterPriv *ofp = ofp_from_ofilter(ofilter);
-OutputStream *ost = ofilter->ost;
 
 *dst = NULL;
 
-if (ost->keep_pix_fmt || ofp->format != AV_PIX_FMT_NONE) {
+if (ofp->flags & OFILTER_FLAG_DISABLE_CONVERT || ofp->format != 
AV_PIX_FMT_NONE) {
 *dst = ofp->format == AV_PIX_FMT_NONE ? NULL :
av_get_pix_fmt_name(ofp->format);
 } else if (ofp->formats) {
@@ -777,6 +778,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream 
*ost,
 ofilter->ost = ost;
 av_freep(>linklabel);
 
+ofp->flags= opts->flags;
 ofp->ts_offset= opts->ts_offset;
 ofp->enc_timebase = ost->enc_timebase;
 
@@ -814,7 +816,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream 
*ost,
 }
 }
 
-fgp->disable_conversions |= ost->keep_pix_fmt;
+fgp->disable_conversions |= !!(ofp->flags & 
OFILTER_FLAG_DISABLE_CONVERT);
 
 ofp->fps.last_frame = av_frame_alloc();
 if (!ofp->fps.last_frame)
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 83eab4276e..d79ae1f491 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -580,7 +580,7 @@ static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, 
const char *name)
 }
 
 static int new_stream_video(Muxer *mux, const OptionsContext *o,
-OutputStream *ost)
+OutputStream *ost, int *keep_pix_fmt)
 {
 AVFormatContext *oc = mux->fc;
 AVStream *st;
@@ -638,7 +638,7 @@ static int new_stream_video(Muxer *mux, const 
OptionsContext *o,
 
 MATCH_PER_STREAM_OPT(frame_pix_fmts, str, frame_pix_fmt, oc, st);
 if (frame_pix_fmt && *frame_pix_fmt == '+') {
-ost->keep_pix_fmt = 1;
+*keep_pix_fmt = 1;
 if (!*++frame_pix_fmt)
 frame_pix_fmt = NULL;
 }
@@ -1041,7 +1041,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
 OutputStream *ost;
 const AVCodec *enc;
 AVStream *st;
-int ret = 0;
+int ret = 0, keep_pix_fmt = 0;
 const char *bsfs = NULL, *time_base = NULL;
 char *filters = NULL, *next, *codec_tag = NULL;
 double qscale = -1;
@@ -1356,7 +1356,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
  ms->copy_initial_nonkeyframes, oc, st);
 
 switch (type) {
-case AVMEDIA_TYPE_VIDEO:  ret = new_stream_video (mux, o, ost); 
break;
+case AVMEDIA_TYPE_VIDEO:  ret = new_stream_video (mux, o, ost, 
_pix_fmt); break;
 case AVMEDIA_TYPE_AUDIO:  ret = new_stream_audio (mux, o, ost); 
break;
 case AVMEDIA_TYPE_SUBTITLE:   ret = new_stream_subtitle  (mux, o, ost); 
break;
 }
@@ -1375,6 +1375,7 @@ static int ost_add(Muxer *mux, const OptionsConte

[FFmpeg-cvslog] fftools/ffmpeg_filter: pass vsync method through OutputFilterOptions

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Apr  1 
06:29:16 2024 +0200| [509afedaafa1c6796dac6c5654a1229d6af945bb] | committer: 
Anton Khirnov

fftools/ffmpeg_filter: pass vsync method through OutputFilterOptions

Do not read it from OutputStream directly.

Will allow decoupling filtering from encoding in future commits.

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

 fftools/ffmpeg.h  |  3 ++-
 fftools/ffmpeg_filter.c   |  9 ++---
 fftools/ffmpeg_mux.c  |  2 +-
 fftools/ffmpeg_mux.h  |  3 +++
 fftools/ffmpeg_mux_init.c | 45 ++---
 5 files changed, 38 insertions(+), 24 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 598ca2fa96..fa8f7d8324 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -287,6 +287,8 @@ typedef struct OutputFilterOptions {
 int width;
 int height;
 
+enum VideoSyncMethod vsync_method;
+
 int sample_rate;
 AVChannelLayout ch_layout;
 } OutputFilterOptions;
@@ -549,7 +551,6 @@ typedef struct OutputStream {
 /* video only */
 AVRational frame_rate;
 AVRational max_frame_rate;
-enum VideoSyncMethod vsync_method;
 int is_cfr;
 int force_fps;
 #if FFMPEG_OPT_TOP
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 3c25d2ed65..d906b72576 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -175,6 +175,8 @@ typedef struct FPSConvContext {
 int   last_dropped;
 int   dropped_keyframe;
 
+enum VideoSyncMethod vsync_method;
+
 AVRationalframerate;
 AVRationalframerate_max;
 const AVRational *framerate_supported;
@@ -799,6 +801,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream 
*ost,
 if (!ofp->fps.last_frame)
 return AVERROR(ENOMEM);
 
+ofp->fps.vsync_method= opts->vsync_method;
 ofp->fps.framerate   = ost->frame_rate;
 ofp->fps.framerate_max   = ost->max_frame_rate;
 ofp->fps.framerate_supported = ost->force_fps && opts->enc ?
@@ -2072,9 +2075,9 @@ static void video_sync_process(OutputFilterPriv *ofp, 
AVFrame *frame,
 
 if (delta0 < 0 &&
 delta > 0 &&
-ost->vsync_method != VSYNC_PASSTHROUGH
+fps->vsync_method != VSYNC_PASSTHROUGH
 #if FFMPEG_OPT_VSYNC_DROP
-&& ost->vsync_method != VSYNC_DROP
+&& fps->vsync_method != VSYNC_DROP
 #endif
 ) {
 if (delta0 < -0.6) {
@@ -2086,7 +2089,7 @@ static void video_sync_process(OutputFilterPriv *ofp, 
AVFrame *frame,
 delta0 = 0;
 }
 
-switch (ost->vsync_method) {
+switch (fps->vsync_method) {
 case VSYNC_VSCFR:
 if (fps->frame_number == 0 && delta0 >= 0.5) {
 av_log(ost, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", 
(int)lrintf(delta0));
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index e8e5c677b8..253c2e58d4 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -140,7 +140,7 @@ static int mux_fixup_ts(Muxer *mux, MuxStream *ms, AVPacket 
*pkt)
 OutputStream *ost = >ost;
 
 #if FFMPEG_OPT_VSYNC_DROP
-if (ost->type == AVMEDIA_TYPE_VIDEO && ost->vsync_method == VSYNC_DROP)
+if (ost->type == AVMEDIA_TYPE_VIDEO && ms->ts_drop)
 pkt->pts = pkt->dts = AV_NOPTS_VALUE;
 #endif
 
diff --git a/fftools/ffmpeg_mux.h b/fftools/ffmpeg_mux.h
index 16af6d38ba..f8b6f7a790 100644
--- a/fftools/ffmpeg_mux.h
+++ b/fftools/ffmpeg_mux.h
@@ -75,6 +75,9 @@ typedef struct MuxStream {
 int copy_initial_nonkeyframes;
 int copy_prior_start;
 int streamcopy_started;
+#if FFMPEG_OPT_VSYNC_DROP
+int ts_drop;
+#endif
 } MuxStream;
 
 typedef struct Muxer {
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index b031cc59d2..6ffa4b7491 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -580,8 +580,10 @@ static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, 
const char *name)
 }
 
 static int new_stream_video(Muxer *mux, const OptionsContext *o,
-OutputStream *ost, int *keep_pix_fmt)
+OutputStream *ost, int *keep_pix_fmt,
+enum VideoSyncMethod *vsync_method)
 {
+MuxStream   *ms = ms_from_ost(ost);
 AVFormatContext *oc = mux->fc;
 AVStream *st;
 char *frame_rate = NULL, *max_frame_rate = NULL, *frame_aspect_ratio = 
NULL;
@@ -773,49 +775,52 @@ static int new_stream_video(Muxer *mux, const 
OptionsContext *o,
 #endif
 
 #if FFMPEG_OPT_VSYNC
-ost->vsync_method = video_sync_method;
+*vsync_method = video_sync_method;
 #else
-   

[FFmpeg-cvslog] fftools/ffmpeg_filter: move the MJPEG format selection hack to muxer setup

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Apr  1 
07:50:31 2024 +0200| [17702c5f7bfdd02bda3a29971d6d564c01971988] | committer: 
Anton Khirnov

fftools/ffmpeg_filter: move the MJPEG format selection hack to muxer setup

That, if anywhere, is a more appropriate place for it.

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

 fftools/ffmpeg.h  |  2 ++
 fftools/ffmpeg_filter.c   | 29 +++--
 fftools/ffmpeg_mux_init.c | 24 
 3 files changed, 29 insertions(+), 26 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 56c2fedcc4..d0e896dbe7 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -270,6 +270,8 @@ enum OFilterFlags {
 typedef struct OutputFilterOptions {
 // Codec used for encoding, may be NULL
 const AVCodec  *enc;
+// Overrides encoder pixel formats when set.
+const enum AVPixelFormat *pix_fmts;
 
 int64_t ts_offset;
 
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 0b78898af0..5661dc960a 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -788,34 +788,11 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream 
*ost,
 ofp->height = ost->enc_ctx->height;
 if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) {
 ofp->format = ost->enc_ctx->pix_fmt;
-} else if (opts->enc) {
+} else if (opts->pix_fmts)
+ofp->formats = opts->pix_fmts;
+else if (opts->enc)
 ofp->formats = opts->enc->pix_fmts;
 
-// MJPEG encoder exports a full list of supported pixel formats,
-// but the full-range ones are experimental-only.
-// Restrict the auto-conversion list unless -strict experimental
-// has been specified.
-if (!strcmp(opts->enc->name, "mjpeg")) {
-// FIXME: YUV420P etc. are actually supported with full color 
range,
-// yet the latter information isn't available here.
-static const enum AVPixelFormat mjpeg_formats[] =
-{ AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, 
AV_PIX_FMT_YUVJ444P,
-  AV_PIX_FMT_NONE };
-
-const AVDictionaryEntry *strict = 
av_dict_get(ost->encoder_opts, "strict", NULL, 0);
-int strict_val = ost->enc_ctx->strict_std_compliance;
-
-if (strict) {
-const AVOption *o = av_opt_find(ost->enc_ctx, strict->key, 
NULL, 0, 0);
-av_assert0(o);
-av_opt_eval_int(ost->enc_ctx, o, strict->value, 
_val);
-}
-
-if (strict_val > FF_COMPLIANCE_UNOFFICIAL)
-ofp->formats = mjpeg_formats;
-}
-}
-
 fgp->disable_conversions |= !!(ofp->flags & 
OFILTER_FLAG_DISABLE_CONVERT);
 
 ofp->fps.last_frame = av_frame_alloc();
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 28090423c6..04642f5c8b 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1384,6 +1384,30 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
 .flags = OFILTER_FLAG_DISABLE_CONVERT * !!keep_pix_fmt,
 };
 
+// MJPEG encoder exports a full list of supported pixel formats,
+// but the full-range ones are experimental-only.
+// Restrict the auto-conversion list unless -strict experimental
+// has been specified.
+if (!strcmp(enc->name, "mjpeg")) {
+// FIXME: YUV420P etc. are actually supported with full color 
range,
+// yet the latter information isn't available here.
+static const enum AVPixelFormat mjpeg_formats[] =
+{ AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, 
AV_PIX_FMT_YUVJ444P,
+  AV_PIX_FMT_NONE };
+
+const AVDictionaryEntry *strict = av_dict_get(ost->encoder_opts, 
"strict", NULL, 0);
+int strict_val = ost->enc_ctx->strict_std_compliance;
+
+if (strict) {
+const AVOption *o = av_opt_find(ost->enc_ctx, strict->key, 
NULL, 0, 0);
+av_assert0(o);
+av_opt_eval_int(ost->enc_ctx, o, strict->value, _val);
+}
+
+if (strict_val > FF_COMPLIANCE_UNOFFICIAL)
+opts.pix_fmts = mjpeg_formats;
+}
+
 if (ofilter) {
 ost->filter   = ofilter;
 ret = ofilter_bind_ost(ofilter, ost, ms->sch_idx_enc, );

___
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] fftools/ffmpeg: warn about ignored -enc_time_base for subtitles earlier

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Apr  1 
07:36:01 2024 +0200| [606c71bb117ab32eb91cfa5b8e14594023fb1175] | committer: 
Anton Khirnov

fftools/ffmpeg: warn about ignored -enc_time_base for subtitles earlier

Can do it as soon as that option is parsed, no need to postpone it until
opening the encoder.

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

 fftools/ffmpeg_enc.c  | 3 ---
 fftools/ffmpeg_mux_init.c | 6 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index d1d1526830..618ba193ff 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -280,9 +280,6 @@ int enc_open(void *opaque, const AVFrame *frame)
 break;
 }
 case AVMEDIA_TYPE_SUBTITLE:
-if (ost->enc_timebase.num)
-av_log(ost, AV_LOG_WARNING,
-   "-enc_time_base not supported for subtitles, ignoring\n");
 enc_ctx->time_base = AV_TIME_BASE_Q;
 
 if (!enc_ctx->width) {
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index d79ae1f491..8b03d3b108 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1233,8 +1233,12 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
 }
 
 MATCH_PER_STREAM_OPT(enc_time_bases, str, enc_time_base, oc, st);
-if (enc_time_base) {
+if (enc_time_base && type == AVMEDIA_TYPE_SUBTITLE)
+av_log(ost, AV_LOG_WARNING,
+   "-enc_time_base not supported for subtitles, ignoring\n");
+else if (enc_time_base) {
 AVRational q;
+
 if (!strcmp(enc_time_base, "demux")) {
 q = (AVRational){ ENC_TIME_BASE_DEMUX, 0 };
 } else if (!strcmp(enc_time_base, "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] fftools/ffmpeg_filter: pass ts offset through OutputFilterOptions

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Apr  1 
06:29:16 2024 +0200| [b3864e7a080d5716d6a6d8dd8e327ed6c6dd2d2f] | committer: 
Anton Khirnov

fftools/ffmpeg_filter: pass ts offset through OutputFilterOptions

Reduces the need to access OutputFile, which will allow decoupling
filtering from encoding in future commits.

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

 fftools/ffmpeg.h  | 2 ++
 fftools/ffmpeg_filter.c   | 3 +--
 fftools/ffmpeg_mux_init.c | 2 ++
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 8455cb23e4..7288a48aa1 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -266,6 +266,8 @@ typedef struct InputFilterOptions {
 typedef struct OutputFilterOptions {
 // Codec used for encoding, may be NULL
 const AVCodec  *enc;
+
+int64_t ts_offset;
 } OutputFilterOptions;
 
 typedef struct InputFilter {
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index a59c61b312..8b05262622 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -766,7 +766,6 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream 
*ost,
  unsigned sched_idx_enc,
  const OutputFilterOptions *opts)
 {
-const OutputFile  *of = ost->file;
 OutputFilterPriv *ofp = ofp_from_ofilter(ofilter);
 FilterGraph  *fg = ofilter->graph;
 FilterGraphPriv *fgp = fgp_from_fg(fg);
@@ -778,7 +777,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream 
*ost,
 ofilter->ost = ost;
 av_freep(>linklabel);
 
-ofp->ts_offset = of->start_time == AV_NOPTS_VALUE ? 0 : of->start_time;
+ofp->ts_offset= opts->ts_offset;
 ofp->enc_timebase = ost->enc_timebase;
 
 switch (ost->enc_ctx->codec_type) {
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index b5869feb80..83eab4276e 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1373,6 +1373,8 @@ static int ost_add(Muxer *mux, const OptionsContext *o, 
enum AVMediaType type,
 (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) {
 OutputFilterOptions opts = {
 .enc = enc,
+.ts_offset = mux->of.start_time == AV_NOPTS_VALUE ?
+ 0 : mux->of.start_time,
 };
 
 if (ofilter) {

___
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] fftools/ffmpeg_filter: do not pass OutputStream to set_channel_layout()

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri Mar 29 
10:15:49 2024 +0100| [8c330853131e1d1f75c6238784596235af2e9603] | committer: 
Anton Khirnov

fftools/ffmpeg_filter: do not pass OutputStream to set_channel_layout()

It only needs a list of allowed layouts and the requested layout.

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

 fftools/ffmpeg_filter.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 2308abf82a..ba6c6c7673 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -722,42 +722,42 @@ static int ifilter_bind_dec(InputFilterPriv *ifp, Decoder 
*dec)
 return 0;
 }
 
-static int set_channel_layout(OutputFilterPriv *f, OutputStream *ost)
+static int set_channel_layout(OutputFilterPriv *f, const AVChannelLayout 
*layouts_allowed,
+  const AVChannelLayout *layout_requested)
 {
-const AVCodec *c = ost->enc_ctx->codec;
 int i, err;
 
-if (ost->enc_ctx->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) {
+if (layout_requested->order != AV_CHANNEL_ORDER_UNSPEC) {
 /* Pass the layout through for all orders but UNSPEC */
-err = av_channel_layout_copy(>ch_layout, >enc_ctx->ch_layout);
+err = av_channel_layout_copy(>ch_layout, layout_requested);
 if (err < 0)
 return err;
 return 0;
 }
 
 /* Requested layout is of order UNSPEC */
-if (!c->ch_layouts) {
+if (!layouts_allowed) {
 /* Use the default native layout for the requested amount of channels 
when the
encoder doesn't have a list of supported layouts */
-av_channel_layout_default(>ch_layout, 
ost->enc_ctx->ch_layout.nb_channels);
+av_channel_layout_default(>ch_layout, 
layout_requested->nb_channels);
 return 0;
 }
 /* Encoder has a list of supported layouts. Pick the first layout in it 
with the
same amount of channels as the requested layout */
-for (i = 0; c->ch_layouts[i].nb_channels; i++) {
-if (c->ch_layouts[i].nb_channels == 
ost->enc_ctx->ch_layout.nb_channels)
+for (i = 0; layouts_allowed[i].nb_channels; i++) {
+if (layouts_allowed[i].nb_channels == layout_requested->nb_channels)
 break;
 }
-if (c->ch_layouts[i].nb_channels) {
+if (layouts_allowed[i].nb_channels) {
 /* Use it if one is found */
-err = av_channel_layout_copy(>ch_layout, >ch_layouts[i]);
+err = av_channel_layout_copy(>ch_layout, _allowed[i]);
 if (err < 0)
 return err;
 return 0;
 }
 /* If no layout for the amount of channels requested was found, use the 
default
native layout for it. */
-av_channel_layout_default(>ch_layout, 
ost->enc_ctx->ch_layout.nb_channels);
+av_channel_layout_default(>ch_layout, layout_requested->nb_channels);
 
 return 0;
 }
@@ -844,7 +844,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream 
*ost,
 ofp->sample_rates = c->supported_samplerates;
 }
 if (ost->enc_ctx->ch_layout.nb_channels) {
-int ret = set_channel_layout(ofp, ost);
+int ret = set_channel_layout(ofp, c->ch_layouts, 
>enc_ctx->ch_layout);
 if (ret < 0)
 return ret;
 } else if (c->ch_layouts) {

___
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] fftools/ffmpeg_filter: check that filter type matches output stream type

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Apr  1 
06:23:58 2024 +0200| [651c79da362b4a9f618458ddd08b92504ffb3b6d] | committer: 
Anton Khirnov

fftools/ffmpeg_filter: check that filter type matches output stream type

For simple filtergraphs. For complex filtergraphs they always match.

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

 fftools/ffmpeg_filter.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 0d359303f7..a59c61b312 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -773,6 +773,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream 
*ost,
 int ret;
 
 av_assert0(!ofilter->ost);
+av_assert0(ofilter->type == ost->type);
 
 ofilter->ost = ost;
 av_freep(>linklabel);
@@ -1106,6 +1107,13 @@ int init_simple_filtergraph(InputStream *ist, 
OutputStream *ost,
graph_desc, fg->nb_inputs, fg->nb_outputs);
 return AVERROR(EINVAL);
 }
+if (fg->outputs[0]->type != ost->type) {
+av_log(fg, AV_LOG_ERROR, "Filtergraph has a %s output, cannot connect "
+   "it to %s output stream\n",
+   av_get_media_type_string(fg->outputs[0]->type),
+   av_get_media_type_string(ost->type));
+return AVERROR(EINVAL);
+}
 
 ost->filter = fg->outputs[0];
 

___
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] fftools/ffmpeg_filter: stop accessing AVCodecContext.codec

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Apr  1 
06:07:45 2024 +0200| [8e35e33d42efb89ff7e3da92b841a3b43a5a95bc] | committer: 
Anton Khirnov

fftools/ffmpeg_filter: stop accessing AVCodecContext.codec

Instead pass the encoder through a newly-added output options struct,
analogous to previously added input options.

Will allow decoupling filtering from encoding in future commits.

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

 fftools/ffmpeg.h  | 11 +--
 fftools/ffmpeg_filter.c   | 36 +++-
 fftools/ffmpeg_mux_init.c |  8 ++--
 3 files changed, 34 insertions(+), 21 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index a575ee70d5..8455cb23e4 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -263,6 +263,11 @@ typedef struct InputFilterOptions {
 AVFrame*fallback;
 } InputFilterOptions;
 
+typedef struct OutputFilterOptions {
+// Codec used for encoding, may be NULL
+const AVCodec  *enc;
+} OutputFilterOptions;
+
 typedef struct InputFilter {
 struct FilterGraph *graph;
 uint8_t*name;
@@ -684,7 +689,8 @@ int parse_and_set_vsync(const char *arg, int *vsync_var, 
int file_idx, int st_id
 int filtergraph_is_simple(const FilterGraph *fg);
 int init_simple_filtergraph(InputStream *ist, OutputStream *ost,
 char *graph_desc,
-Scheduler *sch, unsigned sch_idx_enc);
+Scheduler *sch, unsigned sch_idx_enc,
+const OutputFilterOptions *opts);
 int fg_finalise_bindings(FilterGraph *fg);
 
 /**
@@ -699,7 +705,8 @@ FrameData   *packet_data  (AVPacket *pkt);
 const FrameData *packet_data_c(AVPacket *pkt);
 
 int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost,
- unsigned sched_idx_enc);
+ unsigned sched_idx_enc,
+ const OutputFilterOptions *opts);
 
 /**
  * Create a new filtergraph in the global filtergraph list.
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index ba6c6c7673..0d359303f7 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -763,13 +763,13 @@ static int set_channel_layout(OutputFilterPriv *f, const 
AVChannelLayout *layout
 }
 
 int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost,
- unsigned sched_idx_enc)
+ unsigned sched_idx_enc,
+ const OutputFilterOptions *opts)
 {
 const OutputFile  *of = ost->file;
 OutputFilterPriv *ofp = ofp_from_ofilter(ofilter);
 FilterGraph  *fg = ofilter->graph;
 FilterGraphPriv *fgp = fgp_from_fg(fg);
-const AVCodec *c = ost->enc_ctx->codec;
 int ret;
 
 av_assert0(!ofilter->ost);
@@ -786,14 +786,14 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream 
*ost,
 ofp->height = ost->enc_ctx->height;
 if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) {
 ofp->format = ost->enc_ctx->pix_fmt;
-} else {
-ofp->formats = c->pix_fmts;
+} else if (opts->enc) {
+ofp->formats = opts->enc->pix_fmts;
 
 // MJPEG encoder exports a full list of supported pixel formats,
 // but the full-range ones are experimental-only.
 // Restrict the auto-conversion list unless -strict experimental
 // has been specified.
-if (!strcmp(c->name, "mjpeg")) {
+if (!strcmp(opts->enc->name, "mjpeg")) {
 // FIXME: YUV420P etc. are actually supported with full color 
range,
 // yet the latter information isn't available here.
 static const enum AVPixelFormat mjpeg_formats[] =
@@ -822,11 +822,11 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream 
*ost,
 
 ofp->fps.framerate   = ost->frame_rate;
 ofp->fps.framerate_max   = ost->max_frame_rate;
-ofp->fps.framerate_supported = ost->force_fps ?
-   NULL : c->supported_framerates;
+ofp->fps.framerate_supported = ost->force_fps && opts->enc ?
+   NULL : opts->enc->supported_framerates;
 
 // reduce frame rate for mpeg4 to be within the spec limits
-if (c->id == AV_CODEC_ID_MPEG4)
+if (opts->enc && opts->enc->id == AV_CODEC_ID_MPEG4)
 ofp->fps.framerate_clip = 65535;
 
 ofp->fps.dup_warning = 1000;
@@ -835,20 +835,21 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream 
*ost,
 case AVMEDIA_TYPE_AUDIO:
 if (ost->enc_ctx->sample_fmt != AV_SAMPLE_FMT_NONE) {
 ofp->format = ost->enc_ctx->sample_fmt;
-} else {
-   

[FFmpeg-cvslog] lavfi/vf_scale: fix AVOption flags for "size"/"s"

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri Apr  5 
13:38:45 2024 +0200| [b0e1bc6298ceda81b8f88acdb96d023f1bf00d80] | committer: 
Anton Khirnov

lavfi/vf_scale: fix AVOption flags for "size"/"s"

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

 libavfilter/vf_scale.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index fc0e3802db..1c07daeddf 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -998,8 +998,8 @@ static const AVOption scale_options[] = {
 { "height","Output video height", OFFSET(h_expr),
AV_OPT_TYPE_STRING,.flags = TFLAGS },
 { "flags", "Flags to pass to libswscale", OFFSET(flags_str), 
AV_OPT_TYPE_STRING, { .str = "" }, .flags = FLAGS },
 { "interl", "set interlacing", OFFSET(interlaced), AV_OPT_TYPE_BOOL, {.i64 
= 0 }, -1, 1, FLAGS },
-{ "size",   "set video size",  OFFSET(size_str), 
AV_OPT_TYPE_STRING, {.str = NULL}, 0, FLAGS },
-{ "s",  "set video size",  OFFSET(size_str), 
AV_OPT_TYPE_STRING, {.str = NULL}, 0, FLAGS },
+{ "size",   "set video size",  OFFSET(size_str), 
AV_OPT_TYPE_STRING, {.str = NULL}, 0, .flags = FLAGS },
+{ "s",  "set video size",  OFFSET(size_str), 
AV_OPT_TYPE_STRING, {.str = NULL}, 0, .flags = FLAGS },
 {  "in_color_matrix", "set input YCbCr type",   OFFSET(in_color_matrix),  
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, AVCOL_SPC_NB-1, .flags = FLAGS, .unit = 
"color" },
 { "out_color_matrix", "set output YCbCr type",  OFFSET(out_color_matrix), 
AV_OPT_TYPE_INT, { .i64 = AVCOL_SPC_UNSPECIFIED }, 0, AVCOL_SPC_NB-1, .flags = 
FLAGS, .unit = "color"},
 { "auto",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = -1 },
 0, 0, FLAGS, .unit = "color" },

___
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] lavfi/avfilter: add an "auto" constant to the threads option

2024-04-09 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Thu Apr  4 
11:19:12 2024 +0200| [d7cde009ce7884995bb38505a26e819b9f57a3d2] | committer: 
Anton Khirnov

lavfi/avfilter: add an "auto" constant to the threads option

Analogous to the same constant in avfiltergraph and avcodec.
Cf. f599ae88c25.

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

 libavfilter/avfilter.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 7f94e71fbc..049e4f62ca 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -652,7 +652,8 @@ static const AVOption avfilter_options[] = {
 { "slice", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVFILTER_THREAD_SLICE 
}, .flags = FLAGS, .unit = "thread_type" },
 { "enable", "set enable expression", OFFSET(enable_str), 
AV_OPT_TYPE_STRING, {.str=NULL}, .flags = TFLAGS },
 { "threads", "Allowed number of threads", OFFSET(nb_threads), 
AV_OPT_TYPE_INT,
-{ .i64 = 0 }, 0, INT_MAX, FLAGS },
+{ .i64 = 0 }, 0, INT_MAX, FLAGS, .unit = "threads" },
+{"auto", "autodetect a suitable number of threads to use", 0, 
AV_OPT_TYPE_CONST, {.i64 = 0 }, .flags = FLAGS, .unit = "threads"},
 { "extra_hw_frames", "Number of extra hardware frames to allocate for the 
user",
 OFFSET(extra_hw_frames), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, 
FLAGS },
 { NULL },

___
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] lavc/pthread_frame: avoid leaving stale hwaccel state in worker threads

2024-04-03 Thread Anton Khirnov
ffmpeg | branch: release/4.3 | Anton Khirnov  | Fri Sep  2 
22:21:27 2022 +0200| [031c9601d06759a748adc077f73e3005b5571be1] | committer: 
James Almer

lavc/pthread_frame: avoid leaving stale hwaccel state in worker threads

This state is not refcounted, so make sure it always has a well-defined
owner.

Remove the block added in 091341f2ab5bd35ca1a2aae90503adc74f8d3523, as
this commit also solves that issue in a more general way.

(cherry picked from commit cc867f2c09d2b69cee8a0eccd62aff002cbbfe11)
Signed-off-by: Anton Khirnov 
(cherry picked from commit 35aa7e70e7ec350319e7634a30d8d8aa1e6ecdda)
Signed-off-by: Anton Khirnov 
(cherry picked from commit 3bc28e9d1ab33627cea3c632dd6b0c33e22e93ba)
Signed-off-by: Anton Khirnov 
(cherry picked from commit d4b7b3c03ee2baf0166ce49dff17ec9beff684db)

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

 libavcodec/pthread_frame.c | 46 +++---
 1 file changed, 35 insertions(+), 11 deletions(-)

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 601f170447..f232e59b62 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -135,6 +135,12 @@ typedef struct FrameThreadContext {
 * Set for the first N packets, where N is 
the number of threads.
 * While it is set, 
ff_thread_en/decode_frame won't return any results.
 */
+
+/* hwaccel state is temporarily stored here in order to transfer its 
ownership
+ * to the next decoding thread without the need for extra synchronization 
*/
+const AVHWAccel *stash_hwaccel;
+void*stash_hwaccel_context;
+void*stash_hwaccel_priv;
 } FrameThreadContext;
 
 #define THREAD_SAFE_CALLBACKS(avctx) \
@@ -211,9 +217,17 @@ static attribute_align_arg void *frame_worker_thread(void 
*arg)
 ff_thread_finish_setup(avctx);
 
 if (p->hwaccel_serializing) {
+/* wipe hwaccel state to avoid stale pointers lying around;
+ * the state was transferred to FrameThreadContext in
+ * ff_thread_finish_setup(), so nothing is leaked */
+avctx->hwaccel = NULL;
+avctx->hwaccel_context = NULL;
+avctx->internal->hwaccel_priv_data = NULL;
+
 p->hwaccel_serializing = 0;
 pthread_mutex_unlock(>parent->hwaccel_mutex);
 }
+av_assert0(!avctx->hwaccel);
 
 if (p->async_serializing) {
 p->async_serializing = 0;
@@ -275,14 +289,10 @@ static int update_context_from_thread(AVCodecContext 
*dst, AVCodecContext *src,
 dst->color_range = src->color_range;
 dst->chroma_sample_location = src->chroma_sample_location;
 
-dst->hwaccel = src->hwaccel;
-dst->hwaccel_context = src->hwaccel_context;
-
 dst->channels   = src->channels;
 dst->sample_rate= src->sample_rate;
 dst->sample_fmt = src->sample_fmt;
 dst->channel_layout = src->channel_layout;
-dst->internal->hwaccel_priv_data = src->internal->hwaccel_priv_data;
 
 if (!!dst->hw_frames_ctx != !!src->hw_frames_ctx ||
 (dst->hw_frames_ctx && dst->hw_frames_ctx->data != 
src->hw_frames_ctx->data)) {
@@ -426,6 +436,12 @@ static int submit_packet(PerThreadContext *p, 
AVCodecContext *user_avctx,
 pthread_mutex_unlock(>mutex);
 return err;
 }
+
+/* transfer hwaccel state stashed from previous thread, if any */
+av_assert0(!p->avctx->hwaccel);
+FFSWAP(const AVHWAccel*, p->avctx->hwaccel, 
fctx->stash_hwaccel);
+FFSWAP(void*,p->avctx->hwaccel_context, 
fctx->stash_hwaccel_context);
+FFSWAP(void*,p->avctx->internal->hwaccel_priv_data, 
fctx->stash_hwaccel_priv);
 }
 
 av_packet_unref(>avpkt);
@@ -627,6 +643,14 @@ void ff_thread_finish_setup(AVCodecContext *avctx) {
 async_lock(p->parent);
 }
 
+/* save hwaccel state for passing to the next thread;
+ * this is done here so that this worker thread can wipe its own hwaccel
+ * state after decoding, without requiring synchronization */
+av_assert0(!p->parent->stash_hwaccel);
+p->parent->stash_hwaccel = avctx->hwaccel;
+p->parent->stash_hwaccel_context = avctx->hwaccel_context;
+p->parent->stash_hwaccel_priv= avctx->internal->hwaccel_priv_data;
+
 pthread_mutex_lock(>progress_mutex);
 if(atomic_load(>state) == STATE_SETUP_FINISHED){
 av_log(avctx, AV_LOG_WARNING, "Multiple ff_thread_finish_setup() 
cal

[FFmpeg-cvslog] doc/community: update conflict of interest rule according to GA vote

2024-04-01 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon Apr  1 
15:35:41 2024 +0200| [63f56c99433e68f1360c015f8364cddb99d9dd95] | committer: 
Anton Khirnov

doc/community: update conflict of interest rule according to GA vote

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

 doc/community.texi | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/doc/community.texi b/doc/community.texi
index 90d2b6f366..97a49f15ed 100644
--- a/doc/community.texi
+++ b/doc/community.texi
@@ -82,8 +82,6 @@ The TC has 2 modes of operation: a RFC one and an internal 
one.
 
 If the TC thinks it needs the input from the larger community, the TC can call 
for a RFC. Else, it can decide by itself.
 
-If the disagreement involves a member of the TC, that member should recuse 
themselves from the decision.
-
 The decision to use a RFC process or an internal discussion is a discretionary 
decision of the TC.
 
 The TC can also reject a seizure for a few reasons such as: the matter was not 
discussed enough previously; it lacks expertise to reach a beneficial decision 
on the matter; or the matter is too trivial.
@@ -123,6 +121,13 @@ The decisions from the TC will be sent on the mailing 
list, with the [TC] tag.
 
 Internally, the TC should take decisions with a majority, or using 
ranked-choice voting.
 
+Each TC member must vote on such decision according to what is, in their view, 
best for the project.
+
+If a TC member feels they are affected by a conflict of interest with regards 
to the case, they should announce it and recuse themselves from the TC
+discussion and vote.
+
+A conflict of interest is presumed to occur when a TC member has a personal 
interest (e.g. financial) in a specific outcome of the case.
+
 The decision from the TC should be published with a summary of the reasons 
that lead to this decision.
 
 The decisions from the TC are final, until the matters are reopened after no 
less than one year.

___
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] lavf/vf_setpts: unset output framerate

2024-04-01 Thread Anton Khirnov
ffmpeg | branch: release/7.0 | Anton Khirnov  | Wed Mar 27 
13:55:26 2024 +0100| [43fd3d5df6a19fc768a33e37855aa7f8c7050cf0] | committer: 
Anton Khirnov

lavf/vf_setpts: unset output framerate

This filter produces VFR output in general.

Avoids dropping frames in the setpts test.

(cherry picked from commit f121d954ac89060cb7b07da230479cffe5bf9e5c)
Signed-off-by: Anton Khirnov 

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

 libavfilter/setpts.c | 17 -
 tests/ref/fate/filter-setpts | 89 +---
 2 files changed, 67 insertions(+), 39 deletions(-)

diff --git a/libavfilter/setpts.c b/libavfilter/setpts.c
index 88a8d6af86..4f02a9a617 100644
--- a/libavfilter/setpts.c
+++ b/libavfilter/setpts.c
@@ -150,6 +150,13 @@ static int config_input(AVFilterLink *inlink)
 return 0;
 }
 
+static int config_output_video(AVFilterLink *outlink)
+{
+outlink->frame_rate = (AVRational){ 1, 0 };
+
+return 0;
+}
+
 #define BUF_SIZE 64
 
 static inline char *double2int64str(char *buf, double v)
@@ -322,6 +329,14 @@ static const AVFilterPad avfilter_vf_setpts_inputs[] = {
 },
 };
 
+static const AVFilterPad outputs_video[] = {
+{
+.name = "default",
+.type = AVMEDIA_TYPE_VIDEO,
+.config_props = config_output_video,
+},
+};
+
 const AVFilter ff_vf_setpts = {
 .name= "setpts",
 .description = NULL_IF_CONFIG_SMALL("Set PTS for the output video 
frame."),
@@ -335,7 +350,7 @@ const AVFilter ff_vf_setpts = {
 .priv_class = _class,
 
 FILTER_INPUTS(avfilter_vf_setpts_inputs),
-FILTER_OUTPUTS(ff_video_default_filterpad),
+FILTER_OUTPUTS(outputs_video),
 };
 #endif /* CONFIG_SETPTS_FILTER */
 
diff --git a/tests/ref/fate/filter-setpts b/tests/ref/fate/filter-setpts
index efdcf6a16e..8aa7a1e6a0 100644
--- a/tests/ref/fate/filter-setpts
+++ b/tests/ref/fate/filter-setpts
@@ -1,42 +1,55 @@
-#tb 0: 1/25
+#tb 0: 1/1000
 #media_type 0: video
 #codec_id 0: rawvideo
 #dimensions 0: 352x288
 #sar 0: 0/1
-0,  0,  0,1,   152064, 0x05b789ef
-0,  1,  1,1,   152064, 0x4bb46551
-0,  2,  2,1,   152064, 0x9dddf64a
-0,  3,  3,1,   152064, 0x2a8380b0
-0,  4,  4,1,   152064, 0x4de3b652
-0,  5,  5,1,   152064, 0xedb5a8e6
-0,  6,  6,1,   152064, 0x5ab58bac
-0,  7,  7,1,   152064, 0x1f1b8026
-0,  8,  8,1,   152064, 0x91373915
-0,  9,  9,1,   152064, 0x30f5fcd5
-0, 10, 10,1,   152064, 0xc711ad61
-0, 11, 11,1,   152064, 0x52a48ddd
-0, 12, 12,1,   152064, 0xa91c0f05
-0, 13, 13,1,   152064, 0x8e364e18
-0, 14, 14,1,   152064, 0xf25f6acc
-0, 15, 15,1,   152064, 0xf34ddbff
-0, 16, 16,1,   152064, 0x9dc72412
-0, 17, 17,1,   152064, 0x445d1d59
-0, 18, 18,1,   152064, 0x2f2768ef
-0, 19, 19,1,   152064, 0x95579936
-0, 20, 20,1,   152064, 0x43d796b5
-0, 21, 21,1,   152064, 0x76d2a455
-0, 22, 22,1,   152064, 0x6dc3650e
-0, 23, 23,1,   152064, 0x0f9d6aca
-0, 24, 24,1,   152064, 0xd766fc8d
-0, 25, 25,1,   152064, 0xe22f7a30
-0, 26, 26,1,   152064, 0xfa8d94fb
-0, 27, 27,1,   152064, 0x4c9737ab
-0, 28, 28,1,   152064, 0xa50d01f8
-0, 29, 29,1,   152064, 0x88734edd
-0, 30, 30,1,   152064, 0xd2735925
-0, 31, 31,1,   152064, 0x20cebfa9
-0, 32, 32,1,   152064, 0x575c20ec
-0, 33, 33,1,   152064, 0x61b47e73
-0, 34, 34,1,   152064, 0x09ef53ff
-0, 35, 35,1,   152064, 0x6e88c5c2
-0, 36, 36,1,   152064, 0x4bbad8ea
+0,  0,  0,   40,   152064, 0x05b789ef
+0, 28, 28,   40,   152064, 0x4bb46551
+0, 57, 57,   40,   152064, 0x9dddf64a
+0, 86, 86,   40,   152064, 0x2a8380b0
+0,115,115,   40,   152064, 0x4de3b652
+0,144,144,   40,   152064, 0xedb5a8e6
+0,172,172,   40,   152064, 0xe20f7c23
+0,201,201,   40,   152064, 0x5ab58bac
+0,229,229,   40,   152064, 0x1f1b8026
+0,258,258,   40,   152064, 0x91373915
+0,286,286,   40,   152064, 0x02344760
+0,   

[FFmpeg-cvslog] lavfi/setpts: unset frame durations

2024-04-01 Thread Anton Khirnov
ffmpeg | branch: release/7.0 | Anton Khirnov  | Wed Mar 27 
13:57:15 2024 +0100| [8709604ca1f99ab4f37c3f92f2732d08e60be202] | committer: 
Anton Khirnov

lavfi/setpts: unset frame durations

Actual frame durations are, in general, not computable without buffering
a frame.

FIxes #10886

(cherry picked from commit fa110c32b5168d99098dc0c50c6465054cf9d20b)
Signed-off-by: Anton Khirnov 

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

 libavfilter/setpts.c |   1 +
 tests/ref/fate/filter-setpts | 100 +--
 2 files changed, 51 insertions(+), 50 deletions(-)

diff --git a/libavfilter/setpts.c b/libavfilter/setpts.c
index 4f02a9a617..60cf2b642e 100644
--- a/libavfilter/setpts.c
+++ b/libavfilter/setpts.c
@@ -205,6 +205,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 
 d = eval_pts(setpts, inlink, frame, frame->pts);
 frame->pts = D2TS(d);
+frame->duration = 0;
 
 av_log(inlink->dst, AV_LOG_TRACE,
 "N:%"PRId64" PTS:%s T:%f",
diff --git a/tests/ref/fate/filter-setpts b/tests/ref/fate/filter-setpts
index 8aa7a1e6a0..08e0203831 100644
--- a/tests/ref/fate/filter-setpts
+++ b/tests/ref/fate/filter-setpts
@@ -3,53 +3,53 @@
 #codec_id 0: rawvideo
 #dimensions 0: 352x288
 #sar 0: 0/1
-0,  0,  0,   40,   152064, 0x05b789ef
-0, 28, 28,   40,   152064, 0x4bb46551
-0, 57, 57,   40,   152064, 0x9dddf64a
-0, 86, 86,   40,   152064, 0x2a8380b0
-0,115,115,   40,   152064, 0x4de3b652
-0,144,144,   40,   152064, 0xedb5a8e6
-0,172,172,   40,   152064, 0xe20f7c23
-0,201,201,   40,   152064, 0x5ab58bac
-0,229,229,   40,   152064, 0x1f1b8026
-0,258,258,   40,   152064, 0x91373915
-0,286,286,   40,   152064, 0x02344760
-0,314,314,   40,   152064, 0x30f5fcd5
-0,343,343,   40,   152064, 0xc711ad61
-0,371,371,   40,   152064, 0x24eca223
-0,399,399,   40,   152064, 0x52a48ddd
-0,427,427,   40,   152064, 0xa91c0f05
-0,456,456,   40,   152064, 0x8e364e18
-0,484,484,   40,   152064, 0xb15d38c8
-0,512,512,   40,   152064, 0xf25f6acc
-0,541,541,   40,   152064, 0xf34ddbff
-0,570,570,   40,   152064, 0xfc7bf570
-0,598,598,   40,   152064, 0x9dc72412
-0,627,627,   40,   152064, 0x445d1d59
-0,656,656,   40,   152064, 0x2f2768ef
-0,685,685,   40,   152064, 0xce09f9d6
-0,714,714,   40,   152064, 0x95579936
-0,743,743,   40,   152064, 0x43d796b5
-0,772,772,   40,   152064, 0xd780d887
-0,800,800,   40,   152064, 0x76d2a455
-0,829,829,   40,   152064, 0x6dc3650e
-0,858,858,   40,   152064, 0x0f9d6aca
-0,887,887,   40,   152064, 0xe295c51e
-0,915,915,   40,   152064, 0xd766fc8d
-0,944,944,   40,   152064, 0xe22f7a30
-0,972,972,   40,   152064, 0x7fea4378
-0,   1000,   1000,   40,   152064, 0xfa8d94fb
-0,   1029,   1029,   40,   152064, 0x4c9737ab
-0,   1057,   1057,   40,   152064, 0xa50d01f8
-0,   1085,   1085,   40,   152064, 0x0b07594c
-0,   1113,   1113,   40,   152064, 0x88734edd
-0,   1142,   1142,   40,   152064, 0xd2735925
-0,   1170,   1170,   40,   152064, 0xd4e49e08
-0,   1198,   1198,   40,   152064, 0x20cebfa9
-0,   1227,   1227,   40,   152064, 0x575c20ec
-0,   1255,   1255,   40,   152064, 0xfd500471
-0,   1284,   1284,   40,   152064, 0x61b47e73
-0,   1313,   1313,   40,   152064, 0x09ef53ff
-0,   1341,   1341,   40,   152064, 0x6e88c5c2
-0,   1370,   1370,   40,   152064, 0xbb87b483
-0,   1399,   1399,   40,   152064, 0x4bbad8ea
+0,  0,  0,0,   152064, 0x05b789ef
+0, 28, 28,0,   152064, 0x4bb46551
+0, 57, 57,0,   152064, 0x9dddf64a
+0, 86, 86,0,   152064, 0x2a8380b0
+0,115,115,0,   152064, 0x4de3b652
+0,144,144,0,   152064, 0xedb5a8e6
+0,172,172,0,   152064, 0xe20f7c23
+0,201,201,0,   152064, 0x5ab58bac
+0,229,229,0,   152064, 0x1f1b8026
+0,258,258,0,   152064, 0x91373915
+0,286,286,0,   152064, 0x02344760
+0,314,

[FFmpeg-cvslog] lavfi/setpts: unset frame durations

2024-03-29 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed Mar 27 
13:57:15 2024 +0100| [fa110c32b5168d99098dc0c50c6465054cf9d20b] | committer: 
Anton Khirnov

lavfi/setpts: unset frame durations

Actual frame durations are, in general, not computable without buffering
a frame.

FIxes #10886

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

 libavfilter/setpts.c |   1 +
 tests/ref/fate/filter-setpts | 100 +--
 2 files changed, 51 insertions(+), 50 deletions(-)

diff --git a/libavfilter/setpts.c b/libavfilter/setpts.c
index 4f02a9a617..60cf2b642e 100644
--- a/libavfilter/setpts.c
+++ b/libavfilter/setpts.c
@@ -205,6 +205,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 
 d = eval_pts(setpts, inlink, frame, frame->pts);
 frame->pts = D2TS(d);
+frame->duration = 0;
 
 av_log(inlink->dst, AV_LOG_TRACE,
 "N:%"PRId64" PTS:%s T:%f",
diff --git a/tests/ref/fate/filter-setpts b/tests/ref/fate/filter-setpts
index 8aa7a1e6a0..08e0203831 100644
--- a/tests/ref/fate/filter-setpts
+++ b/tests/ref/fate/filter-setpts
@@ -3,53 +3,53 @@
 #codec_id 0: rawvideo
 #dimensions 0: 352x288
 #sar 0: 0/1
-0,  0,  0,   40,   152064, 0x05b789ef
-0, 28, 28,   40,   152064, 0x4bb46551
-0, 57, 57,   40,   152064, 0x9dddf64a
-0, 86, 86,   40,   152064, 0x2a8380b0
-0,115,115,   40,   152064, 0x4de3b652
-0,144,144,   40,   152064, 0xedb5a8e6
-0,172,172,   40,   152064, 0xe20f7c23
-0,201,201,   40,   152064, 0x5ab58bac
-0,229,229,   40,   152064, 0x1f1b8026
-0,258,258,   40,   152064, 0x91373915
-0,286,286,   40,   152064, 0x02344760
-0,314,314,   40,   152064, 0x30f5fcd5
-0,343,343,   40,   152064, 0xc711ad61
-0,371,371,   40,   152064, 0x24eca223
-0,399,399,   40,   152064, 0x52a48ddd
-0,427,427,   40,   152064, 0xa91c0f05
-0,456,456,   40,   152064, 0x8e364e18
-0,484,484,   40,   152064, 0xb15d38c8
-0,512,512,   40,   152064, 0xf25f6acc
-0,541,541,   40,   152064, 0xf34ddbff
-0,570,570,   40,   152064, 0xfc7bf570
-0,598,598,   40,   152064, 0x9dc72412
-0,627,627,   40,   152064, 0x445d1d59
-0,656,656,   40,   152064, 0x2f2768ef
-0,685,685,   40,   152064, 0xce09f9d6
-0,714,714,   40,   152064, 0x95579936
-0,743,743,   40,   152064, 0x43d796b5
-0,772,772,   40,   152064, 0xd780d887
-0,800,800,   40,   152064, 0x76d2a455
-0,829,829,   40,   152064, 0x6dc3650e
-0,858,858,   40,   152064, 0x0f9d6aca
-0,887,887,   40,   152064, 0xe295c51e
-0,915,915,   40,   152064, 0xd766fc8d
-0,944,944,   40,   152064, 0xe22f7a30
-0,972,972,   40,   152064, 0x7fea4378
-0,   1000,   1000,   40,   152064, 0xfa8d94fb
-0,   1029,   1029,   40,   152064, 0x4c9737ab
-0,   1057,   1057,   40,   152064, 0xa50d01f8
-0,   1085,   1085,   40,   152064, 0x0b07594c
-0,   1113,   1113,   40,   152064, 0x88734edd
-0,   1142,   1142,   40,   152064, 0xd2735925
-0,   1170,   1170,   40,   152064, 0xd4e49e08
-0,   1198,   1198,   40,   152064, 0x20cebfa9
-0,   1227,   1227,   40,   152064, 0x575c20ec
-0,   1255,   1255,   40,   152064, 0xfd500471
-0,   1284,   1284,   40,   152064, 0x61b47e73
-0,   1313,   1313,   40,   152064, 0x09ef53ff
-0,   1341,   1341,   40,   152064, 0x6e88c5c2
-0,   1370,   1370,   40,   152064, 0xbb87b483
-0,   1399,   1399,   40,   152064, 0x4bbad8ea
+0,  0,  0,0,   152064, 0x05b789ef
+0, 28, 28,0,   152064, 0x4bb46551
+0, 57, 57,0,   152064, 0x9dddf64a
+0, 86, 86,0,   152064, 0x2a8380b0
+0,115,115,0,   152064, 0x4de3b652
+0,144,144,0,   152064, 0xedb5a8e6
+0,172,172,0,   152064, 0xe20f7c23
+0,201,201,0,   152064, 0x5ab58bac
+0,229,229,0,   152064, 0x1f1b8026
+0,258,258,0,   152064, 0x91373915
+0,286,286,0,   152064, 0x02344760
+0,314,314,0,   152064, 0x30f5fcd5
+0,343,343,0,   152064, 0xc711ad61
+

[FFmpeg-cvslog] lavf/vf_setpts: unset output framerate

2024-03-29 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Wed Mar 27 
13:55:26 2024 +0100| [f121d954ac89060cb7b07da230479cffe5bf9e5c] | committer: 
Anton Khirnov

lavf/vf_setpts: unset output framerate

This filter produces VFR output in general.

Avoids dropping frames in the setpts test.

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

 libavfilter/setpts.c | 17 -
 tests/ref/fate/filter-setpts | 89 +---
 2 files changed, 67 insertions(+), 39 deletions(-)

diff --git a/libavfilter/setpts.c b/libavfilter/setpts.c
index 88a8d6af86..4f02a9a617 100644
--- a/libavfilter/setpts.c
+++ b/libavfilter/setpts.c
@@ -150,6 +150,13 @@ static int config_input(AVFilterLink *inlink)
 return 0;
 }
 
+static int config_output_video(AVFilterLink *outlink)
+{
+outlink->frame_rate = (AVRational){ 1, 0 };
+
+return 0;
+}
+
 #define BUF_SIZE 64
 
 static inline char *double2int64str(char *buf, double v)
@@ -322,6 +329,14 @@ static const AVFilterPad avfilter_vf_setpts_inputs[] = {
 },
 };
 
+static const AVFilterPad outputs_video[] = {
+{
+.name = "default",
+.type = AVMEDIA_TYPE_VIDEO,
+.config_props = config_output_video,
+},
+};
+
 const AVFilter ff_vf_setpts = {
 .name= "setpts",
 .description = NULL_IF_CONFIG_SMALL("Set PTS for the output video 
frame."),
@@ -335,7 +350,7 @@ const AVFilter ff_vf_setpts = {
 .priv_class = _class,
 
 FILTER_INPUTS(avfilter_vf_setpts_inputs),
-FILTER_OUTPUTS(ff_video_default_filterpad),
+FILTER_OUTPUTS(outputs_video),
 };
 #endif /* CONFIG_SETPTS_FILTER */
 
diff --git a/tests/ref/fate/filter-setpts b/tests/ref/fate/filter-setpts
index efdcf6a16e..8aa7a1e6a0 100644
--- a/tests/ref/fate/filter-setpts
+++ b/tests/ref/fate/filter-setpts
@@ -1,42 +1,55 @@
-#tb 0: 1/25
+#tb 0: 1/1000
 #media_type 0: video
 #codec_id 0: rawvideo
 #dimensions 0: 352x288
 #sar 0: 0/1
-0,  0,  0,1,   152064, 0x05b789ef
-0,  1,  1,1,   152064, 0x4bb46551
-0,  2,  2,1,   152064, 0x9dddf64a
-0,  3,  3,1,   152064, 0x2a8380b0
-0,  4,  4,1,   152064, 0x4de3b652
-0,  5,  5,1,   152064, 0xedb5a8e6
-0,  6,  6,1,   152064, 0x5ab58bac
-0,  7,  7,1,   152064, 0x1f1b8026
-0,  8,  8,1,   152064, 0x91373915
-0,  9,  9,1,   152064, 0x30f5fcd5
-0, 10, 10,1,   152064, 0xc711ad61
-0, 11, 11,1,   152064, 0x52a48ddd
-0, 12, 12,1,   152064, 0xa91c0f05
-0, 13, 13,1,   152064, 0x8e364e18
-0, 14, 14,1,   152064, 0xf25f6acc
-0, 15, 15,1,   152064, 0xf34ddbff
-0, 16, 16,1,   152064, 0x9dc72412
-0, 17, 17,1,   152064, 0x445d1d59
-0, 18, 18,1,   152064, 0x2f2768ef
-0, 19, 19,1,   152064, 0x95579936
-0, 20, 20,1,   152064, 0x43d796b5
-0, 21, 21,1,   152064, 0x76d2a455
-0, 22, 22,1,   152064, 0x6dc3650e
-0, 23, 23,1,   152064, 0x0f9d6aca
-0, 24, 24,1,   152064, 0xd766fc8d
-0, 25, 25,1,   152064, 0xe22f7a30
-0, 26, 26,1,   152064, 0xfa8d94fb
-0, 27, 27,1,   152064, 0x4c9737ab
-0, 28, 28,1,   152064, 0xa50d01f8
-0, 29, 29,1,   152064, 0x88734edd
-0, 30, 30,1,   152064, 0xd2735925
-0, 31, 31,1,   152064, 0x20cebfa9
-0, 32, 32,1,   152064, 0x575c20ec
-0, 33, 33,1,   152064, 0x61b47e73
-0, 34, 34,1,   152064, 0x09ef53ff
-0, 35, 35,1,   152064, 0x6e88c5c2
-0, 36, 36,1,   152064, 0x4bbad8ea
+0,  0,  0,   40,   152064, 0x05b789ef
+0, 28, 28,   40,   152064, 0x4bb46551
+0, 57, 57,   40,   152064, 0x9dddf64a
+0, 86, 86,   40,   152064, 0x2a8380b0
+0,115,115,   40,   152064, 0x4de3b652
+0,144,144,   40,   152064, 0xedb5a8e6
+0,172,172,   40,   152064, 0xe20f7c23
+0,201,201,   40,   152064, 0x5ab58bac
+0,229,229,   40,   152064, 0x1f1b8026
+0,258,258,   40,   152064, 0x91373915
+0,286,286,   40,   152064, 0x02344760
+0,314,314,   40,   152064, 0x30f5fcd5
+0,343,343,   40,   152064, 0xc711ad61

[FFmpeg-cvslog] lavc/packet: schedule AV_PKT_DATA_QUALITY_FACTOR for removal

2024-03-29 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri Mar 22 
21:40:18 2024 +0100| [c240ff98b3dbf46eff954bf2aa0ad3844baca4c8] | committer: 
Anton Khirnov

lavc/packet: schedule AV_PKT_DATA_QUALITY_FACTOR for removal

It is unused internally and has been marked as deprecated a long time
ago.

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

 libavcodec/packet.h| 2 ++
 libavcodec/version_major.h | 1 +
 2 files changed, 3 insertions(+)

diff --git a/libavcodec/packet.h b/libavcodec/packet.h
index b0ba3baea2..a9a41576da 100644
--- a/libavcodec/packet.h
+++ b/libavcodec/packet.h
@@ -341,7 +341,9 @@ enum AVPacketSideDataType {
 AV_PKT_DATA_NB
 };
 
+#if FF_API_QUALITY_FACTOR
 #define AV_PKT_DATA_QUALITY_FACTOR AV_PKT_DATA_QUALITY_STATS //DEPRECATED
+#endif
 
 /**
  * This structure stores auxiliary information for decoding, presenting, or
diff --git a/libavcodec/version_major.h b/libavcodec/version_major.h
index ab1f4511b4..63df40e9dd 100644
--- a/libavcodec/version_major.h
+++ b/libavcodec/version_major.h
@@ -47,5 +47,6 @@
 #define FF_API_AVCODEC_CLOSE   (LIBAVCODEC_VERSION_MAJOR < 62)
 #define FF_API_BUFFER_MIN_SIZE (LIBAVCODEC_VERSION_MAJOR < 62)
 #define FF_API_VDPAU_ALLOC_GET_SET (LIBAVCODEC_VERSION_MAJOR < 62)
+#define FF_API_QUALITY_FACTOR  (LIBAVCODEC_VERSION_MAJOR < 62)
 
 #endif /* AVCODEC_VERSION_MAJOR_H */

___
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] lavc: rename avpacket.c to packet.c

2024-03-29 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri Mar 22 
21:37:20 2024 +0100| [1d843ae6c7b0cc8dcf4e95068c942f86fa5b1a82] | committer: 
Anton Khirnov

lavc: rename avpacket.c to packet.c

For consistency with its API header packet.h.

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

 libavcodec/Makefile | 2 +-
 libavcodec/{avpacket.c => packet.c} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 6eefeeae6e..eef936944d 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -32,7 +32,7 @@ OBJS = ac3_parser.o   
  \
avcodec.o\
avdct.o  \
avfft.o  \
-   avpacket.o   \
+   packet.o \
bitstream.o  \
bitstream_filters.o  \
bsf.o\
diff --git a/libavcodec/avpacket.c b/libavcodec/packet.c
similarity index 100%
rename from libavcodec/avpacket.c
rename to libavcodec/packet.c

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


  1   2   3   4   5   6   7   8   9   10   >