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/asv1.c | |
parent | 32e74395a8e88dee1c149aeb36e7a21df431c181 (diff) | |
parent | 31632e73f47d25e2077fce729571259ee6354854 (diff) |
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/asv1.c')
-rw-r--r-- | libavcodec/asv1.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/libavcodec/asv1.c b/libavcodec/asv1.c index 563c92c335..4bcc8d72b1 100644 --- a/libavcodec/asv1.c +++ b/libavcodec/asv1.c @@ -325,10 +325,12 @@ static inline int decode_mb(ASV1Context *a, DCTELEM block[6][64]){ return 0; } +#define MAX_MB_SIZE (30*16*16*3/2/8) + static inline int encode_mb(ASV1Context *a, DCTELEM block[6][64]){ int i; - if(a->pb.buf_end - a->pb.buf - (put_bits_count(&a->pb)>>3) < 30*16*16*3/2/8){ + if (a->pb.buf_end - a->pb.buf - (put_bits_count(&a->pb)>>3) < MAX_MB_SIZE) { av_log(a->avctx, AV_LOG_ERROR, "encoded frame too large\n"); return -1; } @@ -461,14 +463,22 @@ static int decode_frame(AVCodecContext *avctx, } #if CONFIG_ASV1_ENCODER || CONFIG_ASV2_ENCODER -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) +{ ASV1Context * const a = avctx->priv_data; - AVFrame *pict = data; AVFrame * const p= &a->picture; - int size; + int size, ret; int mb_x, mb_y; - init_put_bits(&a->pb, buf, buf_size); + if (!pkt->data && + (ret = av_new_packet(pkt, a->mb_height*a->mb_width*MAX_MB_SIZE + + FF_MIN_BUFFER_SIZE)) < 0) { + av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); + return ret; + } + + init_put_bits(&a->pb, pkt->data, pkt->size); *p = *pict; p->pict_type= AV_PICTURE_TYPE_I; @@ -505,14 +515,18 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, size= put_bits_count(&a->pb)/32; if(avctx->codec_id == CODEC_ID_ASV1) - a->dsp.bswap_buf((uint32_t*)buf, (uint32_t*)buf, size); + a->dsp.bswap_buf((uint32_t*)pkt->data, (uint32_t*)pkt->data, size); else{ int i; for(i=0; i<4*size; i++) - buf[i]= av_reverse[ buf[i] ]; + pkt->data[i] = av_reverse[pkt->data[i]]; } - return size*4; + pkt->size = size*4; + pkt->flags |= AV_PKT_FLAG_KEY; + *got_packet = 1; + + return 0; } #endif /* CONFIG_ASV1_ENCODER || CONFIG_ASV2_ENCODER */ @@ -634,7 +648,7 @@ AVCodec ff_asv1_encoder = { .id = CODEC_ID_ASV1, .priv_data_size = sizeof(ASV1Context), .init = encode_init, - .encode = encode_frame, + .encode2 = encode_frame, //encode_end, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("ASUS V1"), @@ -648,7 +662,7 @@ AVCodec ff_asv2_encoder = { .id = CODEC_ID_ASV2, .priv_data_size = sizeof(ASV1Context), .init = encode_init, - .encode = encode_frame, + .encode2 = encode_frame, //encode_end, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("ASUS V2"), |