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
209209 {
210210 SelectContext *select = inlink->dst->priv;
211211 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;
212215
213216 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+
215219 for (int plane = 0; plane < select->nb_planes; plane++) {
216220 ptrdiff_t line_size = av_image_get_linesize(inlink->format, inlink->w, plane);
217221 int vsub = desc->log2_chroma_h;
tests/ref/fate/filter-metadata-scenedetect+8−8
@@ -1,11 +1,11 @@
11 pkt_pts=1620|tag:lavfi.scene_score=1.000000
2−pkt_pts=4140|tag:lavfi.scene_score=0.668643
3−pkt_pts=5800|tag:lavfi.scene_score=0.996721
4−pkt_pts=6720|tag:lavfi.scene_score=0.357390
5−pkt_pts=8160|tag:lavfi.scene_score=0.886268
6−pkt_pts=9760|tag:lavfi.scene_score=0.926219
7−pkt_pts=14080|tag:lavfi.scene_score=0.650033
2+pkt_pts=4140|tag:lavfi.scene_score=0.923403
3+pkt_pts=5800|tag:lavfi.scene_score=1.000000
4+pkt_pts=6720|tag:lavfi.scene_score=0.475643
5+pkt_pts=8160|tag:lavfi.scene_score=1.000000
6+pkt_pts=9760|tag:lavfi.scene_score=1.000000
7+pkt_pts=14080|tag:lavfi.scene_score=0.874623
88 pkt_pts=15700|tag:lavfi.scene_score=1.000000
9−pkt_pts=18500|tag:lavfi.scene_score=0.316402
10−pkt_pts=20040|tag:lavfi.scene_score=0.269509
9+pkt_pts=18500|tag:lavfi.scene_score=0.422509
10+pkt_pts=20040|tag:lavfi.scene_score=0.352360
1111 pkt_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