static stp_image_status_t Image_get_row(stp_image_t *image, unsigned char *data, size_t byte_limit, int row) { int depth = global_channel_depth; if (! Image_is_valid) { fputs("Calling Image_get_row with invalid image!\n", stderr); abort(); } if (static_testpatterns[0].type == E_IMAGE) { testpattern_t *t = &(static_testpatterns[0]); int total_read = fread(data, 1, t->d.image.x * depth * global_bit_depth / 8, yyin); if (total_read != t->d.image.x * depth * global_bit_depth / 8) { fputs("Read failed!\n", stderr); return STP_IMAGE_STATUS_ABORT; } if (!global_quiet) fputc('.', stderr); } else { static int previous_band = -1; static int printed_blackline = 0; int band = row / global_band_height; if (row == global_printer_height - 1 && ! global_noblackline) fill_black(data, global_printer_width, global_steps, global_bit_depth / 8); else if (band >= global_n_testpatterns) fill_white(data, global_printer_width, global_steps, global_bit_depth / 8); else { if (band != previous_band) { if (! global_noblackline && printed_blackline == 0) { fill_black(data, global_printer_width, global_steps, global_bit_depth / 8); printed_blackline = 1; return STP_IMAGE_STATUS_OK; } else { previous_band = band; printed_blackline = 0; if (! global_quiet) fputc('.', stderr); } } fill_pattern(&(static_testpatterns[band]), data, global_printer_width, global_steps, depth, global_bit_depth / 8); } } return STP_IMAGE_STATUS_OK; }
static int bks_finalise_blank_source(void* data, const StreamInfo* streamInfo) { BlankSource* source = (BlankSource*)data; if (source->streamInfo.format == UNKNOWN_FORMAT) { source->streamInfo.format = streamInfo->format; } if (source->streamInfo.width < 1) { source->streamInfo.width = streamInfo->width; } if (source->streamInfo.height < 1) { source->streamInfo.height = streamInfo->height; } if (source->streamInfo.frameRate.num < 1 || source->streamInfo.frameRate.den < 1) { source->streamInfo.frameRate = streamInfo->frameRate; source->streamInfo.isHardFrameRate = 0; } if (source->streamInfo.aspectRatio.num < 1 || source->streamInfo.aspectRatio.den < 1) { source->streamInfo.aspectRatio = streamInfo->aspectRatio; } if (source->streamInfo.format == UYVY_FORMAT || source->streamInfo.format == YUV422_FORMAT) { source->imageSize = source->streamInfo.width * source->streamInfo.height * 2; } else if (source->streamInfo.format == UYVY_10BIT_FORMAT) { source->imageSize = (source->streamInfo.width + 47) / 48 * 128 * source->streamInfo.height; } else if (source->streamInfo.format == YUV422_10BIT_FORMAT) { source->imageSize = source->streamInfo.width * source->streamInfo.height * 2 * 2; } else if (source->streamInfo.format == YUV420_FORMAT || source->streamInfo.format == YUV411_FORMAT) { source->imageSize = source->streamInfo.width * source->streamInfo.height * 3 / 2; } else if (source->streamInfo.format == YUV420_10BIT_FORMAT) { source->imageSize = source->streamInfo.width * source->streamInfo.height * 3 / 2 * 2; } else if (source->streamInfo.format == YUV444_FORMAT) { source->imageSize = source->streamInfo.width * source->streamInfo.height * 3; } else { ml_log_error("Unsupported video format for blank video source: %d\n", source->streamInfo.format); return 0; } MALLOC_ORET(source->image, unsigned char, source->imageSize); fill_black(source->streamInfo.format, source->streamInfo.width, source->streamInfo.height, source->image); source->wasFinalised = 1; return 1; }