s->h_max = h_count[i];
if (v_count[i] > s->v_max)
s->v_max = v_count[i];
- if (!h_count[i] || !v_count[i]) {
- av_log(s->avctx, AV_LOG_ERROR, "h/v_count is 0\n");
- return -1;
- }
s->quant_index[i] = get_bits(&s->gb, 8);
if (s->quant_index[i] >= 4) {
av_log(s->avctx, AV_LOG_ERROR, "quant_index is invalid\n");
return AVERROR_INVALIDDATA;
}
+ if (!h_count[i] || !v_count[i]) {
+ av_log(s->avctx, AV_LOG_ERROR,
+ "Invalid sampling factor in component %d %d:%d\n",
+ i, h_count[i], v_count[i]);
+ return AVERROR_INVALIDDATA;
+ }
+
av_log(s->avctx, AV_LOG_DEBUG, "component %d %d:%d id: %d quant:%d\n",
i, h_count[i], v_count[i],
s->component_id[i], s->quant_index[i]);
av_log(s->avctx, AV_LOG_INFO, "comment: '%s'\n", cbuf);
/* buggy avid, it puts EOI only at every 10th frame */
- if (!strcmp(cbuf, "AVID")) {
+ if (!strncmp(cbuf, "AVID", 4)) {
s->buggy_avid = 1;
+ if (len > 14 && cbuf[12] == 1) /* 1 - NTSC, 2 - PAL */
+ s->interlace_polarity = 1;
} else if (!strcmp(cbuf, "CS=ITU601"))
s->cs_itu601 = 1;
- else if ((len > 31 && !strncmp(cbuf, "Intel(R) JPEG Library, version 1", 32)) ||
- (len > 19 && !strncmp(cbuf, "Metasoft MJPEG Codec", 20)))
+ else if ((!strncmp(cbuf, "Intel(R) JPEG Library, version 1", 32)) ||
+ (!strncmp(cbuf, "Metasoft MJPEG Codec", 20)))
s->flipped = 1;
av_free(cbuf);