Use quality level range 0-7 for the encoder, rather than the -4-3 as used in the packet header.
This commit is contained in:
parent
b7128b16be
commit
6ac66a047f
4
main.c
4
main.c
|
@ -35,7 +35,7 @@ void exit_usage()
|
||||||
" -t For testing, drops the specified percentage of packets while decoding.\n"
|
" -t For testing, drops the specified percentage of packets while decoding.\n"
|
||||||
" -c Set the callign. Accepts A-Z 0-9 and space, up to 6 characters.\n"
|
" -c Set the callign. Accepts A-Z 0-9 and space, up to 6 characters.\n"
|
||||||
" -i Set the image ID (0-255).\n"
|
" -i Set the image ID (0-255).\n"
|
||||||
" -q Set the JPEG quality level (-4 to 3, defaults to 0).\n"
|
" -q Set the JPEG quality level (0 to 7, defaults to 4).\n"
|
||||||
" -v Print data for each packet decoded.\n"
|
" -v Print data for each packet decoded.\n"
|
||||||
"\n");
|
"\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
@ -53,7 +53,7 @@ int main(int argc, char *argv[])
|
||||||
int errors;
|
int errors;
|
||||||
char callsign[7];
|
char callsign[7];
|
||||||
uint8_t image_id = 0;
|
uint8_t image_id = 0;
|
||||||
int8_t quality;
|
int8_t quality = 4;
|
||||||
ssdv_t ssdv;
|
ssdv_t ssdv;
|
||||||
|
|
||||||
uint8_t pkt[SSDV_PKT_SIZE], b[128], *jpeg;
|
uint8_t pkt[SSDV_PKT_SIZE], b[128], *jpeg;
|
||||||
|
|
12
ssdv.c
12
ssdv.c
|
@ -893,12 +893,16 @@ static char ssdv_have_marker_data(ssdv_t *s)
|
||||||
|
|
||||||
char ssdv_enc_init(ssdv_t *s, uint8_t type, char *callsign, uint8_t image_id, int8_t quality)
|
char ssdv_enc_init(ssdv_t *s, uint8_t type, char *callsign, uint8_t image_id, int8_t quality)
|
||||||
{
|
{
|
||||||
|
/* Limit the quality level */
|
||||||
|
if(quality < 0) quality = 0;
|
||||||
|
if(quality > 7) quality = 7;
|
||||||
|
|
||||||
memset(s, 0, sizeof(ssdv_t));
|
memset(s, 0, sizeof(ssdv_t));
|
||||||
s->image_id = image_id;
|
s->image_id = image_id;
|
||||||
s->callsign = encode_callsign(callsign);
|
s->callsign = encode_callsign(callsign);
|
||||||
s->mode = S_ENCODING;
|
s->mode = S_ENCODING;
|
||||||
s->type = type;
|
s->type = type;
|
||||||
s->quality = 4 + quality; /* Quality levels are -4 to 3, adjust to 0-7 */
|
s->quality = quality;
|
||||||
ssdv_set_packet_conf(s);
|
ssdv_set_packet_conf(s);
|
||||||
|
|
||||||
/* Prepare the output JPEG tables */
|
/* Prepare the output JPEG tables */
|
||||||
|
@ -1033,7 +1037,7 @@ char ssdv_enc_get_packet(ssdv_t *s)
|
||||||
s->out[9] = s->width >> 4; /* Width / 16 */
|
s->out[9] = s->width >> 4; /* Width / 16 */
|
||||||
s->out[10] = s->height >> 4; /* Height / 16 */
|
s->out[10] = s->height >> 4; /* Height / 16 */
|
||||||
s->out[11] = 0x00;
|
s->out[11] = 0x00;
|
||||||
s->out[11] |= s->quality << 3; /* Quality level */
|
s->out[11] |= ((s->quality - 4) & 7) << 3; /* Quality level */
|
||||||
s->out[11] |= (r == SSDV_EOI ? 1 : 0) << 2; /* EOI flag (1 bit) */
|
s->out[11] |= (r == SSDV_EOI ? 1 : 0) << 2; /* EOI flag (1 bit) */
|
||||||
s->out[11] |= s->mcu_mode & 0x03; /* MCU mode (2 bits) */
|
s->out[11] |= s->mcu_mode & 0x03; /* MCU mode (2 bits) */
|
||||||
s->out[12] = mcu_offset; /* Next MCU offset */
|
s->out[12] = mcu_offset; /* Next MCU offset */
|
||||||
|
@ -1240,7 +1244,7 @@ char ssdv_dec_feed(ssdv_t *s, uint8_t *packet)
|
||||||
s->width = packet[9] << 4;
|
s->width = packet[9] << 4;
|
||||||
s->height = packet[10] << 4;
|
s->height = packet[10] << 4;
|
||||||
s->mcu_count = packet[9] * packet[10];
|
s->mcu_count = packet[9] * packet[10];
|
||||||
s->quality = (packet[11] >> 3) & 7;
|
s->quality = ((((packet[11] >> 3) & 7) ^ 4) - 4) + 4;
|
||||||
s->mcu_mode = packet[11] & 0x03;
|
s->mcu_mode = packet[11] & 0x03;
|
||||||
|
|
||||||
/* Configure the payload size and CRC position */
|
/* Configure the payload size and CRC position */
|
||||||
|
@ -1266,7 +1270,7 @@ char ssdv_dec_feed(ssdv_t *s, uint8_t *packet)
|
||||||
fprintf(stderr, "Resolution: %ix%i\n", s->width, s->height);
|
fprintf(stderr, "Resolution: %ix%i\n", s->width, s->height);
|
||||||
fprintf(stderr, "MCU blocks: %i\n", s->mcu_count);
|
fprintf(stderr, "MCU blocks: %i\n", s->mcu_count);
|
||||||
fprintf(stderr, "Sampling factor: %s\n", factor);
|
fprintf(stderr, "Sampling factor: %s\n", factor);
|
||||||
fprintf(stderr, "Quality level: %d\n", s->quality - 4);
|
fprintf(stderr, "Quality level: %d\n", s->quality);
|
||||||
|
|
||||||
/* Output JPEG headers and enable byte stuffing */
|
/* Output JPEG headers and enable byte stuffing */
|
||||||
ssdv_out_headers(s);
|
ssdv_out_headers(s);
|
||||||
|
|
Loading…
Reference in New Issue