volatile int ff_avcodec_locked;
static int volatile entangled_thread_counter = 0;
-static int (*ff_lockmgr_cb)(void **mutex, enum AVLockOp op);
+static int (*lockmgr_cb)(void **mutex, enum AVLockOp op);
static void *codec_mutex;
static void *avformat_mutex;
MAKE_ACCESSORS(AVCodecContext, codec, AVRational, pkt_timebase)
MAKE_ACCESSORS(AVCodecContext, codec, const AVCodecDescriptor *, codec_descriptor)
+MAKE_ACCESSORS(AVCodecContext, codec, int, lowres)
static void avcodec_get_subtitle_defaults(AVSubtitle *sub)
{
if (!avctx->refcounted_frames) {
avci->to_free = *picture;
avci->to_free.extended_data = avci->to_free.data;
+ memset(picture->buf, 0, sizeof(picture->buf));
}
avctx->frame_number++;
if (!avctx->refcounted_frames) {
avci->to_free = *frame;
avci->to_free.extended_data = avci->to_free.data;
+ memset(frame->buf, 0, sizeof(frame->buf));
+ frame->extended_buf = NULL;
+ frame->nb_extended_buf = 0;
}
}
#endif
}
+static int utf8_check(const uint8_t *str)
+{
+ const uint8_t *byte;
+ uint32_t codepoint, min;
+
+ while (*str) {
+ byte = str;
+ GET_UTF8(codepoint, *(byte++), return 0;);
+ min = byte - str == 1 ? 0 : byte - str == 2 ? 0x80 :
+ 1 << (5 * (byte - str) - 4);
+ if (codepoint < min || codepoint >= 0x110000 ||
+ codepoint == 0xFFFE /* BOM */ ||
+ codepoint >= 0xD800 && codepoint <= 0xDFFF /* surrogates */)
+ return 0;
+ str = byte;
+ }
+ return 1;
+}
+
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
int *got_sub_ptr,
AVPacket *avpkt)
{
- int ret = 0;
+ int i, ret = 0;
if (avctx->codec->type != AVMEDIA_TYPE_SUBTITLE) {
av_log(avctx, AV_LOG_ERROR, "Invalid media type for subtitles\n");
avctx->pkt_timebase, ms);
}
+ for (i = 0; i < sub->num_rects; i++) {
+ if (sub->rects[i]->ass && !utf8_check(sub->rects[i]->ass)) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Invalid UTF-8 in decoded subtitles text; "
+ "maybe missing -sub_charenc option\n");
+ avsubtitle_free(sub);
+ return AVERROR_INVALIDDATA;
+ }
+ }
+
if (tmp.data != pkt_recoded.data) { // did we recode?
/* prevent from destroying side data from original packet */
pkt_recoded.side_data = NULL;
profile = av_get_profile_name(p, enc->profile);
}
- snprintf(buf, buf_size, "%s: %s%s", codec_type ? codec_type : "unknown",
- codec_name, enc->mb_decision ? " (hq)" : "");
+ snprintf(buf, buf_size, "%s: %s", codec_type ? codec_type : "unknown",
+ codec_name);
buf[0] ^= 'a' ^ 'A'; /* first letter in uppercase */
+
+ if (enc->codec && strcmp(enc->codec->name, codec_name))
+ snprintf(buf + strlen(buf), buf_size - strlen(buf), " (%s)", enc->codec->name);
+
if (profile)
snprintf(buf + strlen(buf), buf_size - strlen(buf), " (%s)", profile);
if (enc->codec_tag) {
int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
{
- if (ff_lockmgr_cb) {
- if (ff_lockmgr_cb(&codec_mutex, AV_LOCK_DESTROY))
+ if (lockmgr_cb) {
+ if (lockmgr_cb(&codec_mutex, AV_LOCK_DESTROY))
return -1;
- if (ff_lockmgr_cb(&avformat_mutex, AV_LOCK_DESTROY))
+ if (lockmgr_cb(&avformat_mutex, AV_LOCK_DESTROY))
return -1;
}
- ff_lockmgr_cb = cb;
+ lockmgr_cb = cb;
- if (ff_lockmgr_cb) {
- if (ff_lockmgr_cb(&codec_mutex, AV_LOCK_CREATE))
+ if (lockmgr_cb) {
+ if (lockmgr_cb(&codec_mutex, AV_LOCK_CREATE))
return -1;
- if (ff_lockmgr_cb(&avformat_mutex, AV_LOCK_CREATE))
+ if (lockmgr_cb(&avformat_mutex, AV_LOCK_CREATE))
return -1;
}
return 0;
int ff_lock_avcodec(AVCodecContext *log_ctx)
{
- if (ff_lockmgr_cb) {
- if ((*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN))
+ if (lockmgr_cb) {
+ if ((*lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN))
return -1;
}
entangled_thread_counter++;
av_assert0(ff_avcodec_locked);
ff_avcodec_locked = 0;
entangled_thread_counter--;
- if (ff_lockmgr_cb) {
- if ((*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE))
+ if (lockmgr_cb) {
+ if ((*lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE))
return -1;
}
return 0;
int avpriv_lock_avformat(void)
{
- if (ff_lockmgr_cb) {
- if ((*ff_lockmgr_cb)(&avformat_mutex, AV_LOCK_OBTAIN))
+ if (lockmgr_cb) {
+ if ((*lockmgr_cb)(&avformat_mutex, AV_LOCK_OBTAIN))
return -1;
}
return 0;
int avpriv_unlock_avformat(void)
{
- if (ff_lockmgr_cb) {
- if ((*ff_lockmgr_cb)(&avformat_mutex, AV_LOCK_RELEASE))
+ if (lockmgr_cb) {
+ if ((*lockmgr_cb)(&avformat_mutex, AV_LOCK_RELEASE))
return -1;
}
return 0;