diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-02-18 02:20:19 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-02-18 02:20:19 +0100 |
commit | bbb61a1cd5cb2046e480f367a7ae58a32f2ef907 (patch) | |
tree | 0e7cc2b59558e2dc31d6b8752d90f6b5b5c886e5 /libavcodec/pamenc.c | |
parent | f6492476a63938cc66c51bf61c88407b7749f780 (diff) | |
parent | af468015d972c0dec5c8c37b2685ffa5cbe4ae87 (diff) | |
download | ffmpeg-bbb61a1cd5cb2046e480f367a7ae58a32f2ef907.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (22 commits)
als: prevent infinite loop in zero_remaining().
cook: prevent div-by-zero if channels is zero.
pamenc: switch to encode2().
svq1enc: switch to encode2().
dvenc: switch to encode2().
dpxenc: switch to encode2().
pngenc: switch to encode2().
v210enc: switch to encode2().
xwdenc: switch to encode2().
ttadec: use branchless unsigned-to-signed unfolding
avcodec: add a Sun Rasterfile encoder
sunrast: Move common defines to a new header file.
cdxl: fix video decoding for some files
cdxl: fix audio for some samples
apetag: add proper support for binary tags
ttadec: remove dead code
swscale: make access to filter data conditional on filter type.
swscale: update context offsets after removal of AlpMmxFilter.
prores: initialise encoder and decoder parts only when needed
swscale: make monowhite/black RGB-independent.
...
Conflicts:
Changelog
libavcodec/alsdec.c
libavcodec/dpxenc.c
libavcodec/golomb.h
libavcodec/pamenc.c
libavcodec/pngenc.c
libavformat/img2.c
libswscale/output.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/pamenc.c')
-rw-r--r-- | libavcodec/pamenc.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/libavcodec/pamenc.c b/libavcodec/pamenc.c index 41db4ecb2f..ea0b6f4a32 100644 --- a/libavcodec/pamenc.c +++ b/libavcodec/pamenc.c @@ -20,22 +20,24 @@ */ #include "avcodec.h" +#include "internal.h" #include "pnm.h" -static int pam_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, - int buf_size, void *data) +static int pam_encode_frame(AVCodecContext *avctx, AVPacket *pkt, + const AVFrame *pict, int *got_packet) { PNMContext *s = avctx->priv_data; - AVFrame *pict = data; AVFrame * const p = (AVFrame*)&s->picture; - int i, h, w, n, linesize, depth, maxval; + int i, h, w, n, linesize, depth, maxval, ret; const char *tuple_type; uint8_t *ptr; - if (buf_size < avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height) + 200) { + if ((ret = ff_alloc_packet(pkt, avpicture_get_size(avctx->pix_fmt, + avctx->width, + avctx->height) + 200)) < 0) { av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n"); - return -1; + return ret; } *p = *pict; @@ -43,8 +45,8 @@ static int pam_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, p->key_frame = 1; s->bytestream_start = - s->bytestream = outbuf; - s->bytestream_end = outbuf+buf_size; + s->bytestream = pkt->data; + s->bytestream_end = pkt->data + pkt->size; h = avctx->height; w = avctx->width; @@ -122,7 +124,11 @@ static int pam_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, ptr += linesize; } } - return s->bytestream - s->bytestream_start; + + pkt->size = s->bytestream - s->bytestream_start; + pkt->flags |= AV_PKT_FLAG_KEY; + *got_packet = 1; + return 0; } @@ -132,7 +138,7 @@ AVCodec ff_pam_encoder = { .id = CODEC_ID_PAM, .priv_data_size = sizeof(PNMContext), .init = ff_pnm_init, - .encode = pam_encode_frame, + .encode2 = pam_encode_frame, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGBA, PIX_FMT_RGB48BE, PIX_FMT_RGBA64BE, PIX_FMT_GRAY8, PIX_FMT_GRAY8A, PIX_FMT_GRAY16BE, PIX_FMT_MONOBLACK, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"), }; |