mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-02-04 06:08:26 +02:00
png: Return slightly more meaningful error codes
Signed-off-by: Donny Yang <work@kota.moe> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
7b060a96ad
commit
68ede913d0
@ -373,19 +373,19 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
s->bytestream_end = pkt->data + pkt->size;
|
s->bytestream_end = pkt->data + pkt->size;
|
||||||
|
|
||||||
crow_base = av_malloc((row_size + 32) << (s->filter_type == PNG_FILTER_VALUE_MIXED));
|
crow_base = av_malloc((row_size + 32) << (s->filter_type == PNG_FILTER_VALUE_MIXED));
|
||||||
if (!crow_base)
|
if (!crow_base) {
|
||||||
goto fail;
|
ret = AVERROR(ENOMEM);
|
||||||
|
goto the_end;
|
||||||
|
}
|
||||||
// pixel data should be aligned, but there's a control byte before it
|
// pixel data should be aligned, but there's a control byte before it
|
||||||
crow_buf = crow_base + 15;
|
crow_buf = crow_base + 15;
|
||||||
if (is_progressive) {
|
if (is_progressive) {
|
||||||
progressive_buf = av_malloc(row_size + 1);
|
progressive_buf = av_malloc(row_size + 1);
|
||||||
if (!progressive_buf)
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
if (is_progressive) {
|
|
||||||
top_buf = av_malloc(row_size + 1);
|
top_buf = av_malloc(row_size + 1);
|
||||||
if (!top_buf)
|
if (!progressive_buf || !top_buf) {
|
||||||
goto fail;
|
ret = AVERROR(ENOMEM);
|
||||||
|
goto the_end;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write png header */
|
/* write png header */
|
||||||
@ -501,7 +501,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
if (ret == Z_STREAM_END)
|
if (ret == Z_STREAM_END)
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
goto fail;
|
ret = -1;
|
||||||
|
goto the_end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
png_write_chunk(&s->bytestream, MKTAG('I', 'E', 'N', 'D'), NULL, 0);
|
png_write_chunk(&s->bytestream, MKTAG('I', 'E', 'N', 'D'), NULL, 0);
|
||||||
@ -517,9 +518,6 @@ the_end:
|
|||||||
av_freep(&top_buf);
|
av_freep(&top_buf);
|
||||||
deflateEnd(&s->zstream);
|
deflateEnd(&s->zstream);
|
||||||
return ret;
|
return ret;
|
||||||
fail:
|
|
||||||
ret = -1;
|
|
||||||
goto the_end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_cold int png_enc_init(AVCodecContext *avctx)
|
static av_cold int png_enc_init(AVCodecContext *avctx)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user