[FFmpeg-cvslog] avcodec/aacenc: don't redundantly re-compute max sfb

2024-04-28 Thread Yotam Ofek
ffmpeg | branch: master | Yotam Ofek  | Sun Apr 28 
09:37:11 2024 +| [a9a69a5a312f889d95c60de52485ee8e96e20e47] | committer: 
Lynne

avcodec/aacenc: don't redundantly re-compute max sfb

Remove an unneeded inner loop in adjust_frame_information that
had no effect, the loop body can be run only once and will compute
the same max sfb.

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

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

diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 7feb723289..163598e938 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -538,11 +538,9 @@ static void adjust_frame_information(ChannelElement *cpe, 
int chans)
 maxsfb = 0;
 cpe->ch[ch].pulse.num_pulse = 0;
 for (w = 0; w < ics->num_windows; w += ics->group_len[w]) {
-for (w2 =  0; w2 < ics->group_len[w]; w2++) {
-for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && 
cpe->ch[ch].zeroes[w*16+cmaxsfb-1]; cmaxsfb--)
-;
-maxsfb = FFMAX(maxsfb, cmaxsfb);
-}
+for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && 
cpe->ch[ch].zeroes[w*16+cmaxsfb-1]; cmaxsfb--)
+;
+maxsfb = FFMAX(maxsfb, cmaxsfb);
 }
 ics->max_sfb = maxsfb;
 

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

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


[FFmpeg-cvslog] avcodec/h264dec: Remove unused coded_picture_number

2024-04-28 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sat Apr  6 14:15:53 2024 +0200| [651f3aa7f911d897270ee687128d464bddb7883a] | 
committer: Andreas Rheinhardt

avcodec/h264dec: Remove unused coded_picture_number

Signed-off-by: Andreas Rheinhardt 

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

 libavcodec/h264_slice.c | 1 -
 libavcodec/h264dec.h| 1 -
 2 files changed, 2 deletions(-)

diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index a346839902..90d37f6084 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -388,7 +388,6 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
 
 h->width_from_caller= h1->width_from_caller;
 h->height_from_caller   = h1->height_from_caller;
-h->coded_picture_number = h1->coded_picture_number;
 h->first_field  = h1->first_field;
 h->picture_structure= h1->picture_structure;
 h->mb_aff_frame = h1->mb_aff_frame;
diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h
index 447c2499d9..fc50df90f2 100644
--- a/libavcodec/h264dec.h
+++ b/libavcodec/h264dec.h
@@ -356,7 +356,6 @@ typedef struct H264Context {
 int chroma_x_shift, chroma_y_shift;
 
 int droppable;
-int coded_picture_number;
 
 int context_initialized;
 int flags;

___
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/qsvdec: Use FFmpeg default 1/25 framerate if can't derive it from bitstream

2024-04-28 Thread Fei Wang
ffmpeg | branch: master | Fei Wang  | Thu Apr 18 16:15:09 
2024 +0800| [67fc9b84272a88b5edace5ca25f493c21b02955d] | committer: Haihao Xiang

lavc/qsvdec: Use FFmpeg default 1/25 framerate if can't derive it from bitstream

Fix error:
$ ffmpeg -hwaccel qsv -i input.h265 -f null -
...
[null @ 0x55da1a629200] Application provided invalid, non monotonically
increasing dts to muxer in stream 0: 3 >= 3

Signed-off-by: Fei Wang 

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

 libavcodec/qsvdec.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 5528bcdc8c..ed0bfe4c8b 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -441,6 +441,11 @@ static int qsv_decode_header(AVCodecContext *avctx, 
QSVContext *q,
 param->ExtParam= q->ext_buffers;
 param->NumExtParam = q->nb_ext_buffers;
 
+if (param->mfx.FrameInfo.FrameRateExtN == 0 || 
param->mfx.FrameInfo.FrameRateExtD == 0) {
+param->mfx.FrameInfo.FrameRateExtN = 25;
+param->mfx.FrameInfo.FrameRateExtD = 1;
+}
+
 #if QSV_VERSION_ATLEAST(1, 34)
 if (QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 34) && avctx->codec_id == 
AV_CODEC_ID_AV1)
 param->mfx.FilmGrain = (avctx->export_side_data & 
AV_CODEC_EXPORT_DATA_FILM_GRAIN) ? 0 : param->mfx.FilmGrain;

___
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] lavu/hwcontext_vaapi: Use vaMapBuffer2 for mapping image buffers

