diff options
| author | rimio <vasi.vilvoiu@gmail.com> | 2019-02-16 02:53:29 +0200 |
|---|---|---|
| committer | rimio <vasi.vilvoiu@gmail.com> | 2019-02-16 02:53:29 +0200 |
| commit | d63a9edcfcc39185f7cb746cd5142927a0afc1f3 (patch) | |
| tree | 0f0b451a19dcf010702f07b8e35be301db1d1630 | |
| parent | c06018daf063f023bd82bba21eda2ca8a9e9ab8d (diff) | |
FAX480 mode
| -rw-r--r-- | src/encoder.c | 49 | ||||
| -rw-r--r-- | src/libsstv.template.h | 3 | ||||
| -rw-r--r-- | src/sstv.c | 55 | ||||
| -rw-r--r-- | src/tools/sstv-encode.cpp | 4 |
4 files changed, 107 insertions, 4 deletions
diff --git a/src/encoder.c b/src/encoder.c index f8a378d..b16ca7e 100644 --- a/src/encoder.c +++ b/src/encoder.c @@ -224,6 +224,51 @@ sstv_delete_encoder(void *ctx) } static sstv_error_t +sstv_encode_fax480_state_change(sstv_encoder_context_t *context) +{ + /* start communication */ + if (context->state == SSTV_ENCODER_STATE_VIS_STOP_BIT) { + context->state = SSTV_ENCODER_STATE_SYNC; + context->extra.scan.curr_line = 0; + FSK(context, context->descriptor.sync.time, context->descriptor.sync.freq); + return SSTV_OK; + } + + /* sync->y */ + if ((context->state == SSTV_ENCODER_STATE_SYNC) + || (context->state == SSTV_ENCODER_STATE_Y_SCAN + && context->extra.scan.curr_col < context->image.width)) + { + if (context->state == SSTV_ENCODER_STATE_SYNC) { + context->extra.scan.curr_col = 0; + } + + context->state = SSTV_ENCODER_STATE_Y_SCAN; + + uint32_t pix_offset = context->image.width * context->extra.scan.curr_line + context->extra.scan.curr_col; + uint8_t y = context->image.buffer[pix_offset]; + FSK_PIXEL(context, context->descriptor.pixel.time, y); + + context->extra.scan.curr_col ++; + return SSTV_OK; + } + + /* advance line (y->sync) */ + if ((context->state == SSTV_ENCODER_STATE_Y_SCAN) + && (context->extra.scan.curr_line < context->image.height-1)) + { + context->state = SSTV_ENCODER_STATE_SYNC; + context->extra.scan.curr_line ++; + FSK(context, context->descriptor.sync.time, context->descriptor.sync.freq); + return SSTV_OK; + } + + /* no more state changes, done */ + context->state = SSTV_ENCODER_STATE_END; + return SSTV_OK; +} + +static sstv_error_t sstv_encode_robot_bw_state_change(sstv_encoder_context_t *context) { return SSTV_OK; @@ -871,6 +916,10 @@ sstv_encode_state_change(sstv_encoder_context_t *context) /* call state change routine for specific mode */ switch (context->mode) { + /* Fax modes */ + case SSTV_MODE_FAX480: + return sstv_encode_fax480_state_change(context); + /* Robot modes */ case SSTV_MODE_ROBOT_BW8_R: case SSTV_MODE_ROBOT_BW8_G: diff --git a/src/libsstv.template.h b/src/libsstv.template.h index 3ef620c..ceda0c4 100644 --- a/src/libsstv.template.h +++ b/src/libsstv.template.h @@ -62,6 +62,9 @@ typedef enum { * SSTV modes (value is VIS+Parity) */ typedef enum { + /* FAX modes */ + SSTV_MODE_FAX480 = 85, + /* Robot modes */ SSTV_MODE_ROBOT_BW8_R = 129, SSTV_MODE_ROBOT_BW8_G = 130, @@ -160,6 +160,13 @@ sstv_error_t sstv_get_mode_image_props(sstv_mode_t mode, uint32_t *width, uint32_t *height, sstv_image_format_t *format) { switch (mode) { + /* FAX modes */ + case SSTV_MODE_FAX480: + if (width) *width = 512; + if (height) *height = 480; + if (format) *format = SSTV_FORMAT_Y; + break; + /* Robot modes */ case SSTV_MODE_ROBOT_BW8_R: case SSTV_MODE_ROBOT_BW8_G: @@ -172,7 +179,7 @@ sstv_get_mode_image_props(sstv_mode_t mode, uint32_t *width, uint32_t *height, s case SSTV_MODE_ROBOT_BW12_R: case SSTV_MODE_ROBOT_BW12_G: case SSTV_MODE_ROBOT_BW12_B: - if (width) *width = 320; + if (width) *width = 160; if (height) *height = 120; if (format) *format = SSTV_FORMAT_Y; break; @@ -476,8 +483,16 @@ sstv_get_mode_descriptor(sstv_mode_t mode, uint32_t sample_rate, sstv_mode_descr /* Mode frequencies */ switch (mode) { /* - * Robot modes + * Fax modes */ + case SSTV_MODE_FAX480: + desc->sync.freq = FREQ_DESC_INIT(1200, sample_rate); + desc->porch.freq = FREQ_DESC_INIT(1500, sample_rate); + desc->pixel.low_freq = FREQ_DESC_INIT(1500, sample_rate); + desc->pixel.bandwidth = FREQ_DESC_INIT(800, sample_rate); + break; + + /* Robot B&W modes */ case SSTV_MODE_ROBOT_BW8_R: case SSTV_MODE_ROBOT_BW8_G: case SSTV_MODE_ROBOT_BW8_B: @@ -490,6 +505,15 @@ sstv_get_mode_descriptor(sstv_mode_t mode, uint32_t sample_rate, sstv_mode_descr case SSTV_MODE_ROBOT_BW36_R: case SSTV_MODE_ROBOT_BW36_G: case SSTV_MODE_ROBOT_BW36_B: + desc->sync.freq = FREQ_DESC_INIT(1200, sample_rate); + desc->porch.freq = FREQ_DESC_INIT(1500, sample_rate); + desc->pixel.low_freq = FREQ_DESC_INIT(1500, sample_rate); + desc->pixel.bandwidth = FREQ_DESC_INIT(800, sample_rate); + break; + + /* + * Robot color modes + */ case SSTV_MODE_ROBOT_C12: case SSTV_MODE_ROBOT_C24: case SSTV_MODE_ROBOT_C36: @@ -556,22 +580,47 @@ sstv_get_mode_descriptor(sstv_mode_t mode, uint32_t sample_rate, sstv_mode_descr /* Mode desc */ switch (mode) { /* - * Robot modes + * FAX modes + */ + case SSTV_MODE_FAX480: + desc->sync.time = TIME_DESC_INIT(5120000, sample_rate); + desc->pixel.time = TIME_DESC_INIT(512000, sample_rate); + break; + + /* + * Robot B&W modes */ case SSTV_MODE_ROBOT_BW8_R: case SSTV_MODE_ROBOT_BW8_G: case SSTV_MODE_ROBOT_BW8_B: + desc->sync.time = TIME_DESC_INIT(10000000, sample_rate); + desc->pixel.time = TIME_DESC_INIT(350000, sample_rate); + break; + case SSTV_MODE_ROBOT_BW12_R: case SSTV_MODE_ROBOT_BW12_G: case SSTV_MODE_ROBOT_BW12_B: + desc->sync.time = TIME_DESC_INIT(7000000, sample_rate); + desc->pixel.time = TIME_DESC_INIT(581250, sample_rate); + break; + case SSTV_MODE_ROBOT_BW24_R: case SSTV_MODE_ROBOT_BW24_G: case SSTV_MODE_ROBOT_BW24_B: + desc->sync.time = TIME_DESC_INIT(12000000, sample_rate); + desc->pixel.time = TIME_DESC_INIT(290625, sample_rate); + break; + case SSTV_MODE_ROBOT_BW36_R: case SSTV_MODE_ROBOT_BW36_G: case SSTV_MODE_ROBOT_BW36_B: + desc->sync.time = TIME_DESC_INIT(12000000, sample_rate); + desc->pixel.time = TIME_DESC_INIT(431250, sample_rate); break; + /* + * Robot color modes + */ case SSTV_MODE_ROBOT_C12: desc->sync.time = TIME_DESC_INIT(9000000, sample_rate); desc->porch.time = TIME_DESC_INIT(3000000, sample_rate); diff --git a/src/tools/sstv-encode.cpp b/src/tools/sstv-encode.cpp index aa7798b..b211e9f 100644 --- a/src/tools/sstv-encode.cpp +++ b/src/tools/sstv-encode.cpp @@ -28,7 +28,9 @@ sstv_mode_t mode_from_string(std::string mode) { std::transform(mode.begin(), mode.end(), mode.begin(), ::toupper); - if (mode == "ROBOT_BW8_R"){ + if (mode == "FAX480") { + return SSTV_MODE_FAX480; + } else if (mode == "ROBOT_BW8_R"){ return SSTV_MODE_ROBOT_BW8_R; } else if (mode == "ROBOT_BW8_G"){ return SSTV_MODE_ROBOT_BW8_G; |
