diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-10-02 19:43:01 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-10-02 19:48:54 +0200 |
commit | 032ba74ed29e0af77da04d2305b0470cb42b1955 (patch) | |
tree | 45127c399bf7846d057b07d35d02cf3f6a5f8675 /libavcodec/tiffenc.c | |
parent | dd78e1090b4cae3fbaa71e266c4b6b2f82ea9b7c (diff) | |
parent | 7bda4ed780c23c4bd50cf9ccd91f235e67ab0eae (diff) | |
download | ffmpeg-032ba74ed29e0af77da04d2305b0470cb42b1955.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
ARM: fix Thumb PIC on Apple
nut: add do {} while (0) to GET_V
tiffenc: Check av_malloc() results.
tiffenc: Simplify pixel format setup using AVPixFmtDescriptor.
Use atexit() instead of defining a custom exit_program() interface.
msvc: Fix detection of VFW & Avisynth required libs
Conflicts:
ffmpeg.c
ffmpeg_opt.c
ffplay.c
ffprobe.c
ffserver.c
libavcodec/tiffenc.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/tiffenc.c')
-rw-r--r-- | libavcodec/tiffenc.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c index 7d9752367a..dc87057fc9 100644 --- a/libavcodec/tiffenc.c +++ b/libavcodec/tiffenc.c @@ -28,6 +28,7 @@ #include "libavutil/imgutils.h" #include "libavutil/log.h" #include "libavutil/opt.h" +#include "libavutil/pixdesc.h" #include "avcodec.h" #include "config.h" @@ -250,6 +251,7 @@ static int encode_frame(AVCodecContext * avctx, AVPacket *pkt, int ret = -1; int is_yuv = 0, alpha = 0; int shift_h, shift_v; + const AVPixFmtDescriptor* pfd; *p = *pict; @@ -260,6 +262,7 @@ static int encode_frame(AVCodecContext * avctx, AVPacket *pkt, avctx->bits_per_coded_sample = s->bpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[avctx->pix_fmt]); + s->bpp_tab_size = av_pix_fmt_descriptors[avctx->pix_fmt].nb_components; switch (avctx->pix_fmt) { case PIX_FMT_RGBA64LE: @@ -302,7 +305,6 @@ static int encode_frame(AVCodecContext * avctx, AVPacket *pkt, return -1; } - s->bpp_tab_size = av_pix_fmt_descriptors[avctx->pix_fmt].nb_components; for (i = 0; i < s->bpp_tab_size; i++) bpp_tab[i] = av_pix_fmt_descriptors[avctx->pix_fmt].comp[i].depth_minus1 + 1; @@ -346,6 +348,7 @@ static int encode_frame(AVCodecContext * avctx, AVPacket *pkt, if (is_yuv){ av_fast_padded_malloc(&s->yuv_line, &s->yuv_line_size, bytes_per_row); if (s->yuv_line == NULL){ + av_log(s->avctx, AV_LOG_ERROR, "Not enough memory\n"); ret = AVERROR(ENOMEM); goto fail; } @@ -359,6 +362,10 @@ static int encode_frame(AVCodecContext * avctx, AVPacket *pkt, zlen = bytes_per_row * s->rps; zbuf = av_malloc(zlen); + if (!zbuf) { + ret = AVERROR(ENOMEM); + goto fail; + } s->strip_offsets[0] = ptr - pkt->data; zn = 0; for (j = 0; j < s->rps; j++) { @@ -383,8 +390,13 @@ static int encode_frame(AVCodecContext * avctx, AVPacket *pkt, } else #endif { - if(s->compr == TIFF_LZW) + if (s->compr == TIFF_LZW) { s->lzws = av_malloc(ff_lzw_encode_state_size); + if (!s->lzws) { + ret = AVERROR(ENOMEM); + goto fail; + } + } for (i = 0; i < s->height; i++) { if (s->strip_sizes[i / s->rps] == 0) { if(s->compr == TIFF_LZW){ |