2024-04-28 Thread David Rosca
ffmpeg | branch: master | David Rosca  | Fri Oct 27 22:25:50 
2023 +0200| [1e2ac489a475198460e424fd4a3d166bb3f424a4] | committer: Haihao Xiang

lavu/hwcontext_vaapi: Use vaMapBuffer2 for mapping image buffers

This allows some optimizations in driver, such as not having to read
back the data if write-only mapping is requested.

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

 libavutil/hwcontext_vaapi.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index 56d03aa4cd..4cb25dd032 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -809,6 +809,9 @@ static int vaapi_map_frame(AVHWFramesContext *hwfc,
 VAStatus vas;
 void *address = NULL;
 int err, i;
+#if VA_CHECK_VERSION(1, 21, 0)
+uint32_t vaflags = 0;
+#endif
 
 surface_id = (VASurfaceID)(uintptr_t)src->data[3];
 av_log(hwfc, AV_LOG_DEBUG, "Map surface %#x.\n", surface_id);
@@ -892,7 +895,16 @@ static int vaapi_map_frame(AVHWFramesContext *hwfc,
 }
 }
 
+#if VA_CHECK_VERSION(1, 21, 0)
+if (flags & AV_HWFRAME_MAP_READ)
+vaflags |= VA_MAPBUFFER_FLAG_READ;
+if (flags & AV_HWFRAME_MAP_WRITE)
+vaflags |= VA_MAPBUFFER_FLAG_WRITE;
+// On drivers not implementing vaMapBuffer2 libva calls vaMapBuffer 
instead.
+vas = vaMapBuffer2(hwctx->display, map->image.buf, &address, vaflags);
+#else
 vas = vaMapBuffer(hwctx->display, map->image.buf, &address);
+#endif
 if (vas != VA_STATUS_SUCCESS) {
 av_log(hwfc, AV_LOG_ERROR, "Failed to map image from surface "
"%#x: %d (%s).\n", surface_id, vas, vaErrorStr(vas));

___
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/qsv: Copy metadata fields from the given input

2024-04-28 Thread Haihao Xiang
ffmpeg | branch: master | Haihao Xiang  | Tue Apr 23 
15:57:52 2024 +0800| [578ac5988769592c3b1d80b58af676e38e45e259] | committer: 
Haihao Xiang

lavfi/qsv: Copy metadata fields from the given input

Currently it always copies the metadata fields from the last input when
there are multiple inputs for the filter. For example, the metadata
fields from input1 are copied to the output for overlay_qsv filter,
however for regular overlay filters, the metadata fields from input0 are
copied to the output. With this fix, we may copy the metadata fields
from input0 to the ouput as well.

Signed-off-by: Haihao Xiang 

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

 libavfilter/qsvvpp.c | 29 +++--
 libavfilter/qsvvpp.h |  2 +-
 libavfilter/vf_overlay_qsv.c |  9 ++---
 libavfilter/vf_stack_qsv.c   |  9 ++---
 libavfilter/vf_vpp_qsv.c |  2 +-
 5 files changed, 25 insertions(+), 26 deletions(-)

diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index 8c92fec0c1..10d970652e 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -441,11 +441,6 @@ static QSVFrame *submit_frame(QSVVPPContext *s, 
AVFilterLink *inlink, AVFrame *p
 av_frame_free(&qsv_frame->frame);
 return NULL;
 }
-
-if (av_frame_copy_props(qsv_frame->frame, picref) < 0) {
-av_frame_free(&qsv_frame->frame);
-return NULL;
-}
 } else
 qsv_frame->frame = av_frame_clone(picref);
 
