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/svq1enc.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/svq1enc.c')
-rw-r--r-- | libavcodec/svq1enc.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index b7c196707e..84ff0d8814 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -497,14 +497,19 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx) return 0; } -static int svq1_encode_frame(AVCodecContext *avctx, unsigned char *buf, - int buf_size, void *data) +static int svq1_encode_frame(AVCodecContext *avctx, AVPacket *pkt, + const AVFrame *pict, int *got_packet) { SVQ1Context * const s = avctx->priv_data; - AVFrame *pict = data; AVFrame * const p= (AVFrame*)&s->picture; AVFrame temp; - int i; + int i, ret; + + if (!pkt->data && + (ret = av_new_packet(pkt, s->y_block_width*s->y_block_height*MAX_MB_BYTES*3 + FF_MIN_BUFFER_SIZE) < 0)) { + av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); + return ret; + } if(avctx->pix_fmt != PIX_FMT_YUV410P){ av_log(avctx, AV_LOG_ERROR, "unsupported pixel format\n"); @@ -521,7 +526,7 @@ static int svq1_encode_frame(AVCodecContext *avctx, unsigned char *buf, s->current_picture= s->last_picture; s->last_picture= temp; - init_put_bits(&s->pb, buf, buf_size); + init_put_bits(&s->pb, pkt->data, pkt->size); *p = *pict; p->pict_type = avctx->gop_size && avctx->frame_number % avctx->gop_size ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; @@ -542,7 +547,12 @@ static int svq1_encode_frame(AVCodecContext *avctx, unsigned char *buf, flush_put_bits(&s->pb); - return put_bits_count(&s->pb) / 8; + pkt->size = put_bits_count(&s->pb) / 8; + if (p->pict_type == AV_PICTURE_TYPE_I) + pkt->flags |= AV_PKT_FLAG_KEY; + *got_packet = 1; + + return 0; } static av_cold int svq1_encode_end(AVCodecContext *avctx) @@ -578,7 +588,7 @@ AVCodec ff_svq1_encoder = { .id = CODEC_ID_SVQ1, .priv_data_size = sizeof(SVQ1Context), .init = svq1_encode_init, - .encode = svq1_encode_frame, + .encode2 = svq1_encode_frame, .close = svq1_encode_end, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV410P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1"), |