comparison dv.c @ 903:22ee74da2cd3 libavcodec

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
author michaelni
date Wed, 04 Dec 2002 10:04:03 +0000
parents 6eda806efda9
children 7fccaa0d699d
comparison
equal deleted inserted replaced
902:6acc8394960d 903:22ee74da2cd3
31 GetBitContext gb; 31 GetBitContext gb;
32 VLC *vlc; 32 VLC *vlc;
33 int sampling_411; /* 0 = 420, 1 = 411 */ 33 int sampling_411; /* 0 = 420, 1 = 411 */
34 int width, height; 34 int width, height;
35 UINT8 *current_picture[3]; /* picture structure */ 35 UINT8 *current_picture[3]; /* picture structure */
36 AVVideoFrame picture;
36 int linesize[3]; 37 int linesize[3];
37 DCTELEM block[5*6][64] __align8; 38 DCTELEM block[5*6][64] __align8;
38 UINT8 dv_zigzag[2][64]; 39 UINT8 dv_zigzag[2][64];
39 UINT8 idct_permutation[64]; 40 UINT8 idct_permutation[64];
40 /* XXX: move it to static storage ? */ 41 /* XXX: move it to static storage ? */
126 s->idct_put[1] = simple_idct248_put; 127 s->idct_put[1] = simple_idct248_put;
127 memcpy(s->dv_zigzag[1], dv_248_zigzag, 64); 128 memcpy(s->dv_zigzag[1], dv_248_zigzag, 64);
128 129
129 /* XXX: do it only for constant case */ 130 /* XXX: do it only for constant case */
130 dv_build_unquantize_tables(s); 131 dv_build_unquantize_tables(s);
131 132
132 return 0; 133 return 0;
133 } 134 }
134 135
135 //#define VLC_DEBUG 136 //#define VLC_DEBUG
136 137
497 DVVideoDecodeContext *s = avctx->priv_data; 498 DVVideoDecodeContext *s = avctx->priv_data;
498 int sct, dsf, apt, ds, nb_dif_segs, vs, width, height, i, packet_size; 499 int sct, dsf, apt, ds, nb_dif_segs, vs, width, height, i, packet_size;
499 unsigned size; 500 unsigned size;
500 UINT8 *buf_ptr; 501 UINT8 *buf_ptr;
501 const UINT16 *mb_pos_ptr; 502 const UINT16 *mb_pos_ptr;
502 AVPicture *picture;
503 503
504 /* parse id */ 504 /* parse id */
505 init_get_bits(&s->gb, buf, buf_size); 505 init_get_bits(&s->gb, buf, buf_size);
506 sct = get_bits(&s->gb, 3); 506 sct = get_bits(&s->gb, 3);
507 if (sct != 0) 507 if (sct != 0)
559 } 559 }
560 560
561 avctx->width = width; 561 avctx->width = width;
562 avctx->height = height; 562 avctx->height = height;
563 563
564 if (avctx->flags & CODEC_FLAG_DR1) 564 s->picture.reference= 0;
565 { 565 if(avctx->get_buffer(avctx, &s->picture) < 0) {
566 s->width = -1; 566 fprintf(stderr, "get_buffer() failed\n");
567 avctx->dr_buffer[0] = avctx->dr_buffer[1] = avctx->dr_buffer[2] = 0; 567 return -1;
568 if(avctx->get_buffer_callback(avctx, width, height, I_TYPE) < 0 568 }
569 && avctx->flags & CODEC_FLAG_DR1) { 569
570 fprintf(stderr, "get_buffer() failed\n"); 570 for(i=0;i<3;i++) {
571 return -1; 571 s->current_picture[i] = s->picture.data[i];
572 } 572 s->linesize[i] = s->picture.linesize[i];
573 } 573 if (!s->current_picture[i])
574 574 return -1;
575 /* (re)alloc picture if needed */ 575 }
576 if (s->width != width || s->height != height) { 576 s->width = width;
577 if (!(avctx->flags & CODEC_FLAG_DR1)) 577 s->height = height;
578 for(i=0;i<3;i++) {
579 if (avctx->dr_buffer[i] != s->current_picture[i])
580 av_freep(&s->current_picture[i]);
581 avctx->dr_buffer[i] = 0;
582 }
583
584 for(i=0;i<3;i++) {
585 if (avctx->dr_buffer[i]) {
586 s->current_picture[i] = avctx->dr_buffer[i];
587 s->linesize[i] = (i == 0) ? avctx->dr_stride : avctx->dr_uvstride;
588 } else {
589 size = width * height;
590 s->linesize[i] = width;
591 if (i >= 1) {
592 size >>= 2;
593 s->linesize[i] >>= s->sampling_411 ? 2 : 1;
594 }
595 s->current_picture[i] = av_malloc(size);
596 }
597 if (!s->current_picture[i])
598 return -1;
599 }
600 s->width = width;
601 s->height = height;
602 }
603 578
604 /* for each DIF segment */ 579 /* for each DIF segment */
605 buf_ptr = buf; 580 buf_ptr = buf;
606 for (ds = 0; ds < nb_dif_segs; ds++) { 581 for (ds = 0; ds < nb_dif_segs; ds++) {
607 buf_ptr += 6 * 80; /* skip DIF segment header */ 582 buf_ptr += 6 * 80; /* skip DIF segment header */
618 } 593 }
619 594
620 emms_c(); 595 emms_c();
621 596
622 /* return image */ 597 /* return image */
623 *data_size = sizeof(AVPicture); 598 *data_size = sizeof(AVVideoFrame);
624 picture = data; 599 *(AVVideoFrame*)data= s->picture;
625 for(i=0;i<3;i++) { 600
626 picture->data[i] = s->current_picture[i]; 601 avctx->release_buffer(avctx, &s->picture);
627 picture->linesize[i] = s->linesize[i]; 602
628 }
629 return packet_size; 603 return packet_size;
630 } 604 }
631 605
632 static int dvvideo_decode_end(AVCodecContext *avctx) 606 static int dvvideo_decode_end(AVCodecContext *avctx)
633 { 607 {
634 DVVideoDecodeContext *s = avctx->priv_data; 608 DVVideoDecodeContext *s = avctx->priv_data;
635 int i; 609 int i;
636 610
637 for(i=0;i<3;i++) 611 if(avctx->get_buffer == avcodec_default_get_buffer){
638 if (avctx->dr_buffer[i] != s->current_picture[i]) 612 for(i=0; i<4; i++){
639 av_freep(&s->current_picture[i]); 613 av_freep(&s->picture.base[i]);
614 s->picture.data[i]= NULL;
615 }
616 av_freep(&s->picture.opaque);
617 }
618
640 return 0; 619 return 0;
641 } 620 }
642 621
643 AVCodec dvvideo_decoder = { 622 AVCodec dvvideo_decoder = {
644 "dvvideo", 623 "dvvideo",