@@ -494,12 +489,6 @@ static QSVFrame *query_frame(QSVVPPContext *s, 
AVFilterLink *outlink, const AVFr
 if (!out_frame->frame)
 return NULL;
 
-ret = av_frame_copy_props(out_frame->frame, in);
-if (ret < 0) {
-av_log(ctx, AV_LOG_ERROR, "Failed to copy metadata fields from src 
to dst.\n");
-return NULL;
-}
-
 ret = av_hwframe_get_buffer(outlink->hw_frames_ctx, out_frame->frame, 
0);
 if (ret < 0) {
 av_log(ctx, AV_LOG_ERROR, "Can't allocate a surface.\n");
@@ -516,12 +505,6 @@ static QSVFrame *query_frame(QSVVPPContext *s, 
AVFilterLink *outlink, const AVFr
 if (!out_frame->frame)
 return NULL;
 
-ret = av_frame_copy_props(out_frame->frame, in);
-if (ret < 0) {
-av_log(ctx, AV_LOG_ERROR, "Failed to copy metadata fields from src 
to dst.\n");
-return NULL;
-}
-
 ret = map_frame_to_surface(out_frame->frame,
&out_frame->surface);
 if (ret < 0)
@@ -958,7 +941,7 @@ int ff_qsvvpp_close(AVFilterContext *avctx)
 return 0;
 }
 
-int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame 
*picref)
+int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame 
*picref, AVFrame *propref)
 {
 AVFilterContext  *ctx = inlink->dst;
 AVFilterLink *outlink = ctx->outputs[0];
@@ -1015,6 +998,16 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink 
*inlink, AVFrame *picr
 return AVERROR(EAGAIN);
 break;
 }
+
+if (propref) {
+ret1 = av_frame_copy_props(out_frame->frame, propref);
+if (ret1 < 0) {
+av_frame_free(&out_frame->frame);
+av_log(ctx, AV_LOG_ERROR, "Failed to copy metadata fields from 
src to dst.\n");
+return ret1;
+}
+}
+
 out_frame->frame->pts = av_rescale_q(out_frame->surface.Data.TimeStamp,
  default_tb, outlink->time_base);
 
diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h
index 4eea7a46c7..3b9192b62e 100644
--- a/libavfilter/qsvvpp.h
+++ b/libavfilter/qsvvpp.h
@@ -131,7 +131,7 @@ int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam 
*param);
 int ff_qsvvpp_close(AVFilterContext *avctx);
 
 /* vpp filter frame and call the cb if needed */
-int ff_qsvvpp_filter_frame(QSVVPPContext *vpp, AVFilterLink *inlink, AVFrame 
*frame);
+int ff_qsvvpp_filter_frame(QSVVPPContext *vpp, AVFilterLink *inlink, AVFrame 
*frame, AVFrame *propref);
 
 int ff_qsvvpp_print_iopattern(void *log_ctx, int mfx_iopattern,
   const char *extra_string);
diff --git a/libavfilter/vf_overlay_qsv.c b/libavfilter/vf_overlay_qsv.c
index 0f52c93245..059602fe03 100644
--- a/libavfilter/vf_overlay_qsv.c
+++ b/libavfilter/vf_overlay_qsv.c
@@ -228,13 +228,16 @@ static int process_frame(FFFrameSync *fs)
 {
 AVFilterContext  *ctx = fs->parent;
 QSVVPPContext*qsv = fs->opaque;
-AVFrame*frame = NULL;
+AVFrame*frame = NULL, *propref = NULL;
 int   ret = 0, i;
 
 for (i = 0; i < ctx->nb_inputs; i++) {
 ret = ff_framesync_get_frame(fs, i, &frame, 0);
-if (ret == 0)
-ret = ff_qsvvpp_filter_frame(qsv, ctx->inputs[i], frame);