const vpx_codec_enc_cfg_t *cfg,
const struct vp8_extracfg *vp8_cfg)
{
- RANGE_CHECK(cfg, g_w, 2, 16384);
- RANGE_CHECK(cfg, g_h, 2, 16384);
+ RANGE_CHECK(cfg, g_w, 1, 16384);
+ RANGE_CHECK(cfg, g_h, 1, 16384);
RANGE_CHECK(cfg, g_timebase.den, 1, 1000000000);
RANGE_CHECK(cfg, g_timebase.num, 1, cfg->g_timebase.den);
RANGE_CHECK_HI(cfg, g_profile, 3);
struct detect_buffer {
char buf[4];
- int valid;
+ size_t buf_read;
+ size_t position;
};
for (r = 0; r < h; r++)
{
- if (detect->valid)
+ size_t needed = w;
+ size_t buf_position = 0;
+ const size_t left = detect->buf_read - detect->position;
+ if (left > 0)
{
- memcpy(ptr, detect->buf, 4);
- shortread |= fread(ptr+4, 1, w-4, f) < w-4;
- detect->valid = 0;
+ const size_t more = (left < needed) ? left : needed;
+ memcpy(ptr, detect->buf + detect->position, more);
+ buf_position = more;
+ needed -= more;
+ detect->position += more;
+ }
+ if (needed > 0)
+ {
+ shortread |= (fread(ptr + buf_position, 1, needed, f) < needed);
}
- else
- shortread |= fread(ptr, 1, w, f) < w;
ptr += img->stride[plane];
}
{
int frames_in = 0, frames_out = 0;
unsigned long nbytes = 0;
- size_t detect_bytes;
struct detect_buffer detect;
/* Parse certain options from the input file, if possible */
/* For RAW input sources, these bytes will applied on the first frame
* in read_frame().
- * We can always read 4 bytes because the minimum supported frame size
- * is 2x2.
*/
- detect_bytes = fread(detect.buf, 1, 4, infile);
- detect.valid = 0;
+ detect.buf_read = fread(detect.buf, 1, 4, infile);
+ detect.position = 0;
- if (detect_bytes == 4 && file_is_y4m(infile, &y4m, detect.buf))
+ if (detect.buf_read == 4 && file_is_y4m(infile, &y4m, detect.buf))
{
if (y4m_input_open(&y4m, infile, detect.buf, 4) >= 0)
{
return EXIT_FAILURE;
}
}
- else if (detect_bytes == 4 &&
+ else if (detect.buf_read == 4 &&
file_is_ivf(infile, &fourcc, &cfg.g_w, &cfg.g_h, detect.buf))
{
file_type = FILE_TYPE_IVF;
else
{
file_type = FILE_TYPE_RAW;
- detect.valid = 1;
}
if(!cfg.g_w || !cfg.g_h)