History

avfilter/f_select: yuv will use Y plane only for scenecut detect

At the moment scene change detection score uses all planes to detect scene changes. In this regard this is similar how the frozen frames detection works. However, in classic encoding scene change detection typically only uses the Y plane. We might get more resonable scores for scene change if we also use only the Y plane for calculating the score if the pixel format is YUV. Although this will require additional work once packed YUV formats are added, because for the moment the generic scene sad score calculation has no way to ignore some components in a packed format.

Limin Wang committed 7 years ago

Commit ad3ef001 parent c294f382 files · +13 −9Browse files

Unified · Split

2 files
  1. libavfilter/f_select.c +5 −1
  2. tests/ref/fate/filter-metadata-scenedetect +8 −8
libavfilter/f_select.c+5−1
@@ -209,9 +209,13 @@ static int config_input(AVFilterLink *inlink) · 208 unmodified lines
209{209{
210 SelectContext *select = inlink->dst->priv;210 SelectContext *select = inlink->dst->priv;
211 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);211 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
212 int is_yuv = !(desc->flags & AV_PIX_FMT_FLAG_RGB) &&
213 (desc->flags & AV_PIX_FMT_FLAG_PLANAR) &&
214 desc->nb_components >= 3;
212 215
213 select->bitdepth = desc->comp[0].depth;216 select->bitdepth = desc->comp[0].depth;
214 select->nb_planes = av_pix_fmt_count_planes(inlink->format);217 select->nb_planes = is_yuv ? 1 : av_pix_fmt_count_planes(inlink->format);
218
215 for (int plane = 0; plane < select->nb_planes; plane++) {219 for (int plane = 0; plane < select->nb_planes; plane++) {
216 ptrdiff_t line_size = av_image_get_linesize(inlink->format, inlink->w, plane);220 ptrdiff_t line_size = av_image_get_linesize(inlink->format, inlink->w, plane);
217 int vsub = desc->log2_chroma_h;221 int vsub = desc->log2_chroma_h;
tests/ref/fate/filter-metadata-scenedetect+8−8
@@ -1,11 +1,11 @@
1pkt_pts=1620|tag:lavfi.scene_score=1.0000001pkt_pts=1620|tag:lavfi.scene_score=1.000000
2pkt_pts=4140|tag:lavfi.scene_score=0.6686432pkt_pts=4140|tag:lavfi.scene_score=0.923403
3pkt_pts=5800|tag:lavfi.scene_score=0.9967213pkt_pts=5800|tag:lavfi.scene_score=1.000000
4pkt_pts=6720|tag:lavfi.scene_score=0.3573904pkt_pts=6720|tag:lavfi.scene_score=0.475643
5pkt_pts=8160|tag:lavfi.scene_score=0.8862685pkt_pts=8160|tag:lavfi.scene_score=1.000000
6pkt_pts=9760|tag:lavfi.scene_score=0.9262196pkt_pts=9760|tag:lavfi.scene_score=1.000000
7pkt_pts=14080|tag:lavfi.scene_score=0.6500337pkt_pts=14080|tag:lavfi.scene_score=0.874623
8pkt_pts=15700|tag:lavfi.scene_score=1.0000008pkt_pts=15700|tag:lavfi.scene_score=1.000000
9pkt_pts=18500|tag:lavfi.scene_score=0.3164029pkt_pts=18500|tag:lavfi.scene_score=0.422509
10pkt_pts=20040|tag:lavfi.scene_score=0.26950910pkt_pts=20040|tag:lavfi.scene_score=0.352360
11pkt_pts=21760|tag:lavfi.scene_score=1.00000011pkt_pts=21760|tag:lavfi.scene_score=1.000000

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t