diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-02-24 02:57:18 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-02-24 02:57:18 +0100 |
commit | e2cc39b6096ed4353293252e3955417b7766f161 (patch) | |
tree | 0bc4d98c120dedcffb9b6e50943b4fc9e3c2a877 /libavcodec/ffv1.c | |
parent | 32e74395a8e88dee1c149aeb36e7a21df431c181 (diff) | |
parent | 31632e73f47d25e2077fce729571259ee6354854 (diff) | |
download | ffmpeg-e2cc39b6096ed4353293252e3955417b7766f161.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (40 commits)
swf: check return values for av_get/new_packet().
wavpack: Don't shift minclip/maxclip
rtpenc: Expose the max packet size via an avoption
rtpenc: Move max_packet_size to a context variable
rtpenc: Add an option for not sending RTCP packets
lavc: drop encode() support for video.
snowenc: switch to encode2().
snowenc: don't abuse input picture for storing information.
a64multienc: switch to encode2().
a64multienc: don't write into output buffer when there's no output.
libxvid: switch to encode2().
tiffenc: switch to encode2().
tiffenc: properly forward error codes in encode_frame().
lavc: drop libdirac encoder.
gifenc: switch to encode2().
libvpxenc: switch to encode2().
flashsvenc: switch to encode2().
Remove libpostproc.
lcl: don't overwrite input memory.
swscale: take first/lastline over/underflows into account for MMX.
...
Conflicts:
.gitignore
Makefile
cmdutils.c
configure
doc/APIchanges
libavcodec/Makefile
libavcodec/allcodecs.c
libavcodec/libdiracenc.c
libavcodec/libxvidff.c
libavcodec/qtrleenc.c
libavcodec/tiffenc.c
libavcodec/utils.c
libavformat/mov.c
libavformat/movenc.c
libpostproc/Makefile
libpostproc/postprocess.c
libpostproc/postprocess.h
libpostproc/postprocess_altivec_template.c
libpostproc/postprocess_internal.h
libpostproc/postprocess_template.c
libswscale/swscale.c
libswscale/utils.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/ffv1.c')
-rw-r--r-- | libavcodec/ffv1.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 1535c5e462..4c0ea4517e 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -1135,17 +1135,25 @@ static int encode_slice(AVCodecContext *c, void *arg){ return 0; } -static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ +static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, + const AVFrame *pict, int *got_packet) +{ FFV1Context *f = avctx->priv_data; RangeCoder * const c= &f->slice_context[0]->c; - AVFrame *pict = data; AVFrame * const p= &f->picture; int used_count= 0; uint8_t keystate=128; uint8_t *buf_p; - int i; + int i, ret; + + if (!pkt->data && + (ret = av_new_packet(pkt, avctx->width*avctx->height*((8*2+1+1)*4)/8 + + FF_MIN_BUFFER_SIZE)) < 0) { + av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); + return ret; + } - ff_init_range_encoder(c, buf, buf_size); + ff_init_range_encoder(c, pkt->data, pkt->size); ff_build_rac_states(c, 0.05*(1LL<<32), 256-8); *p = *pict; @@ -1165,7 +1173,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, if(!f->ac){ used_count += ff_rac_terminate(c); //printf("pos=%d\n", used_count); - init_put_bits(&f->slice_context[0]->pb, buf + used_count, buf_size - used_count); + init_put_bits(&f->slice_context[0]->pb, pkt->data + used_count, pkt->size - used_count); }else if (f->ac>1){ int i; for(i=1; i<256; i++){ @@ -1176,8 +1184,8 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, for(i=1; i<f->slice_count; i++){ FFV1Context *fs= f->slice_context[i]; - uint8_t *start= buf + (buf_size-used_count)*i/f->slice_count; - int len= buf_size/f->slice_count; + uint8_t *start = pkt->data + (pkt->size-used_count)*i/f->slice_count; + int len = pkt->size/f->slice_count; if(fs->ac){ ff_init_range_encoder(&fs->c, start, len); @@ -1187,7 +1195,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, } avctx->execute(avctx, encode_slice, &f->slice_context[0], NULL, f->slice_count, sizeof(void*)); - buf_p=buf; + buf_p = pkt->data; for(i=0; i<f->slice_count; i++){ FFV1Context *fs= f->slice_context[i]; int bytes; @@ -1202,7 +1210,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, used_count= 0; } if(i>0){ - av_assert0(bytes < buf_size/f->slice_count); + av_assert0(bytes < pkt->size/f->slice_count); memmove(buf_p, fs->ac ? fs->c.bytestream_start : fs->pb.buf, bytes); av_assert0(bytes < (1<<24)); AV_WB24(buf_p+bytes, bytes); @@ -1255,7 +1263,11 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, avctx->stats_out[0] = '\0'; f->picture_number++; - return buf_p-buf; + pkt->size = buf_p - pkt->data; + pkt->flags |= AV_PKT_FLAG_KEY*p->key_frame; + *got_packet = 1; + + return 0; } #endif /* CONFIG_FFV1_ENCODER */ @@ -1843,7 +1855,7 @@ AVCodec ff_ffv1_encoder = { .id = CODEC_ID_FFV1, .priv_data_size = sizeof(FFV1Context), .init = encode_init, - .encode = encode_frame, + .encode2 = encode_frame, .close = common_end, .capabilities = CODEC_CAP_SLICE_THREADS, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUVA420P, PIX_FMT_YUV444P, PIX_FMT_YUVA444P, PIX_FMT_YUV440P, PIX_FMT_YUV422P, PIX_FMT_YUV411P, PIX_FMT_YUV410P, PIX_FMT_0RGB32, PIX_FMT_RGB32, PIX_FMT_YUV420P16, PIX_FMT_YUV422P16, PIX_FMT_YUV444P16, PIX_FMT_YUV420P9, PIX_FMT_YUV420P10, PIX_FMT_YUV422P10, PIX_FMT_GRAY16, PIX_FMT_GRAY8, PIX_FMT_NONE}, |