Skip to content

Commit

Permalink
Add support for line doubled capture with improved integer scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
IanSB committed Feb 19, 2023
1 parent 156e2f0 commit 0520386
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/defs.h
Expand Up @@ -558,10 +558,11 @@ typedef struct {
#define VSYNC_POLARITY 6
#define NUM_VSYNC 7

#define VIDEO_PROGRESSIVE 0
#define VIDEO_INTERLACED 1
#define VIDEO_TELETEXT 2
#define NUM_VIDEO 3
#define VIDEO_PROGRESSIVE 0
#define VIDEO_INTERLACED 1
#define VIDEO_TELETEXT 2
#define VIDEO_LINE_DOUBLED 3
#define NUM_VIDEO 4

#define SAMPLE_WIDTH_1 0
#define SAMPLE_WIDTH_3 1
Expand Down
17 changes: 14 additions & 3 deletions src/geometry.c
Expand Up @@ -54,7 +54,8 @@ static const char *fb_sizex2_names[] = {
static const char *deint_names[] = {
"Progressive",
"Interlaced",
"Interlaced Teletext"
"Interlaced Teletext",
"Line Doubled"
};

static const char *bpp_names[] = {
Expand All @@ -68,9 +69,9 @@ static param_t params[] = {
{ H_OFFSET, "H Offset", "h_offset", 1, 384, 4 },
{ V_OFFSET, "V Offset", "v_offset", 0, 256, 1 },
{ MIN_H_WIDTH, "Min H Width", "min_h_width", 150, 1920, 8 },
{MIN_V_HEIGHT, "Min V Height", "min_v_height", 150, 1200, 2 },
{MIN_V_HEIGHT, "Min V Height", "min_v_height", 100, 1200, 2 },
{ MAX_H_WIDTH, "Max H Width", "max_h_width", 200, 1920, 8 },
{MAX_V_HEIGHT, "Max V Height", "max_v_height", 200, 1200, 2 },
{MAX_V_HEIGHT, "Max V Height", "max_v_height", 120, 1200, 2 },
{ H_ASPECT, "H Pixel Aspect", "h_aspect", 0, 8, 1 },
{ V_ASPECT, "V Pixel Aspect", "v_aspect", 0, 8, 1 },
{ FB_SIZEX2, "FB Size", "fb_size", 0, 3, 1 },
Expand Down Expand Up @@ -428,6 +429,10 @@ void geometry_get_fb_params(capture_info_t *capinfo) {
capinfo->timingset = modeset;
capinfo->sync_edge = cpld->get_sync_edge();

if (capinfo->video_type == VIDEO_LINE_DOUBLED) {
capinfo->video_type = VIDEO_PROGRESSIVE;
}

capinfo->sizex2 = geometry->fb_sizex2;
switch(geometry->fb_bpp) {
case BPP_4:
Expand Down Expand Up @@ -903,6 +908,12 @@ void geometry_get_fb_params(capture_info_t *capinfo) {
//log_info("Final aspect2: %dx%d, %dx%d, %dx%d", h_aspect, v_aspect, hscale, vscale, caphscale, capvscale);
calculate_cpu_timings();
//log_info("size= %d, %d, %d, %d, %d, %d, %d",capinfo->chars_per_line, capinfo->nlines, geometry_min_h_width, geometry_min_v_height,capinfo->width, capinfo->height, capinfo->sizex2);

if (geometry->video_type == VIDEO_LINE_DOUBLED && (capinfo->sizex2 & SIZEX2_DOUBLE_HEIGHT) != 0) {
capinfo->nlines <<= 1;
capinfo->sizex2 &= SIZEX2_DOUBLE_WIDTH;
}

}

int get_hscale() {
Expand Down
3 changes: 3 additions & 0 deletions src/rgb_to_hdmi.c
Expand Up @@ -474,6 +474,9 @@ int height = 0;
}
}
int height = capinfo->height >> (capinfo->sizex2 & SIZEX2_DOUBLE_HEIGHT);
if (geometry_get_value(VIDEO_TYPE) == VIDEO_LINE_DOUBLED) {
height >>= 1;
}
int vscale = v_size / height;
v_overscan = v_size - (vscale * height);
adj_v_overscan = v_overscan;
Expand Down

0 comments on commit 0520386

Please sign in to comment.