mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-21 21:40:20 +00:00
dummy dump: allow saving raw images again
As it was before saving RGB codecs to PNM was added.
This commit is contained in:
@@ -62,6 +62,7 @@ struct dummy_display_state {
|
||||
size_t dump_bytes;
|
||||
_Bool dump_to_file;
|
||||
_Bool oneshot;
|
||||
_Bool raw;
|
||||
int dump_to_file_skip_frames;
|
||||
};
|
||||
|
||||
@@ -76,7 +77,7 @@ static void *display_dummy_init(struct module *parent, const char *cfg, unsigned
|
||||
struct key_val options[] = {
|
||||
{ "codec=<codec>", "force the use of a codec instead of default set" },
|
||||
{ "rgb_shift=<r>,<g>,<b>", "if using output codec RGBA, use specified shifts instead of default (" TOSTRING(DEFAULT_R_SHIFT) ", " TOSTRING(DEFAULT_G_SHIFT) ", " TOSTRING(DEFAULT_B_SHIFT) ")" },
|
||||
{ "dump[:skip=<n>][:oneshot]", "dump first frame to file dummy.<ext> (optionally skip <n> first frames); 'oneshot' - exit after dumping the picture" },
|
||||
{ "dump[:skip=<n>][:oneshot][:raw]", "dump first frame to file dummy.<ext> (optionally skip <n> first frames); 'oneshot' - exit after dumping the picture; 'raw' - dump raw data" },
|
||||
{ "hexdump[=<n>]", "dump first n (default " TOSTRING(DEFAULT_DUMP_LEN) ") bytes of every frame in hexadecimal format" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
@@ -116,6 +117,8 @@ static void *display_dummy_init(struct module *parent, const char *cfg, unsigned
|
||||
s.dump_to_file_skip_frames = atoi(strchr(item, '=') + 1);
|
||||
} else if (strcmp(item, "oneshot") == 0) {
|
||||
s.oneshot = 1;
|
||||
} else if (strcmp(item, "raw") == 0) {
|
||||
s.raw = 1;
|
||||
} else {
|
||||
log_msg(LOG_LEVEL_ERROR, MOD_NAME "Unrecognized option: %s\n", item);
|
||||
return NULL;
|
||||
@@ -164,7 +167,7 @@ static int display_dummy_putf(void *state, struct video_frame *frame, long long
|
||||
}
|
||||
if (s->dump_to_file) {
|
||||
if (s->dump_to_file_skip_frames-- == 0) {
|
||||
const char *filename = save_video_frame(frame, "dummy");
|
||||
const char *filename = save_video_frame(frame, "dummy", s->raw);
|
||||
if (filename) {
|
||||
log_msg(LOG_LEVEL_NOTICE, MOD_NAME "Written dump to file %s\n", filename);
|
||||
} else {
|
||||
|
||||
@@ -472,10 +472,9 @@ bool save_video_frame_as_pnm(struct video_frame *frame, const char *name)
|
||||
/**
|
||||
* Saves video_frame to file name.<ext>.
|
||||
*/
|
||||
const char *save_video_frame(struct video_frame *frame, const char *name) {
|
||||
const char *save_video_frame(struct video_frame *frame, const char *name, bool raw) {
|
||||
_Thread_local static char filename[FILENAME_MAX];
|
||||
snprintf(filename, sizeof filename, "%s.%s", name, get_codec_file_extension(frame->color_spec));
|
||||
if (!is_codec_opaque(frame->color_spec) && codec_is_a_rgb(frame->color_spec) &&
|
||||
if (!raw && !is_codec_opaque(frame->color_spec) && codec_is_a_rgb(frame->color_spec) &&
|
||||
((get_bits_per_component(frame->color_spec) <= 8 && get_decoder_from_to(frame->color_spec, RGB))
|
||||
|| (get_bits_per_component(frame->color_spec) > 8 && get_decoder_from_to(frame->color_spec, RG48)))) {
|
||||
snprintf(filename, sizeof filename, "%s.pnm", name);
|
||||
|
||||
@@ -189,7 +189,7 @@ void il_merged_to_upper(char *dst, char *src, int linesize, int height, void **s
|
||||
double compute_fps(int fps, int fpsd, int fd, int fi);
|
||||
|
||||
bool save_video_frame_as_pnm(struct video_frame *frame, const char *name);
|
||||
const char *save_video_frame(struct video_frame *frame, const char *name);
|
||||
const char *save_video_frame(struct video_frame *frame, const char *name, bool raw);
|
||||
|
||||
void vf_copy_metadata(struct video_frame *desc, const struct video_frame *src);
|
||||
void vf_store_metadata(struct video_frame *f, void *);
|
||||
|
||||
Reference in New Issue
Block a user