diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2002-12-04 10:04:03 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2002-12-04 10:04:03 +0000 |
commit | 1e491e29c27cf6a6925666e4f4eac41b65e263d7 (patch) | |
tree | 99879470b8deeb55e7d88c62729b62ac27d249ee /libavcodec/dv.c | |
parent | 855ea723b0ea450137e54674179751c14e8fc6b5 (diff) | |
download | ffmpeg-1e491e29c27cf6a6925666e4f4eac41b65e263d7.tar.gz |
cleanup
adding AVVideoFrame
moving quality, pict_type, key_frame, qscale_table, ... to AVVideoFrame
removing obsolete variables in AVCodecContext
skiping of MBs in b frames
correctly initalizing AVCodecContext
picture buffer cleanup
Originally committed as revision 1302 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/dv.c')
-rw-r--r-- | libavcodec/dv.c | 73 |
1 files changed, 26 insertions, 47 deletions
diff --git a/libavcodec/dv.c b/libavcodec/dv.c index 1492d6854b..05128aee45 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -33,6 +33,7 @@ typedef struct DVVideoDecodeContext { int sampling_411; /* 0 = 420, 1 = 411 */ int width, height; UINT8 *current_picture[3]; /* picture structure */ + AVVideoFrame picture; int linesize[3]; DCTELEM block[5*6][64] __align8; UINT8 dv_zigzag[2][64]; @@ -128,7 +129,7 @@ static int dvvideo_decode_init(AVCodecContext *avctx) /* XXX: do it only for constant case */ dv_build_unquantize_tables(s); - + return 0; } @@ -499,7 +500,6 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, unsigned size; UINT8 *buf_ptr; const UINT16 *mb_pos_ptr; - AVPicture *picture; /* parse id */ init_get_bits(&s->gb, buf, buf_size); @@ -561,45 +561,20 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, avctx->width = width; avctx->height = height; - if (avctx->flags & CODEC_FLAG_DR1) - { - s->width = -1; - avctx->dr_buffer[0] = avctx->dr_buffer[1] = avctx->dr_buffer[2] = 0; - if(avctx->get_buffer_callback(avctx, width, height, I_TYPE) < 0 - && avctx->flags & CODEC_FLAG_DR1) { - fprintf(stderr, "get_buffer() failed\n"); - return -1; - } + s->picture.reference= 0; + if(avctx->get_buffer(avctx, &s->picture) < 0) { + fprintf(stderr, "get_buffer() failed\n"); + return -1; } - /* (re)alloc picture if needed */ - if (s->width != width || s->height != height) { - if (!(avctx->flags & CODEC_FLAG_DR1)) - for(i=0;i<3;i++) { - if (avctx->dr_buffer[i] != s->current_picture[i]) - av_freep(&s->current_picture[i]); - avctx->dr_buffer[i] = 0; - } - - for(i=0;i<3;i++) { - if (avctx->dr_buffer[i]) { - s->current_picture[i] = avctx->dr_buffer[i]; - s->linesize[i] = (i == 0) ? avctx->dr_stride : avctx->dr_uvstride; - } else { - size = width * height; - s->linesize[i] = width; - if (i >= 1) { - size >>= 2; - s->linesize[i] >>= s->sampling_411 ? 2 : 1; - } - s->current_picture[i] = av_malloc(size); - } - if (!s->current_picture[i]) - return -1; - } - s->width = width; - s->height = height; + for(i=0;i<3;i++) { + s->current_picture[i] = s->picture.data[i]; + s->linesize[i] = s->picture.linesize[i]; + if (!s->current_picture[i]) + return -1; } + s->width = width; + s->height = height; /* for each DIF segment */ buf_ptr = buf; @@ -620,12 +595,11 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, emms_c(); /* return image */ - *data_size = sizeof(AVPicture); - picture = data; - for(i=0;i<3;i++) { - picture->data[i] = s->current_picture[i]; - picture->linesize[i] = s->linesize[i]; - } + *data_size = sizeof(AVVideoFrame); + *(AVVideoFrame*)data= s->picture; + + avctx->release_buffer(avctx, &s->picture); + return packet_size; } @@ -633,10 +607,15 @@ static int dvvideo_decode_end(AVCodecContext *avctx) { DVVideoDecodeContext *s = avctx->priv_data; int i; + + if(avctx->get_buffer == avcodec_default_get_buffer){ + for(i=0; i<4; i++){ + av_freep(&s->picture.base[i]); + s->picture.data[i]= NULL; + } + av_freep(&s->picture.opaque); + } - for(i=0;i<3;i++) - if (avctx->dr_buffer[i] != s->current_picture[i]) - av_freep(&s->current_picture[i]); return 0; } |