Mercurial > libavcodec.hg
comparison dv.c @ 835:9cec9eab681f libavcodec
* DR1 support
author | kabi |
---|---|
date | Mon, 04 Nov 2002 18:03:10 +0000 |
parents | 044307862b4b |
children | c075abb7fb3c |
comparison
equal
deleted
inserted
replaced
834:d73ad03912f5 | 835:9cec9eab681f |
---|---|
549 if (s->sampling_411) | 549 if (s->sampling_411) |
550 mb_pos_ptr = dv_place_411; | 550 mb_pos_ptr = dv_place_411; |
551 else | 551 else |
552 mb_pos_ptr = dv_place_420; | 552 mb_pos_ptr = dv_place_420; |
553 | 553 |
554 if (avctx->flags & CODEC_FLAG_DR1 && avctx->get_buffer_callback) | |
555 { | |
556 s->width = -1; | |
557 avctx->dr_buffer[0] = avctx->dr_buffer[1] = avctx->dr_buffer[2] = 0; | |
558 if(avctx->get_buffer_callback(avctx, width, height, I_TYPE) < 0){ | |
559 fprintf(stderr, "get_buffer() failed\n"); | |
560 return -1; | |
561 } | |
562 } | |
563 | |
564 | |
554 /* (re)alloc picture if needed */ | 565 /* (re)alloc picture if needed */ |
555 if (s->width != width || s->height != height) { | 566 if (s->width != width || s->height != height) { |
556 for(i=0;i<3;i++) | 567 if (!(avctx->flags & CODEC_FLAG_DR1)) |
557 av_freep(&s->current_picture[i]); | 568 for(i=0;i<3;i++) { |
569 if (avctx->dr_buffer[i] != s->current_picture[i]) | |
570 av_freep(&s->current_picture[i]); | |
571 avctx->dr_buffer[i] = 0; | |
572 } | |
573 | |
558 for(i=0;i<3;i++) { | 574 for(i=0;i<3;i++) { |
559 size = width * height; | 575 if (avctx->dr_buffer[i]) { |
560 s->linesize[i] = width; | 576 s->current_picture[i] = avctx->dr_buffer[i]; |
561 if (i >= 1) { | 577 s->linesize[i] = (i == 0) ? avctx->dr_stride : avctx->dr_uvstride; |
562 size >>= 2; | 578 } else { |
563 s->linesize[i] >>= s->sampling_411 ? 2 : 1; | 579 size = width * height; |
564 } | 580 s->linesize[i] = width; |
565 s->current_picture[i] = av_malloc(size); | 581 if (i >= 1) { |
582 size >>= 2; | |
583 s->linesize[i] >>= s->sampling_411 ? 2 : 1; | |
584 } | |
585 s->current_picture[i] = av_malloc(size); | |
586 } | |
566 if (!s->current_picture[i]) | 587 if (!s->current_picture[i]) |
567 return -1; | 588 return -1; |
568 } | 589 } |
569 s->width = width; | 590 s->width = width; |
570 s->height = height; | 591 s->height = height; |
612 { | 633 { |
613 DVVideoDecodeContext *s = avctx->priv_data; | 634 DVVideoDecodeContext *s = avctx->priv_data; |
614 int i; | 635 int i; |
615 | 636 |
616 for(i=0;i<3;i++) | 637 for(i=0;i<3;i++) |
638 if (avctx->dr_buffer[i] != s->current_picture[i]) | |
617 av_freep(&s->current_picture[i]); | 639 av_freep(&s->current_picture[i]); |
618 return 0; | 640 return 0; |
619 } | 641 } |
620 | 642 |
621 AVCodec dvvideo_decoder = { | 643 AVCodec dvvideo_decoder = { |
625 sizeof(DVVideoDecodeContext), | 647 sizeof(DVVideoDecodeContext), |
626 dvvideo_decode_init, | 648 dvvideo_decode_init, |
627 NULL, | 649 NULL, |
628 dvvideo_decode_end, | 650 dvvideo_decode_end, |
629 dvvideo_decode_frame, | 651 dvvideo_decode_frame, |
630 0, | 652 CODEC_CAP_DR1, |
631 NULL | 653 NULL |
632 }; | 654 }; |
633 | 655 |
634 typedef struct DVAudioDecodeContext { | 656 typedef struct DVAudioDecodeContext { |
635 AVCodecContext *avctx; | 657 AVCodecContext *avctx; |