MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / mjpeg_decode_com

Function mjpeg_decode_com

libavcodec/mjpegdec.c:2154–2194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2152}
2153
2154static int mjpeg_decode_com(MJpegDecodeContext *s)
2155{
2156 int len;
2157 int ret = mjpeg_parse_len(s, &len, "com");
2158 if (ret < 0)
2159 return ret;
2160 if (!len)
2161 return 0;
2162
2163 int i;
2164 char *cbuf = av_malloc(len + 1);
2165 if (!cbuf)
2166 return AVERROR(ENOMEM);
2167
2168 for (i = 0; i < len; i++)
2169 cbuf[i] = bytestream2_get_byteu(&s->gB);
2170 if (cbuf[i - 1] == '\n')
2171 cbuf[i - 1] = 0;
2172 else
2173 cbuf[i] = 0;
2174
2175 if (s->avctx->debug & FF_DEBUG_PICT_INFO)
2176 av_log(s->avctx, AV_LOG_INFO, "comment: '%s'\n", cbuf);
2177
2178 /* buggy avid, it puts EOI only at every 10th frame */
2179 if (!strncmp(cbuf, "AVID", 4)) {
2180 parse_avid(s, cbuf, len);
2181 } else if (!strcmp(cbuf, "CS=ITU601"))
2182 s->cs_itu601 = 1;
2183 else if ((!strncmp(cbuf, "Intel(R) JPEG Library, version 1", 32) && s->avctx->codec_tag) ||
2184 (!strncmp(cbuf, "Metasoft MJPEG Codec", 20)))
2185 s->flipped = 1;
2186 else if (!strcmp(cbuf, "MULTISCOPE II")) {
2187 s->avctx->sample_aspect_ratio = (AVRational) { 1, 2 };
2188 s->multiscope = 2;
2189 }
2190
2191 av_free(cbuf);
2192
2193 return 0;
2194}
2195
2196/* return the 8 bit start code value and update the search
2197 state. Return -1 if no start code found */

Callers 1

Calls 5

mjpeg_parse_lenFunction · 0.85
av_logFunction · 0.85
parse_avidFunction · 0.85
av_mallocFunction · 0.50
av_freeFunction · 0.50

Tested by

no test coverage detected