m_pCodecContext->extradata_size = hints.extrasize;
m_pCodecContext->extradata = (uint8_t*)m_dllAvUtil.av_mallocz(hints.extrasize + FF_INPUT_BUFFER_PADDING_SIZE);
memcpy(m_pCodecContext->extradata, hints.extradata, hints.extrasize);
+
+ // start parsing of extra data - create a copy to be safe and make it zero-terminating to avoid access violations!
+ unsigned int parse_extrasize = hints.extrasize;
+ char* parse_extra = new char[parse_extrasize + 1];
+ memcpy(parse_extra, hints.extradata, parse_extrasize);
+ parse_extra[parse_extrasize] = '\0';
+
+ // assume that the extra data is formatted as a concatenation of lines ('\n' terminated)
+ char *ptr = parse_extra;
+ do // read line by line
+ {
+ if (!strncmp(ptr, "size:", 5))
+ {
+ int width = 0, height = 0;
+ sscanf(ptr, "size: %dx%d", &width, &height);
+ if (width > 0 && height > 0)
+ {
+ m_pCodecContext->width = width;
+ m_pCodecContext->height = height;
+ CLog::Log(LOGDEBUG,"%s - parsed extradata: size: %d x %d", __FUNCTION__, width, height);
+ }
+ }
+ /*
+ // leaving commented code: these items don't work yet... but they may be meaningful
+ if (!strncmp(ptr, "palette:", 8))
+ if (sscanf(ptr, "palette: %x, %x, %x, %x, %x, %x, %x, %x,"
+ " %x, %x, %x, %x, %x, %x, %x, %x", ...
+ if (!strncasecmp(ptr, "forced subs: on", 15))
+ forced_subs_only = 1;
+ */
+ // if tried all possibilities, then read newline char and move to next line
+ ptr = strchr(ptr, '\n');
+ if (ptr != NULL) ptr++;
+ }
+ while (ptr != NULL && ptr <= parse_extra + parse_extrasize);
+
+ delete[] parse_extra;
}
AVCodec* pCodec = m_dllAvCodec.avcodec_find_decoder(hints.codec);