From 8f10f1a6dc0d326a146e169860a2de7a8356fdab Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 9 Mar 2013 22:28:02 +0100 Subject: [PATCH 1/2] anm: Get rid of some very silly goto statements --- libavformat/anm.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/libavformat/anm.c b/libavformat/anm.c index 7e52e8355b..dc24e78941 100644 --- a/libavformat/anm.c +++ b/libavformat/anm.c @@ -135,17 +135,16 @@ static int read_header(AVFormatContext *s) st->codec->extradata_size = 16*8 + 4*256; st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata) { - ret = AVERROR(ENOMEM); - goto fail; + return AVERROR(ENOMEM); } ret = avio_read(pb, st->codec->extradata, st->codec->extradata_size); if (ret < 0) - goto fail; + return ret; /* read page table */ ret = avio_seek(pb, anm->page_table_offset, SEEK_SET); if (ret < 0) - goto fail; + return ret; for (i = 0; i < MAX_PAGES; i++) { Page *p = &anm->pt[i]; @@ -157,8 +156,7 @@ static int read_header(AVFormatContext *s) /* find page of first frame */ anm->page = find_record(anm, 0); if (anm->page < 0) { - ret = anm->page; - goto fail; + return anm->page; } anm->record = -1; @@ -166,10 +164,7 @@ static int read_header(AVFormatContext *s) invalid: av_log_ask_for_sample(s, NULL); - ret = AVERROR_PATCHWELCOME; - -fail: - return ret; + return AVERROR_PATCHWELCOME; } static int read_packet(AVFormatContext *s, From a4472ac01e86f9fae5adb9034f2777b86a9c5480 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 9 Mar 2013 16:30:03 +0100 Subject: [PATCH 2/2] Add informative messages to av_log_ask_for_sample calls lacking them --- libavcodec/h264.c | 5 ++--- libavformat/anm.c | 2 +- libavformat/spdifenc.c | 3 +-- libavformat/xwma.c | 6 ++---- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index e0d5433a4e..472fa475aa 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3356,9 +3356,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0) h->droppable = last_pic_droppable; return AVERROR_INVALIDDATA; } else if (last_pic_droppable != h->droppable) { - av_log(h->avctx, AV_LOG_ERROR, - "Cannot combine reference and non-reference fields in the same frame\n"); - av_log_ask_for_sample(h->avctx, NULL); + av_log_ask_for_sample(h->avctx, + "Found reference and non-reference fields in the same frame.\n"); h->picture_structure = last_pic_structure; h->droppable = last_pic_droppable; return AVERROR_PATCHWELCOME; diff --git a/libavformat/anm.c b/libavformat/anm.c index dc24e78941..064b15739f 100644 --- a/libavformat/anm.c +++ b/libavformat/anm.c @@ -163,7 +163,7 @@ static int read_header(AVFormatContext *s) return 0; invalid: - av_log_ask_for_sample(s, NULL); + av_log_ask_for_sample(s, "Invalid header element encountered.\n"); return AVERROR_PATCHWELCOME; } diff --git a/libavformat/spdifenc.c b/libavformat/spdifenc.c index cf421a7358..fbc757b797 100644 --- a/libavformat/spdifenc.c +++ b/libavformat/spdifenc.c @@ -412,8 +412,7 @@ static int spdif_header_truehd(AVFormatContext *s, AVPacket *pkt) if (pkt->size > TRUEHD_FRAME_OFFSET - mat_code_length) { /* if such frames exist, we'd need some more complex logic to * distribute the TrueHD frames in the MAT frame */ - av_log(s, AV_LOG_ERROR, "TrueHD frame too big, %d bytes\n", pkt->size); - av_log_ask_for_sample(s, NULL); + av_log_ask_for_sample(s, "TrueHD frame too big, %d bytes\n", pkt->size); return AVERROR_PATCHWELCOME; } diff --git a/libavformat/xwma.c b/libavformat/xwma.c index baabf5775e..13ce2bb9f9 100644 --- a/libavformat/xwma.c +++ b/libavformat/xwma.c @@ -85,9 +85,8 @@ static int xwma_read_header(AVFormatContext *s) * anyway. */ if (st->codec->codec_id != AV_CODEC_ID_WMAV2) { - av_log(s, AV_LOG_WARNING, "unexpected codec (tag 0x04%x; id %d)\n", + av_log_ask_for_sample(s, "unexpected codec (tag 0x04%x; id %d)\n", st->codec->codec_tag, st->codec->codec_id); - av_log_ask_for_sample(s, NULL); } else { /* In all xWMA files I have seen, there is no extradata. But the WMA * codecs require extradata, so we provide our own fake extradata. @@ -101,9 +100,8 @@ static int xwma_read_header(AVFormatContext *s) * if it will work, but just go on and try it, after asking * the user for a sample. */ - av_log(s, AV_LOG_WARNING, "unexpected extradata (%d bytes)\n", + av_log_ask_for_sample(s, "unexpected extradata (%d bytes)\n", st->codec->extradata_size); - av_log_ask_for_sample(s, NULL); } else { st->codec->extradata_size = 6; st->codec->extradata = av_mallocz(6 + FF_INPUT_BUFFER_PADDING_SIZE);