Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

V4L/DVB (4548): Better temporal filter handling.

Adjust temporal filter if necessary. The problem with the temporal
filter is that it works well with full resolution capturing, but
not when the capture window is scaled (the filter introduces
a ghosting effect). So if the capture window changed, and there is
no updated filter value, then the filter is set depending on whether
the new window is full resolution or not.
For full resolution a setting of 8 really improves the video
quality, especially if the original video quality is suboptimal.
Also report VBI Format in VIDIOC_LOG_STATUS, it was missing.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
44b579d6 29900661

+22 -3
+22 -3
drivers/media/video/cx2341x.c
··· 691 691 .video_luma_spatial_filter_type = V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_HOR, 692 692 .video_chroma_spatial_filter_type = V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_1D_HOR, 693 693 .video_temporal_filter_mode = V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_MANUAL, 694 - .video_temporal_filter = 0, 694 + .video_temporal_filter = 8, 695 695 .video_median_filter_type = V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF, 696 696 .video_luma_median_filter_top = 255, 697 697 .video_luma_median_filter_bottom = 0, ··· 731 731 }; 732 732 733 733 int err = 0; 734 + u16 temporal = new->video_temporal_filter; 734 735 735 736 cx2341x_api(priv, func, CX2341X_ENC_SET_OUTPUT_PORT, 2, new->port, 0); 736 737 ··· 742 741 743 742 if (old == NULL || old->width != new->width || old->height != new->height || 744 743 old->video_encoding != new->video_encoding) { 744 + int is_scaling; 745 745 u16 w = new->width; 746 746 u16 h = new->height; 747 747 ··· 752 750 } 753 751 err = cx2341x_api(priv, func, CX2341X_ENC_SET_FRAME_SIZE, 2, h, w); 754 752 if (err) return err; 753 + 754 + /* Adjust temporal filter if necessary. The problem with the temporal 755 + filter is that it works well with full resolution capturing, but 756 + not when the capture window is scaled (the filter introduces 757 + a ghosting effect). So if the capture window changed, and there is 758 + no updated filter value, then the filter is set depending on whether 759 + the new window is full resolution or not. 760 + 761 + For full resolution a setting of 8 really improves the video 762 + quality, especially if the original video quality is suboptimal. */ 763 + is_scaling = new->width != 720 || new->height != (new->is_50hz ? 576 : 480); 764 + if (old && old->video_temporal_filter == temporal) { 765 + temporal = is_scaling ? 0 : 8; 766 + } 755 767 } 756 768 757 769 if (old == NULL || old->stream_type != new->stream_type) { ··· 831 815 } 832 816 if (old == NULL || 833 817 old->video_spatial_filter != new->video_spatial_filter || 834 - old->video_temporal_filter != new->video_temporal_filter) { 818 + old->video_temporal_filter != temporal) { 835 819 err = cx2341x_api(priv, func, CX2341X_ENC_SET_DNR_FILTER_PROPS, 2, 836 - new->video_spatial_filter, new->video_temporal_filter); 820 + new->video_spatial_filter, temporal); 837 821 if (err) return err; 838 822 } 839 823 if (old == NULL || old->video_temporal_decimation != new->video_temporal_decimation) { ··· 871 855 printk(KERN_INFO "%s: Stream: %s\n", 872 856 prefix, 873 857 cx2341x_menu_item(p, V4L2_CID_MPEG_STREAM_TYPE)); 858 + printk(KERN_INFO "%s: VBI Format: %s\n", 859 + prefix, 860 + cx2341x_menu_item(p, V4L2_CID_MPEG_STREAM_VBI_FMT)); 874 861 875 862 /* Video */ 876 863 printk(KERN_INFO "%s: Video: %dx%d, %d fps\n",