switch (avctx->codec->type) {
case AVMEDIA_TYPE_VIDEO:
- if (!frame->width)
- frame->width = avctx->width;
- if (!frame->height)
- frame->height = avctx->height;
+ frame->width = FFMAX(avctx->width , -((-avctx->coded_width )>>avctx->lowres));
+ frame->height = FFMAX(avctx->height, -((-avctx->coded_height)>>avctx->lowres));
if (frame->format < 0)
frame->format = avctx->pix_fmt;
if (!frame->sample_aspect_ratio.num)
av_buffer_unref(&dummy_buf);
+ frame->width = avctx->width;
+ frame->height = avctx->height;
+
return 0;
fail:
}
#endif
- return avctx->get_buffer2(avctx, frame, flags);
+ ret = avctx->get_buffer2(avctx, frame, flags);
+
+ if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
+ frame->width = avctx->width;
+ frame->height = avctx->height;
+ }
+
+ return ret;
}
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
if (ret < 0 || !*got_packet_ptr)
av_free_packet(avpkt);
+ else
+ av_packet_merge_side_data(avpkt);
emms_c();
return ret;
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) {