diff options
-rw-r--r-- | ffmpeg.c | 16 | ||||
-rw-r--r-- | libavcodec/ass.c | 45 | ||||
-rw-r--r-- | libavcodec/h264.c | 2 |
3 files changed, 43 insertions, 20 deletions
@@ -129,6 +129,7 @@ static int64_t subtitle_size = 0; static int64_t extra_size = 0; static int nb_frames_dup = 0; static int nb_frames_drop = 0; +static int64_t decode_error_stat[2]; static int current_time; AVIOContext *progress_avio = NULL; @@ -1506,6 +1507,9 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output) ret = AVERROR_INVALIDDATA; } + if (*got_output || ret<0 || pkt->size) + decode_error_stat[ret<0] ++; + if (!*got_output || ret < 0) { if (!pkt->size) { for (i = 0; i < ist->nb_filters; i++) @@ -1640,6 +1644,10 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output) ret = avcodec_decode_video2(ist->st->codec, decoded_frame, got_output, pkt); update_benchmark("decode_video %d.%d", ist->file_index, ist->st->index); + + if (*got_output || ret<0 || pkt->size) + decode_error_stat[ret<0] ++; + if (!*got_output || ret < 0) { if (!pkt->size) { for (i = 0; i < ist->nb_filters; i++) @@ -1730,6 +1738,10 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output) AVSubtitle subtitle; int i, ret = avcodec_decode_subtitle2(ist->st->codec, &subtitle, got_output, pkt); + + if (*got_output || ret<0 || pkt->size) + decode_error_stat[ret<0] ++; + if (ret < 0 || !*got_output) { if (!pkt->size) sub2video_flush(ist); @@ -3349,6 +3361,10 @@ int main(int argc, char **argv) if (do_benchmark) { printf("bench: utime=%0.3fs\n", ti / 1000000.0); } + av_log(NULL, AV_LOG_DEBUG, "%"PRIu64" frames successfully decoded, %"PRIu64" decoding errors\n", + decode_error_stat[0], decode_error_stat[1]); + if (2*decode_error_stat[0] < decode_error_stat[1]) + exit(254); exit(received_nb_signals ? 255 : 0); return 0; diff --git a/libavcodec/ass.c b/libavcodec/ass.c index db0fdd8504..87c73a519a 100644 --- a/libavcodec/ass.c +++ b/libavcodec/ass.c @@ -23,6 +23,7 @@ #include "ass.h" #include "libavutil/avassert.h" #include "libavutil/avstring.h" +#include "libavutil/bprint.h" #include "libavutil/common.h" int ff_ass_subtitle_header(AVCodecContext *avctx, @@ -62,36 +63,42 @@ int ff_ass_subtitle_header_default(AVCodecContext *avctx) ASS_DEFAULT_ALIGNMENT); } -static int ts_to_string(char *str, int strlen, int ts) +static void insert_ts(AVBPrint *buf, int ts) { - int h, m, s; - h = ts/360000; ts -= 360000*h; - m = ts/ 6000; ts -= 6000*m; - s = ts/ 100; ts -= 100*s; - return snprintf(str, strlen, "%d:%02d:%02d.%02d", h, m, s, ts); + if (ts == -1) { + av_bprintf(buf, "9:59:59.99,"); + } else { + int h, m, s; + + h = ts/360000; ts -= 360000*h; + m = ts/ 6000; ts -= 6000*m; + s = ts/ 100; ts -= 100*s; + av_bprintf(buf, "%d:%02d:%02d.%02d,", h, m, s, ts); + } } int ff_ass_add_rect(AVSubtitle *sub, const char *dialog, int ts_start, int duration, int raw) { - int len = 0, dlen; - char s_start[16], s_end[16], header[48] = {0}; + AVBPrint buf; + int ret, dlen; AVSubtitleRect **rects; + av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED); if (!raw) { - ts_to_string(s_start, sizeof(s_start), ts_start); - if (duration == -1) - snprintf(s_end, sizeof(s_end), "9:59:59.99"); - else - ts_to_string(s_end, sizeof(s_end), ts_start + duration); - len = snprintf(header, sizeof(header), "Dialogue: 0,%s,%s,Default,", - s_start, s_end); - av_assert0(len < sizeof(header)); + av_bprintf(&buf, "Dialogue: 0,"); + insert_ts(&buf, ts_start); + insert_ts(&buf, duration == -1 ? -1 : ts_start + duration); + av_bprintf(&buf, "Default,"); } dlen = strcspn(dialog, "\n"); dlen += dialog[dlen] == '\n'; + av_bprintf(&buf, "%.*s", dlen, dialog); + if (!av_bprint_is_complete(&buf)) + return AVERROR(ENOMEM); + rects = av_realloc(sub->rects, (sub->num_rects+1) * sizeof(*sub->rects)); if (!rects) return AVERROR(ENOMEM); @@ -99,9 +106,9 @@ int ff_ass_add_rect(AVSubtitle *sub, const char *dialog, sub->end_display_time = FFMAX(sub->end_display_time, 10 * duration); rects[sub->num_rects] = av_mallocz(sizeof(*rects[0])); rects[sub->num_rects]->type = SUBTITLE_ASS; - rects[sub->num_rects]->ass = av_malloc(len + dlen + 1); - strcpy (rects[sub->num_rects]->ass , header); - av_strlcpy(rects[sub->num_rects]->ass + len, dialog, dlen + 1); + ret = av_bprint_finalize(&buf, &rects[sub->num_rects]->ass); + if (ret < 0) + return ret; sub->num_rects++; return dlen; } diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 35387fac5f..929889043c 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -4248,7 +4248,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) avctx->codec_id != AV_CODEC_ID_H264 || (CONFIG_GRAY && (h->flags & CODEC_FLAG_GRAY)); - if (!(h->avctx->active_thread_type & FF_THREAD_SLICE)) { + if (!(h->avctx->active_thread_type & FF_THREAD_SLICE) && h->picture_structure == PICT_FRAME) { const int start_i = av_clip(h->resync_mb_x + h->resync_mb_y * h->mb_width, 0, h->mb_num - 1); if (start_i) { int prev_status = h->er.error_status_table[h->er.mb_index2xy[start_i - 1]]; |