mirror of
https://github.com/bluenviron/mediamtx
synced 2025-01-21 22:43:47 +00:00
28 lines
567 B
C
28 lines
567 B
C
#include <stdio.h>
|
|
#include <ctype.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "sensor_mode.h"
|
|
|
|
bool sensor_mode_load(const char *encoded, sensor_mode_t *mode) {
|
|
char p;
|
|
int n = sscanf(encoded, "%u:%u:%u:%c", &(mode->width), &(mode->height), &(mode->bit_depth), &p);
|
|
if (n < 2) {
|
|
return false;
|
|
}
|
|
|
|
if (n < 4) {
|
|
mode->packed = true;
|
|
} else if (toupper(p) == 'P') {
|
|
mode->packed = true;
|
|
} else if (toupper(p) == 'U') {
|
|
mode->packed = false;
|
|
}
|
|
|
|
if (n < 3) {
|
|
mode->bit_depth = 12;
|
|
}
|
|
|
|
return true;
|
|
}
|